primitive timeout.. its not even that good.. :)

SVN revision: 1147
This commit is contained in:
Carsten Haitzler 1999-11-02 14:34:46 +00:00
parent 4b69037861
commit dbb01a2a05
1 changed files with 157 additions and 89 deletions

View File

@ -7,7 +7,10 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "Imlib2.h"
Display *disp;
@ -135,12 +138,18 @@ main (int argc, char **argv)
}
for(;;)
{
int x, y, b;
int x, y, b, count, fdsize, xfd, timeout = 0;
XEvent ev;
static int zoom_mode = 0, zx, zy;
static double zoom = 1.0;
char aa = 0, dith = 0;
struct timeval tval;
fd_set fdset;
double t1;
XFlush(disp);
while (XPending(disp))
{
XNextEvent(disp, &ev);
switch (ev.type)
{
@ -239,9 +248,68 @@ main (int argc, char **argv)
NULL, IMLIB_OP_COPY);
XSetWindowBackgroundPixmap(disp, win, pm);
XClearWindow(disp, win);
timeout = 1;
}
default:
break;
}
t1 = 0.5;
tval.tv_sec = (long)t1;
tval.tv_usec = (long)((t1 - ((double)tval.tv_sec)) * 1000000);
xfd = ConnectionNumber(disp);
fdsize = xfd + 1;
FD_ZERO(&fdset);
FD_SET(xfd, &fdset);
if (timeout)
count = select(fdsize, &fdset, NULL, NULL, &tval);
else
count = select(fdsize, &fdset, NULL, NULL, NULL);
if (count < 0)
{
if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))
exit(1);
}
else
{
if ((count == 0) && (timeout))
{
int sx, sy, sw, sh, dx, dy, dw, dh;
if (zoom > 1.0)
{
dx = 0;
dy = 0;
dw = image_width;
dh = image_height;
sx = zx - (zx / zoom);
sy = zy - (zy / zoom);
sw = image_width / zoom;
sh = image_height / zoom;
}
else
{
dx = zx - (zx * zoom);
dy = zy - (zy * zoom);
dw = image_width * zoom;
dh = image_height * zoom;
sx = 0;
sy = 0;
sw = image_width;
sh = image_height;
}
imlib_render_image_part_on_drawable_at_size
(bg_im,
disp, pm, vis, cm, depth,
1, 1, 0,
sx, sy, sw, sh, dx, dy, dw, dh,
NULL, IMLIB_OP_COPY);
XSetWindowBackgroundPixmap(disp, win, pm);
XClearWindow(disp, win);
timeout = 0;
}
}
}
}