Use for range based loop in X11Window::restackWindow() when traversing through stack

It's more readable and it also makes code more refactorable. For example,
if somebody makes Workspace::stackingOrder() return a normal QList, KWin
won't crash at this code.
This commit is contained in:
Vlad Zahorodnii 2024-08-21 20:39:25 +03:00
parent 0622526e8f
commit d56dbb04e6

View file

@ -5443,17 +5443,15 @@ void X11Window::restackWindow(xcb_window_t above, int detail, NET::RequestSource
workspace()->raiseOrLowerWindow(this); workspace()->raiseOrLowerWindow(this);
return; return;
} }
auto it = workspace()->stackingOrder().constBegin(), const auto stack = workspace()->stackingOrder();
end = workspace()->stackingOrder().constEnd(); for (Window *window : stack) {
while (it != end) { if (window == this) {
if (*it == this) {
detail = XCB_STACK_MODE_ABOVE; detail = XCB_STACK_MODE_ABOVE;
break; break;
} else if (*it == other) { } else if (window == other) {
detail = XCB_STACK_MODE_BELOW; detail = XCB_STACK_MODE_BELOW;
break; break;
} }
++it;
} }
} else if (detail == XCB_STACK_MODE_TOP_IF) { } else if (detail == XCB_STACK_MODE_TOP_IF) {
if (other && other->frameGeometry().intersects(frameGeometry())) { if (other && other->frameGeometry().intersects(frameGeometry())) {