Package: wmwave
Tags: patch
This patch is from Julien BLACHE with the following comment.
-- Guido
| Attached is a small patch for wmwave to use select() instead of
| sleeping.
|
| The goal is to be able to use a longer update interval without ugly
| visual side-effects. I've been told it also helps a lot when using the
| dockapp swallowed in non-WMaker WMs.
|
| The patch relies on timeout being updated by select() and hence it's
| Linux-specific, but wmwave itself is Linux-specific TTBOMK.
|
| I've no strong feelings about this, so I'm just sending the patch and
| not opening a bug about it. After all, it doesn't help reducing the
| number of CPU wakeups, so...
diff -ru orig/wmwave-0.4/wmgeneral.c wmwave-0.4/wmgeneral.c
--- orig/wmwave-0.4/wmgeneral.c 1999-08-15 17:38:38.000000000 +0200
+++ wmwave-0.4/wmgeneral.c 2008-11-13 13:37:24.826233102 +0100
@@ -65,6 +65,7 @@
/* X11 Variables */
/*****************/
+Display *display;
Window Root;
int screen;
int x_fd;
diff -ru orig/wmwave-0.4/wmgeneral.h wmwave-0.4/wmgeneral.h
--- orig/wmwave-0.4/wmgeneral.h 1999-08-15 17:32:50.000000000 +0200
+++ wmwave-0.4/wmgeneral.h 2008-11-13 13:37:01.194230361 +0100
@@ -36,7 +36,8 @@
/* Global variable */
/*******************/
-Display *display;
+extern Display *display;
+extern int x_fd;
/***********************/
/* Function Prototypes */
diff -ru orig/wmwave-0.4/wmwave.c wmwave-0.4/wmwave.c
--- orig/wmwave-0.4/wmwave.c 2008-11-13 14:00:06.000000000 +0100
+++ wmwave-0.4/wmwave.c 2008-11-13 13:56:23.122377584 +0100
@@ -49,6 +49,7 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/param.h>
+#include <sys/select.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -70,7 +71,7 @@
#define WMWAVE_VERSION "0.4"
-int update_rate=100000;
+int update_rate = 100;
char *ProgName;
@@ -280,7 +281,7 @@
break;
case 'r':
if (argc > (i+1)) {
- update_rate = (atoi(argv[i+1]) * 1000);
+ update_rate = atoi(argv[i+1]);
i++;
}
break;
@@ -302,29 +303,30 @@
*/
void wmwave_routine(int argc, char **argv) {
XEvent Event;
- struct timeval tv={0,0};
- struct timeval last={0,0};
-
+ fd_set fds;
+ struct timeval tv_rate;
+ struct timeval tv = {0, 0};
+
+ tv_rate.tv_sec = update_rate / 1000;
+ tv_rate.tv_usec = (update_rate - tv_rate.tv_sec * 1000) * 1000;
+
createXBMfromXPM(wmwave_mask_bits, wmwave_master_xpm, wmwave_mask_width, wmwave_mask_height);
openXwindow(argc, argv, wmwave_master_xpm, wmwave_mask_bits, wmwave_mask_width, wmwave_mask_height);
RedrawWindow();
-
-
+
+
while (1) {
-
- curtime = time(0);
-
- if (1) {
- memcpy(&last, &tv, sizeof(tv));
-
+ if ((tv.tv_sec == 0) && (tv.tv_usec == 0)) {
/*
* Update display
*/
DisplayWireless();
-
+
RedrawWindow();
+
+ tv = tv_rate;
}
/*
@@ -342,8 +344,10 @@
break;
}
}
-
- usleep(update_rate);
+
+ FD_ZERO(&fds);
+ FD_SET(x_fd, &fds);
+ select(FD_SETSIZE, &fds, NULL, NULL, &tv);
}
}