[PATCH 6/7] mi: move switching screen on dequeue to separate helper function

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 1 03:41:29 PDT 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 mi/mieq.c |   47 ++++++++++++++++++++++++++++-------------------
 1 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/mi/mieq.c b/mi/mieq.c
index fc3738a..3a5aaf0 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -347,6 +347,30 @@ CopyGetMasterEvent(DeviceIntPtr sdev,
     return mdev;
 }
 
+static void
+switch_screen(DeviceIntPtr dev, InternalEvent *event, ScreenPtr screen)
+{
+    int x = 0, y = 0;
+
+    switch (event->any.type)
+    {
+        /* Catch events that include valuator information and check if they
+         * are changing the screen */
+        case ET_Motion:
+        case ET_KeyPress:
+        case ET_KeyRelease:
+        case ET_ButtonPress:
+        case ET_ButtonRelease:
+            DequeueScreen(dev) = screen;
+            x = event->device_event.root_x;
+            y = event->device_event.root_y;
+            NewCurrentScreen (dev, DequeueScreen(dev), x, y);
+            break;
+        default:
+            return;
+    }
+
+}
 
 /**
  * Post the given @event through the device hierarchy, as appropriate.
@@ -359,7 +383,6 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
                        ScreenPtr screen)
 {
     mieqHandler handler;
-    int x = 0, y = 0;
     DeviceIntPtr master;
     InternalEvent mevent; /* master event */
 
@@ -368,24 +391,10 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
     /* Custom event handler */
     handler = miEventQueue.handlers[event->any.type];
 
-    switch (event->any.type) {
-        /* Catch events that include valuator information and check if they
-         * are changing the screen */
-        case ET_Motion:
-        case ET_KeyPress:
-        case ET_KeyRelease:
-        case ET_ButtonPress:
-        case ET_ButtonRelease:
-            if (dev && screen && screen != DequeueScreen(dev) && !handler) {
-                DequeueScreen(dev) = screen;
-                x = event->device_event.root_x;
-                y = event->device_event.root_y;
-                NewCurrentScreen (dev, DequeueScreen(dev), x, y);
-            }
-            break;
-        default:
-            break;
-    }
+
+    if (dev && screen && screen != DequeueScreen(dev) && !handler)
+        switch_screen(dev, event, screen);
+
     master = CopyGetMasterEvent(dev, event, &mevent);
 
     if (master)
-- 
1.7.6



More information about the xorg-devel mailing list