diff --git a/activation.cpp b/activation.cpp --- a/activation.cpp +++ b/activation.cpp @@ -271,7 +271,7 @@ 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.h b/netinfo.h --- a/netinfo.h +++ b/netinfo.h @@ -30,6 +30,7 @@ namespace KWin { +class AbstractClient; class Client; /** @@ -44,6 +45,8 @@ 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 @@ 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() diff --git a/netinfo.cpp b/netinfo.cpp --- a/netinfo.cpp +++ b/netinfo.cpp @@ -138,6 +138,7 @@ 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 @@ 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 // ****************************************