From 7255352e625ad21d7db9858d7b57c1febec8ef6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 8 Feb 2013 19:54:13 +0100 Subject: [PATCH] fix restacking ... code - don't cast Window's to pointers for no apparent reason bug introduced with ac0f8bfb24403168199027a77bba0107bc6d42e1 - no stupid java style iterators, we've stl everywhere - postfix in a for loop is a bug. period. ;-) BUG: 313145 FIXED-IN: 4.10.1 --- layers.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/layers.cpp b/layers.cpp index 1a88ad3b1b..17498cc660 100644 --- a/layers.cpp +++ b/layers.cpp @@ -169,27 +169,29 @@ void Workspace::stackScreenEdgesUnderOverrideRedirect() */ void Workspace::propagateClients(bool propagate_new_clients) { - Window *cl; // MW we should not assume WId and Window to be compatible - // when passig pointers around. - // restack the windows according to the stacking order - // 1 - supportWindow, 1 - topmenu_space, 8 - electric borders - QVector newWindowStack; + // supportWindow > screen edges > clients > hidden clients + QVector newWindowStack; + // Stack all windows under the support window. The support window is // not used for anything (besides the NETWM property), and it's not shown, // but it was lowered after kwin startup. Stacking all clients below // it ensures that no client will be ever shown above override-redirect // windows (e.g. popups). - newWindowStack << (Window*)supportWindow->winId(); + newWindowStack << supportWindow->winId(); + #ifdef KWIN_BUILD_SCREENEDGES - QVectorIterator it(m_screenEdge.windows()); - while (it.hasNext()) { - if ((Window)it.next() != None) { - newWindowStack << (Window*)⁢ + QVector edges(m_screenEdge.windows()); + for (QVector::const_iterator it = edges.constBegin(), end = edges.constEnd(); it != end; ++it) { + if (*it != None) { + newWindowStack << *it; } } #endif - for (int i = stacking_order.size() - 1; i >= 0; i--) { + + newWindowStack.reserve(newWindowStack.count() + 2*stacking_order.count()); + + for (int i = stacking_order.size() - 1; i >= 0; --i) { Client *client = qobject_cast(stacking_order.at(i)); if (!client || client->hiddenPreview()) { continue; @@ -197,26 +199,28 @@ void Workspace::propagateClients(bool propagate_new_clients) if (client->inputId()) // Stack the input window above the frame - newWindowStack << (Window*)client->inputId(); + newWindowStack << client->inputId(); - newWindowStack << (Window*)client->frameId(); + newWindowStack << client->frameId(); } // when having hidden previews, stack hidden windows below everything else // (as far as pure X stacking order is concerned), in order to avoid having // these windows that should be unmapped to interfere with other windows - for (int i = stacking_order.size() - 1; i >= 0; i--) { + for (int i = stacking_order.size() - 1; i >= 0; --i) { Client *client = qobject_cast(stacking_order.at(i)); if (!client || !client->hiddenPreview()) continue; - newWindowStack << (Window*)client->frameId(); + newWindowStack << client->frameId(); } + // TODO isn't it too inefficient to restack always all clients? // TODO don't restack not visible windows? assert(newWindowStack.at(0) == (Window*)supportWindow->winId()); XRestackWindows(display(), (Window*)newWindowStack.data(), newWindowStack.count()); int pos = 0; + Window *cl; if (propagate_new_clients) { cl = new Window[ desktops.count() + clients.count()]; // TODO this is still not completely in the map order