diff --git a/activation.cpp b/activation.cpp index 554dfb082b..9ded1a0569 100644 --- a/activation.cpp +++ b/activation.cpp @@ -271,7 +271,7 @@ void Workspace::setActiveClient(AbstractClient* c) updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active if (rootInfo()) { - rootInfo()->setActiveWindow(active_client ? active_client->window() : 0); + rootInfo()->setActiveClient(active_client); } emit clientActivated(active_client); diff --git a/netinfo.cpp b/netinfo.cpp index 326f6b1fb5..9da14d63f0 100644 --- a/netinfo.cpp +++ b/netinfo.cpp @@ -138,6 +138,7 @@ void RootInfo::destroy() RootInfo::RootInfo(xcb_window_t w, const char *name, NET::Properties properties, NET::WindowTypes types, NET::States states, NET::Properties2 properties2, NET::Actions actions, int scr) : NETRootInfo(connection(), w, name, properties, types, states, properties2, actions, scr) + , m_activeWindow(activeWindow()) { } @@ -224,6 +225,16 @@ void RootInfo::changeShowingDesktop(bool showing) Workspace::self()->setShowingDesktop(showing); } +void RootInfo::setActiveClient(AbstractClient *client) +{ + const xcb_window_t w = client ? client->window() : xcb_window_t{XCB_WINDOW_NONE}; + if (m_activeWindow == w) { + return; + } + m_activeWindow = w; + setActiveWindow(m_activeWindow); +} + // **************************************** // WinInfo // **************************************** diff --git a/netinfo.h b/netinfo.h index 46a91b1402..b5f8a2e620 100644 --- a/netinfo.h +++ b/netinfo.h @@ -30,6 +30,7 @@ along with this program. If not, see . namespace KWin { +class AbstractClient; class Client; /** @@ -44,6 +45,8 @@ public: static RootInfo *create(); static void destroy(); + void setActiveClient(AbstractClient *client); + protected: virtual void changeNumberOfDesktops(int n) override; virtual void changeCurrentDesktop(int d) override; @@ -60,6 +63,8 @@ private: NET::States states, NET::Properties2 properties2, NET::Actions actions, int scr = -1); static RootInfo *s_self; friend RootInfo *rootInfo(); + + xcb_window_t m_activeWindow; }; inline RootInfo *rootInfo()