f79a9e8556605e24fa3aba39e4c56be26b88e110
[winnie] / src / winnie.cc
1 #include <sys/time.h>
2
3 #include "keyboard.h"
4 #include "mouse.h"
5 #include "shalloc.h"
6 #include "winnie.h"
7
8 bool winnie_init()
9 {
10         if(!init_shared_memory()) {
11                 return false;
12         }
13
14         if(!init_gfx()) {
15                 return false;
16         }
17
18         if(!init_window_manager()) {
19                 return false;
20         }
21
22         if(!init_keyboard()) {
23                 return false;
24         }
25
26         if(!init_mouse()) {
27                 return false;
28         }
29
30         if(!init_text()) {
31                 return false;
32         }
33
34         wm->invalidate_region(get_screen_size());
35         return true;
36 }
37
38 void winnie_shutdown()
39 {
40         destroy_gfx();
41         destroy_keyboard();
42         destroy_mouse();
43         destroy_text();
44
45         destroy_shared_memory();
46 }
47
48 long winnie_get_time()
49 {
50         static struct timeval init_tv;
51         struct timeval tv;
52
53         gettimeofday(&tv, 0);
54
55         if(!tv.tv_sec && !tv.tv_usec) {
56                 init_tv = tv;
57                 return 0;
58         }
59
60         return (tv.tv_usec - init_tv.tv_usec) / 1000 + (tv.tv_sec - init_tv.tv_sec) * 1000;
61 }