blob: 5be93bc4795e6b7e72242ca0760d2f14562d114e [file] [log] [blame]
scroggob7e9aee2011-03-15 15:15:15 +00001#include "X11/Xlib.h"
2#include "X11/keysym.h"
3
4#include "SkApplication.h"
Scroggo9df214e2011-04-15 14:48:08 +00005#include "SkEvent.h"
scroggob7e9aee2011-03-15 15:15:15 +00006#include "SkWindow.h"
scroggob7e9aee2011-03-15 15:15:15 +00007#include "SkTypes.h"
Scroggo9df214e2011-04-15 14:48:08 +00008
Scroggo5a234242011-06-13 19:17:58 +00009#include <signal.h>
10#include <sys/time.h>
scroggob7e9aee2011-03-15 15:15:15 +000011
Scroggo9df214e2011-04-15 14:48:08 +000012SkOSWindow* gWindow;
scroggob7e9aee2011-03-15 15:15:15 +000013
scroggob7e9aee2011-03-15 15:15:15 +000014static void catch_alarm(int sig)
15{
scroggob7e9aee2011-03-15 15:15:15 +000016 SkEvent::ServiceQueueTimer();
17}
scroggob7e9aee2011-03-15 15:15:15 +000018
19int main(){
Scroggo5a234242011-06-13 19:17:58 +000020 signal(SIGALRM, catch_alarm);
scroggob7e9aee2011-03-15 15:15:15 +000021
Scroggo9df214e2011-04-15 14:48:08 +000022 gWindow = create_sk_window(NULL);
scroggob7e9aee2011-03-15 15:15:15 +000023 // Start normal Skia sequence
24 application_init();
25
Scroggo9df214e2011-04-15 14:48:08 +000026 gWindow->loop();
scroggob7e9aee2011-03-15 15:15:15 +000027
28 application_term();
29 return 0;
30}
31
32// SkEvent handlers
33
34void SkEvent::SignalNonEmptyQueue()
35{
Scroggo9df214e2011-04-15 14:48:08 +000036 if (gWindow)
37 gWindow->post_linuxevent();
38 else
39 while (SkEvent::ProcessEvent());
scroggob7e9aee2011-03-15 15:15:15 +000040}
41
42void SkEvent::SignalQueueTimer(SkMSec delay)
43{
scroggob7e9aee2011-03-15 15:15:15 +000044 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;
Scroggo5a234242011-06-13 19:17:58 +000049
50 setitimer(ITIMER_REAL, &newTimer, NULL);
scroggob7e9aee2011-03-15 15:15:15 +000051}