-/* xscreensaver, Copyright (c) 1992, 1997, 1998, 2001, 2003, 2006
- * Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1992-2014 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
goto DEFAULT;
}
free (s);
- return color.pixel;
+ return (unsigned int) color.pixel;
DEFAULT:
if (s) free (s);
color.flags = DoRed|DoGreen|DoBlue;
color.red = color.green = color.blue = (black_p ? 0 : 0xFFFF);
if (XAllocColor (dpy, cmap, &color))
- return color.pixel;
+ return (unsigned int) color.pixel;
else
{
fprintf (stderr, "%s: couldn't allocate %s either!\n", progname,
{
return get_time_resource (dpy, res_name, res_class, False);
}
+
+
+/* A utility function for event-handler functions:
+ Returns True if the event is a simple click, Space, Tab, etc.
+ Returns False otherwise.
+ The idea here is that most hacks interpret to clicks or basic
+ keypresses as "change it up".
+
+ This isn't really the right file for this, but whatever.
+ */
+Bool
+screenhack_event_helper (Display *dpy, Window window, XEvent *event)
+{
+ if (event->xany.type == KeyPress)
+ {
+ KeySym keysym;
+ char c = 0;
+ XLookupString (&event->xkey, &c, 1, &keysym, 0);
+ if (c == ' ' || c == '\t' || c == '\r' || c == '\n' ||
+ keysym == XK_Left || keysym == XK_Right ||
+ keysym == XK_Up || keysym == XK_Down ||
+ keysym == XK_Prior || keysym == XK_Next)
+ return True;
+ }
+ else if (event->xany.type == ButtonPress)
+ {
+ if (event->xbutton.button == 1)
+ return True;
+ }
+
+ return False;
+}