45eed6e966fe0e1cc2b7b969402e14a6c2789d3d
[winnie] / src / event.cc
1 #include <stdio.h>
2
3 #include <errno.h>
4 #include <unistd.h>
5 #include <sys/select.h>
6
7 #include "event.h"
8 #include "wm.h"
9 #include "keyboard.h"
10 #include "mouse.h"
11
12 void process_events()
13 {
14         int keyb_fd = get_keyboard_fd();
15         int mouse_fd = get_mouse_fd();
16
17         for(;;) {
18                 wm->process_windows();
19
20                 fd_set read_set;
21
22                 FD_ZERO(&read_set);
23                 FD_SET(keyb_fd, &read_set);
24                 FD_SET(mouse_fd, &read_set);
25
26                 int maxfd = keyb_fd > mouse_fd ? keyb_fd : mouse_fd;
27
28                 while(select(maxfd + 1, &read_set, 0, 0, 0) == -1 && errno == EINTR);
29
30                 if(FD_ISSET(keyb_fd, &read_set)) {
31                         printf("WINNIE TODO PROCESS KEYB\n");
32                         process_keyboard_event();
33                 }
34 /*              if(FD_ISSET(mouse_fd, &read_set)) {
35                         process_mouse_event();
36                 }*/
37         }
38 }