XGrabButton

Carsten Haitzler raster at rasterman.com
Fri Jul 28 08:36:13 UTC 2023


On Wed, 26 Jul 2023 17:45:56 +0300 Riza Dindir <riza.dindir at gmail.com> said:

> Hello All,
> 
> I am grabbing buttons in an xlib. I am new to xlib.
> 
> I have 3 grabs (XGrabButton) on buttons. One for button1+Mod1, another
> for Button3+Mod1 and the last one for Button1+(Mod1|Control). All
> these grabs are for button presses (ButtonPressMask).
> 
> When I grab these with 3 different calls to XGrabButton (one for each
> of the grabs mentioned above), they work fine. I can operate on
> application windows which handle only Button 1 presses (no modifiers,
> the application does its own thing with that button press).
> 
> But when I call XGrabPointer with AnyButton and AnyModifier (one call.
> and handle the modifier filtering in the event handler), this does not
> work on windows that process Button 1 presses (with no modifiers).
> 
> Since the XGrabPointer call with AnyButton and AnyModifier does grab
> for all modifiers and buttons, how should I make it propagate to the
> window the button press event (without modifiers). I tried XSendEvent
> to send the button press event to that window, but it did not respond.
> The application does not operate as expected.

XAllowEvents() is what you want to allow grabbed events to go on to the client.

As already mentioned - you really want to stick to grabbing just the
events+modifiers you need, not everything. this is what window managers have
done for decades to handle click-to-focus and other bindings like alt+left mouse
to move a window anywhere on the window etc.

> It is perfectly ok for me to use 3 XGrabButton calls, but was
> wondering why this would not work for a XGrabButton call with
> AnyButton and AnyModifier parameters.
> 
> Best Regards
> Riza
> 


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
Carsten Haitzler - raster at rasterman.com



More information about the xorg mailing list