*in progress*
authorEleni Maria Stea <elene.mst@gmail.com>
Mon, 18 Feb 2013 22:04:32 +0000 (00:04 +0200)
committerEleni Maria Stea <elene.mst@gmail.com>
Mon, 18 Feb 2013 22:04:32 +0000 (00:04 +0200)
mouse, keyboard events + focus window work!!!!!!!!

src/event.cc
src/keyboard.cc
src/mouse.cc
src/winnie.cc

index 1586c95..a54fe7a 100644 (file)
@@ -28,7 +28,6 @@ void process_events()
                while(select(maxfd + 1, &read_set, 0, 0, 0) == -1 && errno == EINTR);
 
                if(FD_ISSET(keyb_fd, &read_set)) {
                while(select(maxfd + 1, &read_set, 0, 0, 0) == -1 && errno == EINTR);
 
                if(FD_ISSET(keyb_fd, &read_set)) {
-                       printf("WINNIE TODO PROCESS KEYB\n");
                        process_keyboard_event();
                }
                if(FD_ISSET(mouse_fd, &read_set)) {
                        process_keyboard_event();
                }
                if(FD_ISSET(mouse_fd, &read_set)) {
index 6275227..1b23e12 100644 (file)
@@ -81,9 +81,9 @@ void process_keyboard_event()
                return;
        }
 
                return;
        }
 
-/*     if(key == 'q') {
+       if(key == 'q') {
                exit(0);
                exit(0);
-       }*/
+       }
 
        Window *focused_win = wm->get_focused_window();
        if(focused_win) {
 
        Window *focused_win = wm->get_focused_window();
        if(focused_win) {
index f29841c..861b597 100644 (file)
@@ -27,7 +27,7 @@ static int bnstate;
 
 bool init_mouse()
 {
 
 bool init_mouse()
 {
-       if((dev_fd = open("/dev/psaux", O_RDONLY)) == -1) {
+       if((dev_fd = open("/dev/psaux", O_RDONLY | O_NONBLOCK)) == -1) {
                fprintf(stderr, "Cannot open /dev/psaux : %s\n", strerror(errno));
                return false;
        }
                fprintf(stderr, "Cannot open /dev/psaux : %s\n", strerror(errno));
                return false;
        }
@@ -69,6 +69,14 @@ void process_mouse_event()
                return;
        }
 
                return;
        }
 
+       unsigned char *fb = get_framebuffer();
+       fb += (bounds.width * pointer_y + pointer_x) * 4;
+       fb[0] = 0;
+       fb[1] = 0;
+       fb[2] = 0;
+
+       //printf("pointer (x, y) = (%d, %d)\r\n", pointer_x, pointer_y);
+
        Window *top = wm->get_window_at_pos(pointer_x, pointer_y);
        if(top) {
                wm->set_focused_window(top);
        Window *top = wm->get_window_at_pos(pointer_x, pointer_y);
        if(top) {
                wm->set_focused_window(top);
@@ -92,7 +100,7 @@ void process_mouse_event()
                        motion_callback(top, pointer_x - rect.x, pointer_y - rect.y);
                }
        }
                        motion_callback(top, pointer_x - rect.x, pointer_y - rect.y);
                }
        }
-       
+
        MouseButtonFuncType button_callback = top->get_mouse_button_callback();
        if(button_callback && (bnstate != prev_state)) {
                int num_bits = sizeof bnstate * CHAR_BIT;
        MouseButtonFuncType button_callback = top->get_mouse_button_callback();
        if(button_callback && (bnstate != prev_state)) {
                int num_bits = sizeof bnstate * CHAR_BIT;
@@ -104,13 +112,6 @@ void process_mouse_event()
                        }
                }
        }
                        }
                }
        }
-
-       unsigned char *fb = get_framebuffer();
-       Rect scr = get_screen_size();
-       fb += (scr.width * pointer_y + pointer_x) * 4;
-       fb[0] = 0;
-       fb[1] = 0;
-       fb[2] = 0;
 }
 
 void get_pointer_pos(int *x, int *y)
 }
 
 void get_pointer_pos(int *x, int *y)
index fe81799..4ec10b1 100644 (file)
@@ -24,4 +24,5 @@ void winnie_shutdown()
 {
        destroy_gfx();
        destroy_keyboard();
 {
        destroy_gfx();
        destroy_keyboard();
+       destroy_mouse();
 }
 }