[GRASS-SVN] r32601 - in grass/trunk/visualization: . ximgview
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 6 23:23:52 EDT 2008
Author: glynn
Date: 2008-08-06 23:23:52 -0400 (Wed, 06 Aug 2008)
New Revision: 32601
Modified:
grass/trunk/visualization/Makefile
grass/trunk/visualization/ximgview/
grass/trunk/visualization/ximgview/main.c
Log:
Build ximgview if USE_X11
Allow wake-up via SIGUSR1
Modified: grass/trunk/visualization/Makefile
===================================================================
--- grass/trunk/visualization/Makefile 2008-08-07 03:22:40 UTC (rev 32600)
+++ grass/trunk/visualization/Makefile 2008-08-07 03:23:52 UTC (rev 32601)
@@ -21,6 +21,10 @@
SUBDIRS += xganim
endif
+ifneq ($(USE_X11),)
+ SUBDIRS += ximgview
+endif
+
include $(MODULE_TOPDIR)/include/Make/Dir.make
default: parsubdirs
Property changes on: grass/trunk/visualization/ximgview
___________________________________________________________________
Name: svn:ignore
+ *.tmp.html
*OBJ*
Modified: grass/trunk/visualization/ximgview/main.c
===================================================================
--- grass/trunk/visualization/ximgview/main.c 2008-08-07 03:22:40 UTC (rev 32600)
+++ grass/trunk/visualization/ximgview/main.c 2008-08-07 03:23:52 UTC (rev 32601)
@@ -16,6 +16,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <signal.h>
+#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
@@ -97,16 +99,13 @@
XFlush(dpy);
}
-static void redraw(void)
+static void draw(void)
{
int x0 = (w_width - i_width) / 2;
int y0 = (w_height - i_height) / 2;
const unsigned char *p = imgbuf;
- struct timeval tv0, tv1;
int row, col;
- gettimeofday(&tv0, NULL);
-
for (row = 0; row < i_height; row++) {
for (col = 0; col < i_width; col++) {
unsigned char b = *p++;
@@ -121,15 +120,34 @@
XPutImage(dpy, grwin, gc, ximg, 0, 0, x0, y0, i_width, i_height);
XSync(dpy, False);
+}
+static void redraw(void)
+{
+ struct timeval tv0, tv1;
+
+ gettimeofday(&tv0, NULL);
+
+ draw();
+
gettimeofday(&tv1, NULL);
last = (tv1.tv_sec - tv0.tv_sec) * 1000000L + (tv1.tv_usec - tv0.tv_usec);
}
+static void dummy_handler(int sig)
+{
+}
+
static void main_loop(void)
{
int xfd = ConnectionNumber(dpy);
+ struct sigaction act;
+ act.sa_handler = &dummy_handler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGUSR1, &act, NULL);
+
for (;;) {
fd_set waitset;
struct timeval tv;
@@ -142,7 +160,7 @@
switch (event.type) {
case Expose:
- redraw();
+ draw();
break;
case ConfigureNotify:
w_width = event.xconfigure.width;
@@ -158,10 +176,11 @@
FD_ZERO(&waitset);
FD_SET(xfd, &waitset);
- if (select(FD_SETSIZE, &waitset, NULL, NULL, &tv) < 0)
+ errno = 0;
+ if (select(FD_SETSIZE, &waitset, NULL, NULL, &tv) < 0 && errno != EINTR)
continue;
- if (!FD_ISSET(xfd, &waitset))
+ if (!FD_ISSET(xfd, &waitset) || errno == EINTR)
redraw();
}
}
More information about the grass-commit
mailing list