ioctl doesn't work for my intel
[winnie] / src / main.cc
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include "winnie.h"
5
6 static void display(Window *win);
7 static void keyboard(Window *win, int key, bool pressed);
8 static void button(Window *win, int bn, bool pressed, int x, int y);
9 static void motion(Window *win, int x, int y);
10 static void cleanup();
11
12 int main()
13 {
14         if(!winnie_init()) {
15                 exit(1);
16         }
17
18         atexit(cleanup);
19
20         Window *win1 = new Window;
21         win1->set_title("title1");
22         win1->move(5, 10);
23         win1->resize(200, 300);
24         win1->set_display_callback(display);
25         win1->set_keyboard_callback(keyboard);
26         win1->set_mouse_button_callback(button);
27         win1->set_mouse_motion_callback(motion);
28
29         wm->add_window(win1);
30
31         while(1) {
32                 process_events();
33         }
34 }
35
36 static void display(Window *win)
37 {
38         if(wm->get_focused_window() != win) {
39                 fill_rect(win->get_absolute_rect(), 106, 106, 250);
40         }
41         else {
42                 fill_rect(win->get_absolute_rect(), 0, 0, 255);
43         }
44 }
45
46 static void keyboard(Window *win, int key, bool pressed)
47 {
48         switch(key) {
49         case 'q':
50                 exit(0);
51         }
52 }
53
54 static void button(Window *win, int bn, bool pressed, int x, int y)
55 {
56         printf("WINDOW(%p) button %d %s\n", (void*)win, bn, pressed ? "press" : "release");
57 }
58
59 static void motion(Window *win, int x, int y)
60 {
61         printf("WINDOW(%p) motion %d %d\n", (void*)win, x, y);
62 }
63
64 static void cleanup()
65 {
66         winnie_shutdown();
67 }