automatic/passive grab vs XGrabPointer/XUngrabPointer q

automatic/passive grab vs XGrabPointer/XUngrabPointer q

guy keren choo at actcom.co.il
Thu Jul 8 18:28:32 IDT 2010


Erez D wrote:
> hi
> 
> X automatically does pointer grab when the mouse drags (i.e. press and 
> hold the mouse button while moving it).
> It is possible to override the auto grab settings (i.e owner_events, 
> etc) with a passive grab (e.g. XGrabButton)
> 
> what if:
> 
> 1. the user presses mouse button 1 (and holds it down)
> 2. the use moves the mouse
> 3. the application calles XUngrabPointer -> will it ungrab ?
> or..
> 3. the application calles XGrabPointer  (withough XUngrabPointer first) 
> -> will it regrab ?
> 
> thanks,
> erez.

3.a no idea - this is not specifically explained in the man page - 
you'll need to check with a test program.

3.b read the man page for XGrabPointer:
" If the pointer is actively grabbed by some other client, it fails and 
returns Already‐Grabbed. If the pointer is frozen by an active grab of 
another client, it fails and returns GrabFrozen."

note: the grab is done by some client. the question is - when you say "X 
automatically does pointer grab" - who are you talking about? the X 
server does NOT do that. it is more likely that the toolkit in use (or 
the window manager, if this is a drag on one of the windows it created, 
which include the title-bar/borders of all application windows) does this.

so the question is - do you want to affect a drag&drop done by the same 
application in which your code resides? if so - it seems to be possible 
to do this - provider that you can send the right time-stamp (with 
regards to re-grabs). however, by doing this, you _might_ disrapt the 
working of the toolkit - so you should check that this does not happen 
by testing and by reading the source - and probably also by asking on 
the mailing list of the relevant toolkit.

--guy



More information about the Linux-il mailing list