#include <sys/select.h>
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
#include <xcb/xcb.h>
#include <xcb/damage.h>
int foo;
} d_options_t;
+static gboolean quit = FALSE;
+
static void
read_options(int argc, char **argv, d_options_t *opts)
{
}
static void
+signal_quit_handler(int sig)
+{
+ printf("caught signal %d, quitting\n", sig);
+ quit = TRUE;
+}
+
+static void
event(d_display_t *dpy)
{
xcb_generic_event_t *ev;
- while ((ev = xcb_poll_for_event(dpy->conn))) {
+ while ((ev = xcb_poll_for_event(dpy->conn)) && !quit) {
//printf("event %d\n", ev->response_type);
if (!ev->response_type) {
static void
run(d_display_t *dpy)
{
- gboolean quit;
-
- quit = FALSE;
while (!quit) {
struct timeval next, now, *wait;
int r, npaint;
else {
/* don't wait cuz a redraw is due now already */
next.tv_sec = 0;
- next.tv_usec = 1;
+ next.tv_usec = 100;
wait = &next;
}
//printf("select %d\n", npaint);
r = select(dpy->fd+1, &fds, NULL, NULL, wait);
- if (r < 0)
- printf("select error\n");
- else if (r == 0) {
+ if (r == 0) {
//printf("select timeout\n");
paint(dpy);
xcb_flush(dpy->conn);
return 0;
}
+ signal(SIGINT, signal_quit_handler);
+ signal(SIGHUP, signal_quit_handler);
+ signal(SIGTERM, signal_quit_handler);
+ signal(SIGQUIT, signal_quit_handler);
+
setup_functions(dpy);
{
screen_set_next_repaint(d_screen_t *sc)
{
gettimeofday(&sc->next_repaint, NULL);
- /* add time for the refresh rate (30 hz) */
- time_add(&sc->next_repaint, 1000000/30);
+ /* add time for the refresh rate (60 hz) */
+ time_add(&sc->next_repaint, 1000000/60);
sc->need_repaint = FALSE;
}