Bug 477833

Summary: In WindowHeap-based effects, weird window placement with "Natural" algorithm
Product: [Plasma] kwin Reporter: patrick.jansky
Component: effects-window-managementAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: fanzhuyifan, nate
Priority: NOR Keywords: usability
Version: 5.90.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.1
Sentry Crash Report:
Attachments: Closing windows in overview shows some weird windows arrangments with lots of empty space

Description patrick.jansky 2023-12-01 12:14:35 UTC
Created attachment 163699 [details]
Closing windows in overview shows some weird windows arrangments with lots of empty space

SUMMARY
The window placement looks quite weird in some window arrangements. Some windows are large and some are the same size (and its not the currently active window that is large, which would make some sense) and they are not arranged in a grid. This becomes especially apparent if you close  windows in the overview and the whole layout changes and some windows get bigger and some get smaller, per my last bug report. Some three windows arrangements also produce some quite weird result with lots of unused space.

The algorithm to arrange the open windows produces some quite strange results, see attached videos. The GNOME way of arranging the windows in a semi constant grid is nice but I'm sure there are other ways of doing it, but I find the current implementation in Plasma lacking.

STEPS TO REPRODUCE
1.  Open some windows 
2.  Go in to overview
3.  Play around with opening and closing some windows

OBSERVED RESULT

The windows are (in my eyes arbitrarily) differently sized and produce constellations with lots of unused space and weird uneven distributions of windows.

EXPECTED RESULT
Are more uniform distribution of windows with less empty space and a more uniform window size (not uniform!, more uniform, small variations to highlight active windows or to show window size are welcome)


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

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2023-12-01 18:44:35 UTC
Can confirm, but not a Qt 6 issue. This one is pretty old.
Comment 2 fanzhuyifan 2023-12-14 18:53:32 UTC
If a new algorithm were to be used, would this be considered a new feature so it would be targeted for 6.1?

Also, what is the best place to get feedback for a newly proposed algorithm? On here or as an issue on gitlab?

I plan to work on this a bit
Comment 3 Nate Graham 2023-12-15 15:53:49 UTC
That sounds great! I'm not sure whether a new placement algorithm should be considered a feature or not. From a user perspective it would be a UX improvement.

To get feedback about a proposal, https://invent.kde.org/plasma/kwin/-/issues/ probably makes sense.
Comment 4 fanzhuyifan 2023-12-15 20:47:43 UTC
See https://invent.kde.org/plasma/kwin/-/issues/189 for new proposal.
Comment 5 fanzhuyifan 2024-02-19 11:56:15 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 478097, bug 477830, 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