Bug 405807 - Affix the origin to the primary monitor on X11
Summary: Affix the origin to the primary monitor on X11
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: multi-screen (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-24 10:36 UTC by leftcrane
Modified: 2019-03-26 21:24 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description leftcrane 2019-03-24 10:36:36 UTC
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.
Comment 1 Martin Flöser 2019-03-24 10:45:54 UTC
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.
Comment 2 leftcrane 2019-03-24 10:52:38 UTC
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?
Comment 3 leftcrane 2019-03-24 10:54:57 UTC
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?
Comment 4 David Edmundson 2019-03-24 12:16:16 UTC
It is currently the case on wayland. 

Arguably we could have a different behaviour as we know what clients position themselves.
Comment 5 Martin Flöser 2019-03-24 12:29:40 UTC
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.
Comment 6 leftcrane 2019-03-24 12:33:38 UTC
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.
Comment 7 leftcrane 2019-03-24 12:37:03 UTC
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.
Comment 8 leftcrane 2019-03-24 12:38:27 UTC
(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).
Comment 9 Martin Flöser 2019-03-24 18:48:13 UTC
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.
Comment 10 leftcrane 2019-03-25 17:05:19 UTC
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?
Comment 11 Martin Flöser 2019-03-25 17:41:03 UTC
I'm not sure, but it's common to make windows invisible by giving them a geometry in the negative coordinates.
Comment 12 leftcrane 2019-03-26 10:34:25 UTC
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.
Comment 13 Martin Flöser 2019-03-26 12:38:11 UTC
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.
Comment 14 leftcrane 2019-03-26 21:24:02 UTC
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.