From ec7fe44190114dfaa8ed8eac761c0bc1c26631a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 17 Sep 2017 09:26:24 +0200 Subject: [PATCH] Make xstacking order dirty handling work without X11 Summary: The xStackingOrder unlike indicated by it's name is relevant for both X11 and Wayland and contains the stacking order of the windows used for compositing. So far it was determined whether it needs to be recreated based on whether an xcb query is pending. This change introduces a boolean variable to check whether the stacking order is dirty and guards the X11 specific code to only be run if we have an X11 connection. This is to my current knowledge the last remaining issue where X11 was used during the normal Wayland operation mode. Now it should be possible to re-order the Workspace startup [1] and try to run kwin_wayland without Wayland support. [1] Workspace::Workspace and Workspace::init is still highly X11 specific and needs to be split into X11 only and general parts. Test Plan: Compiles Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7856 --- layers.cpp | 5 +++-- workspace.cpp | 5 ++++- workspace.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/layers.cpp b/layers.cpp index 28db06785a..0e109bb00d 100644 --- a/layers.cpp +++ b/layers.cpp @@ -693,7 +693,7 @@ bool Workspace::keepTransientAbove(const AbstractClient* mainwindow, const Abstr // Returns all windows in their stacking order on the root window. ToplevelList Workspace::xStackingOrder() const { - if (m_xStackingQueryTree) { + if (m_xStackingDirty) { const_cast(this)->updateXStackingOrder(); } return x_stacking; @@ -707,7 +707,7 @@ void Workspace::updateXStackingOrder() foreach (Toplevel * c, stacking_order) x_stacking.append(c); - if (!tree->isNull()) { + if (tree && !tree->isNull()) { xcb_window_t *windows = tree->children(); const auto count = tree->data()->children_len; int foundUnmanagedCount = unmanaged.count(); @@ -735,6 +735,7 @@ void Workspace::updateXStackingOrder() } } } + m_xStackingDirty = false; } //******************************* diff --git a/workspace.cpp b/workspace.cpp index c1b3816865..8610f79e47 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1696,7 +1696,10 @@ Toplevel *Workspace::findInternal(QWindow *w) const void Workspace::markXStackingOrderAsDirty() { - m_xStackingQueryTree.reset(new Xcb::Tree(rootWindow())); + m_xStackingDirty = true; + if (kwinApp()->x11Connection()) { + m_xStackingQueryTree.reset(new Xcb::Tree(kwinApp()->x11RootWindow())); + } } void Workspace::setWasUserInteraction() diff --git a/workspace.h b/workspace.h index a50772b80b..e70cf7daf3 100644 --- a/workspace.h +++ b/workspace.h @@ -565,6 +565,7 @@ private: bool force_restacking; ToplevelList x_stacking; // From XQueryTree() std::unique_ptr m_xStackingQueryTree; + bool m_xStackingDirty = false; QList should_get_focus; // Last is most recent QList attention_chain;