Don't include screen connector names in screen position/size data
We have code that saves window positions (on X11) and sizes. It saves this data independently for single screens, different resolutions, and multi-screen arrangements. Identifying these in a way that's reliable has proved to be a challenge and multiple approaches have been taken over time. Currently we do the following:
- For single screens, save data on a per-primary-screen-connector-name and per-resolution basis
- For multi-screen, save data on a per-screen-arrangement basis (with "screen arrangement" being defined as "an alphabetically-sorted string list of all connector names)
Unfortunately, we know that under various circumstances connector names are volatile and change their text. For example:
- When switching GPUs
- When plugging a screen into a different type of port in the same GPU (e.g. HDMI -> DP or vice versa)
- When using an external screen with a laptop and switching between the external screen being connected to a dock vs connected directly to the laptop
- When switching between the X11 and wayland sessions
- Due to kernel bugs like https://bugzilla.kernel.org/show_bug.cgi?id=206387
We've done our best to minimize the impact of this volatility by sorting the list alphabetically and no longer including the connector name of the "current" screen in the config file key. But the whole approach of using screen connectors in the first place is inherently flawed due to the above-mentioned volatility and cannot be made to work perfectly reliably. For this reason, as of Plasma 5.27, Plasma and KScreen no longer use connector names to try to identify specific screens.
We can do the same here to significantly increase the robustness of the size and position restoration code. Instead of using connector names anywhere, now we do the following:
Single screen
Only save data on a per-resolution basis. Example config file contents:
[MainWindow]
1920x1080 screen: Height=770
1920x1080 screen: Width=1122
1920x1080 screen: XPosition=588
1920x1080 screen: YPosition=216
Multi-screen arrangements
Only save data on a "number of connected screens" basis. Example config file contents:
[MainWindow]
2 screens: Height=770
2 screens: Width=1122
2 screens: XPosition=1865
2 screens: YPosition=1274
This commit implements that change in the most minimal and backportable-to-kf5 manner. Further refactoring to remove now-unnecessary code will be done later only for KF6, to minimize risk.
Test Plan:
X11, single screen:
- Open Info Center
- Move it to another location on screen and resize it
- Close Info Center
- Re-open Info Center -> position and size are remembered
Wayland, single screen as well as 2 screens
- Open Info Center
- Move it to another location on screen and resize it
- Close Info Center
- Re-open Info Center -> size is remembered; position is not and it instead opens on the screen with the cursor on it according to the active window positioning mode, which is intentional at this point in time on Wayland
X11, 2 screens:
- Pin Info Center to Task Manager on Panel
- Open Info Center using Task Manager, and, if it doesn't open on the screen with the Panel, move it there, close it, and open it again
- Move it to the other screen that does not have the Panel on it
- Close Info Center
- Re-open Info Center from Task manager pinned icon -> position and size are remembered, including opening on the screen that doesn't have the Panel on it