Bug 453141 - When changing display resolutions, desktop Widgets should try to keep the same position as much as possible
Summary: When changing display resolutions, desktop Widgets should try to keep the sam...
Status: CLOSED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Desktop Containment (show other bugs)
Version: master
Platform: Other Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-28 13:27 UTC by tomashnyk
Modified: 2023-03-05 22:56 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomashnyk 2022-04-28 13:27:12 UTC
This is a follow-up bug to https://bugs.kde.org/show_bug.cgi?id=360478

Previously, when changing resolutions, icons and widgets positioning would get scrambled. Now, Plasma remembers layouts for each resolution, but that still leaves two problems:
1) Icons still get scrambled once per new resolution.
2) When icon gets moved in one resolution, it is not moved in other resolutions.

Therefore,  I think the behvaiour when changing resolution should be modified as follows:

1. Unless manually moved, icons are always top aligned (this is the current state). User can change whether they are left-or right align (also current state). This sets "corner alignment".
2. When resolution changes, a test should be made whether each icon is still visible on screen.
3a. If an icon is is visible and it has not been automatically moved in a previous resolution change, keep it where it is.
3b. If an icon is is visible and it has been automatically moved in previous resolution, move it back where it was previously.
4. If an icon is not visible, test whether there is a saved resolution with a saved position of this icon.
5a. If yes, place it to that saved position.
5b. If not, place the icon to the opposite corner of the "alignment corner", starting with icons that are th furthest from the "alignmnet corner", respecting whether icons are sorted into columns or rows.

The rationale: I think nobody wants icons to dissapper and most or all people want to keep placement of the icons as much as possible across different resolutions. The above logic would solve the current state when moving icon in one resolution is not preserved into another resolution. I will try to illustrate it with a diagram. Lets have a 4x4 grid of icons. Numbers are positions, letters are icons:
  A   B   3   4
  C   D   7   8
  9 10   E  12
13 14   G   H

When the alignment is top left and into columns, transforming to 3x3 would yield this:
  A    B   G
  C    D   H
  7    8    E 
(H and G went off screen, so they get automatically re-arranged, from bottom right corner, which is opposite to the "alignment corner", starting with H, which was the most "off screen"), number 9 is occupied, so it i placed on 8, then G on 7 - if there was another icon, it would have gone to 8 and 7).

When the alignment is top left and into rows, transforming to 3x3 would yield this:
A    B    3
C    D    6
G    H   E
(the same as above, but now G and H are rearranged into rows, not columns)

Now imagine we move icons as follows (from the previous example with rows):
A    B   H
C    D   E
G    8   9
(so H and E were moved from 8 and 9 respecitvely to 3 and 6 - a property would need to be added tha would record whether placement is manual or automatic - only automatically placed icons would change place when going back to a higher resolution)

Now going back to 4x4 would give:
  A   B   H   4
  C   D   E   8
  9 10  11  12
13 14   G   16
(note H and E staying i their place set in 3x3, but G is rearranged).

An obvious question is what should happen when we have 4x4 grid and more than 16 icons. Actually, I think then a scrollbar is a good solution.


Also, I played with the current implementation a bit more
1) When one changes Alignment in "Desktop folder settings > Icons", it behaves in funny ways.  It seems to just flip X and Y coordinates. Previously, it would rearrange icons so they would all fit onto the screen. Now it happilly introduces scrollbars. I think it should behave according to the logic above using the property "manually|automatically placed" and should only change the position of  automatically placed icons. Further, it should not just flip their x and Y coordinates, but fill them one by one onto the visible untaken-by-other-icons area starting from the alignmnet corner (roughly the behaviour before this patch). The more I think about it, the property "manually|automatically placed" is quite crucial.
Comment 1 Nate Graham 2022-05-02 18:20:57 UTC
The implementation would be quite a can of worms, but it would be nice indeed.

