[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: X11 passive grab - help needed
From:       Lubos Lunak <l.lunak () suse ! cz>
Date:       2005-08-31 8:45:43
Message-ID: 200508311045.44108.l.lunak () suse ! cz
[Download RAW message or body]

Dne st 31. srpna 2005 03:40 Raul Fernandes napsal(a):
> Hi,
> I'm developing a dictionary program named KTranslator and I have trouble in
> using the X11 functions.
> I want to be notified about all right button mouse clicks while pressing
> some modifier key to call a function to get to word below the cursor and
> translate it. I've tried the XGrabButton to get all of these clicks. This
> works, but not all the time. Sometimes works perfect, sometimes doesn't
> work at all. This is piece of code that I use to do the work:
>
> ...
>   kapp->installX11EventFilter( this );
>   XGrabButton( qt_xdisplay(), Button3, ShiftMask, qt_xrootwin(), FALSE,
> ButtonReleaseMask, GrabModeSync, GrabModeAsync, None, None );

 The modifiers mask includes things like NumLock status, so just 
sayingShiftMask will work only if your NumLock etc. are turned off. You need 
to do the grab for all combinations of the irrelevant modifiers. See 
kdelibs/kdecore/kglobalaccel_x11.cpp.

> ...
>
> bool OcrWatchdog::x11Event( XEvent *event )
> {
>   XAllowEvents( qt_xdisplay(), SyncPointer, CurrentTime );
>   if( event->type != ButtonPress || event->xbutton.button != 3 /*button 3*/
>
> || !(event->xbutton.state & ShiftMask)/* Shift not pressed*/ ) return
> || false;
>
>   clickOccured();
>   return true;
> }

-- 
Lubos Lunak
KDE Developer
l.lunak@kde.org     l.lunak@suse.cz
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic