X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=utils%2Fresources.c;h=d95a103cd52e04fb6b6c5ba33e1d261741c5dd80;hp=f02ab91f77ec9614d6808af1b6f4bca00581ff43;hb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;hpb=dba664f31aa87285db4d76cf8c5e66335299703a diff --git a/utils/resources.c b/utils/resources.c index f02ab91f..d95a103c 100644 --- a/utils/resources.c +++ b/utils/resources.c @@ -1,5 +1,4 @@ -/* xscreensaver, Copyright (c) 1992, 1997, 1998, 2001, 2003, 2006 - * Jamie Zawinski +/* xscreensaver, Copyright (c) 1992-2014 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -263,3 +262,35 @@ get_minutes_resource (Display *dpy, char *res_name, char *res_class) { 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; +}