You are not logged in.
Hi ,
Can anyone help me with XLib and XGrabKey function?
I want to add key combination to my application .
but it didn't work.
code:
--------------------------
Window root ;
XEvent event;
Display *dpy = XOpenDisplay(0);
if(!dpy)
{
printf("Error for openning display.\nExit..\n");
return ;
}
root = DefaultRootWindow(dpy);
XGrabKey(dpy, XKeysymToKeycode(dpy,XK_F9 ) , ControlMask , root, true, GrabModeAsync, GrabModeAsync);
for( ; ; )
{
XNextEvent(dpy, &event);
if(event.type == KeyPress && event.xkey.keycode == key ) //
{
// do sth...
}
}
XAllowEvents(dpy,AsyncKeyboard,CurrentTime);
XUngrabKey(dpy, key, AnyModifier, root);
XSync(dpy,false);
-----------------------
How should I use it to get it work?
Offline
but it works well like this :
XGrabKey( dpy, XKeysymToKeycode(dpy,XK_F9 ) , AnyModifier , root,true, GrabModeAsync, GrabModeAsync ) ;
when i used 'ControlMask' ,
it seems that ,
"XNextEvent(dpy, &event);" didn't copy any event from queue .
Any help, much appreciated.
Last edited by xdd123www (2008-11-12 03:14:29)
Offline