LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-31-2009, 08:01 AM   #1
morsch
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
Confine mouse movement ("mouse jail")


I'm looking for a utility that confines mouse movement to a certain area (e.g. a window or manually set coordinates). Seemed like a really simple problem, but I haven't found anything that would accomplish it. Note that a couple of programs have the ability to lock the mouse cursor to their own window built-in, mostly emulation software like VirtualBox -- that's exactly what I want, but for other windows.

This question was asked once before, in 2004, with no answer: http://www.linuxquestions.org/questi...d.php?t=220486

My first thought was to see if Compiz offers anything, and indeed the Enhanced Mouse Zoom plugin lets you zoom in on a window and restrain mouse movement to the "field of vision". This kinda sorta works, but it's not elegant at all, and in fact only works when the window has the same aspect ratio as the screen. I also need to disable my right-hand display (run in TwinView), otherwise the cursor will move off the right side of the screen. And of course, the window is zoomed.

Another thing I found was on the Gentoo wiki: http://en.gentoo-wiki.com/wiki/HOWTO...in_the_monitor

There's a link to a fairly simple C program which is supposed to confine the cursor to the current screen. Well, first of all this doesn't work for me, assumedly because TwinView registers both displays as one large screen. Apart from that, I assume the code could be adapted to limit movement to an arbitrary rectangle. On the other hand, it seems to work simply by polling, and, if necessary, resetting the position every millisecond, which is far from an elegant approach. The archive contains an executable as well as the code; I couldn't compile the code because I haven't, so far, installed the X development packages.

So yeah. I found numerous people who had the same problem, and I found approximately 100 programs which lock the mouse to a window/region in Windows, but apparently it's not as easy on Linux.

Any help is appreciated.
 
Old 08-20-2009, 08:32 AM   #2
pfanne
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
i had the same problem an i've been looking for ages and found nothing...
my main problem was, that warcraft 3 with a second monitor or windowed would make it impossible to scroll by moving the mouse to the edge...
compiz didn't really work that well, because the bounding box for the mouse wasn't really accurate and you had problems when the window had a different ratio compared to your monitor.
so i wrote a simple bash script based on xdotool.
the script works the same way the compiz enhanced zoom plugin works (resetting the mouse if it leaves the bounding box), but it works way better for me
to use it you have to install xdotool of course.
the script takes 4 parameters x1 y1 x2 y2..
x1 and y1 refer to the upper left corner of the bounding box and the other two to the the lower right corner.
for example:
restrainmouse 500 500 1000 1000

restrainmouse

have fun with my simple script.
if this file is no longer available on pastebin... write me an email and i'll reupload it
pfannenwender@googlemail.com

i add some "tags" so people desperately searching for a solution can find this thread
constrain mouse
restrain mouse
mouse box
mouse jail
jail mouse
this ought to be enough

Last edited by pfanne; 04-02-2010 at 07:30 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
evdev/xorg help? USB mouse/kbd: 2.6.24="just works">2.6.25="unplug/replug to work". GrapefruiTgirl Linux - Hardware 4 12-13-2012 02:23 PM
"Back" and "Forward" side-buttons of my mouse Unforgiven79 Linux - Hardware 1 10-31-2006 12:10 AM
what are the other "config's" like "mouse/xorg/xwmconfig ??? b0nd Slackware 2 01-10-2006 01:51 AM
Microsoft Bluetooth mouse on suse9.2 "HID create error 25" mr-pear Linux - Hardware 0 08-16-2005 02:33 PM
"I have a4 tech 5 button mouse but can't use the two for back&forward in browsing " aicholate Linux - Hardware 1 02-26-2004 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration