From e306e1b287b23b31da9a5852e04a51244be2a97b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 30 Mar 2023 12:58:10 +0300 Subject: [PATCH] tabbox: Port away from legacy desktop ids --- src/tabbox/clientmodel.cpp | 19 +++++++------------ src/tabbox/clientmodel.h | 10 ++-------- src/tabbox/tabbox.cpp | 15 +++++---------- src/tabbox/tabbox.h | 5 ++--- src/tabbox/tabboxhandler.h | 8 +------- 5 files changed, 17 insertions(+), 40 deletions(-) diff --git a/src/tabbox/clientmodel.cpp b/src/tabbox/clientmodel.cpp index 3a728d9595..a7a3b171a8 100644 --- a/src/tabbox/clientmodel.cpp +++ b/src/tabbox/clientmodel.cpp @@ -144,12 +144,7 @@ QModelIndex ClientModel::index(Window *client) const return createIndex(row, column); } -void ClientModel::createClientList(bool partialReset) -{ - createClientList(tabBox->currentDesktop(), partialReset); -} - -void ClientModel::createFocusChainClientList(int desktop, Window *start) +void ClientModel::createFocusChainClientList(Window *start) { auto c = start; if (!tabBox->isInFocusChain(c)) { @@ -160,7 +155,7 @@ void ClientModel::createFocusChainClientList(int desktop, Window *start) } auto stop = c; do { - Window *add = tabBox->clientToAddToList(c, desktop); + Window *add = tabBox->clientToAddToList(c); if (add) { m_mutableClientList += add; } @@ -168,7 +163,7 @@ void ClientModel::createFocusChainClientList(int desktop, Window *start) } while (c && c != stop); } -void ClientModel::createStackingOrderClientList(int desktop, Window *start) +void ClientModel::createStackingOrderClientList(Window *start) { // TODO: needs improvement const QList stacking = tabBox->stackingOrder(); @@ -176,7 +171,7 @@ void ClientModel::createStackingOrderClientList(int desktop, Window *start) auto stop = c; int index = 0; while (c) { - Window *add = tabBox->clientToAddToList(c, desktop); + Window *add = tabBox->clientToAddToList(c); if (add) { if (start == add) { m_mutableClientList.removeAll(add); @@ -197,7 +192,7 @@ void ClientModel::createStackingOrderClientList(int desktop, Window *start) } } -void ClientModel::createClientList(int desktop, bool partialReset) +void ClientModel::createClientList(bool partialReset) { auto start = tabBox->activeClient(); // TODO: new clients are not added at correct position @@ -212,11 +207,11 @@ void ClientModel::createClientList(int desktop, bool partialReset) switch (tabBox->config().clientSwitchingMode()) { case TabBoxConfig::FocusChainSwitching: { - createFocusChainClientList(desktop, start); + createFocusChainClientList(start); break; } case TabBoxConfig::StackingOrderSwitching: { - createStackingOrderClientList(desktop, start); + createStackingOrderClientList(start); break; } } diff --git a/src/tabbox/clientmodel.h b/src/tabbox/clientmodel.h index ee5c97934c..c491feec95 100644 --- a/src/tabbox/clientmodel.h +++ b/src/tabbox/clientmodel.h @@ -67,14 +67,8 @@ public: * the top of the list is kept as a starting point. If not the * current active client is used as the starting point to generate the * list. - * @param desktop The desktop for which the list should be created * @param partialReset Keep the currently selected client or regenerate everything */ - void createClientList(int desktop, bool partialReset = false); - /** - * This method is provided as a overload for current desktop - * @see createClientList - */ void createClientList(bool partialReset = false); /** * @return Returns the current list of Windows. @@ -93,8 +87,8 @@ public Q_SLOTS: void activate(int index); private: - void createFocusChainClientList(int desktop, Window *start); - void createStackingOrderClientList(int desktop, Window *start); + void createFocusChainClientList(Window *start); + void createStackingOrderClientList(Window *start); QList m_clientList; QList m_mutableClientList; diff --git a/src/tabbox/tabbox.cpp b/src/tabbox/tabbox.cpp index 010750df00..0cbdafe26c 100644 --- a/src/tabbox/tabbox.cpp +++ b/src/tabbox/tabbox.cpp @@ -71,11 +71,6 @@ int TabBoxHandlerImpl::activeScreen() const return workspace()->outputs().indexOf(workspace()->activeOutput()); } -int TabBoxHandlerImpl::currentDesktop() const -{ - return VirtualDesktopManager::self()->current(); -} - QString TabBoxHandlerImpl::desktopName(Window *client) const { if (!client->isOnAllDesktops()) { @@ -104,15 +99,15 @@ Window *TabBoxHandlerImpl::activeClient() const return Workspace::self()->activeWindow(); } -bool TabBoxHandlerImpl::checkDesktop(Window *client, int desktop) const +bool TabBoxHandlerImpl::checkDesktop(Window *client) const { switch (config().clientDesktopMode()) { case TabBoxConfig::AllDesktopsClients: return true; case TabBoxConfig::ExcludeCurrentDesktopClients: - return !client->isOnDesktop(desktop); + return !client->isOnCurrentDesktop(); default: // TabBoxConfig::OnlyCurrentDesktopClients - return client->isOnDesktop(desktop); + return client->isOnCurrentDesktop(); } } @@ -174,14 +169,14 @@ bool TabBoxHandlerImpl::checkMultiScreen(Window *client) const } } -Window *TabBoxHandlerImpl::clientToAddToList(Window *client, int desktop) const +Window *TabBoxHandlerImpl::clientToAddToList(Window *client) const { if (!client) { return nullptr; } Window *ret = nullptr; - bool addClient = checkDesktop(client, desktop) + bool addClient = checkDesktop(client) && checkActivity(client) && checkApplications(client) && checkMinimized(client) diff --git a/src/tabbox/tabbox.h b/src/tabbox/tabbox.h index 93d7abac5c..6731eb003d 100644 --- a/src/tabbox/tabbox.h +++ b/src/tabbox/tabbox.h @@ -42,7 +42,6 @@ public: int activeScreen() const override; Window *activeClient() const override; - int currentDesktop() const override; QString desktopName(Window *client) const override; bool isKWinCompositing() const override; Window *nextClientFocusChain(Window *client) const override; @@ -53,14 +52,14 @@ public: void raiseClient(Window *client) const override; void restack(Window *c, Window *under) override; void shadeClient(Window *c, bool b) const override; - Window *clientToAddToList(Window *client, int desktop) const override; + Window *clientToAddToList(Window *client) const override; Window *desktopClient() const override; void activateAndClose() override; void highlightWindows(Window *window = nullptr, QWindow *controller = nullptr) override; bool noModifierGrab() const override; private: - bool checkDesktop(Window *client, int desktop) const; + bool checkDesktop(Window *client) const; bool checkActivity(Window *client) const; bool checkApplications(Window *client) const; bool checkMinimized(Window *client) const; diff --git a/src/tabbox/tabboxhandler.h b/src/tabbox/tabboxhandler.h index 5a5cdc819e..2deec5f932 100644 --- a/src/tabbox/tabboxhandler.h +++ b/src/tabbox/tabboxhandler.h @@ -120,10 +120,6 @@ public: * on all desktops the name of current desktop will be returned. */ virtual QString desktopName(Window *client) const = 0; - /** - * @return The number of current desktop - */ - virtual int currentDesktop() const = 0; /** * whether KWin is currently compositing and it's related features (elevating) can be used @@ -162,7 +158,6 @@ public: /** * Determines if given client will be added to the list: *
    - *
  • Depends on desktop
  • *
  • if the client wants to have tab focus.
  • *
  • The client won't be added if it has modal dialogs
  • *
  • In that case the modal dialog will be returned if it isn't already @@ -171,11 +166,10 @@ public: * screen focus
  • *
* @param client The client to be checked for inclusion - * @param desktop The desktop the client should be on. This is irrelevant if allDesktops is set * @param allDesktops Add clients from all desktops or only from current * @return The client to be included in the list or NULL if it isn't to be included */ - virtual Window *clientToAddToList(Window *client, int desktop) const = 0; + virtual Window *clientToAddToList(Window *client) const = 0; /** * @return The first desktop window in the stacking order. */