[mutter] backend-x11: Split out event translation to another method



commit c5d4f4a24574c4446949a6ff4b17b9251c122a7e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 24 12:06:32 2014 -0400

    backend-x11: Split out event translation to another method
    
    Keep the indentation from getting too hairy.

 src/backends/x11/meta-backend-x11.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 089b8c2..de5c418 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -68,6 +68,19 @@ handle_alarm_notify (MetaBackend *backend,
       meta_idle_monitor_xsync_handle_xevent (backend->device_monitors[i], (XSyncAlarmNotifyEvent*) event);
 }
 
+static void
+translate_device_event (MetaBackendX11 *x11,
+                        XIDeviceEvent  *device_event)
+{
+  MetaDisplay *display = meta_get_display ();
+  MetaCompositor *compositor = display->compositor;
+  ClutterStage *stage = CLUTTER_STAGE (compositor->stage);
+
+  device_event->event = clutter_x11_get_stage_window (stage);
+  device_event->event_x = device_event->root_x;
+  device_event->event_y = device_event->root_y;
+}
+
 /* Clutter makes the assumption that there is only one X window
  * per stage, which is a valid assumption to make for a generic
  * application toolkit. As such, it will ignore any events sent
@@ -87,7 +100,6 @@ maybe_spoof_event_as_stage_event (MetaBackendX11 *x11,
       event->xcookie.extension == priv->xinput_opcode)
     {
       XIEvent *input_event = (XIEvent *) event->xcookie.data;
-      XIDeviceEvent *device_event = ((XIDeviceEvent *) input_event);
 
       switch (input_event->evtype)
         {
@@ -96,15 +108,8 @@ maybe_spoof_event_as_stage_event (MetaBackendX11 *x11,
         case XI_ButtonRelease:
         case XI_KeyPress:
         case XI_KeyRelease:
-          {
-            MetaDisplay *display = meta_get_display ();
-            MetaCompositor *compositor = display->compositor;
-            ClutterStage *stage = CLUTTER_STAGE (compositor->stage);
-            device_event->event = clutter_x11_get_stage_window (stage);
-            device_event->event_x = device_event->root_x;
-            device_event->event_y = device_event->root_y;
-            break;
-          }
+          translate_device_event (x11, (XIDeviceEvent *) input_event);
+          break;
         default:
           break;
         }


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