2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2011-03-15 15:15:15 +00:00
|
|
|
#include "X11/Xlib.h"
|
|
|
|
#include "X11/keysym.h"
|
|
|
|
|
|
|
|
#include "SkApplication.h"
|
2011-04-15 14:48:08 +00:00
|
|
|
#include "SkEvent.h"
|
2011-03-15 15:15:15 +00:00
|
|
|
#include "SkWindow.h"
|
|
|
|
#include "SkTypes.h"
|
2011-04-15 14:48:08 +00:00
|
|
|
|
2011-06-13 19:17:58 +00:00
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/time.h>
|
2011-03-15 15:15:15 +00:00
|
|
|
|
2011-04-15 14:48:08 +00:00
|
|
|
SkOSWindow* gWindow;
|
2011-03-15 15:15:15 +00:00
|
|
|
|
|
|
|
static void catch_alarm(int sig)
|
|
|
|
{
|
|
|
|
SkEvent::ServiceQueueTimer();
|
|
|
|
}
|
|
|
|
|
2011-06-28 19:44:03 +00:00
|
|
|
int main(int argc, char** argv){
|
2011-06-13 19:17:58 +00:00
|
|
|
signal(SIGALRM, catch_alarm);
|
2011-03-15 15:15:15 +00:00
|
|
|
|
2011-06-28 19:44:03 +00:00
|
|
|
gWindow = create_sk_window(NULL, argc, argv);
|
2011-07-14 14:30:46 +00:00
|
|
|
|
|
|
|
// drain any events that occurred before gWindow was assigned.
|
|
|
|
while (SkEvent::ProcessEvent());
|
|
|
|
|
2011-03-15 15:15:15 +00:00
|
|
|
// Start normal Skia sequence
|
|
|
|
application_init();
|
|
|
|
|
2011-04-15 14:48:08 +00:00
|
|
|
gWindow->loop();
|
2011-03-15 15:15:15 +00:00
|
|
|
|
2011-06-21 16:01:26 +00:00
|
|
|
delete gWindow;
|
2011-03-15 15:15:15 +00:00
|
|
|
application_term();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SkEvent handlers
|
|
|
|
|
|
|
|
void SkEvent::SignalNonEmptyQueue()
|
|
|
|
{
|
2011-07-14 14:30:46 +00:00
|
|
|
if (gWindow) {
|
2011-04-15 14:48:08 +00:00
|
|
|
gWindow->post_linuxevent();
|
2011-07-14 14:30:46 +00:00
|
|
|
}
|
2011-03-15 15:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkEvent::SignalQueueTimer(SkMSec delay)
|
|
|
|
{
|
|
|
|
itimerval newTimer;
|
|
|
|
newTimer.it_interval.tv_sec = 0;
|
|
|
|
newTimer.it_interval.tv_usec = 0;
|
|
|
|
newTimer.it_value.tv_sec = 0;
|
|
|
|
newTimer.it_value.tv_usec = delay * 1000;
|
2011-06-13 19:17:58 +00:00
|
|
|
|
|
|
|
setitimer(ITIMER_REAL, &newTimer, NULL);
|
2011-03-15 15:15:15 +00:00
|
|
|
}
|