Bug 455066

Summary: Windows don't remember what screen they were on if that screen is disconnected and reconnected
Product: [Plasma] kwin Reporter: K Freed <kortrax11>
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: aleixpol, evorster, linuxguy123, nate, notmart, rlk, rocketraman, xaver.hugl
Priority: NOR    
Version: 5.24.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.26
Sentry Crash Report:

Description K Freed 2022-06-09 04:29:02 UTC
SUMMARY
***
This is a simple one (to describe at least). When turning a screen off or disconnecting it, the windows move on to the main screen. This is good. However, if that second screen is reconnected or turned back on, the windows do not go back onto the second screen.
***


STEPS TO REPRODUCE
1.  Disconnect screen
2. Reconnect screen
3. 

OBSERVED RESULT
On re-connection, the windows do not move back on to the second screen. It instead shows the desktop. Windows remain on the first screen.

EXPECTED RESULT
On re-connection, the windows should move back on to the second screen

SOFTWARE/OS VERSIONS

KDE 5.24.5 on Xorg
Comment 1 Nate Graham 2022-06-09 17:16:26 UTC
That's what they're supposed to do. If they don't, it's a bug.
Comment 2 Aleix Pol 2022-06-09 21:42:50 UTC
Maybe, we'd need to have a logic for that to happen though.

As it is, once a window is moved (because it's dragged or because it was moved for the display was disconnected) the window belongs there.
Comment 3 Nate Graham 2022-06-10 15:50:02 UTC
I could have sworn this was what it did on Wayland, but now that I test again, I see that you're right. When the screen is disconnected, windows move over to a still-connected screen, but when the disconnected screen is re-connected, they don't return there. 

We maybe need to conditionalize the logic so that a window only belongs to a screen if the user takes action to move it there from another, and thereafter that's its preferred screen such that it will automatically move there if that screen is reconnected. Belongingness shouldn't be updated due to automatic movements, only user-initiated ones.

This is what KXMLGUI tries to do manually for KDE app windows on X11. Of course it can't do everything like KWin can on Wayland.
Comment 4 Bug Janitor Service 2022-06-23 16:13:35 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2573
Comment 5 Zamundaaa 2022-07-13 22:55:08 UTC
*** Bug 456681 has been marked as a duplicate of this bug. ***
Comment 6 Raman Gupta 2022-07-15 22:45:50 UTC
Please make sure this handles the use case I mentioned in https://bugs.kde.org/show_bug.cgi?id=456681 in which multiple screens are turned off and on in a very short period of time, which might cause multiple screen disconnects before everything is restored back to normal. An example of what would cause this: a power blip. IMO, a delay of a few seconds in which KDE doesn't move windows at all is preferable to moving them instantaneously when a screen disappears, and then again when another screen disappears, and then trying to restore all that back to the original configuration when both screens reappear.
Comment 7 Zamundaaa 2022-08-19 14:26:54 UTC
*** Bug 458053 has been marked as a duplicate of this bug. ***
Comment 8 Fushan Wen 2022-08-21 03:46:16 UTC
*** Bug 452247 has been marked as a duplicate of this bug. ***
Comment 9 Zamundaaa 2022-08-31 21:06:14 UTC
Git commit ba0799974ed7b30b973c6a6a40c35be4d30d2ca2 by Xaver Hugl.
Committed on 31/08/2022 at 20:30.
Pushed by zamundaaa into branch 'master'.

workspace: restore window position after output changes
Related: bug 374908, bug 444082, bug 454003, bug 453589

M  +1    -0    src/CMakeLists.txt
A  +197  -0    src/placementtracker.cpp     [License: GPL(v2.0+)]
A  +68   -0    src/placementtracker.h     [License: GPL(v2.0+)]
M  +6    -0    src/window.cpp
M  +3    -0    src/window.h
M  +29   -0    src/workspace.cpp
M  +3    -0    src/workspace.h

https://invent.kde.org/plasma/kwin/commit/ba0799974ed7b30b973c6a6a40c35be4d30d2ca2
Comment 10 Zamundaaa 2022-10-15 21:20:54 UTC
*** Bug 460454 has been marked as a duplicate of this bug. ***