It would also need to be separately implemented for desktop icons and widgets, so let's use this for widgets, and can you please open a new bug report for icons?
Comment 2 tomashnyk 2022-05-02 18:38:36 UTC
Done, here: https://bugs.kde.org/show_bug.cgi?id=453314
Comment 3 DarkThoughts 2022-05-18 13:37:23 UTC
This is still an issue if you use a non native monitor resolution (unlike https://bugs.kde.org/show_bug.cgi?id=360478). I believe it is caused by the login screen (SDDM) running in native and then applies the screen resolution of the user profile after the login, which scrambles all my widgets around.
Comment 4 Bug Janitor Service 2023-01-25 14:27:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2535
Comment 5 Marco Martin 2023-01-25 16:08:50 UTC
Git commit 39dd7bc3b75df58eb2d569df4f89cbe65f1113b6 by Marco Martin.
Committed on 25/01/2023 at 16:07.
Pushed by mart into branch 'master'.

fix problems in plasmoid layout restore

The layout manager has a functionality that when the layout is resized,
it tries to move all plasmoids to keep roughtly the same proportional
distance they had before the resize happened, to make screen resolution
change the least "suprising" possible.

We actually need this in only one case:
The screen resoltion changed and there is not a saved plasmoid layout
for this resolution.

What was actually happening was that this heuristic was executed *only*
when the layout was resized due to panels being added/resized (and not
when it should have been).
When a panel gets added/resized we want the plasmoids layoput to change
*as little as possible* again, to not make surprises.
As a side effect , it casued a pretty serious bug:
plasmoids near to the vertical center of the screen migrated upwards of
few pixels at every plasma restart, because ever time it starts without
a panel which appears only later, causing that heuristic to execute and
break havoc.
Now the heuristic is executed only when the screen resolution changes,
which will cause a "config key change" event.
Execute this also when the containment migrates to a new screen, and as
soon this heuristic got executed, save the layout on the new key.
Related: bug 442919, bug 437538, bug 431432

M  +7    -2    components/containmentlayoutmanager/abstractlayoutmanager.h
M  +14   -4    components/containmentlayoutmanager/appletslayout.cpp
M  +9    -2    components/containmentlayoutmanager/gridlayoutmanager.cpp
M  +1    -1    components/containmentlayoutmanager/gridlayoutmanager.h

https://invent.kde.org/plasma/plasma-workspace/commit/39dd7bc3b75df58eb2d569df4f89cbe65f1113b6
Comment 6 Marco Martin 2023-01-25 16:23:59 UTC
Git commit c7fe9fc0d271a145c9025994673599fb51872446 by Marco Martin.
Committed on 25/01/2023 at 16:23.
Pushed by mart into branch 'Plasma/5.27'.

fix problems in plasmoid layout restore

The layout manager has a functionality that when the layout is resized,
it tries to move all plasmoids to keep roughtly the same proportional
distance they had before the resize happened, to make screen resolution
change the least "suprising" possible.

We actually need this in only one case:
The screen resoltion changed and there is not a saved plasmoid layout
for this resolution.

What was actually happening was that this heuristic was executed *only*
when the layout was resized due to panels being added/resized (and not
when it should have been).
When a panel gets added/resized we want the plasmoids layoput to change
*as little as possible* again, to not make surprises.
As a side effect , it casued a pretty serious bug:
plasmoids near to the vertical center of the screen migrated upwards of
few pixels at every plasma restart, because ever time it starts without
a panel which appears only later, causing that heuristic to execute and
break havoc.
Now the heuristic is executed only when the screen resolution changes,
which will cause a "config key change" event.
Execute this also when the containment migrates to a new screen, and as
soon this heuristic got executed, save the layout on the new key.
Related: bug 442919, bug 437538, bug 431432

M  +7    -2    components/containmentlayoutmanager/abstractlayoutmanager.h
M  +14   -4    components/containmentlayoutmanager/appletslayout.cpp
M  +9    -2    components/containmentlayoutmanager/gridlayoutmanager.cpp
M  +1    -1    components/containmentlayoutmanager/gridlayoutmanager.h

https://invent.kde.org/plasma/plasma-workspace/commit/c7fe9fc0d271a145c9025994673599fb51872446
Comment 7 tomashnyk 2023-03-05 02:17:12 UTC
I am not sure this should have been closed as fixed by this merge request.

The commit message starts with: 'The layout manager has a functionality that when the layout is resized, it tries to move all plasmoids to keep roughtly the same proportional distance they had before the resize happened, to make screen resolution change the least "suprising" possible.'

I think that is incorrect. I do not think such functionality exists. This bug is about requesting such functionality - and I do not think this commit added it. So I am reopening this. If I am mistaken, sorry for the noise.
Comment 8 Nate Graham 2023-03-05 22:01:21 UTC
Please don't re-open bug reports based on conjecture. If you're experiencing an issue, please submit a new bug report. Thanks!
Comment 9 tomashnyk 2023-03-05 22:56:29 UTC
Ok, though if this functionality had been there all along, this should never have been accepted as a bug:-).