Bug 477830

Summary: In WindowHeap-based effects, closing windows using "Natural" algorithm causes erratic rearranging of windows
Product: [Plasma] kwin Reporter: patrick.jansky
Component: effects-window-managementAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: nate
Priority: NOR    
Version: 5.90.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.1
Sentry Crash Report:
Attachments: Erratic behavior in overview

Description patrick.jansky 2023-12-01 11:40:24 UTC
Created attachment 163695 [details]
Erratic behavior in overview

SUMMARY
When you have lots of windows open and close some them in the overview the remaining windows rearrange themselves in an erratic an quite unpredictable way. GNOME solves this by only rearranging the remaining windows after a timeout and has more of a "the windows bellow the closed one move up to fill the void way". Looking at the video in KDE I can not really predict how the windows will move and as this happens after every windows you close. 


STEPS TO REPRODUCE
1. Open a lot of windows (20 or so suffice)
2. Go into overview 
3. Close some of those windows in the overview

OBSERVED RESULT
Erratic and jarring rearranging of the remaining windows after every window closed. This looks weird and is disorientating as you know longer know where the other windows will be after the rearrangement

EXPECTED RESULT
Smoother rearranging with a more predictable pattern. GNOME does this really well for reference


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Arch with KDE unstable Repo/Plasma 5.90.0
(available in About System)
KDE Plasma Version: 5.90.0
KDE Frameworks Version: 5.246
Qt Version: 6.6.1

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2023-12-01 18:03:35 UTC
FWIW not a Qt 6 issue; this is how it's basically always worked.
Comment 2 fanzhuyifan 2024-02-19 11:55:51 UTC
Git commit c3cda8b62ad3825883826bdd1928c8761aeb026d by Yifan Zhu.
Committed on 19/02/2024 at 11:46.
Pushed by fanzhuyifan into branch 'master'.

effects/overview: implement new layout algorithm

Replace old "closest" and "natural" layout algorithms with new layout
algorithm. The new layout algorithm tries to
- use screen space efficiently, given diverse geometries of windows
- be aesthetically pleasing
- and minimize movement of windows from initial positions.

More concretely, find a layered layout, where each layer, or strip, is a
row or column. Ensure that different strips have similar widths, and use
binary search to find a packing with similar aspect ratio to the layout
area. Within each strip, minimize horizontal movement (for rows) or
vertical movement (for columns) of windows.

Run time is O(n) (up to log factors), where n is the number of windows.
Related: bug 450263, bug 477833, bug 478097, bug 453749

M  +6    -27   src/plugins/overview/kcm/overvieweffectkcm.ui
M  +0    -3    src/plugins/overview/overviewconfig.kcfg
M  +0    -14   src/plugins/overview/overvieweffect.cpp
M  +0    -6    src/plugins/overview/overvieweffect.h
M  +0    -1    src/plugins/overview/qml/main.qml
M  +436  -399  src/plugins/private/expolayout.cpp
M  +204  -28   src/plugins/private/expolayout.h
M  +2    -2    src/plugins/private/qml/WindowHeap.qml
M  +4    -25   src/plugins/windowview/kcm/windowvieweffectkcm.ui
M  +0    -1    src/plugins/windowview/qml/main.qml
M  +0    -3    src/plugins/windowview/windowviewconfig.kcfg
M  +0    -14   src/plugins/windowview/windowvieweffect.cpp
M  +0    -6    src/plugins/windowview/windowvieweffect.h

https://invent.kde.org/plasma/kwin/-/commit/c3cda8b62ad3825883826bdd1928c8761aeb026d