take out a bunch of unused stuff
authordaniel watson <ozzloy@gmail.com>
Sat, 28 Apr 2012 05:54:48 +0000 (01:54 -0400)
committerdaniel watson <ozzloy@gmail.com>
Sat, 28 Apr 2012 05:54:48 +0000 (01:54 -0400)
idle_x11.cpp
idle_x11.h

index 1b5e6e4f9105cf38df54c40096f56a02ae9e0460..ebe49f5aed72a46b0d4accfed921361ecd2e0eab 100644 (file)
 
 static Display *dpy = NULL;
 
-static void get_alarm(XSyncAlarm *alarm, XSyncCounter counter, XSyncTestType type, XSyncValue value)
-{
-       XSyncAlarmAttributes attrs;
-
-       XSyncValue delta;
-       XSyncIntToValue(&delta, 0);
-
-       static const unsigned long flags = XSyncCACounter | XSyncCATestType | XSyncCAValue | XSyncCADelta;
-
-       attrs.trigger.counter = counter;
-       attrs.trigger.test_type = type;
-       attrs.trigger.wait_value = value;
-       attrs.delta = delta;
-
-       if (*alarm)
-               XSyncChangeAlarm(dpy, *alarm, flags, &attrs);
-       else
-               *alarm = XSyncCreateAlarm(dpy, flags, &attrs);
-}
-
-static void die(const char *errstr)
-{
-       fputs(errstr, stderr);
-       fflush(stderr);
-       exit(EXIT_FAILURE);
-}
-
-bool wait_for_idle_time(int idle_time)
-{
-       static int xsync_event_base;
-       static XSyncAlarm idle_alarm = None;
-       static XSyncAlarm reset_alarm = None;
-       static XSyncCounter idle = None;
-       static XSyncValue idle_timeout;
-
-       if (idle == None) {
-               if (!(dpy = XOpenDisplay(NULL)))
-                       die("Could not open X11 display; exiting.\n");
-
-               int dummy;
-               if (!XQueryExtension(dpy, "XTEST", &dummy, &dummy, &dummy))
-                       die("XTEST extension not available; cannot reset idle time\n");
-
-               int xsync_error_base;
-               int xsync_major = SYNC_MAJOR_VERSION;
-               int xsync_minor = SYNC_MINOR_VERSION;
-
-               if (!XSyncQueryExtension(dpy, &xsync_event_base, &xsync_error_base) || !XSyncInitialize(dpy, &xsync_major, &xsync_minor))
-                       die("No XSync extension; exiting.\n");
-
-               int i;
-               XSyncSystemCounter *counters = XSyncListSystemCounters(dpy, &i);
-               while (i--)
-                       if (!strcmp(counters[i].name, "IDLETIME"))
-                               idle = counters[i].counter;
-               XSyncFreeSystemCounterList(counters);
-
-               if (idle == None)
-                       die("No IDLETIME counter! xorg-server 1.3 and higher should support it. Exiting.\n");
-
-               XSyncIntToValue(&idle_timeout, idle_time * 1000);
-               get_alarm(&idle_alarm, idle, XSyncPositiveComparison, idle_timeout);
-       }
-
-       XEvent ev;
-
-       while (!XNextEvent(dpy, &ev)) {
-               if (ev.type == xsync_event_base + XSyncAlarmNotify) {
-                       XSyncAlarmNotifyEvent *e = (XSyncAlarmNotifyEvent*)&ev;
-
-                       if (e->alarm == idle_alarm) {
-                               int overflow;
-                               XSyncValue reset_timeout;
-                               XSyncValue minus_one;
-
-                               XSyncIntToValue(&minus_one, -1);
-                               XSyncValueAdd(&reset_timeout, e->counter_value, minus_one, &overflow);
-                               get_alarm(&reset_alarm, idle, XSyncNegativeComparison, reset_timeout);
-
-                               return true;
-                       } else if (e->alarm == reset_alarm) {
-                               get_alarm(&idle_alarm, idle, XSyncPositiveComparison, idle_timeout);
-                       }
-               }
-       }
-
-       return false;
-}
-
 void reset_idle_time()
 {
        if (!dpy) {
index 9bc48f1401ee0b1623e8b659dca10127f5714056..fc54ac0622c8c0d12f13bf4305375957223397bf 100644 (file)
@@ -1,3 +1,2 @@
 
-bool wait_for_idle_time(int idle_time);
 void reset_idle_time();