Bug 479694 - Sometimes windows are not moved to the remaining display when the display they were on is disconnected
Summary: Sometimes windows are not moved to the remaining display when the display the...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: multi-screen (show other bugs)
Version: 5.92.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: multiscreen
: 480032 490733 491812 492244 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-01-12 14:04 UTC by madcatx
Modified: 2024-09-03 14:06 UTC (History)
12 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1.5
Sentry Crash Report:


Attachments
Screen layout (11.73 KB, image/jpeg)
2024-01-13 13:16 UTC, madcatx
Details
screencast of the bug (1.52 MB, video/mp4)
2024-05-26 12:51 UTC, eifr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description madcatx 2024-01-12 14:04:13 UTC
I started to notice this after update to RC1. If I leave some windows open on an external display and disconnect it, the windows remain on their original positions instead of moving to the remaining internal display. I can right-click on the affected windows in the taskbar, select the "Move" action and drag the windows back into view. This is happening under Wayland, I didn't check under X11.

Arch Linux
KF6 5.248.0
Plasma 5.92.0
Comment 1 Nate Graham 2024-01-12 20:34:30 UTC
You say it broke in RC1; does this mean it was working in the earlier beta release?
Comment 2 madcatx 2024-01-12 20:41:34 UTC
(In reply to Nate Graham from comment #1)
> You say it broke in RC1; does this mean it was working in the earlier beta
> release?

As far as I can tell, yes, at least I cannot recall this to happen since a very long time ago. I'm juggling my external screens quite a lot so I think I would have noticed. To be fair it isn't reliably reproducible so maybe there is something else going on...
Comment 3 Nate Graham 2024-01-12 21:08:39 UTC
Thanks. It would be great if you can narrow down the exact circumstances under which it happens, because I'm not able to reproduce the issue for my own multi-monitor use case of unplugging a secondary screen and using my laptop as a laptop.
Comment 4 madcatx 2024-01-13 13:16:30 UTC
Created attachment 164861 [details]
Screen layout
Comment 5 madcatx 2024-01-13 13:16:37 UTC
I got it to happen again. It does not appear to be connected to (dis)connections of displays but to changes of display modes in general.

I managed to trigger the issue twice by resuming the laptop from sleep, hooking the screen up, waiting for it to light up and *then* unlocking the session. In those cases, one of my windows was placed at (0,0) coordinates of the bounding rectangle of my display space. Since that's outside of what my displays show, the window was invisible (my display config is on the attached screenshot). I could tell what the window's position was by looking at the preview of window positions on the virtual desktops widget.

Another time it happened when I switched the resolution of my external screen. In that case, one window got moved somewhere to the bottom right of my display space and I couldn't even see its position on the virtual desktops widget.

In all cases I could eventually pull the window back into view.

I have been using RC1 for about one day and this has happened about 5 or 6 times now. I'm, therefore, sure that I would have noticed this if it was happening before RC1.
Comment 6 madcatx 2024-01-13 14:30:33 UTC
Unfortunately the root cause is probably even more elusive than I had originally thought.  One window got moved to (0, 0) position without any change in display configuration. The window was on a virtual desktop that I was not using when it happened so I don't know what exactly triggered it. I know I was moving some windows around to arrange them neatly for some screenshots.

Additionally, when this happens, KWin seems to become confused about the display setup. This manifests by new windows opening on the wrong screen or the window snapping feature using wrong dimensions.

I'm afraid that there is no easily discernible way how to trigger this but it keeps happening rather frequently
Comment 7 Nate Graham 2024-03-14 17:06:09 UTC

*** This bug has been marked as a duplicate of bug 379333 ***
Comment 8 Nate Graham 2024-03-14 17:07:52 UTC
Sorry, maybe not.

The issue looks rather like the one reported in Bug 452118 which is supposed to be fixed in Plasma 6; can you reproduce the issue with the final release of Plasma 6?
Comment 9 Aaron Wolf 2024-03-15 21:08:05 UTC
I have this problem now on KDE Neon 6, and I never had the issue before moving to KDE 6 and Wayland
Comment 10 Nate Graham 2024-04-01 16:32:32 UTC
Can affected people mention which specific windows are affected? Is it always the same ones?
Comment 11 eifr 2024-04-02 08:30:56 UTC
(In reply to Nate Graham from comment #10)
> Can affected people mention which specific windows are affected? Is it
> always the same ones?

reproducing steps (on fedora 40 plasma 6.0.3, laptop with external monitor connected):

1. open System settings on external monitor (while external is set to primary)
2. uncheck "enabled" + apply
3. System settings is not moving to the available monitor, and I'm unable to use is (it's also not showing on overview)
4. the app is showing is open in the "Icons only task manager" so when minimizing and opening again, it opens on the available monitor.


I tried to record it with Spectacle, but it seems to crash when disabling a monitor while recording screen
Comment 12 eifr 2024-05-26 12:51:18 UTC
Created attachment 169851 [details]
screencast of the bug

happened again so this time i recorded it,
this is so frustrating that when i disconnect a monitor, im unable to use some windows, i usually quit the app and re-open
Comment 13 Zamundaaa 2024-06-09 17:01:41 UTC
*** Bug 480032 has been marked as a duplicate of this bug. ***
Comment 14 Nate Graham 2024-06-12 17:52:34 UTC
I'm able to reproduce this 100% with only NeoChat. When I have it on my external screen (to the right of the laptop screen), unplugging the screen makes NeoChat move to an off-screen area, and it's not accessible on the laptop screen until I minimize it and then un-minimize it; when it un-minimizes, it gets moved to the laptop screen.
Comment 15 Arazil 2024-06-22 14:30:53 UTC
I have been running into this issue quite a bit on KDE 6.1. My display setup is two 4K monitors situated side by side with an external 1080P TV situated on the top right edge when it's turned on. In certain situations, I will lock the system with Firefox maximized on the TV display. When I come back, I unlock the system which wakes everything up except for the TV containing Firefox. At this point, Firefox becomes inaccessible to me unless I do the "maximize/un-maximize" trick to force it onto one of the two surviving 4K displays.

Setup:
Arch Linux
Plasma 6.1.0
Frameworks 6.3.0
Qt 6.7.1
Linux 6.9.5-arch1-1
Wayland

AMD Ryzen 9 5950X
AMD Radeon RX 6900 XT
Comment 16 Zamundaaa 2024-07-02 21:55:29 UTC
That doesn't necessarily sound related. Is the TV still shown in the display settings? TVs usually don't disconnect just because they're in standby
Comment 17 David Edmundson 2024-07-25 11:21:32 UTC
*** Bug 490733 has been marked as a duplicate of this bug. ***
Comment 18 Bug Janitor Service 2024-08-12 13:38:37 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6234
Comment 19 Zamundaaa 2024-08-14 12:24:01 UTC
Git commit 370c9c895373838cb5d4b51ff26ad9b54f3f9ef5 by Xaver Hugl.
Committed on 14/08/2024 at 11:38.
Pushed by zamundaaa into branch 'master'.

window: make setQuickTileMode more sane

...by removing the keyboard flag, moving keyboard shortcut handling into a separate
method and making the position to tile the window at explicit

This also means KWin doesn't do as many intermediary changes to window geometry on output
hotplugs, which may work around some clients not always reacting to no-op changes.

M  +1    -1    autotests/integration/move_resize_window_test.cpp
M  +2    -2    autotests/integration/outputchanges_test.cpp
M  +7    -7    autotests/integration/quick_tiling_test.cpp
M  +1    -1    src/placement.cpp
M  +1    -10   src/placementtracker.cpp
M  +65   -65   src/window.cpp
M  +3    -7    src/window.h

https://invent.kde.org/plasma/kwin/-/commit/370c9c895373838cb5d4b51ff26ad9b54f3f9ef5
Comment 20 Zamundaaa 2024-08-16 13:44:23 UTC
The underlying issue in Qt is still there, but the bug doesn't happen anymore with the commit, so I'm closing this
Comment 21 fanzhuyifan 2024-08-17 15:33:46 UTC
*** Bug 491812 has been marked as a duplicate of this bug. ***
Comment 22 Jonatan Cloutier 2024-08-19 10:40:08 UTC
Can this be included/backported in 6.1.5? 2 months with disappearing windows is quite long.
Comment 23 Bug Janitor Service 2024-08-22 21:20:40 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6306
Comment 24 Zamundaaa 2024-08-23 10:47:07 UTC
Git commit dd5b7d6e6df01d2c07bc8b96374fbf46f5c333ce by Xaver Hugl.
Committed on 22/08/2024 at 21:12.
Pushed by zamundaaa into branch 'Plasma/6.1'.

window: make setQuickTileMode more sane

...by removing the keyboard flag, moving keyboard shortcut handling into a separate
method and making the position to tile the window at explicit

This also means KWin doesn't do as many intermediary changes to window geometry on output
hotplugs, which may work around some clients not always reacting to no-op changes.
(cherry picked from commit 370c9c895373838cb5d4b51ff26ad9b54f3f9ef5)

M  +1    -1    autotests/integration/move_resize_window_test.cpp
M  +2    -2    autotests/integration/outputchanges_test.cpp
M  +7    -7    autotests/integration/quick_tiling_test.cpp
M  +1    -1    src/placement.cpp
M  +1    -10   src/placementtracker.cpp
M  +65   -65   src/window.cpp
M  +3    -7    src/window.h

https://invent.kde.org/plasma/kwin/-/commit/dd5b7d6e6df01d2c07bc8b96374fbf46f5c333ce
Comment 25 Nate Graham 2024-08-27 19:51:50 UTC
*** Bug 492244 has been marked as a duplicate of this bug. ***
Comment 26 Bug Janitor Service 2024-09-03 12:47:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6349
Comment 27 Bug Janitor Service 2024-09-03 13:43:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6350
Comment 28 Zamundaaa 2024-09-03 13:44:15 UTC
Git commit 24ab95bdd76dd189aa9a190d75f19ee94f733077 by Xaver Hugl.
Committed on 03/09/2024 at 13:29.
Pushed by zamundaaa into branch 'master'.

workspace: don't rearrange immediately when a window with struts gets removed

Otherwise, rearrange can happen on intermediate output configurations, as layer shell
windows can get closed in response to outputs being disabled.
That rearrange on intermediate output configurations can confuse the placement tracker
logic, which may then move windows to weird locations or even offscreen

M  +1    -1    src/workspace.cpp

https://invent.kde.org/plasma/kwin/-/commit/24ab95bdd76dd189aa9a190d75f19ee94f733077
Comment 29 Zamundaaa 2024-09-03 14:06:46 UTC
Git commit 4b1caed5644bf34aabfa7af533d19fad420568d5 by Xaver Hugl.
Committed on 03/09/2024 at 13:43.
Pushed by zamundaaa into branch 'Plasma/6.1'.

workspace: don't rearrange immediately when a window with struts gets removed

Otherwise, rearrange can happen on intermediate output configurations, as layer shell
windows can get closed in response to outputs being disabled.
That rearrange on intermediate output configurations can confuse the placement tracker
logic, which may then move windows to weird locations or even offscreen


(cherry picked from commit 24ab95bdd76dd189aa9a190d75f19ee94f733077)

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>

M  +1    -1    src/workspace.cpp

https://invent.kde.org/plasma/kwin/-/commit/4b1caed5644bf34aabfa7af533d19fad420568d5