/* xlockmore.c --- xscreensaver compatibility layer for xlockmore modules.
- * xscreensaver, Copyright (c) 1997, 1998, 2001 Jamie Zawinski <jwz@jwz.org>
+ * xscreensaver, Copyright (c) 1997, 1998, 2001, 2002
+ * Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
static void
xlockmore_handle_events (ModeInfo *mi,
- void (*reshape) (ModeInfo *, int, int))
+ void (*reshape) (ModeInfo *, int, int),
+ Bool (*hook) (ModeInfo *, XEvent *))
{
while (XPending (mi->dpy))
{
XGetWindowAttributes (mi->dpy, mi->window, &mi->xgwa);
reshape (mi, mi->xgwa.width, mi->xgwa.height);
}
+ else if (hook && hook (mi, &event))
+ {
+ }
else
{
screenhack_handle_event (mi->dpy, &event);
Bool want_uniform_colors,
Bool want_smooth_colors,
Bool want_bright_colors,
+ unsigned long event_mask,
void (*hack_init) (ModeInfo *),
void (*hack_draw) (ModeInfo *),
void (*hack_reshape) (ModeInfo *, int, int),
+ Bool (*hack_handle_events) (ModeInfo *, XEvent *),
void (*hack_free) (ModeInfo *))
{
ModeInfo mi;
int i;
time_t start, now;
int orig_pause;
+ Bool root_p;
memset(&mi, 0, sizeof(mi));
mi.dpy = dpy;
mi.window = window;
XGetWindowAttributes (dpy, window, &mi.xgwa);
+ root_p = (window == RootWindowOfScreen (mi.xgwa.screen));
+
+ /* If this is the root window, don't allow ButtonPress to be selected.
+ Bad Things Happen. */
+ if (root_p)
+ event_mask &= (~(ButtonPressMask|ButtonReleaseMask));
+
+ /* If this hack wants additional events, select them. */
+ if (event_mask && ! (mi.xgwa.your_event_mask & event_mask))
+ XSelectInput (dpy, window, (mi.xgwa.your_event_mask | event_mask));
color.flags = DoRed|DoGreen|DoBlue;
color.red = color.green = color.blue = 0;
mi.xgwa.colormap);
mi.wireframe_p = get_boolean_resource ("wireframe", "Boolean");
- mi.root_p = (window == RootWindowOfScreen (mi.xgwa.screen));
+ mi.root_p = root_p;
mi.fps_p = get_boolean_resource ("showFPS", "Boolean");
#ifdef HAVE_XSHM_EXTENSION
mi.use_shm = get_boolean_resource ("useSHM", "Boolean");
do {
hack_draw (&mi);
XSync(dpy, False);
- xlockmore_handle_events (&mi, hack_reshape);
+ xlockmore_handle_events (&mi, hack_reshape, hack_handle_events);
if (mi.pause)
usleep(mi.pause);
mi.pause = orig_pause;