X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fevent.cc;h=45eed6e966fe0e1cc2b7b969402e14a6c2789d3d;hb=ffd2c0a0f8b898cb4199a0c63aff255a85cc0f11;hp=4656575d564272889978657ccc9af38ebf2fd5eb;hpb=0860ce537422597075fbc63ddcc9a73303362a93;p=winnie diff --git a/src/event.cc b/src/event.cc index 4656575..45eed6e 100644 --- a/src/event.cc +++ b/src/event.cc @@ -1,46 +1,38 @@ -#include "event.h" +#include -static DisplayFuncType display_func; -static KeyboardFuncType keyboard_func; -static MouseButtonFuncType mouse_button_func; -static MouseMotionFuncType mouse_motion_func; +#include +#include +#include -void set_display_callback(DisplayFuncType display) -{ - display_func = display; -} +#include "event.h" +#include "wm.h" +#include "keyboard.h" +#include "mouse.h" -void set_keyboard_callback(KeyboardFuncType keyboard) +void process_events() { - keyboard_func = keyboard; -} + int keyb_fd = get_keyboard_fd(); + int mouse_fd = get_mouse_fd(); -void set_mouse_button_callback(MouseButtonFuncType mouse_button) -{ - mouse_button_func = mouse_button; -} + for(;;) { + wm->process_windows(); -void set_mouse_motion_callback(MouseMotionFuncType mouse_motion) -{ - mouse_motion_func = mouse_motion; -} + fd_set read_set; -DisplayFuncType get_display_callback() -{ - return display_func; -} + FD_ZERO(&read_set); + FD_SET(keyb_fd, &read_set); + FD_SET(mouse_fd, &read_set); -KeyboardFuncType get_keyboard_callback() -{ - return keyboard_func; -} + int maxfd = keyb_fd > mouse_fd ? keyb_fd : mouse_fd; -MouseButtonFuncType get_mouse_button_callback() -{ - return mouse_button_func; -} + while(select(maxfd + 1, &read_set, 0, 0, 0) == -1 && errno == EINTR); -MouseMotionFuncType get_mouse_motion_callback() -{ - return mouse_motion_func; + if(FD_ISSET(keyb_fd, &read_set)) { + printf("WINNIE TODO PROCESS KEYB\n"); + process_keyboard_event(); + } +/* if(FD_ISSET(mouse_fd, &read_set)) { + process_mouse_event(); + }*/ + } }