Tuomo,

I have a refinement of the request which I think moves this into the
scope of Ion -- I'd like the mouse enabled or disabled based on what
window has focus.  In other words, when my "vim" window has focus, I'd
like the rodent to be completely banished.  But when I tab over to
Konqueror, I'd like it visible.   Right now Ion puts the mouse pointer
in the upper left hand corner of the window when you change focus,
I'd like, for some windows, the option to get rid of it altogether.

Best,

Clark

On Mon, Apr 05, 2004 at 07:45:42PM +0300, Tuomo Valkonen wrote:
| On Mon, Apr 05, 2004 at 12:22:42PM -0400, Clark C. Evans wrote:
| >   Is there a way to 'toggle mouse' aka turning it on and
| >   off via the keyboard?  If the mouse is off, then the 
| >   only way to get it back on should be via keyboard.
| 
| I don't think such feature belongs in Ion, but it should be
| quite easy to write a program to handle grabbing/ungrabbing
| the mouse when a key is pressed.
| 
| bool grabbed=FALSE;
| Display *dpy=XOpenDisplay(NULL);
| int kc=XKeysymToKeycode(dpy, XK_Scroll_Lock)
| XGrabKey(dpy, kc, 0, DefaultRootWindow(dpy), False, 
|          GrabModeAsync, GrabModeAsync);
| 
| while(1){
|     XEvent ev;
|     XNextEvent(dpy, &ev);
|     if(ev.type==KeyPress && ev.xkey.keycode==kc){
|         if(!grabbed){
|             XGrabPointer(... similarly to XGrabKey above, 
|                          mask=KeyPressMask; rtfm ...)
|             grabbed=TRUE;
|       }else{
|             XUngrabPointer(...);
|             grabbed=FALSE;
|       }
|     }
| }
| 
| -- 
| Tuomo

Reply via email to