5559N/AFrom 9bf12ae3168aa6f9234304a8a376d47962f0d589 Mon Sep 17 00:00:00 2001
5559N/AFrom: Alan Coopersmith <alan.coopersmith@oracle.com>
5559N/ADate: Sat, 2 Jan 2016 20:11:05 -0800
5398N/ACentralize atom handling and use XInternAtoms to get the atoms from
5398N/Around trip for each XInternAtom individual call.
5398N/AWas offered upstream in 2011 - jwz responded with:
5398N/A I'd sure like to see some kind of performance metrics -- like, any -- before
5398N/A making a big change to something so central. When it comes to the xscreensaver
5398N/A driver I'm a firm believer in "don't fix what ain't broke"...
5398N/ANeed to find some time to actually measure that someday (dtrace?).
5559N/A 10 files changed, 189 insertions(+), 114 deletions(-)
5559N/Aindex a5b94bf..90ef1d2 100644
5398N/A- $(SAVER_UTIL_SRCS) $(GL_SRCS)
5398N/A- $(SAVER_UTIL_OBJS) $(GL_OBJS)
5559N/A@@ -228,7 +228,7 @@ SCRIPTS = $(SCRIPTS_1) @SCRIPTS_OSX@
5398N/A+/* xscreensaver, Copyright (c) 1991-2010 Jamie Zawinski <jwz@jwz.org>
5398N/A+ * Permission to use, copy, modify, distribute, and sell this software and its
5398N/A+ * documentation for any purpose is hereby granted without fee, provided that
5398N/A+ * the above copyright notice appear in all copies and that both that
5398N/A+ * copyright notice and this permission notice appear in supporting
5398N/A+ * documentation. No representations are made about the suitability of this
5398N/A+ * software for any purpose. It is provided "as is" without express or
5398N/A+/* Atoms to retrieve info from remote daemon */
5398N/A+Atom XA_SCREENSAVER, XA_SCREENSAVER_ID, XA_SCREENSAVER_VERSION,
5398N/A+ XA_SCREENSAVER_RESPONSE, XA_SCREENSAVER_STATUS;
5398N/A+/* Atoms to send commands to remote daemon */
5398N/A+Atom XA_ACTIVATE, XA_BLANK, XA_CYCLE, XA_DEACTIVATE, XA_DEMO,
5398N/A+ XA_EXIT, XA_LOCK, XA_NEXT, XA_PREFS, XA_PREV, XA_RESTART,
5398N/A+ XA_SELECT, XA_THROTTLE, XA_UNTHROTTLE;
5398N/A+static const struct atom_request remote_control_atom_list[] =
5398N/A+ { &XA_SCREENSAVER, "SCREENSAVER" },
5398N/A+ { &XA_SCREENSAVER_ID, "_SCREENSAVER_ID" },
5398N/A+ { &XA_SCREENSAVER_VERSION, "_SCREENSAVER_VERSION" },
5398N/A+ { &XA_SCREENSAVER_RESPONSE, "_SCREENSAVER_RESPONSE" },
5398N/A+ { &XA_SCREENSAVER_STATUS, "_SCREENSAVER_STATUS" },
5398N/A+ { &XA_ACTIVATE, "ACTIVATE" },
5398N/A+ { &XA_DEACTIVATE, "DEACTIVATE" },
5398N/A+ { &XA_RESTART, "RESTART" },
5398N/A+ { &XA_THROTTLE, "THROTTLE" },
5398N/A+ { &XA_UNTHROTTLE, "UNTHROTTLE" },
5398N/A+ { NULL, NULL } /* Must be last to terminate list */
5398N/A+const struct atom_request *remote_control_atoms = remote_control_atom_list;
5398N/A+/* Load a list of atoms in a single round trip to the X server instead of
5398N/A+ waiting for a synchronous round trip for each and every atom */
5398N/A+Status request_atoms ( Display *dpy,
5398N/A+ const struct atom_request **request_lists )
5398N/A+ const struct atom_request **l, *r;
5398N/A+ /* Count the number of items across all the lists passed in */
5398N/A+ for (l = request_lists; l != NULL && *l != NULL; l++)
5398N/A+ for (r = *l; r != NULL && r->name != NULL; r++)
5398N/A+ atoms = calloc(atom_count, sizeof(Atom));
5398N/A+ names = calloc(atom_count, sizeof(char *));
5398N/A+ for (l = request_lists; l != NULL && *l != NULL; l++)
5398N/A+ for (r = *l; r != NULL && r->name != NULL; r++)
5398N/A+ result = XInternAtoms( dpy, (char **) names, atom_count, False, atoms );
5398N/A+ for (l = request_lists; l != NULL && *l != NULL; l++)
5398N/A+ for (r = *l; r != NULL && r->name != NULL; r++)
5398N/A+ fprintf (stderr, "atom: %s => %d\n", names[n], atoms[n]);
5398N/A+/* xscreensaver, Copyright (c) 1991-2010 Jamie Zawinski <jwz@jwz.org>
5398N/A+ * Permission to use, copy, modify, distribute, and sell this software and its
5398N/A+ * documentation for any purpose is hereby granted without fee, provided that
5398N/A+ * the above copyright notice appear in all copies and that both that
5398N/A+ * copyright notice and this permission notice appear in supporting
5398N/A+ * documentation. No representations are made about the suitability of this
5398N/A+ * software for any purpose. It is provided "as is" without express or
5398N/A+#ifndef _XSCREENSAVER_ATOMS_H_
5398N/A+#define _XSCREENSAVER_ATOMS_H_
5398N/A+extern const struct atom_request *remote_control_atoms;
5398N/A+extern Status request_atoms ( Display *dpy,
5398N/A+ const struct atom_request **request_lists );
5398N/A+/* Atoms to retrieve info from remote daemon */
5398N/A+extern Atom XA_SCREENSAVER, XA_SCREENSAVER_ID, XA_SCREENSAVER_VERSION,
5398N/A+ XA_SCREENSAVER_RESPONSE, XA_SCREENSAVER_STATUS;
5398N/A+/* Atoms to send commands to remote daemon */
5398N/A+extern Atom XA_ACTIVATE, XA_BLANK, XA_CYCLE, XA_DEACTIVATE, XA_DEMO,
5398N/A+ XA_EXIT, XA_LOCK, XA_NEXT, XA_PREFS, XA_PREV, XA_RESTART,
5398N/A+ XA_SELECT, XA_THROTTLE, XA_UNTHROTTLE;
5398N/A+#endif /* _XSCREENSAVER_ATOMS_H_ */
5559N/Aindex 6c449f2..3fa27c3 100644
5559N/A@@ -247,12 +248,6 @@ typedef struct {
5398N/A a closure object of our own down into the various widget callbacks. */
5398N/A static state *global_state_kludge;
5398N/A-Atom XA_SCREENSAVER, XA_SCREENSAVER_RESPONSE, XA_SCREENSAVER_VERSION;
5398N/A-Atom XA_SCREENSAVER_ID, XA_SCREENSAVER_STATUS, XA_SELECT, XA_DEMO;
5398N/A-Atom XA_ACTIVATE, XA_BLANK, XA_LOCK, XA_RESTART, XA_EXIT;
5398N/A static void populate_demo_window (state *, int list_elt);
5398N/A static void populate_prefs_page (state *);
5398N/A static void populate_popup_window (state *);
5559N/A@@ -5068,20 +5063,11 @@ main (int argc, char **argv)
5398N/A /* Intern the atoms that xscreensaver_command() needs.
5398N/A- XA_VROOT = XInternAtom (dpy, "__SWM_VROOT", False);
5398N/A- XA_SCREENSAVER = XInternAtom (dpy, "SCREENSAVER", False);
5398N/A- XA_SCREENSAVER_VERSION = XInternAtom (dpy, "_SCREENSAVER_VERSION",False);
5398N/A- XA_SCREENSAVER_STATUS = XInternAtom (dpy, "_SCREENSAVER_STATUS", False);
5398N/A- XA_SCREENSAVER_ID = XInternAtom (dpy, "_SCREENSAVER_ID", False);
5398N/A- XA_SCREENSAVER_RESPONSE = XInternAtom (dpy, "_SCREENSAVER_RESPONSE", False);
5398N/A- XA_SELECT = XInternAtom (dpy, "SELECT", False);
5398N/A- XA_DEMO = XInternAtom (dpy, "DEMO", False);
5398N/A- XA_ACTIVATE = XInternAtom (dpy, "ACTIVATE", False);
5398N/A- XA_BLANK = XInternAtom (dpy, "BLANK", False);
5398N/A- XA_LOCK = XInternAtom (dpy, "LOCK", False);
5398N/A- XA_EXIT = XInternAtom (dpy, "EXIT", False);
5398N/A- XA_RESTART = XInternAtom (dpy, "RESTART", False);
5398N/A+ const struct atom_request *atom_lists[2] = { NULL, NULL };
5398N/A+ atom_lists[0] = remote_control_atoms;
5398N/A+ request_atoms (dpy, atom_lists);
5398N/A /* Create the window and all its widgets.
5398N/A@@ -110,12 +111,6 @@ extern const char *visual_menu[];
5398N/A static char *short_version = 0;
5398N/A-Atom XA_SCREENSAVER, XA_SCREENSAVER_RESPONSE, XA_SCREENSAVER_VERSION;
5398N/A-Atom XA_SCREENSAVER_ID, XA_SCREENSAVER_STATUS, XA_SELECT, XA_DEMO;
5398N/A-Atom XA_ACTIVATE, XA_BLANK, XA_LOCK, XA_RESTART, XA_EXIT;
5398N/A static void populate_demo_window (Widget toplevel,
5398N/A int which, prefs_pair *pair);
5398N/A static void populate_prefs_page (Widget top, prefs_pair *pair);
5398N/A@@ -1791,19 +1786,11 @@ main (int argc, char **argv)
5398N/A /* Intern the atoms that xscreensaver_command() needs.
5398N/A- XA_VROOT = XInternAtom (dpy, "__SWM_VROOT", False);
5398N/A- XA_SCREENSAVER = XInternAtom (dpy, "SCREENSAVER", False);
5398N/A- XA_SCREENSAVER_VERSION = XInternAtom (dpy, "_SCREENSAVER_VERSION",False);
5398N/A- XA_SCREENSAVER_STATUS = XInternAtom (dpy, "_SCREENSAVER_STATUS", False);
5398N/A- XA_SCREENSAVER_ID = XInternAtom (dpy, "_SCREENSAVER_ID", False);
5398N/A- XA_SCREENSAVER_RESPONSE = XInternAtom (dpy, "_SCREENSAVER_RESPONSE", False);
5398N/A- XA_SELECT = XInternAtom (dpy, "SELECT", False);
5398N/A- XA_DEMO = XInternAtom (dpy, "DEMO", False);
5398N/A- XA_ACTIVATE = XInternAtom (dpy, "ACTIVATE", False);
5398N/A- XA_BLANK = XInternAtom (dpy, "BLANK", False);
5398N/A- XA_LOCK = XInternAtom (dpy, "LOCK", False);
5398N/A- XA_EXIT = XInternAtom (dpy, "EXIT", False);
5398N/A- XA_RESTART = XInternAtom (dpy, "RESTART", False);
5398N/A+ const struct atom_request *atom_lists[2] = { NULL, NULL };
5398N/A+ atom_lists[0] = remote_control_atoms;
5398N/A+ request_atoms (dpy, atom_lists);
5398N/A /* Create the window and all its widgets.
5559N/Aindex 775036a..59e30c1 100644
5398N/A-extern Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_RESPONSE;
5398N/A-extern Atom XA_SCREENSAVER_ID, XA_SCREENSAVER_STATUS, XA_EXIT;
5398N/A-extern Atom XA_VROOT, XA_SELECT, XA_DEMO, XA_BLANK, XA_LOCK;
5398N/A static XErrorHandler old_handler = 0;
5559N/Aindex d33f251..6acaddb 100644
5559N/A@@ -69,14 +69,13 @@ typedef long PROP32;
5398N/A Atom XA_VROOT, XA_XSETROOT_ID, XA_ESETROOT_PMAP_ID, XA_XROOTPMAP_ID;
5398N/A-Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_ID;
5398N/A-Atom XA_SCREENSAVER_STATUS;
5398N/A extern saver_info *global_si_kludge; /* I hate C so much... */
5559N/Aindex 0057438..80b2813 100644
5398N/A@@ -48,13 +49,6 @@ ERROR! you must not include
vroot.h in this file
5398N/A-Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_RESPONSE;
5398N/A-Atom XA_SCREENSAVER_ID, XA_SCREENSAVER_STATUS, XA_SELECT, XA_DEMO, XA_EXIT;
5398N/A-static Atom XA_ACTIVATE, XA_DEACTIVATE, XA_CYCLE, XA_NEXT, XA_PREV;
5398N/A-static Atom XA_RESTART, XA_PREFS, XA_THROTTLE, XA_UNTHROTTLE;
5398N/A static char *screensaver_version;
5398N/A __extension__ /* don't warn about "string length is greater than the
5559N/A@@ -292,28 +286,11 @@ main (int argc, char **argv)
5398N/A- XA_VROOT = XInternAtom (dpy, "__SWM_VROOT", False);
5398N/A- XA_SCREENSAVER = XInternAtom (dpy, "SCREENSAVER", False);
5398N/A- XA_SCREENSAVER_ID = XInternAtom (dpy, "_SCREENSAVER_ID", False);
5398N/A- XA_SCREENSAVER_VERSION = XInternAtom (dpy, "_SCREENSAVER_VERSION",False);
5398N/A- XA_SCREENSAVER_STATUS = XInternAtom (dpy, "_SCREENSAVER_STATUS", False);
5398N/A- XA_SCREENSAVER_RESPONSE = XInternAtom (dpy, "_SCREENSAVER_RESPONSE", False);
5398N/A- XA_ACTIVATE = XInternAtom (dpy, "ACTIVATE", False);
5398N/A- XA_DEACTIVATE = XInternAtom (dpy, "DEACTIVATE", False);
5398N/A- XA_RESTART = XInternAtom (dpy, "RESTART", False);
5398N/A- XA_CYCLE = XInternAtom (dpy, "CYCLE", False);
5398N/A- XA_NEXT = XInternAtom (dpy, "NEXT", False);
5398N/A- XA_PREV = XInternAtom (dpy, "PREV", False);
5398N/A- XA_SELECT = XInternAtom (dpy, "SELECT", False);
5398N/A- XA_EXIT = XInternAtom (dpy, "EXIT", False);
5398N/A- XA_DEMO = XInternAtom (dpy, "DEMO", False);
5398N/A- XA_PREFS = XInternAtom (dpy, "PREFS", False);
5398N/A- XA_LOCK = XInternAtom (dpy, "LOCK", False);
5398N/A- XA_BLANK = XInternAtom (dpy, "BLANK", False);
5398N/A- XA_THROTTLE = XInternAtom (dpy, "THROTTLE", False);
5398N/A- XA_UNTHROTTLE = XInternAtom (dpy, "UNTHROTTLE", False);
5398N/A+ const struct atom_request *atom_lists[2] = { NULL, NULL };
5398N/A+ atom_lists[0] = remote_control_atoms;
5398N/A+ request_atoms (dpy, atom_lists);
5559N/Aindex 45f0f0c..06f5c13 100644
5398N/A saver_info *global_si_kludge = 0; /* I hate C so much... */
5559N/A@@ -240,12 +241,6 @@ char *progclass = 0;
5398N/A-static Atom XA_SCREENSAVER_RESPONSE;
5398N/A-static Atom XA_ACTIVATE, XA_DEACTIVATE, XA_CYCLE, XA_NEXT, XA_PREV;
5398N/A-static Atom XA_RESTART, XA_SELECT;
5398N/A-static Atom XA_THROTTLE, XA_UNTHROTTLE;
5398N/A-Atom XA_DEMO, XA_PREFS, XA_EXIT, XA_LOCK, XA_BLANK;
5398N/A static XrmOptionDescRec options [] = {
5559N/A@@ -667,31 +662,21 @@ connect_to_server (saver_info *si, int *argc, char **argv)
5398N/A- XA_VROOT = XInternAtom (si->dpy, "__SWM_VROOT", False);
5398N/A- XA_SCREENSAVER = XInternAtom (si->dpy, "SCREENSAVER", False);
5398N/A- XA_SCREENSAVER_VERSION = XInternAtom (si->dpy, "_SCREENSAVER_VERSION",False);
5398N/A- XA_SCREENSAVER_ID = XInternAtom (si->dpy, "_SCREENSAVER_ID", False);
5398N/A- XA_SCREENSAVER_STATUS = XInternAtom (si->dpy, "_SCREENSAVER_STATUS", False);
5398N/A- XA_SCREENSAVER_RESPONSE = XInternAtom (si->dpy, "_SCREENSAVER_RESPONSE",
5398N/A- XA_XSETROOT_ID = XInternAtom (si->dpy, "_XSETROOT_ID", False);
5398N/A- XA_ESETROOT_PMAP_ID = XInternAtom (si->dpy, "ESETROOT_PMAP_ID", False);
5398N/A- XA_XROOTPMAP_ID = XInternAtom (si->dpy, "_XROOTPMAP_ID", False);
5559N/A- XA_NET_WM_USER_TIME = XInternAtom (si->dpy, "_NET_WM_USER_TIME", False);
5398N/A- XA_ACTIVATE = XInternAtom (si->dpy, "ACTIVATE", False);
5398N/A- XA_DEACTIVATE = XInternAtom (si->dpy, "DEACTIVATE", False);
5398N/A- XA_RESTART = XInternAtom (si->dpy, "RESTART", False);
5398N/A- XA_CYCLE = XInternAtom (si->dpy, "CYCLE", False);
5398N/A- XA_NEXT = XInternAtom (si->dpy, "NEXT", False);
5398N/A- XA_PREV = XInternAtom (si->dpy, "PREV", False);
5398N/A- XA_SELECT = XInternAtom (si->dpy, "SELECT", False);
5398N/A- XA_EXIT = XInternAtom (si->dpy, "EXIT", False);
5398N/A- XA_DEMO = XInternAtom (si->dpy, "DEMO", False);
5398N/A- XA_PREFS = XInternAtom (si->dpy, "PREFS", False);
5398N/A- XA_LOCK = XInternAtom (si->dpy, "LOCK", False);
5398N/A- XA_BLANK = XInternAtom (si->dpy, "BLANK", False);
5398N/A- XA_THROTTLE = XInternAtom (si->dpy, "THROTTLE", False);
5398N/A- XA_UNTHROTTLE = XInternAtom (si->dpy, "UNTHROTTLE", False);
5398N/A+ const struct atom_request root_atoms[] =
5398N/A+ { &XA_VROOT, "__SWM_VROOT" },
5398N/A+ { &XA_XSETROOT_ID, "_XSETROOT_ID" },
5398N/A+ { &XA_ESETROOT_PMAP_ID, "ESETROOT_PMAP_ID" },
5398N/A+ { &XA_XROOTPMAP_ID, "_XROOTPMAP_ID" },
5559N/A+ { &XA_NET_WM_USER_TIME, "_NET_WM_USER_TIME" },
5398N/A+ { NULL, NULL } /* Must be last to terminate list */
5398N/A+ const struct atom_request *atom_lists[3] = { NULL, NULL, NULL };
5398N/A+ atom_lists[0] = remote_control_atoms;
5398N/A+ atom_lists[1] = root_atoms;
5398N/A+ request_atoms (si->dpy, atom_lists);
5559N/Aindex d67966e..064e9c4 100644
5559N/A@@ -202,8 +202,5 @@ Bool safe_XF86VidModeGetViewPort (Display *, int, int *, int *);
5398N/A extern Atom XA_VROOT, XA_XSETROOT_ID, XA_ESETROOT_PMAP_ID, XA_XROOTPMAP_ID;
5559N/A extern Atom XA_NET_WM_USER_TIME;
5398N/A-extern Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_ID;
5398N/A-extern Atom XA_SCREENSAVER_STATUS, XA_LOCK, XA_BLANK;
5398N/A-extern Atom XA_DEMO, XA_PREFS;
5398N/A #endif /* __XSCREENSAVER_H__ */