X.Org/Dual Monitors/Mouse Control

From Gentoo Linux Wiki
Jump to: navigation, search


X.Org TOC


[edit] Switchscreen

It is no problem to move the mouse pointer between dual head screens, if you don't mind reaching for your mouse. After searching endlessly for something to allow him to move the pointer between non-xinerama dual head screens purely from the keyboard and finding nothing, David Antliff wrote a program to accomplish this:

http://unlogical.net/files/scripts/switchscreen-0.4.tar.gz

Compile it up (see comment in source) and bind it to a key in Fluxbox.

File: ~/.fluxbox/keys
# switch between groups
Mod1 Tab :PrevWindow 5
Mod1 Shift Tab :NextWindow 5

# switch between workspaces
Mod1 Up : Mod1 Down :NextWorkspace

# switch between group members
Mod1 Left :PrevTab
Mod1 Right :NextTab

# switch between screens
Mod1 End :ExecCommand /usr/local/bin/switchscreen

It uses the XTEST extension to perform a 'fake' absolute mouse pointer move. It remembers the previous pointer location so you can effortlessly switch backwards and forwards between two screens. It could do with a little more work but it's perfectly functional right now. The XWarpPointer library function didn't seem to allow moving between screens so I use XTestFakeMotionEvent instead.

It can be used with any window manager since it uses pure X11 library calls. However combined with Fluxbox and keybindings to change virtual desktops, it allows you to easily change between sixteen virtual workspaces across two heads without using the mouse at all.

David Mohr adopted the above program to work with xorg 7.4 and added a small utility to wrap the mouse cursor between two separate X screens. See dualscreen-mouse-utils for more details and to download.

xbindkeys is another way to go for other window managers than Fluxbox.

[edit] Mouse Jail: How to lock your mouse in the monitor

Playing games when using a dual monitor configuration can be a pain. The problem is that the mouse would move to the other monitor while playing the game, and you would lose control of the mouse for your game. To avoid this problem, there's a small program you can use, mostly based on David Antliff's switchscreen program. The idea is simply to lock your mouse in the monitor it currently is in. The tarball for this program is available at http://www.cs.kent.ac.uk/~sm244/Jail.tar.gz . You can then simply bind a shortcut key to the program from your window manager.

[edit] Switchscreen with Mouse Jail

You might like to use the second screen for certain tasks only (eg. TV). The Problem is the same as in "Mouse Jail" described above, which means you have to run jail at startup. There is an alternative solution: configure the second Screen "far away" from the first one:

File: xorg.conf
Section "ServerLayout"

       Identifier     "double"
       Screen         0 "Screen0" 0 0
       Screen         1 "Screen1" 2000 0
       InputDevice    "Mouse0" "CorePointer"
       InputDevice    "Keyboard0" "CoreKeyboard"

EndSection

X Configured like above, prevents you from moving your mouse to the second screen. When you want to move the mouse there, use a hotkey configured on your Window Manager, which runs Switchscreen (see link above) to move the mouse on the second screen. Now you are able to view TV on my second screen for example:

DISPLAY=:0.1 xine -f test.avi

while still working on the first one.

Jail might not work for you (in one case Warcraft III was lagging when Jail worked to keep the cursor in the right screen). So instead configure the screens "far away" like mentioned above in this section, and then use an adapted version of the Jail program to allow the crossing of the cursor: http://dsp.mcbf.net/releases/mouse-switchscreen-0.3b.tar.bz2 . It turns out that allowing the cursor to cross over is much easier for the computer than it is to jail the cursor. The included "mouse-switchscreen.sh" script makes it easy to toggle the feature with a keyboard shortcut. That way you can have it on by default, and turn it off quickly when starting a game.

If Screen 1 has a lower resolution than Screen 0 (e.g. TV), you can also stack screen 1 on top of screen 0:

       Screen         0 "Screen0" 0 0
       Screen         1 "Screen1" 0 0

Then you can switch to Screen 0 with switchscreen and come back to Screen 1 by moving the mouse across the bottom or right border! The mouse will still be jailed in screen 0.

Also you can configure one monitor as the side of another.

File: xorg.conf
Section "ServerLayout"

       Identifier     "double"
       Screen         0 "Screen0" 
       Screen         1 "Screen1" LeftOf "Screen0"
       InputDevice    "Mouse0" "CorePointer"
       InputDevice    "Keyboard0" "CoreKeyboard"

EndSection

When you move the mouse to the left of the screen 0 appears in the screen 1.

Personal tools