Re-arrange code in X11Window::restackWindow()

Above and Below modes should be handled as follows:

   if (sibling) {
       workspace_stack_below/above(window, sibling);
   } else {
       workspace_lower/raise(window);
   }

But with the current code, it's difficult to see. This change rearranges
the code in the restackWindow() so it's more clear how the Above and the
Below modes are implemented.

It also moves workspace()->findClient(Predicate::WindowMatch, above); to
the top because all branches have it.
This commit is contained in:
Vlad Zahorodnii 2024-08-21 11:37:57 +03:00
parent e022bd7141
commit b6c1f7fb51

View file

@ -5437,9 +5437,8 @@ bool X11Window::allowWindowActivation(xcb_timestamp_t time, bool focus_in)
void X11Window::restackWindow(xcb_window_t above, int detail, NET::RequestSource src, xcb_timestamp_t timestamp, bool send_event)
{
X11Window *other = nullptr;
X11Window *other = workspace()->findClient(Predicate::WindowMatch, above);
if (detail == XCB_STACK_MODE_OPPOSITE) {
other = workspace()->findClient(Predicate::WindowMatch, above);
if (!other) {
workspace()->raiseOrLowerWindow(this);
return;
@ -5457,24 +5456,19 @@ void X11Window::restackWindow(xcb_window_t above, int detail, NET::RequestSource
++it;
}
} else if (detail == XCB_STACK_MODE_TOP_IF) {
other = workspace()->findClient(Predicate::WindowMatch, above);
if (other && other->frameGeometry().intersects(frameGeometry())) {
workspace()->raiseWindowRequest(this, src, timestamp);
}
return;
} else if (detail == XCB_STACK_MODE_BOTTOM_IF) {
other = workspace()->findClient(Predicate::WindowMatch, above);
if (other && other->frameGeometry().intersects(frameGeometry())) {
workspace()->lowerWindowRequest(this, src, timestamp);
}
return;
}
if (!other) {
other = workspace()->findClient(Predicate::WindowMatch, above);
}
if (other && detail == XCB_STACK_MODE_ABOVE) {
if (detail == XCB_STACK_MODE_ABOVE) {
if (other) {
auto it = workspace()->stackingOrder().constEnd(),
begin = workspace()->stackingOrder().constBegin();
while (--it != begin) {
@ -5504,11 +5498,16 @@ void X11Window::restackWindow(xcb_window_t above, int detail, NET::RequestSource
if (other) {
workspace()->stackBelow(this, other);
} else if (detail == XCB_STACK_MODE_BELOW) {
workspace()->lowerWindowRequest(this, src, timestamp);
} else if (detail == XCB_STACK_MODE_ABOVE) {
} else {
workspace()->raiseWindowRequest(this, src, timestamp);
}
} else if (detail == XCB_STACK_MODE_BELOW) {
if (other) {
workspace()->stackBelow(this, other);
} else {
workspace()->lowerWindowRequest(this, src, timestamp);
}
}
if (send_event) {
sendSyntheticConfigureNotify();