Changeset View
Changeset View
Standalone View
Standalone View
abstract_client.cpp
Show First 20 Lines • Show All 565 Lines • ▼ Show 20 Line(s) | |||||
566 | } | 566 | } | ||
567 | 567 | | |||
568 | void AbstractClient::doSetDesktop(int desktop, int was_desk) | 568 | void AbstractClient::doSetDesktop(int desktop, int was_desk) | ||
569 | { | 569 | { | ||
570 | Q_UNUSED(desktop) | 570 | Q_UNUSED(desktop) | ||
571 | Q_UNUSED(was_desk) | 571 | Q_UNUSED(was_desk) | ||
572 | } | 572 | } | ||
573 | 573 | | |||
574 | void AbstractClient::unSetDesktop(int desktop) | 574 | void AbstractClient::enterDesktop(VirtualDesktop *virtualDesktop) | ||
575 | { | 575 | { | ||
576 | // Case in which we are on all desktops and gets asked to unset | 576 | if (m_desktops.contains(virtualDesktop)) { | ||
zzag: Noob question: What would happen if the client is already on all desktops and you call… | |||||
davidedmundson: that works fine | |||||
577 | if (desktop == NET::OnAllDesktops) { | | |||
578 | if (m_desktops.isEmpty()) { | | |||
579 | setOnAllDesktops(false); | | |||
580 | } | | |||
581 | return; | 577 | return; | ||
582 | } | 578 | } | ||
579 | auto desktops = m_desktops; | ||||
580 | desktops.append(virtualDesktop); | ||||
581 | setDesktops(desktops); | ||||
582 | } | ||||
583 | 583 | | |||
584 | // Out of range | 584 | void AbstractClient::leaveDesktop(VirtualDesktop *virtualDesktop) | ||
585 | if (desktop < 1 || desktop > VirtualDesktopManager::self()->count()) { | 585 | { | ||
586 | return; | 586 | QVector<VirtualDesktop*> currentDesktops; | ||
587 | if (m_desktops.isEmpty()) { | ||||
588 | currentDesktops = VirtualDesktopManager::self()->desktops(); | ||||
589 | } else { | ||||
590 | currentDesktops = m_desktops; | ||||
587 | } | 591 | } | ||
588 | 592 | | |||
589 | VirtualDesktop *virtualDesktop = VirtualDesktopManager::self()->desktopForX11Id(desktop); | 593 | if (!m_desktops.contains(virtualDesktop)) { | ||
590 | Q_ASSERT(virtualDesktop); | 594 | return; | ||
Noob question: Same here, what would happen if the client is already on all desktops? zzag: Noob question: Same here, what would happen if the client is already on all desktops? | |||||
It currently does nothing. davidedmundson: It currently does nothing.
Probably it should end up on everything but this one, especially as… | |||||
595 | } | ||||
591 | auto desktops = m_desktops; | 596 | auto desktops = m_desktops; | ||
592 | desktops.removeOne(virtualDesktop); | 597 | desktops.removeOne(virtualDesktop); | ||
593 | setDesktops(desktops); | 598 | setDesktops(desktops); | ||
594 | } | 599 | } | ||
595 | 600 | | |||
596 | void AbstractClient::setOnAllDesktops(bool b) | 601 | void AbstractClient::setOnAllDesktops(bool b) | ||
597 | { | 602 | { | ||
598 | if ((b && isOnAllDesktops()) || | 603 | if ((b && isOnAllDesktops()) || | ||
599 | (!b && !isOnAllDesktops())) | 604 | (!b && !isOnAllDesktops())) | ||
600 | return; | 605 | return; | ||
601 | if (b) | 606 | if (b) | ||
602 | setDesktop(NET::OnAllDesktops); | 607 | setDesktop(NET::OnAllDesktops); | ||
603 | else | 608 | else | ||
604 | setDesktop(VirtualDesktopManager::self()->current()); | 609 | setDesktop(VirtualDesktopManager::self()->current()); | ||
605 | } | 610 | } | ||
606 | 611 | | |||
607 | QVector<int> AbstractClient::x11DesktopIds() const | 612 | QVector<uint> AbstractClient::x11DesktopIds() const | ||
608 | { | 613 | { | ||
609 | const auto desks = desktops(); | 614 | const auto desks = desktops(); | ||
610 | QVector<int> x11Ids; | 615 | QVector<uint> x11Ids; | ||
611 | x11Ids.reserve(desks.count()); | 616 | x11Ids.reserve(desks.count()); | ||
612 | std::transform(desks.constBegin(), desks.constEnd(), | 617 | std::transform(desks.constBegin(), desks.constEnd(), | ||
613 | std::back_inserter(x11Ids), | 618 | std::back_inserter(x11Ids), | ||
614 | [] (const VirtualDesktop *vd) { | 619 | [] (const VirtualDesktop *vd) { | ||
615 | return vd->x11DesktopNumber(); | 620 | return vd->x11DesktopNumber(); | ||
616 | } | 621 | } | ||
617 | ); | 622 | ); | ||
618 | return x11Ids; | 623 | return x11Ids; | ||
▲ Show 20 Lines • Show All 375 Lines • ▼ Show 20 Line(s) | 836 | { | |||
994 | ); | 999 | ); | ||
995 | 1000 | | |||
996 | //Plasma Virtual desktop management | 1001 | //Plasma Virtual desktop management | ||
997 | //show/hide when the window enters/exits from desktop | 1002 | //show/hide when the window enters/exits from desktop | ||
998 | connect(w, &PlasmaWindowInterface::enterPlasmaVirtualDesktopRequested, this, | 1003 | connect(w, &PlasmaWindowInterface::enterPlasmaVirtualDesktopRequested, this, | ||
999 | [this] (const QString &desktopId) { | 1004 | [this] (const QString &desktopId) { | ||
1000 | VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId.toUtf8()); | 1005 | VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId.toUtf8()); | ||
1001 | if (vd) { | 1006 | if (vd) { | ||
1002 | workspace()->sendClientToDesktop(this, vd->x11DesktopNumber(), false); | 1007 | enterDesktop(vd); | ||
1003 | } | 1008 | } | ||
1004 | } | 1009 | } | ||
1005 | ); | 1010 | ); | ||
1006 | connect(w, &PlasmaWindowInterface::enterNewPlasmaVirtualDesktopRequested, this, | 1011 | connect(w, &PlasmaWindowInterface::enterNewPlasmaVirtualDesktopRequested, this, | ||
1007 | [this] () { | 1012 | [this] () { | ||
1008 | VirtualDesktopManager::self()->setCount(VirtualDesktopManager::self()->count() + 1); | 1013 | VirtualDesktopManager::self()->setCount(VirtualDesktopManager::self()->count() + 1); | ||
1009 | workspace()->sendClientToDesktop(this, VirtualDesktopManager::self()->count(), false); | 1014 | enterDesktop(VirtualDesktopManager::self()->desktops().last()); | ||
1010 | } | 1015 | } | ||
1011 | ); | 1016 | ); | ||
1012 | connect(w, &PlasmaWindowInterface::leavePlasmaVirtualDesktopRequested, this, | 1017 | connect(w, &PlasmaWindowInterface::leavePlasmaVirtualDesktopRequested, this, | ||
1013 | [this] (const QString &desktopId) { | 1018 | [this] (const QString &desktopId) { | ||
1014 | VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId.toUtf8()); | 1019 | VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId.toUtf8()); | ||
1015 | if (vd) { | 1020 | if (vd) { | ||
1016 | unSetDesktop(vd->x11DesktopNumber()); | 1021 | leaveDesktop(vd); | ||
1017 | } | 1022 | } | ||
1018 | } | 1023 | } | ||
1019 | ); | 1024 | ); | ||
1020 | 1025 | | |||
1021 | m_windowManagementInterface = w; | 1026 | m_windowManagementInterface = w; | ||
1022 | } | 1027 | } | ||
1023 | 1028 | | |||
1024 | void AbstractClient::destroyWindowManagementInterface() | 1029 | void AbstractClient::destroyWindowManagementInterface() | ||
▲ Show 20 Lines • Show All 989 Lines • Show Last 20 Lines |
Noob question: What would happen if the client is already on all desktops and you call enterDesktop for the first desktop?