Summary: | On a multi screen setup on Wayland, KDE app windows do not remember the size they had if the primary monitor is not the leftmost one. | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kconfig | Reporter: | David Rubio <david.alejandro.rubio> |
Component: | general | Assignee: | Nate Graham <nate> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alexandre, benedekppeter, david.alejandro.rubio, deafpolygon, dkxls23, dode, herzenschein, indecisiveautomator, kdebugs, kdelibs-bugs, mafriki, mail, miranda, mosaulp, nate |
Priority: | NOR | Keywords: | multiscreen, regression, usability |
Version: | 5.99.0 | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
See Also: | https://bugs.kde.org/show_bug.cgi?id=427875 | ||
Latest Commit: | https://invent.kde.org/frameworks/kconfig/commit/d254f9861c4df375525323815081c3f1b64d42b2 | Version Fixed In: | 5.104 |
Sentry Crash Report: |
Description
David Rubio
2022-10-11 18:20:39 UTC
Can reproduce 100%. I want to add that this mostly happens with KDE apps. It works for GTK apps, for example. My leftmost monitor is my primary monitor and this is affecting me as well. Hello, It is also affecting me. I have two monitors and the primary one is on the right. If I switch my primary on the left one, the windows size are remembered. My configuration : Fedora 37 Kinoite on Wayland - up to date version 221117 Nvidia RTX 2080 with driver 520.56.06 Left monitor : Dell U2515H 1440p @ 60hz Right monitor : AG271QG 1440p @ 144Hz Ryzen 3900X RAM 32Go 3466Mhz Thank you. Wanted to comment that I think I'm hitting this exact bug, as well. I have 3 monitor setup (shown below). It only affects size. Window placement is determined by KWin, I think, so this isn't an issue here. Additional testing steps, if they will help: When I say "an application", I am referring to any KDE based application (Kate, Konsole, etc). I have not tested with non-KDE applications at this point but I did not remember experiencing this issue with Firefox. At first: - Setting primary monitor to left-most and launching applications from the Application Launcher seems fine - size is remembered. Launching applications from KRunner on left-most monitor while it's set to primary - size is remembered on re-opening. Then I realized; - When left-most monitor is set to primary, and you launch applications using Alt+Space (KRunner) on any other monitor, size is still not remembered. - Trying to be clever, moving the default bar in the default layout for Breeze Dark to another monitor (while left is set to primary) and launching applications - size is not remembered. - Set the middle monitor to primary, and launched application with KRunner on left most monitor - size is remembered. This is repeated even when setting right-most monitor as primary. - Opening an application on any monitor, moving it to the left-most one, resizing and then closing will lead to size being remembered. - Opening an application on any monitor that is not the left-most, resizing it, THEN moving it to the left-most will not lead to size being remembered. - Similarly, opening an application on the left-most monitor, then moving it to another monitor will not lead to size being remembered. Conclusion; has nothing to do with which screen is set to the primary monitor. It only has to do with when a window being resized on the left-most display. If it is resized on the left-most display, then moved anywhere else AND THEN subsequently closed, size is still remembered. Example - left, center, right monitor. - Launching Konsole on the right monitor - Moving it to the left one - resizing - then moving it to the center one and closing - This will remember size. - Launching Konsole on the right monitor - Move it to the left one - Resizing while on left monitor, - Move to center and resize again. - Will only remember the size from the left-most monitor. If this is not the same as David's report, I will edit this and move it to a new bug report. Hope this helps! It's quite an irritating bug. Operating System: Fedora Linux 37 KDE Plasma Version: 5.26.3 KDE Frameworks Version: 5.100.0 Qt Version: 5.15.7 Kernel Version: 6.0.9-300.fc37.x86_64 (64-bit) Graphics Platform: Wayland Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor Memory: 31.2 GiB of RAM Graphics Processor: AMD Radeon RX 5700 XT Manufacturer: ASUS interface: 'wl_output', version: 4, name: 45 x: 3840, y: 0, scale: 1, physical_width: 600 mm, physical_height: 340 mm, make: 'LG Electronics', model: 'LG HDR 4K/110959', subpixel_orientation: unknown, output_transform: normal, mode: width: 3840 px, height: 2160 px, refresh: 59.997 Hz, flags: current interface: 'wl_output', version: 4, name: 46 x: 7680, y: 0, scale: 1, physical_width: 600 mm, physical_height: 340 mm, make: 'LG Electronics', model: 'LG HDR 4K/603556', subpixel_orientation: unknown, output_transform: normal, mode: width: 3840 px, height: 2160 px, refresh: 59.997 Hz, flags: current interface: 'wl_output', version: 4, name: 47 x: 0, y: 0, scale: 1, physical_width: 600 mm, physical_height: 340 mm, make: 'LG Electronics', model: 'LG HDR 4K/215425', subpixel_orientation: unknown, output_transform: normal, mode: width: 3840 px, height: 2160 px, refresh: 59.997 Hz, flags: current FWIW this is on my to-do list to fix; I know which file the bug is in (https://invent.kde.org/frameworks/kconfig/-/blob/master/src/gui/kwindowconfig.cpp); I just need to dig into it sometime when I have a second screen attached. Most of the time I don't. I'll get to it eventually, but anyone else should feel free to work on it themselves if they have time. *** Bug 461405 has been marked as a duplicate of this bug. *** *** Bug 460779 has been marked as a duplicate of this bug. *** How would someone go about fixing this? Whoever changed it to Fedora RPMs: i made this report on arch, but it probably includes all distros. Switching back to Arch just because that's where the report was taken from. No updates? Managed to investigate this today. The problem is that when we read and write the config values, we rely on the config key used for both being static as long as the screen arrangement itself is static. But that's not happening; with a multi-screen setup, the value of window->screen() changes when the same code is run in restoreWindowSize() compared to saveWindowSize(), and I don't yet understand why. It doesn't make much sense to me. However, this has exposed a flaw in the code; we currently embed the name of the current screen (which changes if you have a multi-screen setup) into the key but we actually don't need to do that at all; simply using the string representing the set of all current screens is good enough. That was the original design intention and the fact that the name of the current screen sneaks in again again looks like a bug. Continuing the investigation... Removing that extra data from the the key fixes part of the issue. But there's still another related issue that the last-used size for a screen setup isn't honored if you change screen setups and then go back. It's weird. Still working on that one. Will try to fix both related issues together. Eh, they're separate enough that I'll fix them separately. MR incoming. A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kconfig/-/merge_requests/180 The exact behavior of this bug happens like the following for me: ===== 1: Primary monitor on the right : Left is external screen, Right is laptop screen Resize in right and close in right = FORGOTTEN Resize in right and close in left = REMEMBER Resize in left and close in left = REMEMBER Resize in left and close in right = REMEMBER 2: Primary monitor on the left : Left is external screen, Right is laptop screen Resize in right and close in right = FORGOTTEN Resize in right and close in left = REMEMBER Resize in left and close in left = REMEMBER Resize in left and close in right = REMEMBER --- 1: Primary monitor on the right : Left is laptop screen, Right is external monitor Resize in right and close in right = FORGOTTEN Resize in right and close in left = REMEMBER Resize in left and close in left = REMEMBER Resize in left and close in right = REMEMBER 2: Primary monitor on the left : Left is laptop screen, Right is external monitor Resize in right and close in right = FORGOTTEN Resize in right and close in left = REMEMBER Resize in left and close in left = REMEMBER Resize in left and close in right = REMEMBER ===== I rebooted every time I changed the primary screen or moved the screen to the other side. The conclusion I arrive here is that primary monitor is indeed not what matters, like deafpolygon noted. Additionally, whether the screen is internal or external does not matter. In my case, the bug only happens when you resize and close the app in the right screen, no matter which one it is. A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kconfig/-/merge_requests/181 Git commit 3f84ef821d76cd7c646d4328b4627eb70dae4ab3 by Nate Graham. Committed on 14/02/2023 at 15:30. Pushed by ngraham into branch 'master'. Sort connector names for multi-screen size/position keys A string including the connector names is used in the config file key for storing per-screen-arrangement size and position data, which means we need this string to be consistent for the same screen arrangement. But connector order is non-deterministic. We need to sort the list to keep a consistent order and avoid losing multi-screen size and position data. M +6 -0 src/gui/kwindowconfig.cpp https://invent.kde.org/frameworks/kconfig/commit/3f84ef821d76cd7c646d4328b4627eb70dae4ab3 Git commit a502123a847decefb3a283784dc2edb4e42d932f by Nate Graham. Committed on 14/02/2023 at 16:22. Pushed by ngraham into branch 'kf5'. Sort connector names for multi-screen size/position keys A string including the connector names is used in the config file key for storing per-screen-arrangement size and position data, which means we need this string to be consistent for the same screen arrangement. But connector order is non-deterministic. We need to sort the list to keep a consistent order and avoid losing multi-screen size and position data. (cherry picked from commit 3f84ef821d76cd7c646d4328b4627eb70dae4ab3) M +6 -0 src/gui/kwindowconfig.cpp https://invent.kde.org/frameworks/kconfig/commit/a502123a847decefb3a283784dc2edb4e42d932f Git commit fc46a2215809abebfdab8ca471c1b27b65b7ad56 by Nate Graham. Committed on 16/02/2023 at 15:21. Pushed by ngraham into branch 'master'. Fix multimonitor window size restoration The size saving and restoring code saves width and height values under a config key that changes based on the active screens, the name of the current screen, and the resolution of the current screen. This suffers from a few issues: - Due to https://bugreports.qt.io/browse/QTBUG-50788, what counts as the current screen is volatile at runtime, and hence data gets saved to and read from different config file keys. - Including the screen resolution of the current screen only makes sense for single-screen setups anyway as it's just random data causing entropy for multi-screen setups. Both of these issues contribute to the problem of window size being restored incorrectly for multi-screen setups. This commit fixes the issue by no longer including current-screen-based data in the config file keys for multi-screen setups; just including the current set of screens is good enough and it's non-volatile within the scope of what we care about. FIXED-IN: 5.104 M +11 -4 src/gui/kwindowconfig.cpp https://invent.kde.org/frameworks/kconfig/commit/fc46a2215809abebfdab8ca471c1b27b65b7ad56 Git commit d254f9861c4df375525323815081c3f1b64d42b2 by Nate Graham. Committed on 16/02/2023 at 15:39. Pushed by ngraham into branch 'kf5'. Fix multimonitor window size restoration The size saving and restoring code saves width and height values under a config key that changes based on the active screens, the name of the current screen, and the resolution of the current screen. This suffers from a few issues: - Due to https://bugreports.qt.io/browse/QTBUG-50788, what counts as the current screen is volatile at runtime, and hence data gets saved to and read from different config file keys. - Including the screen resolution of the current screen only makes sense for single-screen setups anyway as it's just random data causing entropy for multi-screen setups. Both of these issues contribute to the problem of window size being restored incorrectly for multi-screen setups. This commit fixes the issue by no longer including current-screen-based data in the config file keys for multi-screen setups; just including the current set of screens is good enough and it's non-volatile within the scope of what we care about. FIXED-IN: 5.104 (cherry picked from commit fc46a2215809abebfdab8ca471c1b27b65b7ad56) M +11 -4 src/gui/kwindowconfig.cpp https://invent.kde.org/frameworks/kconfig/commit/d254f9861c4df375525323815081c3f1b64d42b2 A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kconfig/-/merge_requests/184 Git commit 9d4418b3b9521514298c8aca1191617eb4be9985 by Nate Graham. Committed on 24/02/2023 at 16:10. Pushed by ngraham into branch 'master'. 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-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 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 screen 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 screen 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: 1. Open Info Center 2. Move it to another location on screen and resize it 3. Close Info Center 4. Re-open Info Center -> position and size are remembered Wayland, single screen as well as 2 screens 1. Open Info Center 2. Move it to another location on screen and resize it 3. Close Info Center 4. Re-open Info Center -> size is remembered; position is not wnd 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: 1. Pin Info Center to Task Manager on Panel 1. 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 2. Move it to the other screen that does not have the Panel on it 3. Close Info Center 4. 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 M +11 -8 src/gui/kwindowconfig.cpp https://invent.kde.org/frameworks/kconfig/commit/9d4418b3b9521514298c8aca1191617eb4be9985 Git commit 239bb9c4be1b49116a45e708135dec85b526966c by Nate Graham. Committed on 26/02/2023 at 01:02. Pushed by ngraham into branch 'kf5'. 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-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 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 screen 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 screen 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: 1. Open Info Center 2. Move it to another location on screen and resize it 3. Close Info Center 4. Re-open Info Center -> position and size are remembered Wayland, single screen as well as 2 screens 1. Open Info Center 2. Move it to another location on screen and resize it 3. Close Info Center 4. Re-open Info Center -> size is remembered; position is not wnd 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: 1. Pin Info Center to Task Manager on Panel 1. 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 2. Move it to the other screen that does not have the Panel on it 3. Close Info Center 4. 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 (cherry picked from commit 9d4418b3b9521514298c8aca1191617eb4be9985) M +11 -8 src/gui/kwindowconfig.cpp https://invent.kde.org/frameworks/kconfig/commit/239bb9c4be1b49116a45e708135dec85b526966c *** Bug 450091 has been marked as a duplicate of this bug. *** |