From a user perspective i've narrowed down the issue to display scaling (is that the right term?) like in the screenshots above.
If I use 1x scaling inead of 0.6x the move_to_monitor feature works. I switched to DPI scaling in the fonts settings instead of the above scaling for now, which seems to work/look much better than in 4.16 and even better than display scaling.
Maybe this information helps to fix the issue when scaling in the display settings is active. Let me know if i can do anything else related to this issue.
Thanks for reporting this one, indeed your debugging will help fix it. The move to monitor feature requires monitors to be "touching" on an edge, so it might be off by some small factor (or simply float rounding).
I'll run some tests to reproduce in the next day or 2 and see how easy of a fix this may be.
This is my fault, as I (never having coded much with glib before) saw them in other parts of the code, and was using them as regular flow-control.
I'll replace them all with if-statements so these don't show up unnecessarily.
The move to monitor functionality doesn't work
This is caused by a slight misalignment when using scaling. Printing out the current/other monitor positions being considered, we get things like (x, y, width, height):
current (0, 0, 2048, 1152)other (2047, 0, 2048, 1152)
This sounds very much like a rounding issue somewhere, and may or may not be intentional. When having my monitors scaled I do notice a single pixel of the first monitor's (maximized) window showing on the second.
@olivier I'm thinking of mitigating this by changing the == check to <= 2px, do you think that sounds fair?
I'll also submit an issue about the overflow when using scaling. @robberer can you check if you also had that single pixel bleed-over from one monitor to the next?
This feature doesn't work properly for me, either, and I think I have slightly different problems than the reports in this thread so far.
In contrast to the OP, I don't use scaling!
I use a laptop (left) and two external 27" screens (middle and right).
When I first attached the screens to the laptop, everything worked fine, but now I cannot get it to work anymore, although I deleted the saved profile, disconnected and reconnected the screens.
Here's what happens:
I have Super+Shift+Left and Super+Shift+Right mapped to move to left/right monitor.
The shortcut for Move to left monitor works flawlessly, but the shortcut for move to right monitor doesn't work at all.
However (!), right clicking on the window bar, then move to other monitor and selecting right monitor works, which seems really surprising to me because I would have expected this to be the same feature under the hood.
For move to left monitor shortcut (which works) the .xsession-errors shows this:
For move to right monitor shortcut, simply nothing happens, and no entries in .xsession-errors are created.
For move to left monitor and move to right monitor using the window titlebar (which works) I get a lot of spam, which is probably related to the g_return_val_if_fail thing mentioned above:
Wait, nevermind, it seems that this is a keyboard issue – super+shift+left is recognized correctly, but super+shift+right is not recognized at all. When I use the external keyboard, everything works as expected. This is a weird bug that I don't understand yet, but it seems to not have to do anything with this issue. o_O
I wonder why the code needs to be so strict about the layout though.
I understand this is to deal with setup with more than two monitors, it has to pick the closest one in the layout.
Maybe a more flexible approach would be to find the best monitor, picking the closest one even though it's not strictly contiguous?
The existing solution is fairly simple in that it 1) Must be contiguous 2) Favours one with more overlap perpendicular to the desired direction. However as soon as I try to drop the "must be contiguous" constraint (which I agree should be dropped), I spiral into philosophy!
Consider these 6 example 3-monitor configurations:
A little exaggerated I know, but good for philosophical discussion. In each example, we're on monitor 1, and thus there's 3 potential movements we could reasonably consider:
Move right to monitor 2
Move right to monitor 3 (directly, not "via monitor 2")
Move down to monitor 2
So let's consider the examples, and the argument for each.
Example 1
Move right to monitor 2? Probably, as there is overlap, and one could imagine a setup like this when using 3 "horizontal" monitors.
Move right to monitor 3? Probably not, as 2 really seems a better choice.
Move down to monitor 2? Probably, it's more right than down, but there is horizontal overlap.
Example 2
Move right to monitor 2? Maybe, the centre of 2 is very low though, and 3 seems a better choice.
Move right to monitor 3? Probably, it's much more "right" than 2.
Move down to monitor 2? Yes I think so.
Example 3
Move right to monitor 2? Probably not, as there's no overlap, and 3 seems a better choice.
Move right to monitor 3? Probably, as it's vertically aligned and there's no better choice.
Move down to monitor 2? Yes I think so.
Example 4
Move right to monitor 2? Probably not, even though its centre is to the right, it feels like it's not really "right" of 1.
Move right to monitor 3? Yes I think so.
Move down to monitor 2? Yes definitely.
Example 5
Move right to monitor 2? Probably not, as with example 3 the centroid is very low, and especially now because it compasses the entire horizontal portion of 1.
Move right to monitor 3? Yes I think so.
Move down to monitor 2? Yes definitely.
Example 6
Move right to monitor 2? No, for the same reasons as example 3.
Move right to monitor 3? Yes, as 2 really doesn't sound like a good candidate for "right".
Move down to monitor 2? Yes definitely.
In all of this, there are really 4 factors I'm really looking at:
How much overlap there is perpendicular to the direction of travel (when moving right, consider vertical overlap). This is why in example 1 I say monitor 2 can be considered "right", while in example 3 it shouldn't.
How much overlap there is in the same direction as the travel (when moving right, consider horizontal overlap). This is why in example 4 I hesitate to say monitor 2 should be considered "right" of monitor 1.
Angle between the centre of each monitor, relative to direction of travel. This is why in example 1 I say monitor 2 is right, but not so much in example 2.
Offset in the desired movement direction. This is why in example 1 I favour monitor 2 for "right" over monitor 3.
To add to the above 4 factors, in example 1 thoughts, I've selected monitor 2 as a candidate for both right and down. This leads to 2 similar but not equivalent questions:
Should a monitor be a candidate for more than 1 direction?
If so, should we allow the monitor to win both directions, and indeed show both?
If we say yes to Q1 but no to Q2, then we could hit some odd scenarios. Consider this setup:
We're using example 1 setup
Monitor 3 is off, so only 1/2 are active
We're on monitor 1
Monitor 2 is considered a candidate for both right and down, but "right" is preferred, so only that is shown.
Now we plug in monitor 3, and we consider it a better candidate for "right".
Because monitor 3 is preferred for "right", monitor 2 now doesn't win that, but does still win "down", so that option can be displayed (because it's no longer winning "right" also).
In adding a monitor to the right, the "down" option became available.
I'm not saying such an outcome would be "wrong", but it doesn't "sound" right.
In terms of actually putting together a valid algorithm for this, I'm only at constraints based on factors 1/2:
Require some overlap perpendicular to direction of travel to eliminate bad candidates. This eliminates going "right to monitor 2" in examples 3/6.
Overlap in the direction of travel is conditional in both boundaries. That is, if you're going right, the min-x and max-x of the monitor you're going from must be lower than the monitor you're going to. This eliminates going "right to monitor 2" in examples 4/5/6.
This is only good for elimination though, choosing a "best" is really tough, and keeps leaning towards a weighted sum of factors or something similar, which doesn't seem right (e.g. adding "angle between centres" with "overlap perpendicular to direction of travel").
I'll keep mulling it over, but if you find yourself with too much time, I'd love to hear your thoughts.