Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 0455fa9e authored by Martin Flöser's avatar Martin Flöser

Only send active window changes to X11 root window if the X11 window changed

So far KWin always updated the active window property even if the actual
window id hasn't changed. E.g. if a Wayland window was active and another
Wayland window gets activated the window id was and stays 0.

Nevertheless KWin updated the property causing wakeups in X server and
any application listening to property changes on the root window.

Futhermore this situation is an information leak: we leak when a Wayland
window gets activated to X11.

To solve this problem RootInfo caches the active window id and only
updates if it changes.

Test Plan:
Verified with xev -root that the active window does not get
updated needlessly.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision:
parent 778b7d03
......@@ -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);
emit clientActivated(active_client);
......@@ -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)
void RootInfo::setActiveClient(AbstractClient *client)
const xcb_window_t w = client ? client->window() : xcb_window_t{XCB_WINDOW_NONE};
if (m_activeWindow == w) {
m_activeWindow = w;
// ****************************************
// WinInfo
// ****************************************
......@@ -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);
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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment