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);
return;
}
auto it = workspace()->stackingOrder().constBegin(),
end = workspace()->stackingOrder().constEnd();
while (it != end) {
if (*it == this) {
const auto stack = workspace()->stackingOrder();
for (Window *window : stack) {
if (window == this) {
detail = XCB_STACK_MODE_ABOVE;
break;
} else if (*it == other) {
} else if (window == other) {
detail = XCB_STACK_MODE_BELOW;
break;
}
++it;
}
} else if (detail == XCB_STACK_MODE_TOP_IF) {
if (other && other->frameGeometry().intersects(frameGeometry())) {