Bug 480032

Summary: Window is out of screen after unplugging external display
Product: [Plasma] kwin Reporter: hexchain <kde>
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: carlon.luca, nate, xaver.hugl
Priority: NOR Keywords: multiscreen, qt6, wayland
Version: git master   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot when moving the window

Description hexchain 2024-01-19 06:35:58 UTC
SUMMARY
After unplugging the external display, a Wayland window from a Chrome PWA is out of the visible screen area.

Screen configuration:
(1) Laptop internal screen, eDP, 2880x1800, 175%, off when (2) is connected
(2) Monitor, DP, 3840x2160, 150%

Status of the window from KWin debug console:
bufferGeometry: -1572,316 1386x871
clientGeometry: -1556,326 1354x829
frameGeometry: -1556,326 1354x829
height: 829
width: 1354
pos: -1556,326
rect: 0,0 1354x829
size: 1354x829
x: -1556
y: 326
windowType: NET::Normal

The sequence of actions leading to this issue:
1. Connect the monitor
2. Switch to another user (screen configuration is the same)
3. Unplug the monitor and close the lid (put the laptop to sleep)
4. Open the lid (wake up)
5. Switch back

I am not sure if user switching is crucial but they are included for completeness.

STEPS TO REPRODUCE
Not sure.

EXPECTED RESULT
The window should be in the visible screen area.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.80
KDE Frameworks Version: 5.249.0
Qt Version: 6.7.0
Kernel Version: 6.7.0-arch3-1 (64-bit)
Graphics Platform: Wayland
Graphics Processor: AMD Radeon Graphics

KWin is (probably) at 9f10d5d79f.

ADDITIONAL INFORMATION
I also noticed that after unplugging the external monitor, non-maximized windows are only partly inside the visible screen.
Comment 1 hexchain 2024-01-19 06:43:28 UTC
Created attachment 165029 [details]
Screenshot when moving the window

Using the "Move" action in the task manager menu, I'm able to move the window back into the screen with arrow keys. The move cursor is outside the window, as expected.
Comment 2 Nate Graham 2024-01-19 19:41:23 UTC
Switching users seems very relevant indeed. Can you try again without switching users and see if it still happens?
Comment 3 hexchain 2024-01-21 14:28:27 UTC
It still happens without switching users. It is also a bit random - I cannot seem to figure out if there is a relationship between a window's position in its original screen, and where the window is after unplugging the monitor.
Comment 4 Nate Graham 2024-01-21 14:57:38 UTC
Thanks. I've got a theory: when this happens, did some part of the system fail to notice that the external screen was unplugged? Some signs that this might have happened?
- The cursor can move offscreen into the area that the disconnected screen was occupying
- The system fails to go to sleep when the laptop lid is closed, and the Power and Battery widget displays a message about this in its header area
Comment 5 Luca Carlon 2024-06-01 08:56:11 UTC
This happens to me very frequently, without any user switch. Simply unplug a screen when multiple windows are open: some windows are moved from the unplugged screen to the visible one, others remain invisible.
Comment 6 Zamundaaa 2024-06-09 17:01:41 UTC

*** This bug has been marked as a duplicate of bug 479694 ***