evdev: don't even process events without a default stage
authorLionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
Fri, 17 Jun 2011 10:31:34 +0000 (11:31 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 10 Nov 2011 15:39:16 +0000 (15:39 +0000)
The evdev system is a bit different from other input systems in
Clutter because it's completly decorrelated from anything graphic.

In the case of embedded devices with no proper windowing system, you
might want to not implicitly create a default stage when you're
receiving the first input event.

This patch changes this behavior by not forwarding any event if you
don't have a default stage.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
https://bugzilla.gnome.org/show_bug.cgi?id=651718

clutter/evdev/clutter-device-manager-evdev.c

index 26079f1..80c0698 100644 (file)
@@ -44,6 +44,7 @@
 #include "clutter-input-device-evdev.h"
 #include "clutter-main.h"
 #include "clutter-private.h"
+#include "clutter-stage-manager.h"
 #include "clutter-xkb-utils.h"
 
 #include "clutter-device-manager-evdev.h"
@@ -268,9 +269,14 @@ clutter_event_dispatch (GSource     *g_source,
   ClutterEvent *event;
   gint len, i, dx = 0, dy = 0;
   uint32_t _time;
+  ClutterStageManager *stage_manager;
+  ClutterStage *default_stage;
 
   clutter_threads_enter ();
 
+  stage_manager = clutter_stage_manager_get_default ();
+  default_stage = clutter_stage_manager_get_default_stage (stage_manager);
+
   /* Don't queue more events if we haven't finished handling the previous batch
    */
   if (!clutter_events_pending ())
@@ -303,6 +309,10 @@ clutter_event_dispatch (GSource     *g_source,
          goto out;
        }
 
+       /* Drop events if we don't have any stage to forward them to */
+       if (!default_stage)
+         goto out;
+
        for (i = 0; i < len / sizeof (ev[0]); i++)
          {
            struct input_event *e = &ev[i];