1 /* test-uid.c --- playing with grabs.
2 * xscreensaver, Copyright (c) 1999, 2004 Jamie Zawinski <jwz@jwz.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
26 #include <X11/Intrinsic.h>
29 char *progclass = "XScreenSaver";
31 #define ALL_POINTER_EVENTS \
32 (ButtonPressMask | ButtonReleaseMask | EnterWindowMask | \
33 LeaveWindowMask | PointerMotionMask | PointerMotionHintMask | \
34 Button1MotionMask | Button2MotionMask | Button3MotionMask | \
35 Button4MotionMask | Button5MotionMask | ButtonMotionMask)
38 main (int argc, char **argv)
44 Widget toplevel_shell = XtAppInitialize (&app, progclass, 0, 0,
45 &argc, argv, 0, 0, 0);
46 Display *dpy = XtDisplay (toplevel_shell);
47 Window w = RootWindow (dpy, DefaultScreen(dpy));
48 XtGetApplicationNameAndClass (dpy, &progname, &progclass);
50 kstatus = XGrabKeyboard (dpy, w, True,
51 GrabModeSync, GrabModeAsync,
53 fprintf (stderr, "%s: grabbing keyboard on 0x%lx... %s.\n",
54 progname, (unsigned long) w,
55 (kstatus == GrabSuccess ? "GrabSuccess" :
56 kstatus == AlreadyGrabbed ? "AlreadyGrabbed" :
57 kstatus == GrabInvalidTime ? "GrabInvalidTime" :
58 kstatus == GrabNotViewable ? "GrabNotViewable" :
59 kstatus == GrabFrozen ? "GrabFrozen" :
62 mstatus = XGrabPointer (dpy, w, True, ALL_POINTER_EVENTS,
63 GrabModeAsync, GrabModeAsync, None,
65 fprintf (stderr, "%s: grabbing mouse on 0x%lx... %s.\n",
66 progname, (unsigned long) w,
67 (mstatus == GrabSuccess ? "GrabSuccess" :
68 mstatus == AlreadyGrabbed ? "AlreadyGrabbed" :
69 mstatus == GrabInvalidTime ? "GrabInvalidTime" :
70 mstatus == GrabNotViewable ? "GrabNotViewable" :
71 mstatus == GrabFrozen ? "GrabFrozen" :
76 if (kstatus == GrabSuccess || mstatus == GrabSuccess)
78 fprintf (stderr, "%s: sleeping for %d:%02d:%02d...\n",
81 (delay % (60 * 60)) / 60,