summaryrefslogtreecommitdiff
path: root/lib/engine.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/engine.cc')
-rw-r--r--lib/engine.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/engine.cc b/lib/engine.cc
index d065346..fac660e 100644
--- a/lib/engine.cc
+++ b/lib/engine.cc
@@ -3,6 +3,7 @@
#define _(x) x
int mogltk::engine::inited = 0;
+bool mogltk::engine::appactive = false, mogltk::engine::cursorvisible = false;
int mogltk::engine::setup() throw(GeneralException) {
if (inited) {
@@ -14,8 +15,6 @@ int mogltk::engine::setup() throw(GeneralException) {
}
atexit(SDL_Quit);
- SDL_ShowCursor(0);
-
inited = 1;
return 0;
@@ -92,15 +91,22 @@ SDL_RWops * mogltk::engine::RWFromHandle(Handle * h) throw (GeneralException) {
void mogltk::engine::pollevents() {
SDL_Event event;
+ bool hastoreturn = appactive;
while(true) {
+ if (hastoreturn)
+ if (!SDL_PollEvent(NULL))
+ return;
SDL_WaitEvent(&event);
switch(event.type) {
case SDL_VIDEOEXPOSE:
printm(M_INFO, "Needs to redraw\n");
- return;
+ hastoreturn = true;
+ break;
case SDL_MOUSEMOTION:
printm(M_INFO, "Mouse has gone over the screen - (%i, %i)\n", event.motion.x, event.motion.y);
+ if (cursorvisible)
+ hastoreturn = true;
break;
case SDL_QUIT:
printm(M_INFO, "Quit requested\n");
@@ -125,3 +131,19 @@ void mogltk::engine::pollevents() {
}
}
}
+
+void mogltk::engine::setappactive(bool p) {
+ appactive = p;
+}
+
+bool mogltk::engine::getappactive() {
+ return appactive;
+}
+
+void mogltk::engine::setcursorvisible(bool p) {
+ cursorvisible = p;
+}
+
+bool mogltk::engine::getcursorvisible() {
+ return cursorvisible;
+}