Expanded select() construct

This commit is contained in:
buffet 2018-10-19 11:14:07 +02:00
parent 7db3bf4d01
commit 49d022c6b1

View file

@ -17,11 +17,15 @@
#include <sys/wait.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include "ipc.h"
#include "xcb.h"
#include "common.h"
#define MAX(a, b) ((a) > (b) ? (a) : (b))
static void exec_config(const char *path);
static void sig_handler(int sig);
@ -85,12 +89,15 @@ main(int argc, char *argv[])
exec_config(config_path);
int max_fd = g_sock_fd + 1;
int max_fd = MAX(g_sock_fd, g_dpy_fd) + 1;
fd_set file_descriptors;
while (!g_is_about_to_quit) {
xcb_flush(g_dpy);
FD_ZERO(&file_descriptors);
FD_SET(g_sock_fd, &file_descriptors);
FD_SET(g_dpy_fd, &file_descriptors);
select(max_fd, &file_descriptors, NULL, NULL, NULL);
@ -108,6 +115,10 @@ main(int argc, char *argv[])
close(client_fd);
}
}
if (FD_ISSET(g_dpy_fd, &file_descriptors)) {
// TODO: handle event
}
}
}