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
This commit is contained in:
Thomas Lübking 2013-02-08 19:54:13 +01:00
parent ae7474a6c4
commit 7255352e62

View file

@ -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<Window*> newWindowStack;
// supportWindow > screen edges > clients > hidden clients
QVector<Window> 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<Window> it(m_screenEdge.windows());
while (it.hasNext()) {
if ((Window)it.next() != None) {
newWindowStack << (Window*)&it;
QVector<Window> edges(m_screenEdge.windows());
for (QVector<Window>::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<Client*>(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<Client*>(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