[cogl] sdl: Wakeup the event blocking immediately if necessary



commit 9e34a1e8ce97b67ebb2889c622f2c9f1076b087d
Author: Neil Roberts <neil linux intel com>
Date:   Thu Jan 31 16:53:18 2013 +0000

    sdl: Wakeup the event blocking immediately if necessary
    
    It is expected that cogl_sdl_idle() will be called from the
    application immediately before blocking in SDL_WaitEvent. However,
    dispatching the onscreen events may cause more events to be queued. If
    that happens we need to make sure the blocking returns immediately.
    This patch makes it post the dummy event that the application chose in
    order to make that happen.
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl/cogl-sdl.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/cogl/cogl-sdl.c b/cogl/cogl-sdl.c
index b49890f..8e04f16 100644
--- a/cogl/cogl-sdl.c
+++ b/cogl/cogl-sdl.c
@@ -3,7 +3,7 @@
  *
  * An object oriented GL/GLES Abstraction/Utility Layer
  *
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012, 2013 Intel Corporation.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -80,8 +80,27 @@ cogl_sdl_handle_event (CoglContext *context, SDL_Event *event)
     winsys->poll_dispatch (context, NULL, 0);
 }
 
+static void
+_cogl_sdl_push_wakeup_event (CoglContext *context)
+{
+  SDL_Event wakeup_event;
+
+  wakeup_event.type = context->display->renderer->sdl_event_type;
+
+  SDL_PushEvent (&wakeup_event);
+}
+
 void
 cogl_sdl_idle (CoglContext *context)
 {
   _cogl_dispatch_onscreen_events (context);
+
+  /* It is expected that this will be called from the application
+   * immediately before blocking in SDL_WaitEvent. However,
+   * dispatching the onscreen events may cause more events to be
+   * queued. If that happens we need to make sure the blocking returns
+   * immediately. We'll post our dummy event to make sure that
+   * happens */
+  if (!COGL_TAILQ_EMPTY (&context->onscreen_events_queue))
+    _cogl_sdl_push_wakeup_event (context);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]