STEPS TO REPRODUCE
1. Connect two displays, with the primary display on the RIGHT of the secondary one.
2. Create a Kwin rule forcing all windows to Monitor 1 (which should be your primary display in this context).
3. Disconnect the secondary left-hand display.
4. Reboot. (Maybe logging out is sufficient, not sure).
5. Open some windows (you are now just using one monitor).
6. Connect the secondary display.
All Windows shift from the display you were using to the freshly connected secondary display. To get the rule to catch, you have to disable and re-enable it.
The rule should force the windows to the display at all times.
This rule is very handy when the origin of the display assembly isn't located inside the primary monitor. Without this rule, Kwin will move all your windows to the secondary display when you connect it, which is extremely disruptive.
Ofc the ideal solution would be for Kwin to ensure that windows stay on the primary display when the assembly changes, but in the meantime the rule is an indispensable hack.
(perhaps a better setting would be to a "force to primary display" rule, since monitor numbers are confusing and unstable)
Operating System: Kubuntu 19.04
KDE Plasma Version: 5.15.4
KDE Frameworks Version: 5.56.0
Qt Version: 5.12.2
Kernel Version: 5.0.0-20-generic
OS Type: 64-bit
Rules are not evaluated when the screen layout changes. Only apply initial and apply now makes sense for the screen rule. If you want dynamic actions use a script instead.
*** Bug 447488 has been marked as a duplicate of this bug. ***
Git commit 75d71a1c1a0b837757fd1a5f687bfb98c9907bc6 by Ismael Asensio.
Committed on 16/04/2022 at 16:02.
Pushed by iasensio into branch 'master'.
AbstractClient: Re-check screen rules on screen enabled
M +0 -1 autotests/integration/xdgshellclient_rules_test.cpp
M +5 -0 src/workspace.cpp