The current behavior is that the origin is taken to be the upper-left corner across all displays. If you have a secondary monitor on the left, this means that that monitor becomes the primary one, because you windows will shift to that display on connect. The origin always shifts to the left-most monitor and this is what causes unexpected and undesired behavior for the users. This is the most serious issue for me on Kwin and I haven't observed this issue on any other desktop. Why not affix the origin of the multihead assembly to the center (or at least the left upper corner) of the primary monitor? I don't know if this problem is resolved in Wayland or whether it's possible to backport a fix to Kwin X11. Hopefully it can, since X11 will continue to be relevant for at least a couple more years.
I'm sorry but there's actually nothing wrong. This is actually a big limitation of X11. Windows are positioned in global coordinates and don't know on which screen they are. If you change the screen layout you change the global coordinate system, but the windows are not changed. This is the expected behavior of X11. Can we do something about it? Not really, because we don't know what the user expects and what the windows do. Easy example: Plasma reacts on it and adjusts it's windows. Imagine KWin would also adjust: it would completely break. There's no way for the window manager to know whether a window reacts itself, expects to stay or expects to move. Due to that we cannot do anything. Other window managers might do something, but we prefer to only do things which are actually possible and don't break as soon as you look at it from the wrong side.
Is there something in X11 that necessitates this? Why can't the origin be located on the primary monitor (instead of whichever monitor happens to be on the left)? I don't agree that nothing is wrong. Nobody wants all their windows to shift to the secondary monitor, or do they?
Is it different in Wayland, btw? If you connect a secondary monitor, will your coordinates also shift and cause windows to move to the left?
It is currently the case on wayland. Arguably we could have a different behaviour as we know what clients position themselves.
Also on Wayland windows don't know their own position in global coordinates and cannot move themselves. Given that we can keep them on the screen they are on when changing the global coordinate system. As David wrote we don't do that yet and I would say our code doesn't support it yet. That's an area which is still very X inspired - we don't have screen information at all.
Sorry to nag, but why can't the origin be located on the primary monitor? Right now I have to move all the windows back to the primary monitor manually after I connect a secondary, because most of them shift. That's at least ten clicks and drags every time I connect. I am going to have to write KWin script to make KWin viable with multihead - something most users will never do themselves. And my script will never be as good as a real solution because it can't allow clients to position themselves intelligently - it'd just stupidly move every window to a specific monitor.
Either that, or just change the setup to make sure the primary monitor is always in a specific position in the grid. So if you have three monitors horizontally, you'd actually have to arrange them vertically with the primary one at the top.
(actually no that won't work with window snapping. so you'd have to make sure the primary is always leftmost horizontally, regardless of how the monitors are actually positioned on your desk).
KWin doesn't know and doesn't care about primary monitors. It's not a concept for window managers. Primary monitor has zero influence on placement of windows. The windows "move" because they have a position of e.g. 100x200 in global coordinates. If you attach a screen to the left this results in the overall geometry to increase, but the left most is still at x 0. Due to that it seems like the windows move to another screen. KWin is not involved in the positioning of screens. This is handled by the xrandr protocol.
Yeah, I've looked into this and it seems like this is native behavior for X11. So there is no way to set the origin elsewhere? It always has to the be in the left corner?
I'm not sure, but it's common to make windows invisible by giving them a geometry in the negative coordinates.
I "fixed" it on my end by writing a script that sets/unsets a kwin rule forcing all windows to monitor one. Pretty crude and has to be run as hotplug, but it gets the job done. KDE should consider should consider shipping a workaround. Something as simple as a script to move all windows to pramary on display hotplug would be welcome. Users of right-secondary display will never need, but it'd be a a gosend to anyone struggling with a secondary display on the left.
I'm pretty much against shipping solutions which cannot work. Sorry. We cannot get that right for the reasons I mentioned and we won't start providing solutions which will break in other parts. That's exactly what scripts on store.kde.org for: to provide solutions for things which are not suitable as being shipped by us.
I think a shortcut or trigger to move all windows to primary is simple enough to work as advertised. But it's your call obviously.