You are not logged in.
I have two displays, HDMI-0 (2560x1440) and HDMI-1 (1980x1080), set up via xrandr as follows:
xrandr --output HDMI-0 --auto --output HDMI-1 --auto --pos 2570x0
It works as expected, however I find it very annoying that mouse easily leaves my primary screen. For example, when I try to grab something on the right side of primary display (like a browser scrollbar) I often overshoot and end up on secondary display. Previously I used a single-monitor setup, and it was quite nice that I didn't need to target scrollbar (and other elements) precisely and could just yank the mouse to the right.
Is there a way to "bind" the mouse to dimensions of primary display and forbid it from leaving outside that area?
Last edited by Rogach (2020-08-12 07:12:14)
Offline
Would you not want to use the mouse on the other display at all? Why not just arrange the two with different geometry so that edge is not shared?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Yes, it would be acceptable if I would not be able to use the mouse on the secondary display (I plan to display some metrics and dashboards on it, so mouse is not that important).
I tried setting them up without shared edges, but it looks like the mouse can still travel over the "union" of those two areas. For example if I do this:
xrandr --output HDMI-0 --auto --output HDMI-1 --auto --pos 3000x2000
then my mouse can leave the primary display on the right side or on the bottom.
Offline
This only works if the outputs touch at least in one point (ie. you'd have to create a ridiculously large root window to have a diagonal layout)
https://aur.archlinux.org/packages/xpointerbarrier-git/ uses X11 pointer barriers which is MUCH better than https://aur.archlinux.org/packages/jail/ which polls the pointer position in a while true loop and warps the pointer into the jail.
Offline
Yes, creating a diagonal layout works! I did it the following way:
xrandr --output HDMI-0 --auto --output HDMI-1 --auto --pos 2560x1440
As an added bonus I can move the mouse between screens if I put it exactly in the lower-right corner.
xpointerbarrier also works, but with it I have to bind a small xdotool script to some hotkey if I would want to move mouse between scripts.
Are there any downsides to such diagonal layout and huge root window?
Offline
(GPU) Memory demands.
Clients that ignore the output configuration, wallpaper tools, … everthing that assumes the workspace is some rectangle might act "weird" because of the two blind quarters.
Offline
While I agree with the above - all but the first one depends on the WM/DE and related tools that you use such that in some cases they simply may not even apply. The increased video memory seems a logical necessity, but in my own use I've never noticed a diagonal configuration using more memory than a rectangular. While I've not specifically checked for it, I have always run quite old and limited hardware and am a fairly maniacal about minimumizing resource use.
The fact that it never registered for me makes me wonder (pure speculation) whether Xorg actually uses more memory for that space. In fact, while it seems intuitively obvious that the added unused space should need some ram, it's not clear why unused space in a rectangular or single screen root window wouldn't also: with a single screen set up, windows can still be moved to a anywhere within a fairly large offscreen root window area. There's no obvious logical reason why the offscreen diagonal patches should need more memory than all the other offscreen areas in any other configuration.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I would suspect that it is "easy" programming-wise to just keep the huge rectange in memory and map the necessary parts to the necessary outputs, especially since displays may be overlapping. Regarding off-screen windows - I always suspected that the drawing outside the visible area just gets clipped and thus no actual memory is needed for off-screen portions of the windows. But I do not know X internals, so can't confirm.
I tried experimenting a bit - tried different xrandr configurations (side-by-side and diagonal), and checked video memory used by Xorg with different configurations. Side-by-side uses 18-20 MB less, which is consistent with hypothesis that there's simply a huge rectangle in memory:
(2560+1980)*(1440+1080)*4 - (2560+1980)*(1440)*4 = 19612800 ~= 19MB
Offline