| 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 | |
| 19 | int main(){ | ||||
| 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 | |
| Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 22 | gWindow = create_sk_window(NULL); |
| 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 | |
| 28 | application_term(); | ||||
| 29 | return 0; | ||||
| 30 | } | ||||
| 31 | |||||
| 32 | // SkEvent handlers | ||||
| 33 | |||||
| 34 | void SkEvent::SignalNonEmptyQueue() | ||||
| 35 | { | ||||
| Scroggo | 9df214e | 2011-04-15 14:48:08 +0000 | [diff] [blame] | 36 | if (gWindow) |
| 37 | gWindow->post_linuxevent(); | ||||
| 38 | else | ||||
| 39 | while (SkEvent::ProcessEvent()); | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 40 | } |
| 41 | |||||
| 42 | void SkEvent::SignalQueueTimer(SkMSec delay) | ||||
| 43 | { | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 44 | itimerval newTimer; |
| 45 | newTimer.it_interval.tv_sec = 0; | ||||
| 46 | newTimer.it_interval.tv_usec = 0; | ||||
| 47 | newTimer.it_value.tv_sec = 0; | ||||
| 48 | newTimer.it_value.tv_usec = delay * 1000; | ||||
| Scroggo | 5a23424 | 2011-06-13 19:17:58 +0000 | [diff] [blame] | 49 | |
| 50 | setitimer(ITIMER_REAL, &newTimer, NULL); | ||||
| scroggo | b7e9aee | 2011-03-15 15:15:15 +0000 | [diff] [blame] | 51 | } |