| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 1 | #include "X11/Xlib.h" |
| 2 | #include "X11/keysym.h" | ||||
| 3 | |||||
| 4 | #include "SkApplication.h" | ||||
| Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 5 | #include "SkEvent.h" |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 6 | #include "SkWindow.h" |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 7 | #include "SkTypes.h" |
| Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 8 | |
| Scroggo | 5a23424 | 2011-06-13 19:17:58 +0000 | [diff] [blame] | 9 | #include <signal.h> |
| 10 | #include <sys/time.h> | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 11 | |
| Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 12 | SkOSWindow* gWindow; |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 13 | |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 14 | static void catch_alarm(int sig) |
| 15 | { | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 16 | SkEvent::ServiceQueueTimer(); |
| 17 | } | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 18 | |
| senorblanco@chromium.org | 78b8253 | 2011-06-28 19:44:03 +0000 | [diff] [blame] | 19 | int main(int argc, char** argv){ |
| Scroggo | 5a23424 | 2011-06-13 19:17:58 +0000 | [diff] [blame] | 20 | signal(SIGALRM, catch_alarm); |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 21 | |
| senorblanco@chromium.org | 78b8253 | 2011-06-28 19:44:03 +0000 | [diff] [blame] | 22 | gWindow = create_sk_window(NULL, argc, argv); |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 23 | // Start normal Skia sequence |
| 24 | application_init(); | ||||
| 25 | |||||
| Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 26 | gWindow->loop(); |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 27 | |
| Scroggo | 62b65b0 | 2011-06-21 16:01:26 +0000 | [diff] [blame] | 28 | delete gWindow; |
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 29 | application_term(); |
| 30 | return 0; | ||||
| 31 | } | ||||
| 32 | |||||
| 33 | // SkEvent handlers | ||||
| 34 | |||||
| 35 | void SkEvent::SignalNonEmptyQueue() | ||||
| 36 | { | ||||
| Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 37 | if (gWindow) |
| 38 | gWindow->post_linuxevent(); | ||||
| 39 | else | ||||
| 40 | while (SkEvent::ProcessEvent()); | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 41 | } |
| 42 | |||||
| 43 | void SkEvent::SignalQueueTimer(SkMSec delay) | ||||
| 44 | { | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 45 | itimerval newTimer; |
| 46 | newTimer.it_interval.tv_sec = 0; | ||||
| 47 | newTimer.it_interval.tv_usec = 0; | ||||
| 48 | newTimer.it_value.tv_sec = 0; | ||||
| 49 | newTimer.it_value.tv_usec = delay * 1000; | ||||
| Scroggo | 5a23424 | 2011-06-13 19:17:58 +0000 | [diff] [blame] | 50 | |
| 51 | setitimer(ITIMER_REAL, &newTimer, NULL); | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 52 | } |