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;