Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37658599
en ru br
ALT Linux repos
S:1.0.16-alt1
5.0: 1.0.12.2-alt2
4.1: 1.0.12.2-alt2
4.0: 1.0.12.2-alt2
3.0: 1.0.12.2-alt1

Group :: Graphical desktop/Window Maker
RPM: wmclock

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: wmclock-1.0.12.2-debian-nopolling.patch
Download


diff -Naur wmclock-1.0.12.2-orig/wmclock.c wmclock-1.0.12.2/wmclock.c
--- wmclock-1.0.12.2-orig/wmclock.c	2000-03-08 09:31:33 +0200
+++ wmclock-1.0.12.2/wmclock.c	2009-01-17 22:35:38 +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]);
@@ -842,7 +845,7 @@
    screen       = DefaultScreen(dpy);
    rootWindow   = RootWindow(dpy, screen);
    displayDepth = DefaultDepth(dpy, screen);
-   /* xFd          = XConnectionNumber(dpy); */
+   xFd          = XConnectionNumber(dpy);
    
    /* Icon Daten nach XImage konvertieren */
    GetXpms();
@@ -1042,14 +1045,32 @@
 	   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;
+	     }
+	 }
+//       printf("xFd %d\n", xFd);
+       FD_ZERO(&xFdSet);
+       FD_SET(xFd,&xFdSet);
+//       printf("debut select %d\n", nextEvent.tv_sec);
+       select(FD_SETSIZE,&xFdSet,NULL,NULL,&nextEvent);
+//       printf("fin select\n");
 #endif
     }
    return(0);
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin