Only send active window changes to X11 root window if the X11 window changed
Summary: 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: https://phabricator.kde.org/D7096
This commit is contained in:
parent
778b7d037f
commit
0455fa9ef9
3 changed files with 17 additions and 1 deletions
|
@ -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);
|
||||
|
|
11
netinfo.cpp
11
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
|
||||
// ****************************************
|
||||
|
|
|
@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
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()
|
||||
|
|
Loading…
Reference in a new issue