Workaround for Ubuntu 8.10 mouse bug
Ubuntu 8.10 has a massive bug in the xorg window code at the moment. Originally reported in November when 8.10 shipped, the lack of action on this is kind of unusual for the generally excellent Linux community.
However I’ve worked out a minimally intrusive hacktastic workaround. What seems to be happening with this bug is sometimes when X traffic is moving from one GPU to the other (this only affect multi video card setups) it causes the mouse hardware to get disconnected from the internal desktop model so X thinks the mouse is somewhere else and nothing works. The problem only affects configurations using >2 monitors using xinerama, the currently suggested fixes are either to downgrade to the Hardy version of Xorg, which has pretty poor xinerama performance or to follow a strange set of keyboard based window movements until the problem disappears.
My fix is to use some nifty Linux tools and a bit of Gnome fu to get the two to be in agreement again.
First you need to install xautomation,
Control X from the command line, and find things on the screen
Control X from the command line for scripts, and do “visual scraping” to
find things on the screen. The control interface allows mouse movement,
clicking, button up/down, key up/down, etc, and uses the XTest extension so
you don’t have the annoying problems that xse has when apps ignore sent
events. The visgrep program find images inside of images and reports the
coordinates, allowing programs to find buttons, etc, on the screen to click
on.
The install as usual is trivial (gotta love dat package management)
sudo apt-get install xautomation
OK now you have xautomation, the command we are going to use will locate the mouse pointer at the origin (0,0) of the desktop, and doing this seems to re-align the mouse and X.
xte "mousemove 0 0"
really it’s that simple. [edit - well of not really, turns out some folks need to move the mouse onto the primary display and off again, just add a second mousemove line with co-ords for your second display]
So you could just type this into a terminal when the mouse borks and that would be good enough to repair, but who can really be bothered with all that malarkey, as this is happening to me every couple of hours, I dont want to be reminded how messed up my Ubuntu install is and have to learn all the window navigation keystrokes needed to pop a terminal without a mouse, although with Gnome-do (the Gnome version of quicksilver) it’s kinda easy.
so create a script to run the command.
echo xte "mousemove 0 0" > mm.sh chmod 777 mm.sh
Running the script will move the cursor as we want, so now we need to assign this to a hot-key. Gnome desktop doesn’t give you a particularly easy way to do this, so you have to run the Gnome Configuration Editor, which is sort of like a regedit for gnome apps.
gconf-editor
That will bring up the Gnome Configuration Editor, If you’ve ever messed with the Windows registry this will be reasonably familiar. To set up the hotkey we need to edit two entries, the first to register the script, the second to assign the hotkey.
Navigate to apps/metacity/keybinding_commands and enter the path to the mm.sh script we created earlier in one of the available slots. I’m using the command_1 slot, you can choose any of the 12 available slots.

Now navigate to apps/metacity/global_keybindings and set the matching run_command key-binding to the value for the hotkey you want to run the script. The values for this are a string, and the tokens <Control> <Shift> <Alt> <Super> are used for the special combo keys. In my case I’m using <Super>M, which will be either the Window or the Command key depending on the keyboard your are using.

So if it all works according to plan, the script will be attached to the Super-M key combo, so if your mouse locks, pressing Super-M will repair the damage and let you carry on.
This will hopefully tide you over until the Xorg bug is fixed or nvidia release the forthcoming SLI support that will allow >2 monitors to be used without having to use xinerama.
enjoy.














Arnfinn
Jan 21 '09 at 2:47 am
Thank you very much! You saved my day.
Tufla
Jan 23 '09 at 11:44 am
Thank you in advance my friend !!! This is an excellent solution, I was following all posts in the bug page, and I’m sure that will be very useful for all of us !
Sbay
Feb 13 '09 at 8:15 pm
I am seeing the same type of problem switching out of a VMWare player or VirtualBox Virtual guest OS back to the host OS. Your workaround described here works for this situation too. Many thanks for your work!
Nina
Feb 18 '09 at 2:57 am
Thank you so much! Now I can work on my code without problems!
Chris
Feb 25 '09 at 3:09 pm
Thanks – working on intrepid is tolerable again. Here’s hoping that this bug fix hits the repos soon.
jo
Feb 27 '09 at 6:57 pm
I was 3rd degree bill bixby b4 this post. thnx
Enguelberth
Nov 15 '09 at 12:40 pm
Hi, thanks, I have a question though, i have this problem too, i do not use two monitors, and it comes and goes, what I mean is that when it starts I simply switch to windows and continue using my other OS, until I start missing Linux again so I reboot into Ubuntu and if I am lucky enough the bug will be gone, but then after a few days of using Ubuntu continuously it starts again (Pretty crazy bug hu?) I tried your solution and it did not work, for me, I would really appreciate any sugestion and if you wanna take a look at it you are more than welcome to give it a shot, thanks in advance and congrats for the great site!!