Quoting root <[EMAIL PROTECTED]>:
> Hi Xperts,
>
> Can anyone help me how to grab all key events and send
> them to a single window. Also when i do any mouse operations
> it should take only those operations done on that window.
>
> Like say i opened a dialog box. Until i close the window the focus
> shouldn't go to any other window. Any key i press should be directed
> to the dialog
>
> I tried something and i have attached. but the window couldn't
> get the key and mouse input
>
> Can somebody give me clear picture!
>
> Thanks,
> Jeyasudha.
>
The sample code seems to be working, but you should check for
GrabSuccess and not GrabFrozen when grabbing the keyboard. Why
not just call XGrabServer?
Just a hint to anyone trying this:
Make sure the ServerFlags section in XF86Config has the options
"AllowDeactivateGrabs" and "AllowClosedownGrabs" or you will not
be able to close the test program. Something like:
Section "ServerFlags"
Option "AllowDeactivateGrabs"
Option "AllowClosedownGrabs"
EndSection
<propaganda>
AllowDeactivateGrabs releases any active grab when pressing
Ctrl+Alt+Keypad-Divide.
AllowClosedownGrabs closes the conection to the grabbing client
when pressing Ctrl+Alt+Keypad-Multiply.
These options also work when the client program called XGrabServer.
Note that these options will allow users to bypass screen savers.
I wrote this small/simple example of how to disable the options from
a screensaver:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/extensions/xf86misc.h>
int
main(int argc, char *argv[])
{
int xfree86, major, minor;
Display *display = XOpenDisplay(NULL);
if (display == NULL) {
fprintf(stderr, "Cannot open display.\n");
exit(1);
}
xfree86 = strstr(ServerVendor(display), "XFree86") != NULL;
if (xfree86) {
signal(SIGHUP, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
if (XF86MiscQueryVersion(display, &major, &minor) == False) {
fprintf(stderr, "Failed to call XF86MiscQueryVersion.\n");
exit(1);
}
if (major >= 0 && minor >= 5 &&
XF86MiscSetGrabKeysState(display, False) ==
MiscExtGrabStateLocked) {
fprintf(stderr, "Cannot disable XFree86 hotkeys to remove grabs.\n");
exit(1);
}
XFlush(display);
}
system("xlock");
if (xfree86 && major >= 0 && minor >= 5) {
XF86MiscSetGrabKeysState(display, True);
XFlush(display);
}
return (0);
}
</propaganda>
Paulo
_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert