Bug 480991

Summary: Windows resize oddly when 200% scaled monitor hot-replugs itself
Product: [Plasma] kwin Reporter: Christopher Snowhill <kode54>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: normal CC: xaver.hugl
Priority: NOR Keywords: qt6
Version First Reported In: 5.93.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Wezterm Wayland debug log

Description Christopher Snowhill 2024-02-07 09:59:24 UTC
SUMMARY
***

I have my desktop configured with an LG 24UD58-B 3840x2160@60Hz monitor, set to 200% scaling, either on HDMI or DisplayPort, it will do this on either one. And a Dell P2414H at 1920x1080@60Hz at 100% scaling, over DisplayPort.

When my primary monitor is put into DPMS power off state, and successfully turns itself off after displaying the "power save" notice, it does something odd when powering back on. At the instant the operating system powers it back on with DPMS controls, it hot detaches itself from DRM, then needs to be re-attached. This causes a video mode change, possibly causing scaling to temporarily reset to 100% and back to 200% again.

This has the effect of causing several of my desktop windows to resize themselves. Wezterm in Wayland mode shrinks to a tiny box. Firefox, in its Wayland mode, maintains its size for the most part. Discord, an Electron app running in Xwayland mode, grows its window frame to 200% of its original size, but the content remains its original size in the top left corner of the window frame, while the rest of the window frame becomes transparent to what's underneath of it, and also becomes transparent to clicking in those empty regions. When resizing this Electron window's frame, or using the Super+Right button resize on a non-transparent region of the window contents, the window contents suddenly grow to the full size of the 200% scaled window frame. I have to shrink this Electron app every time I log back into my desktop, and grow the size of Wezterm to a usable size as well.


STEPS TO REPRODUCE
1. Have a 200% scaled monitor that does the above indicated DPMS dance every time it's powered back on, and a 100% scaled monitor to the right of it, which does not do any sort of port resetting when restored to powered on state.
2. Start some of the above mentioned apps, and arrange their windows in a semblance of normalcy.
3. Lock the screen.
4. Press the Escape key to DPMS power off.
5. Wait for the display to fully power off.
6. Move the mouse or press a key to power back on.
7. Unlock the desktop.

OBSERVED RESULT
Several different apps, depending on GTK+, Qt, Electron, either Xwayland or Wayland native, will be resized oddly, in somewhat consistent ways depending on what type of app it is.

EXPECTED RESULT
Windows should maintain their original size as they had prior to the video mode change, considering the mode change was same mode to same mode, but maybe had an inconsistent mode in between due to the DPMS power cycling and subsequent DRM mode reset.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux rolling, testing repositories enabled
KDE Plasma Version: 5.93.0
KDE Frameworks Version: 5.249.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION
None that I can think of.
Comment 1 Zamundaaa 2024-02-07 22:49:56 UTC
Xwayland apps being weird after scale changes is bug 480642, and is already fixed.

I can't reproduce the issue with wezterm. Please attach the output of running it with WAYLAND_DEBUG=1 while causing the problem to happen.
Comment 2 Christopher Snowhill 2024-02-08 00:01:33 UTC
Created attachment 165654 [details]
Wezterm Wayland debug log

Here's a log from the terminal being launched from Konsole with WAYLAND_DEBUG=1, locking my displays, letting them power off, then waking and unlocking them, then resizing the window back to a usable size again, then closing it.
Comment 3 Zamundaaa 2024-02-09 17:25:47 UTC
Okay, KWin sends a configure event with 150x150, the minimum size for all decorated windows. It definitely shouldn't do that.
Comment 4 Zamundaaa 2025-10-17 10:53:16 UTC
Does this still happen in Plasma 6.4? We've done a lot of work to ensure apps get resized back to how they were after whatever happens in output hotplugs.
Comment 5 Christopher Snowhill 2025-10-18 12:42:27 UTC
I can't say this has happened recently at all. And I have a different monitor layout now. The monitor that hot detaches itself is now my secondary monitor, so most of my windows don't live on it.