Skip to content

Fix "Toggle raise and lower" functionality

Jarek Janik requested to merge yaro/kwin:fixToggleRaiseLower into master

This MR has 2 commits - 1st adds tests for Toggle Raise and Lower functionality (they would fail now), second fixes #440540

Problem

Toggle Raise & Lower functionality basically works on the following principle: the window being acted upon is to be lowered if it is currently topmost, otherwise it is to be raised (Workspace::raiseOrLowerWindow()). This however won't work properly if there is a window in higher layer present on the same desktop (because none of normal windows could be topmost in such a case) - Toggle Raise & Lower would only raise normal windows in such a scenario (generally this applies to any window from any layer if there is a window present that sits in a higher layer, in practice however, the problem mostly touches normal layer windows if you happen to have at least one "Keep Above Others" window on the same desktop).

Back in the day when this feature had worked correctly, there had been a special field in Workspace class (named most_recently_raised) used for tracking last window that had been raised and such a window had been eligible for lowering (even if it couldn't be topmost, because of a window in higher layer). That code was removed ~3 years ago however, on the false assumption of being just a "micro optimization" (see commit 9577423d). That code itself has had some problems as well - when the aforementioned field was null (e.g. because you raised and then closed a window) and you wanted to use Toggle Raise & Lower to lower a window - you had to use it twice (first time just saved such a window in most_recently_raised field without any visible effect, the second time actually lowered it). Plus - there were some other issues mentioned in the commit that removed that original solution.

My solution takes much simpler approach - a window will be lowered if it is topmost within its own layer (and raised otherwise). The behavior is the same as in aforementioned older code, but the quirk when you sometimes needed to trigger the feature twice to get a result is absent now.

BUG: 440540

Edited by Jarek Janik

Merge request reports