Changeset View
Changeset View
Standalone View
Standalone View
workspace.cpp
Show All 23 Lines | |||||
24 | // kwin libs | 24 | // kwin libs | ||
25 | #include <kwinglplatform.h> | 25 | #include <kwinglplatform.h> | ||
26 | // kwin | 26 | // kwin | ||
27 | #ifdef KWIN_BUILD_ACTIVITIES | 27 | #ifdef KWIN_BUILD_ACTIVITIES | ||
28 | #include "activities.h" | 28 | #include "activities.h" | ||
29 | #endif | 29 | #endif | ||
30 | #include "appmenu.h" | 30 | #include "appmenu.h" | ||
31 | #include "atoms.h" | 31 | #include "atoms.h" | ||
32 | #include "client.h" | 32 | #include "x11client.h" | ||
33 | #include "composite.h" | 33 | #include "composite.h" | ||
34 | #include "cursor.h" | 34 | #include "cursor.h" | ||
35 | #include "dbusinterface.h" | 35 | #include "dbusinterface.h" | ||
36 | #include "deleted.h" | 36 | #include "deleted.h" | ||
37 | #include "effects.h" | 37 | #include "effects.h" | ||
38 | #include "focuschain.h" | 38 | #include "focuschain.h" | ||
39 | #include "group.h" | 39 | #include "group.h" | ||
40 | #include "input.h" | 40 | #include "input.h" | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
85 | 85 | | |||
86 | ColorMapper::~ColorMapper() | 86 | ColorMapper::~ColorMapper() | ||
87 | { | 87 | { | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | void ColorMapper::update() | 90 | void ColorMapper::update() | ||
91 | { | 91 | { | ||
92 | xcb_colormap_t cmap = m_default; | 92 | xcb_colormap_t cmap = m_default; | ||
93 | if (Client *c = dynamic_cast<Client*>(Workspace::self()->activeClient())) { | 93 | if (X11Client *c = dynamic_cast<X11Client *>(Workspace::self()->activeClient())) { | ||
94 | if (c->colormap() != XCB_COLORMAP_NONE) { | 94 | if (c->colormap() != XCB_COLORMAP_NONE) { | ||
95 | cmap = c->colormap(); | 95 | cmap = c->colormap(); | ||
96 | } | 96 | } | ||
97 | } | 97 | } | ||
98 | if (cmap != m_installed) { | 98 | if (cmap != m_installed) { | ||
99 | xcb_install_colormap(connection(), cmap); | 99 | xcb_install_colormap(connection(), cmap); | ||
100 | m_installed = cmap; | 100 | m_installed = cmap; | ||
101 | } | 101 | } | ||
▲ Show 20 Lines • Show All 437 Lines • ▼ Show 20 Line(s) | 535 | { | |||
539 | 539 | | |||
540 | // Use stacking_order, so that kwin --replace keeps stacking order | 540 | // Use stacking_order, so that kwin --replace keeps stacking order | ||
541 | const ToplevelList stack = stacking_order; | 541 | const ToplevelList stack = stacking_order; | ||
542 | // "mutex" the stackingorder, since anything trying to access it from now on will find | 542 | // "mutex" the stackingorder, since anything trying to access it from now on will find | ||
543 | // many dangeling pointers and crash | 543 | // many dangeling pointers and crash | ||
544 | stacking_order.clear(); | 544 | stacking_order.clear(); | ||
545 | 545 | | |||
546 | for (ToplevelList::const_iterator it = stack.constBegin(), end = stack.constEnd(); it != end; ++it) { | 546 | for (ToplevelList::const_iterator it = stack.constBegin(), end = stack.constEnd(); it != end; ++it) { | ||
547 | Client *c = qobject_cast<Client*>(const_cast<Toplevel*>(*it)); | 547 | X11Client *c = qobject_cast<X11Client *>(const_cast<Toplevel*>(*it)); | ||
548 | if (!c) { | 548 | if (!c) { | ||
549 | continue; | 549 | continue; | ||
550 | } | 550 | } | ||
551 | // Only release the window | 551 | // Only release the window | ||
552 | c->releaseWindow(true); | 552 | c->releaseWindow(true); | ||
553 | // No removeClient() is called, it does more than just removing. | 553 | // No removeClient() is called, it does more than just removing. | ||
554 | // However, remove from some lists to e.g. prevent performTransiencyCheck() | 554 | // However, remove from some lists to e.g. prevent performTransiencyCheck() | ||
555 | // from crashing. | 555 | // from crashing. | ||
556 | clients.removeAll(c); | 556 | clients.removeAll(c); | ||
557 | m_allClients.removeAll(c); | 557 | m_allClients.removeAll(c); | ||
558 | desktops.removeAll(c); | 558 | desktops.removeAll(c); | ||
559 | } | 559 | } | ||
560 | Client::cleanupX11(); | 560 | X11Client::cleanupX11(); | ||
561 | 561 | | |||
562 | if (waylandServer()) { | 562 | if (waylandServer()) { | ||
563 | const QList<XdgShellClient *> shellClients = waylandServer()->clients(); | 563 | const QList<XdgShellClient *> shellClients = waylandServer()->clients(); | ||
564 | for (XdgShellClient *shellClient : shellClients) { | 564 | for (XdgShellClient *shellClient : shellClients) { | ||
565 | shellClient->destroyClient(); | 565 | shellClient->destroyClient(); | ||
566 | } | 566 | } | ||
567 | } | 567 | } | ||
568 | 568 | | |||
Show All 31 Lines | |||||
600 | 600 | | |||
601 | void Workspace::setupClientConnections(AbstractClient *c) | 601 | void Workspace::setupClientConnections(AbstractClient *c) | ||
602 | { | 602 | { | ||
603 | connect(c, &Toplevel::needsRepaint, m_compositor, &Compositor::scheduleRepaint); | 603 | connect(c, &Toplevel::needsRepaint, m_compositor, &Compositor::scheduleRepaint); | ||
604 | connect(c, &AbstractClient::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged); | 604 | connect(c, &AbstractClient::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged); | ||
605 | connect(c, &AbstractClient::minimizedChanged, this, std::bind(&Workspace::clientMinimizedChanged, this, c)); | 605 | connect(c, &AbstractClient::minimizedChanged, this, std::bind(&Workspace::clientMinimizedChanged, this, c)); | ||
606 | } | 606 | } | ||
607 | 607 | | |||
608 | Client* Workspace::createClient(xcb_window_t w, bool is_mapped) | 608 | X11Client *Workspace::createClient(xcb_window_t w, bool is_mapped) | ||
609 | { | 609 | { | ||
610 | StackingUpdatesBlocker blocker(this); | 610 | StackingUpdatesBlocker blocker(this); | ||
611 | Client* c = new Client(); | 611 | X11Client *c = new X11Client(); | ||
612 | setupClientConnections(c); | 612 | setupClientConnections(c); | ||
613 | if (X11Compositor *compositor = X11Compositor::self()) { | 613 | if (X11Compositor *compositor = X11Compositor::self()) { | ||
614 | connect(c, &Client::blockingCompositingChanged, compositor, &X11Compositor::updateClientCompositeBlocking); | 614 | connect(c, &X11Client::blockingCompositingChanged, compositor, &X11Compositor::updateClientCompositeBlocking); | ||
615 | } | 615 | } | ||
616 | connect(c, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), ScreenEdges::self(), SIGNAL(checkBlocking())); | 616 | connect(c, SIGNAL(clientFullScreenSet(KWin::X11Client *,bool,bool)), ScreenEdges::self(), SIGNAL(checkBlocking())); | ||
617 | if (!c->manage(w, is_mapped)) { | 617 | if (!c->manage(w, is_mapped)) { | ||
618 | Client::deleteClient(c); | 618 | X11Client::deleteClient(c); | ||
619 | return nullptr; | 619 | return nullptr; | ||
620 | } | 620 | } | ||
621 | addClient(c); | 621 | addClient(c); | ||
622 | return c; | 622 | return c; | ||
623 | } | 623 | } | ||
624 | 624 | | |||
625 | Unmanaged* Workspace::createUnmanaged(xcb_window_t w) | 625 | Unmanaged* Workspace::createUnmanaged(xcb_window_t w) | ||
626 | { | 626 | { | ||
627 | if (X11Compositor *compositor = X11Compositor::self()) { | 627 | if (X11Compositor *compositor = X11Compositor::self()) { | ||
628 | if (compositor->checkForOverlayWindow(w)) { | 628 | if (compositor->checkForOverlayWindow(w)) { | ||
629 | return nullptr; | 629 | return nullptr; | ||
630 | } | 630 | } | ||
631 | } | 631 | } | ||
632 | Unmanaged* c = new Unmanaged(); | 632 | Unmanaged* c = new Unmanaged(); | ||
633 | if (!c->track(w)) { | 633 | if (!c->track(w)) { | ||
634 | Unmanaged::deleteUnmanaged(c); | 634 | Unmanaged::deleteUnmanaged(c); | ||
635 | return nullptr; | 635 | return nullptr; | ||
636 | } | 636 | } | ||
637 | connect(c, &Unmanaged::needsRepaint, m_compositor, &Compositor::scheduleRepaint); | 637 | connect(c, &Unmanaged::needsRepaint, m_compositor, &Compositor::scheduleRepaint); | ||
638 | addUnmanaged(c); | 638 | addUnmanaged(c); | ||
639 | emit unmanagedAdded(c); | 639 | emit unmanagedAdded(c); | ||
640 | return c; | 640 | return c; | ||
641 | } | 641 | } | ||
642 | 642 | | |||
643 | void Workspace::addClient(Client* c) | 643 | void Workspace::addClient(X11Client *c) | ||
644 | { | 644 | { | ||
645 | Group* grp = findGroup(c->window()); | 645 | Group* grp = findGroup(c->window()); | ||
646 | 646 | | |||
647 | emit clientAdded(c); | 647 | emit clientAdded(c); | ||
648 | 648 | | |||
649 | if (grp != nullptr) | 649 | if (grp != nullptr) | ||
650 | grp->gotLeader(c); | 650 | grp->gotLeader(c); | ||
651 | 651 | | |||
Show All 31 Lines | |||||
683 | { | 683 | { | ||
684 | unmanaged.append(c); | 684 | unmanaged.append(c); | ||
685 | markXStackingOrderAsDirty(); | 685 | markXStackingOrderAsDirty(); | ||
686 | } | 686 | } | ||
687 | 687 | | |||
688 | /** | 688 | /** | ||
689 | * Destroys the client \a c | 689 | * Destroys the client \a c | ||
690 | */ | 690 | */ | ||
691 | void Workspace::removeClient(Client* c) | 691 | void Workspace::removeClient(X11Client *c) | ||
692 | { | 692 | { | ||
693 | if (c == active_popup_client) | 693 | if (c == active_popup_client) | ||
694 | closeActivePopup(); | 694 | closeActivePopup(); | ||
695 | if (m_userActionsMenu->isMenuClient(c)) { | 695 | if (m_userActionsMenu->isMenuClient(c)) { | ||
696 | m_userActionsMenu->close(); | 696 | m_userActionsMenu->close(); | ||
697 | } | 697 | } | ||
698 | 698 | | |||
699 | if (client_keys_client == c) | 699 | if (client_keys_client == c) | ||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Line(s) | 924 | { | |||
933 | emit currentDesktopChanged(oldDesktop, movingClient); | 933 | emit currentDesktopChanged(oldDesktop, movingClient); | ||
934 | } | 934 | } | ||
935 | 935 | | |||
936 | void Workspace::updateClientVisibilityOnDesktopChange(uint newDesktop) | 936 | void Workspace::updateClientVisibilityOnDesktopChange(uint newDesktop) | ||
937 | { | 937 | { | ||
938 | for (ToplevelList::ConstIterator it = stacking_order.constBegin(); | 938 | for (ToplevelList::ConstIterator it = stacking_order.constBegin(); | ||
939 | it != stacking_order.constEnd(); | 939 | it != stacking_order.constEnd(); | ||
940 | ++it) { | 940 | ++it) { | ||
941 | Client *c = qobject_cast<Client*>(*it); | 941 | X11Client *c = qobject_cast<X11Client *>(*it); | ||
942 | if (!c) { | 942 | if (!c) { | ||
943 | continue; | 943 | continue; | ||
944 | } | 944 | } | ||
945 | if (!c->isOnDesktop(newDesktop) && c != movingClient && c->isOnCurrentActivity()) { | 945 | if (!c->isOnDesktop(newDesktop) && c != movingClient && c->isOnCurrentActivity()) { | ||
946 | (c)->updateVisibility(); | 946 | (c)->updateVisibility(); | ||
947 | } | 947 | } | ||
948 | } | 948 | } | ||
949 | // Now propagate the change, after hiding, before showing | 949 | // Now propagate the change, after hiding, before showing | ||
950 | if (rootInfo()) { | 950 | if (rootInfo()) { | ||
951 | rootInfo()->setCurrentDesktop(VirtualDesktopManager::self()->current()); | 951 | rootInfo()->setCurrentDesktop(VirtualDesktopManager::self()->current()); | ||
952 | } | 952 | } | ||
953 | 953 | | |||
954 | if (movingClient && !movingClient->isOnDesktop(newDesktop)) { | 954 | if (movingClient && !movingClient->isOnDesktop(newDesktop)) { | ||
955 | movingClient->setDesktop(newDesktop); | 955 | movingClient->setDesktop(newDesktop); | ||
956 | } | 956 | } | ||
957 | 957 | | |||
958 | for (int i = stacking_order.size() - 1; i >= 0 ; --i) { | 958 | for (int i = stacking_order.size() - 1; i >= 0 ; --i) { | ||
959 | Client *c = qobject_cast<Client*>(stacking_order.at(i)); | 959 | X11Client *c = qobject_cast<X11Client *>(stacking_order.at(i)); | ||
960 | if (!c) { | 960 | if (!c) { | ||
961 | continue; | 961 | continue; | ||
962 | } | 962 | } | ||
963 | if (c->isOnDesktop(newDesktop) && c->isOnCurrentActivity()) | 963 | if (c->isOnDesktop(newDesktop) && c->isOnCurrentActivity()) | ||
964 | c->updateVisibility(); | 964 | c->updateVisibility(); | ||
965 | } | 965 | } | ||
966 | if (showingDesktop()) // Do this only after desktop change to avoid flicker | 966 | if (showingDesktop()) // Do this only after desktop change to avoid flicker | ||
967 | setShowingDesktop(false); | 967 | setShowingDesktop(false); | ||
Show All 32 Lines | 998 | if (movingClient != nullptr && active_client == movingClient && | |||
1000 | active_client->isShown(true) && active_client->isOnCurrentDesktop()) { | 1000 | active_client->isShown(true) && active_client->isOnCurrentDesktop()) { | ||
1001 | // A requestFocus call will fail, as the client is already active | 1001 | // A requestFocus call will fail, as the client is already active | ||
1002 | return active_client; | 1002 | return active_client; | ||
1003 | } | 1003 | } | ||
1004 | // from actiavtion.cpp | 1004 | // from actiavtion.cpp | ||
1005 | if (options->isNextFocusPrefersMouse()) { | 1005 | if (options->isNextFocusPrefersMouse()) { | ||
1006 | ToplevelList::const_iterator it = stackingOrder().constEnd(); | 1006 | ToplevelList::const_iterator it = stackingOrder().constEnd(); | ||
1007 | while (it != stackingOrder().constBegin()) { | 1007 | while (it != stackingOrder().constBegin()) { | ||
1008 | Client *client = qobject_cast<Client*>(*(--it)); | 1008 | X11Client *client = qobject_cast<X11Client *>(*(--it)); | ||
1009 | if (!client) { | 1009 | if (!client) { | ||
1010 | continue; | 1010 | continue; | ||
1011 | } | 1011 | } | ||
1012 | 1012 | | |||
1013 | if (!(client->isShown(false) && client->isOnDesktop(desktop) && | 1013 | if (!(client->isShown(false) && client->isOnDesktop(desktop) && | ||
1014 | client->isOnCurrentActivity() && client->isOnActiveScreen())) | 1014 | client->isOnCurrentActivity() && client->isOnActiveScreen())) | ||
1015 | continue; | 1015 | continue; | ||
1016 | 1016 | | |||
Show All 27 Lines | 1036 | #ifdef KWIN_BUILD_ACTIVITIES | |||
1044 | 1044 | | |||
1045 | // Optimized Desktop switching: unmapping done from back to front | 1045 | // Optimized Desktop switching: unmapping done from back to front | ||
1046 | // mapping done from front to back => less exposure events | 1046 | // mapping done from front to back => less exposure events | ||
1047 | //Notify::raise((Notify::Event) (Notify::DesktopChange+new_desktop)); | 1047 | //Notify::raise((Notify::Event) (Notify::DesktopChange+new_desktop)); | ||
1048 | 1048 | | |||
1049 | for (ToplevelList::ConstIterator it = stacking_order.constBegin(); | 1049 | for (ToplevelList::ConstIterator it = stacking_order.constBegin(); | ||
1050 | it != stacking_order.constEnd(); | 1050 | it != stacking_order.constEnd(); | ||
1051 | ++it) { | 1051 | ++it) { | ||
1052 | Client *c = qobject_cast<Client*>(*it); | 1052 | X11Client *c = qobject_cast<X11Client *>(*it); | ||
1053 | if (!c) { | 1053 | if (!c) { | ||
1054 | continue; | 1054 | continue; | ||
1055 | } | 1055 | } | ||
1056 | if (!c->isOnActivity(new_activity) && c != movingClient && c->isOnCurrentDesktop()) { | 1056 | if (!c->isOnActivity(new_activity) && c != movingClient && c->isOnCurrentDesktop()) { | ||
1057 | c->updateVisibility(); | 1057 | c->updateVisibility(); | ||
1058 | } | 1058 | } | ||
1059 | } | 1059 | } | ||
1060 | 1060 | | |||
1061 | // Now propagate the change, after hiding, before showing | 1061 | // Now propagate the change, after hiding, before showing | ||
1062 | //rootInfo->setCurrentDesktop( currentDesktop() ); | 1062 | //rootInfo->setCurrentDesktop( currentDesktop() ); | ||
1063 | 1063 | | |||
1064 | /* TODO someday enable dragging windows to other activities | 1064 | /* TODO someday enable dragging windows to other activities | ||
1065 | if ( movingClient && !movingClient->isOnDesktop( new_desktop )) | 1065 | if ( movingClient && !movingClient->isOnDesktop( new_desktop )) | ||
1066 | { | 1066 | { | ||
1067 | movingClient->setDesktop( new_desktop ); | 1067 | movingClient->setDesktop( new_desktop ); | ||
1068 | */ | 1068 | */ | ||
1069 | 1069 | | |||
1070 | for (int i = stacking_order.size() - 1; i >= 0 ; --i) { | 1070 | for (int i = stacking_order.size() - 1; i >= 0 ; --i) { | ||
1071 | Client *c = qobject_cast<Client*>(stacking_order.at(i)); | 1071 | X11Client *c = qobject_cast<X11Client *>(stacking_order.at(i)); | ||
1072 | if (!c) { | 1072 | if (!c) { | ||
1073 | continue; | 1073 | continue; | ||
1074 | } | 1074 | } | ||
1075 | if (c->isOnActivity(new_activity)) | 1075 | if (c->isOnActivity(new_activity)) | ||
1076 | c->updateVisibility(); | 1076 | c->updateVisibility(); | ||
1077 | } | 1077 | } | ||
1078 | 1078 | | |||
1079 | //FIXME not sure if I should do this either | 1079 | //FIXME not sure if I should do this either | ||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Line(s) | 1293 | if (c && c->isOnCurrentDesktop()) { | |||
1294 | if (c->isDock()) { | 1294 | if (c->isDock()) { | ||
1295 | c->updateLayer(); | 1295 | c->updateLayer(); | ||
1296 | } else if (c->isDesktop() && c->isShown(true)) { | 1296 | } else if (c->isDesktop() && c->isShown(true)) { | ||
1297 | c->updateLayer(); | 1297 | c->updateLayer(); | ||
1298 | lowerClient(c); | 1298 | lowerClient(c); | ||
1299 | if (!topDesk) | 1299 | if (!topDesk) | ||
1300 | topDesk = c; | 1300 | topDesk = c; | ||
1301 | if (auto group = c->group()) { | 1301 | if (auto group = c->group()) { | ||
1302 | foreach (Client *cm, group->members()) { | 1302 | foreach (X11Client *cm, group->members()) { | ||
1303 | cm->updateLayer(); | 1303 | cm->updateLayer(); | ||
1304 | } | 1304 | } | ||
1305 | } | 1305 | } | ||
1306 | } | 1306 | } | ||
1307 | } | 1307 | } | ||
1308 | } | 1308 | } | ||
1309 | } // ~StackingUpdatesBlocker | 1309 | } // ~StackingUpdatesBlocker | ||
1310 | 1310 | | |||
▲ Show 20 Lines • Show All 333 Lines • ▼ Show 20 Line(s) | 1642 | foreach (const QString &effect, static_cast<EffectsHandlerImpl*>(effects)->loadedEffects()) { | |||
1644 | support.append(QStringLiteral("\n")); | 1644 | support.append(QStringLiteral("\n")); | ||
1645 | } | 1645 | } | ||
1646 | } else { | 1646 | } else { | ||
1647 | support.append(QStringLiteral("Compositing is not active\n")); | 1647 | support.append(QStringLiteral("Compositing is not active\n")); | ||
1648 | } | 1648 | } | ||
1649 | return support; | 1649 | return support; | ||
1650 | } | 1650 | } | ||
1651 | 1651 | | |||
1652 | Client *Workspace::findClient(std::function<bool (const Client*)> func) const | 1652 | X11Client *Workspace::findClient(std::function<bool (const X11Client *)> func) const | ||
1653 | { | 1653 | { | ||
1654 | if (Client *ret = Toplevel::findInList(clients, func)) { | 1654 | if (X11Client *ret = Toplevel::findInList(clients, func)) { | ||
1655 | return ret; | 1655 | return ret; | ||
1656 | } | 1656 | } | ||
1657 | if (Client *ret = Toplevel::findInList(desktops, func)) { | 1657 | if (X11Client *ret = Toplevel::findInList(desktops, func)) { | ||
1658 | return ret; | 1658 | return ret; | ||
1659 | } | 1659 | } | ||
1660 | return nullptr; | 1660 | return nullptr; | ||
1661 | } | 1661 | } | ||
1662 | 1662 | | |||
1663 | AbstractClient *Workspace::findAbstractClient(std::function<bool (const AbstractClient*)> func) const | 1663 | AbstractClient *Workspace::findAbstractClient(std::function<bool (const AbstractClient*)> func) const | ||
1664 | { | 1664 | { | ||
1665 | if (AbstractClient *ret = Toplevel::findInList(m_allClients, func)) { | 1665 | if (AbstractClient *ret = Toplevel::findInList(m_allClients, func)) { | ||
1666 | return ret; | 1666 | return ret; | ||
1667 | } | 1667 | } | ||
1668 | if (Client *ret = Toplevel::findInList(desktops, func)) { | 1668 | if (X11Client *ret = Toplevel::findInList(desktops, func)) { | ||
1669 | return ret; | 1669 | return ret; | ||
1670 | } | 1670 | } | ||
1671 | if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) { | 1671 | if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) { | ||
1672 | return ret; | 1672 | return ret; | ||
1673 | } | 1673 | } | ||
1674 | return nullptr; | 1674 | return nullptr; | ||
1675 | } | 1675 | } | ||
1676 | 1676 | | |||
1677 | Unmanaged *Workspace::findUnmanaged(std::function<bool (const Unmanaged*)> func) const | 1677 | Unmanaged *Workspace::findUnmanaged(std::function<bool (const Unmanaged*)> func) const | ||
1678 | { | 1678 | { | ||
1679 | return Toplevel::findInList(unmanaged, func); | 1679 | return Toplevel::findInList(unmanaged, func); | ||
1680 | } | 1680 | } | ||
1681 | 1681 | | |||
1682 | Unmanaged *Workspace::findUnmanaged(xcb_window_t w) const | 1682 | Unmanaged *Workspace::findUnmanaged(xcb_window_t w) const | ||
1683 | { | 1683 | { | ||
1684 | return findUnmanaged([w](const Unmanaged *u) { | 1684 | return findUnmanaged([w](const Unmanaged *u) { | ||
1685 | return u->window() == w; | 1685 | return u->window() == w; | ||
1686 | }); | 1686 | }); | ||
1687 | } | 1687 | } | ||
1688 | 1688 | | |||
1689 | Client *Workspace::findClient(Predicate predicate, xcb_window_t w) const | 1689 | X11Client *Workspace::findClient(Predicate predicate, xcb_window_t w) const | ||
1690 | { | 1690 | { | ||
1691 | switch (predicate) { | 1691 | switch (predicate) { | ||
1692 | case Predicate::WindowMatch: | 1692 | case Predicate::WindowMatch: | ||
1693 | return findClient([w](const Client *c) { | 1693 | return findClient([w](const X11Client *c) { | ||
1694 | return c->window() == w; | 1694 | return c->window() == w; | ||
1695 | }); | 1695 | }); | ||
1696 | case Predicate::WrapperIdMatch: | 1696 | case Predicate::WrapperIdMatch: | ||
1697 | return findClient([w](const Client *c) { | 1697 | return findClient([w](const X11Client *c) { | ||
1698 | return c->wrapperId() == w; | 1698 | return c->wrapperId() == w; | ||
1699 | }); | 1699 | }); | ||
1700 | case Predicate::FrameIdMatch: | 1700 | case Predicate::FrameIdMatch: | ||
1701 | return findClient([w](const Client *c) { | 1701 | return findClient([w](const X11Client *c) { | ||
1702 | return c->frameId() == w; | 1702 | return c->frameId() == w; | ||
1703 | }); | 1703 | }); | ||
1704 | case Predicate::InputIdMatch: | 1704 | case Predicate::InputIdMatch: | ||
1705 | return findClient([w](const Client *c) { | 1705 | return findClient([w](const X11Client *c) { | ||
1706 | return c->inputId() == w; | 1706 | return c->inputId() == w; | ||
1707 | }); | 1707 | }); | ||
1708 | } | 1708 | } | ||
1709 | return nullptr; | 1709 | return nullptr; | ||
1710 | } | 1710 | } | ||
1711 | 1711 | | |||
1712 | Toplevel *Workspace::findToplevel(std::function<bool (const Toplevel*)> func) const | 1712 | Toplevel *Workspace::findToplevel(std::function<bool (const Toplevel*)> func) const | ||
1713 | { | 1713 | { | ||
1714 | if (Client *ret = Toplevel::findInList(clients, func)) { | 1714 | if (X11Client *ret = Toplevel::findInList(clients, func)) { | ||
1715 | return ret; | 1715 | return ret; | ||
1716 | } | 1716 | } | ||
1717 | if (Client *ret = Toplevel::findInList(desktops, func)) { | 1717 | if (X11Client *ret = Toplevel::findInList(desktops, func)) { | ||
1718 | return ret; | 1718 | return ret; | ||
1719 | } | 1719 | } | ||
1720 | if (Unmanaged *ret = Toplevel::findInList(unmanaged, func)) { | 1720 | if (Unmanaged *ret = Toplevel::findInList(unmanaged, func)) { | ||
1721 | return ret; | 1721 | return ret; | ||
1722 | } | 1722 | } | ||
1723 | if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) { | 1723 | if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) { | ||
1724 | return ret; | 1724 | return ret; | ||
1725 | } | 1725 | } | ||
1726 | return nullptr; | 1726 | return nullptr; | ||
1727 | } | 1727 | } | ||
1728 | 1728 | | |||
1729 | bool Workspace::hasClient(const AbstractClient *c) | 1729 | bool Workspace::hasClient(const AbstractClient *c) | ||
1730 | { | 1730 | { | ||
1731 | if (auto cc = dynamic_cast<const Client*>(c)) { | 1731 | if (auto cc = dynamic_cast<const X11Client *>(c)) { | ||
1732 | return hasClient(cc); | 1732 | return hasClient(cc); | ||
1733 | } else { | 1733 | } else { | ||
1734 | return findAbstractClient([c](const AbstractClient *test) { | 1734 | return findAbstractClient([c](const AbstractClient *test) { | ||
1735 | return test == c; | 1735 | return test == c; | ||
1736 | }) != nullptr; | 1736 | }) != nullptr; | ||
1737 | } | 1737 | } | ||
1738 | return false; | 1738 | return false; | ||
1739 | } | 1739 | } | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |