Bug 477833 - In WindowHeap-based effects, weird window placement with "Natural" algorithm
Summary: In WindowHeap-based effects, weird window placement with "Natural" algorithm
Alias: None
Product: kwin
Classification: Plasma
Component: effects-window-management (show other bugs)
Version: 5.90.0
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
Keywords: usability
Depends on:
Reported: 2023-12-01 12:14 UTC by patrick.jansky
Modified: 2024-02-24 02:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1

Closing windows in overview shows some weird windows arrangments with lots of empty space (1.54 MB, video/webm)
2023-12-01 12:14 UTC, patrick.jansky

Note You need to log in before you can comment on or make changes to this bug.
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

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.

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


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

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)

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

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