From e022bd7141e99da464eca10f005b6534fd5e90c4 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 21 Aug 2024 10:59:40 +0300 Subject: [PATCH] Rename Workspace::restack() function There are several ways how a window can be restacked relative to another: either by placing it below the reference window or above the reference window. Currently, the restack() function places the given window below the refererence window. But it's hard to decipher from the name, one needs to take a look at the argument names to understand what's going on. Another reason to rename is that it could be useful to have a stackAbove() function to make X11Window::restackWindow() implementation simpler and more straightforward. --- src/layers.cpp | 20 ++++++++++---------- src/tabbox/tabbox.cpp | 2 +- src/workspace.h | 2 +- src/x11window.cpp | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/layers.cpp b/src/layers.cpp index 51943a8db1..a39a80835f 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -445,32 +445,32 @@ void Workspace::lowerWindowRequest(Window *window) lowerWindowWithinApplication(window); } -void Workspace::restack(Window *window, Window *under, bool force) +void Workspace::stackBelow(Window *window, Window *reference, bool force) { if (window->isDeleted()) { - qCWarning(KWIN_CORE) << "Workspace::restack: closed window" << window << "cannot be restacked"; + qCWarning(KWIN_CORE) << "Workspace::stackBelow: closed window" << window << "cannot be restacked"; return; } - if (!force && !Window::belongToSameApplication(under, window)) { + if (!force && !Window::belongToSameApplication(reference, window)) { // put in the stacking order below _all_ windows belonging to the active application for (int i = 0; i < unconstrained_stacking_order.size(); ++i) { auto other = unconstrained_stacking_order.at(i); - if (other->isClient() && other->layer() == window->layer() && Window::belongToSameApplication(under, other)) { - under = other; + if (other->isClient() && other->layer() == window->layer() && Window::belongToSameApplication(reference, other)) { + reference = other; break; } } } - Q_ASSERT(unconstrained_stacking_order.contains(under)); - if (under == window) { + Q_ASSERT(unconstrained_stacking_order.contains(reference)); + if (reference == window) { return; } unconstrained_stacking_order.removeAll(window); - unconstrained_stacking_order.insert(unconstrained_stacking_order.indexOf(under), window); + unconstrained_stacking_order.insert(unconstrained_stacking_order.indexOf(reference), window); - m_focusChain->moveAfterWindow(window, under); + m_focusChain->moveAfterWindow(window, reference); updateStackingOrder(); } @@ -480,7 +480,7 @@ void Workspace::restackWindowUnderActive(Window *window) raiseWindow(window); return; } - restack(window, m_activeWindow); + stackBelow(window, m_activeWindow); } #if KWIN_BUILD_X11 diff --git a/src/tabbox/tabbox.cpp b/src/tabbox/tabbox.cpp index e4ff5f2c22..b5b1475041 100644 --- a/src/tabbox/tabbox.cpp +++ b/src/tabbox/tabbox.cpp @@ -226,7 +226,7 @@ void TabBoxHandlerImpl::raiseClient(Window *c) const void TabBoxHandlerImpl::restack(Window *c, Window *under) { - Workspace::self()->restack(c, under, true); + Workspace::self()->stackBelow(c, under, true); } void TabBoxHandlerImpl::elevateClient(Window *c, QWindow *tabbox, bool b) const diff --git a/src/workspace.h b/src/workspace.h index e7ae60e5c1..e2a7ae2893 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -235,7 +235,7 @@ public: #endif void lowerWindowRequest(Window *window); void restackWindowUnderActive(Window *window); - void restack(Window *window, Window *under, bool force = false); + void stackBelow(Window *window, Window *reference, bool force = false); void raiseOrLowerWindow(Window *window); void updateStackingOrder(bool propagate_new_windows = false); void forceRestacking(); diff --git a/src/x11window.cpp b/src/x11window.cpp index e788b68efb..96f913e101 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -1738,7 +1738,7 @@ void X11Window::doSetShade(ShadeMode previousShadeMode) shade_geometry_change = false; if (previousShadeMode == ShadeHover) { if (shade_below && workspace()->stackingOrder().indexOf(shade_below) > -1) { - workspace()->restack(this, shade_below, true); + workspace()->stackBelow(this, shade_below, true); } if (isActive()) { workspace()->activateNextWindow(this); @@ -5503,7 +5503,7 @@ void X11Window::restackWindow(xcb_window_t above, int detail, NET::RequestSource } if (other) { - workspace()->restack(this, other); + workspace()->stackBelow(this, other); } else if (detail == XCB_STACK_MODE_BELOW) { workspace()->lowerWindowRequest(this, src, timestamp); } else if (detail == XCB_STACK_MODE_ABOVE) {