Revision: 74161 http://trac.macports.org/changeset/74161 Author: jmr@macports.org Date: 2010-12-06 04:30:40 -0800 (Mon, 06 Dec 2010) Log Message: ----------- wmclock: patchfile Added Paths: ----------- trunk/dports/x11/wmclock/files/ trunk/dports/x11/wmclock/files/wmclock_nopolling.patch Added: trunk/dports/x11/wmclock/files/wmclock_nopolling.patch =================================================================== --- trunk/dports/x11/wmclock/files/wmclock_nopolling.patch (rev 0) +++ trunk/dports/x11/wmclock/files/wmclock_nopolling.patch 2010-12-06 12:30:40 UTC (rev 74161) @@ -0,0 +1,74 @@ +--- wmclock.c.orig 2008-09-28 17:41:49.000000000 +0200 ++++ wmclock.c 2008-09-28 20:33:59.000000000 +0200 +@@ -20,6 +20,7 @@ + * with the software or the use or other dealings in the software. + */ + ++#include <sys/select.h> + #include <sys/types.h> + #include <sys/wait.h> + #include <sys/time.h> +@@ -141,7 +142,8 @@ + Display *dpy; + Window rootWindow; + int screen; +-/* int xFd; */ ++int xFd; ++fd_set xFdSet; + int displayDepth; + XSizeHints sizeHints; + XWMHints wmHints; +@@ -801,6 +803,7 @@ + XTextProperty wmName; + XClassHint classHint; + Pixmap shapeMask; ++ struct timeval nextEvent; + + /* Parse command line options */ + progName = extractProgName(argv[0]); +@@ -849,7 +852,7 @@ + screen = DefaultScreen(dpy); + rootWindow = RootWindow(dpy, screen); + displayDepth = DefaultDepth(dpy, screen); +- /* xFd = XConnectionNumber(dpy); */ ++ xFd = XConnectionNumber(dpy); + + /* Icon Daten nach XImage konvertieren */ + GetXpms(); +@@ -1049,14 +1052,29 @@ + poll((struct poll *) 0, (size_t) 0, 50); /* 5/100 sec */ + } + #else +- if (enableYearDisplay) +- { +- usleep(200000L); /* 1/5 sec */ +- } ++ //We compute the date of next event, in order to avoid polling ++ if (enableBlinking) ++ { ++ gettimeofday(&nextEvent,NULL); ++ nextEvent.tv_sec = 0; ++ nextEvent.tv_usec = 1000000-nextEvent.tv_usec; ++ } + else +- { +- usleep(50000L); /* 5/100 sec */ +- } ++ { ++ if (enableYearDisplay) ++ { ++ nextEvent.tv_sec = 86400-actualTime%86400; ++ nextEvent.tv_usec = 0; ++ } ++ else ++ { ++ nextEvent.tv_sec = 60-actualTime%60; ++ nextEvent.tv_usec = 0; ++ } ++ } ++ FD_ZERO(&xFdSet); ++ FD_SET(xFd,&xFdSet); ++ select(FD_SETSIZE,&xFdSet,NULL,NULL,&nextEvent); + #endif + } + return(0);
participants (1)
-
jmr@macports.org