[Xquartz-changes] xserver: Branch 'master' - 11 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Thu Apr 19 16:09:09 PDT 2012


Rebased ref, commits from common ancestor:
commit 832d322d9868a740e0184677338d35da658226de
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Apr 18 17:50:55 2012 -0700

    XQuartz: Separate out tablet and mouse event delivery into separate functions
    
    This should have no immediate impact aside from fake mouse buttons no longer
    working with tablets (where they aren't needed or desired anyways).  This
    prepares us for future changes.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index a203f78..f700c67 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -215,9 +215,7 @@ message_kit_thread(SEL selector, NSObject *arg)
     if (state) {
         if (bgMouseLocationUpdated) {
             DarwinSendPointerEvents(darwinPointer, MotionNotify, 0,
-                                    bgMouseLocation.x, bgMouseLocation.y, 0.0,
-                                    0.0,
-                                    0.0);
+                                    bgMouseLocation.x, bgMouseLocation.y);
             bgMouseLocationUpdated = FALSE;
         }
         DarwinSendDDXEvent(kXquartzActivate, 0);
@@ -1549,9 +1547,9 @@ handle_mouse:
             if ([e isEnteringProximity])
                 needsProximityIn = YES;
             else
-                DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
-                                          location.x, location.y, pressure,
-                                          tilt.x, tilt.y);
+                DarwinSendTabletEvents(darwinTabletCurrent, ProximityOut, 0,
+                                       location.x, location.y, pressure,
+                                       tilt.x, tilt.y);
             return;
         }
 
@@ -1563,9 +1561,9 @@ handle_mouse:
             pDev = darwinTabletCurrent;
 
             if (needsProximityIn) {
-                DarwinSendProximityEvents(darwinTabletCurrent, ProximityIn,
-                                          location.x, location.y, pressure,
-                                          tilt.x, tilt.y);
+                DarwinSendTabletEvents(darwinTabletCurrent, ProximityIn, 0,
+                                       location.x, location.y, pressure,
+                                       tilt.x, tilt.y);
 
                 needsProximityIn = NO;
             }
@@ -1596,14 +1594,20 @@ handle_mouse:
 
         if (bgMouseLocationUpdated) {
             if (!(ev_type == MotionNotify && ev_button == 0)) {
-                DarwinSendPointerEvents(pDev, MotionNotify, 0, location.x,
-                                        location.y, pressure, tilt.x, tilt.y);
+                DarwinSendPointerEvents(darwinPointer, MotionNotify, 0,
+                                        location.x, location.y);
             }
             bgMouseLocationUpdated = FALSE;
         }
 
-        DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x,
-                                location.y, pressure, tilt.x, tilt.y);
+        if (pDev == darwinPointer) {
+            DarwinSendPointerEvents(pDev, ev_type, ev_button,
+                                    location.x, location.y);
+        } else {
+            DarwinSendTabletEvents(pDev, ev_type, ev_button,
+                                   location.x, location.y, pressure,
+                                   tilt.x, tilt.y);
+        }
 
         break;
 
@@ -1627,9 +1631,9 @@ handle_mouse:
         if ([e isEnteringProximity])
             needsProximityIn = YES;
         else
-            DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
-                                      location.x, location.y, pressure,
-                                      tilt.x, tilt.y);
+            DarwinSendTabletEvents(darwinTabletCurrent, ProximityOut, 0,
+                                   location.x, location.y, pressure,
+                                   tilt.x, tilt.y);
         break;
 
     case NSScrollWheel:
@@ -1643,8 +1647,7 @@ handle_mouse:
         if (!XQuartzServerVisible && noTestExtensions) {
             bgMouseLocationUpdated = FALSE;
             DarwinSendPointerEvents(darwinPointer, MotionNotify, 0,
-                                    location.x, location.y, pressure, 
-                                    tilt.x, tilt.y);
+                                    location.x, location.y);
         }
 #endif
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index c62dd44..9fc23a3 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -44,19 +44,20 @@
 #include <dix-config.h>
 #endif
 
-#include   <X11/X.h>
-#include   <X11/Xmd.h>
-#include   <X11/Xproto.h>
-#include   "misc.h"
-#include   "windowstr.h"
-#include   "pixmapstr.h"
-#include   "inputstr.h"
-#include   "inpututils.h"
-#include   "eventstr.h"
-#include   "mi.h"
-#include   "scrnintstr.h"
-#include   "mipointer.h"
-#include   "os.h"
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "inputstr.h"
+#include "inpututils.h"
+#include "eventstr.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+#include "os.h"
+#include "exglobals.h"
 
 #include "darwin.h"
 #include "quartz.h"
@@ -442,56 +443,6 @@ DarwinPokeEQ(void)
     write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte));
 }
 
-/* Convert from Appkit pointer input values to X input values:
- * Note: pointer_x and pointer_y are relative to the upper-left of primary
- *       display.
- */
-static void
-DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask,
-                       ScreenPtr screen,
-                       double pointer_x, double pointer_y,
-                       double pressure, double tilt_x,
-                       double tilt_y)
-{
-
-    valuator_mask_zero(pmask);
-
-    /* Fix offset between darwin and X screens */
-    pointer_x -= darwinMainScreenX + screen->x;
-    pointer_y -= darwinMainScreenY + screen->y;
-
-    if (pointer_x < 0.0)
-        pointer_x = 0.0;
-
-    if (pointer_y < 0.0)
-        pointer_y = 0.0;
-
-    if (pDev == darwinPointer) {
-        valuator_mask_set_double(pmask, 0, pointer_x);
-        valuator_mask_set_double(pmask, 1, pointer_y);
-    }
-    else {
-        valuator_mask_set_double(pmask, 0, XQUARTZ_VALUATOR_LIMIT *
-                                 (pointer_x /
-                                  (double)screenInfo.screens[0]->width));
-        valuator_mask_set_double(pmask, 1, XQUARTZ_VALUATOR_LIMIT *
-                                 (pointer_y /
-                                  (double)screenInfo.screens[0]->height));
-        valuator_mask_set_double(pmask, 2, XQUARTZ_VALUATOR_LIMIT * pressure);
-        valuator_mask_set_double(pmask, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x);
-        valuator_mask_set_double(pmask, 4, XQUARTZ_VALUATOR_LIMIT * tilt_y);
-        DEBUG_LOG("Pointer (%lf, %lf), Valuators: {%lf,%lf,%lf,%lf,%lf}\n",
-                  pointer_x, pointer_y,
-                  valuator_mask_get_double(pmask,
-                                           0),
-                  valuator_mask_get_double(pmask, 1),
-                  valuator_mask_get_double(pmask,
-                                           2),
-                  valuator_mask_get_double(pmask, 3),
-                  valuator_mask_get_double(pmask, 4));
-    }
-}
-
 void
 DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
 {
@@ -521,27 +472,78 @@ DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
 }
 
 void
+DarwinSendTabletEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
+                       double pointer_x, double pointer_y,
+                       double pressure, double tilt_x,
+                       double tilt_y)
+{
+    ScreenPtr screen;
+    ValuatorMask valuators;
+
+    if (!darwinEvents) {
+        DEBUG_LOG("%s called before darwinEvents was initialized\n",
+                  __FUNCTION__);
+        return;
+    }
+
+    screen = miPointerGetScreen(pDev);
+    if (!screen) {
+        DEBUG_LOG("%s called before screen was initialized\n",
+                  __FUNCTION__);
+        return;
+    }
+
+    /* Fix offset between darwin and X screens */
+    pointer_x -= darwinMainScreenX + screen->x;
+    pointer_y -= darwinMainScreenY + screen->y;
+
+    if (pointer_x < 0.0)
+        pointer_x = 0.0;
+
+    if (pointer_y < 0.0)
+        pointer_y = 0.0;
+    
+    /* Adjust our pointer location to the [0,1] range */
+    pointer_x = pointer_x / (double)screenInfo.screens[0]->width;
+    pointer_y = pointer_y / (double)screenInfo.screens[0]->height;
+
+    valuator_mask_zero(&valuators);
+    valuator_mask_set_double(&valuators, 0, XQUARTZ_VALUATOR_LIMIT * pointer_x);
+    valuator_mask_set_double(&valuators, 1, XQUARTZ_VALUATOR_LIMIT * pointer_y);
+    valuator_mask_set_double(&valuators, 2, XQUARTZ_VALUATOR_LIMIT * pressure);
+    valuator_mask_set_double(&valuators, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x);
+    valuator_mask_set_double(&valuators, 4, XQUARTZ_VALUATOR_LIMIT * tilt_y);
+
+    darwinEvents_lock();
+    {
+        if (ev_type == ProximityIn || ev_type == ProximityOut) {
+            QueueProximityEvents(pDev, ev_type, &valuators);
+        } else {
+            QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE,
+                               &valuators);
+        }
+        DarwinPokeEQ();
+    } darwinEvents_unlock();
+}
+
+void
 DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
-                        double pointer_x, double pointer_y,
-                        double pressure, double tilt_x,
-                        double tilt_y)
+                        double pointer_x, double pointer_y)
 {
     static int darwinFakeMouseButtonDown = 0;
     ScreenPtr screen;
     ValuatorMask valuators;
 
-    //DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
-
     if (!darwinEvents) {
-        DEBUG_LOG(
-            "DarwinSendPointerEvents called before darwinEvents was initialized\n");
+        DEBUG_LOG("%s called before darwinEvents was initialized\n",
+                  __FUNCTION__);
         return;
     }
 
     screen = miPointerGetScreen(pDev);
     if (!screen) {
-        DEBUG_LOG(
-            "DarwinSendPointerEvents called before screen was initialized\n");
+        DEBUG_LOG("%s called before screen was initialized\n",
+                  __FUNCTION__);
         return;
     }
 
@@ -550,9 +552,8 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
         if (darwinFakeMouseButtonDown != 0) {
             /* We're currently "down" with another button, so release it first */
             DarwinSendPointerEvents(pDev, ButtonRelease,
-                                    darwinFakeMouseButtonDown, pointer_x,
-                                    pointer_y, pressure, tilt_x,
-                                    tilt_y);
+                                    darwinFakeMouseButtonDown,
+                                    pointer_x, pointer_y);
             darwinFakeMouseButtonDown = 0;
         }
         if (darwin_all_modifier_flags & darwinFakeMouse2Mask) {
@@ -586,9 +587,20 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
         darwinFakeMouseButtonDown = 0;
     }
 
-    DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y,
-                           pressure, tilt_x,
-                           tilt_y);
+    /* Fix offset between darwin and X screens */
+    pointer_x -= darwinMainScreenX + screen->x;
+    pointer_y -= darwinMainScreenY + screen->y;
+
+    if (pointer_x < 0.0)
+        pointer_x = 0.0;
+
+    if (pointer_y < 0.0)
+        pointer_y = 0.0;
+
+    valuator_mask_zero(&valuators);
+    valuator_mask_set_double(&valuators, 0, pointer_x);
+    valuator_mask_set_double(&valuators, 1, pointer_y);
+
     darwinEvents_lock();
     {
         QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE,
@@ -615,42 +627,6 @@ DarwinSendKeyboardEvents(int ev_type, int keycode)
     } darwinEvents_unlock();
 }
 
-void
-DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
-                          double pointer_y,
-                          double pressure, double tilt_x,
-                          double tilt_y)
-{
-    ScreenPtr screen;
-    ValuatorMask valuators;
-
-    DEBUG_LOG("DarwinSendProximityEvents: %d l:%f,%f p:%f t:%f,%f\n", ev_type,
-              pointer_x, pointer_y, pressure, tilt_x,
-              tilt_y);
-
-    if (!darwinEvents) {
-        DEBUG_LOG(
-            "DarwinSendProximityEvents called before darwinEvents was initialized\n");
-        return;
-    }
-
-    screen = miPointerGetScreen(pDev);
-    if (!screen) {
-        DEBUG_LOG(
-            "DarwinSendPointerEvents called before screen was initialized\n");
-        return;
-    }
-
-    DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y,
-                           pressure, tilt_x,
-                           tilt_y);
-    darwinEvents_lock();
-    {
-        QueueProximityEvents(pDev, ev_type, &valuators);
-        DarwinPokeEQ();
-    } darwinEvents_unlock();
-}
-
 /* Send the appropriate number of button clicks to emulate scroll wheel */
 void
 DarwinSendScrollEvents(double scroll_x, double scroll_y) {
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 61ace6e..812a5dc 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -44,14 +44,12 @@ DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
 void
 DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev);
 void
-DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
-                        double pointer_x, double pointer_y, double pressure,
-                        double tilt_x,
-                        double tilt_y);
+DarwinSendTabletEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
+                       double pointer_x, double pointer_y, double pressure,
+                       double tilt_x, double tilt_y);
 void
-DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
-                          double pointer_y, double pressure, double tilt_x,
-                          double tilt_y);
+DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
+                        double pointer_x, double pointer_y);
 void
 DarwinSendKeyboardEvents(int ev_type, int keycode);
 void
commit 0bd3e972763cce2548c8dc7d6b679a03bb40a60a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu Apr 19 16:06:45 2012 -0700

    XQuartz: Correct calculation of the size of our file descriptor array in console_redirect
    
    Reported-by: Joe Rohde <joer at valvesoftware.com>
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index 7b92eca..1e0e56b 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -336,7 +336,7 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
                   {
                       /* Reallocate if we need more space */
                       if (fd >= n_redirect_fds) {
-                          size_t new_n = 1 << (ffs(fd) + 1);
+                          size_t new_n = 1 << (fls(fd) + 1);
                           asl_redirect *new_array =
                               realloc(redirect_fds, new_n *
                                       sizeof(*redirect_fds));
commit c40af64fb405db73de375bf2a349ff0f665b26d3
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Apr 18 01:01:44 2012 -0700

    XQuartz: Fix a deadlock in pre-dispatch code
    
    The fact that this has been in place so long makes me really wonder if
    anybody cares about this running in Tiger or Leopard.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 4c7aac4..01f1def 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -212,7 +212,7 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
 #else
     pthread_rwlock_wrlock(&window_hash_rwlock);
     x_hash_table_insert(window_hash, pFrame->wid, pFrame);
-    pthread_rwlock_wrlock(&window_hash_rwlock);
+    pthread_rwlock_unlock(&window_hash_rwlock);
 #endif
 
     xprSetNativeProperty(pFrame);
commit 57ff522b0dbdbc751cb847dabfd28ab6aeef03cf
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Apr 7 15:26:53 2012 -0700

    test: Fix make dist
    
    It seems like make dist should be doing te right thing without this commit,
    but it's not in some cases.  Don't ask me to explain why.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/test/Makefile.am b/test/Makefile.am
index eb61470..32be00d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -53,8 +53,6 @@ libxservertest_la_LIBADD += \
             $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la \
             @XORG_LIBS@
 
-EXTRA_DIST = ddxstubs.c
-
 else
 nodist_libxservertest_la_SOURCES = \
             ddxstubs.c \
@@ -110,3 +108,6 @@ endif
 
 libxservertest_la_DEPENDENCIES = $(libxservertest_la_LIBADD)
 endif
+
+EXTRA_DIST = ddxstubs.c
+
commit 169de9e3756cbf861604231b5d97759e784847f6
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Tue Apr 3 17:31:01 2012 -0700

    Use touch state when querying pointer through core protocol
    
    QueryPointer is part of the core protocol. As such, it knows nothing
    about touch devices. Touches are converted to button 1 press, pointer
    motion, and button 1 release for core clients, so we should ensure the
    pointer state mask has button 1 set when XQueryPointer is used.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 4470947..b9f9cfa 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -5098,8 +5098,7 @@ ProcQueryPointer(ClientPtr client)
     memset(&rep, 0, sizeof(xQueryPointerReply));
     rep.type = X_Reply;
     rep.sequenceNumber = client->sequence;
-    rep.mask = mouse->button ? (mouse->button->state) : 0;
-    rep.mask |= XkbStateFieldFromRec(&keyboard->key->xkbInfo->state);
+    rep.mask = event_get_corestate(mouse, keyboard);
     rep.length = 0;
     rep.root = (GetCurrentRootWindow(mouse))->drawable.id;
     rep.rootX = pSprite->hot.x;
commit 9edb5f3205e444be7b45a74461705431c0848cb4
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Tue Apr 10 17:12:42 2012 -0700

    Ensure sequential touches are pointer emulated sequentially
    
    Issue:
    * Two sequential touches (i.e. down, up, down, up)
    * Both are grabbed by a touch grab
    * Both have a second listener in the form of a pointer grab or selection
    * The second and first touches are rejected in that order
    
    The first touch must be pointer emulated before the second touch, so the
    second touch must be paused until the first touch is rejected or
    accepted and all events are delivered to pointer clients.
    
    This change ensures all pointer emulated events are emitted
    sequentially. It necessarily imposes a delay on further touch events
    when pointer grabs and selections are used, but there is no way around
    it.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index a843e03..c05c226 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1111,6 +1111,48 @@ EmitTouchEnd(DeviceIntPtr dev, TouchPointInfoPtr ti, int flags, XID resource)
 }
 
 /**
+ * Find the oldest touch that still has a pointer emulation client.
+ *
+ * Pointer emulation can only be performed for the oldest touch. Otherwise, the
+ * order of events seen by the client will be wrong. This function helps us find
+ * the next touch to be emulated.
+ *
+ * @param dev The device to find touches for.
+ */
+static TouchPointInfoPtr
+FindOldestPointerEmulatedTouch(DeviceIntPtr dev)
+{
+    TouchPointInfoPtr oldest = NULL;
+    int i;
+
+    for (i = 0; i < dev->touch->num_touches; i++) {
+        TouchPointInfoPtr ti = dev->touch->touches + i;
+        int j;
+
+        if (!ti->active || !ti->emulate_pointer)
+            continue;
+
+        for (j = 0; j < ti->num_listeners; j++) {
+            if (ti->listeners[j].type == LISTENER_POINTER_GRAB ||
+                ti->listeners[j].type == LISTENER_POINTER_REGULAR)
+                break;
+        }
+        if (j == ti->num_listeners)
+            continue;
+
+        if (!oldest) {
+            oldest = ti;
+            continue;
+        }
+
+        if (oldest->client_id - ti->client_id < UINT_MAX / 2)
+            oldest = ti;
+    }
+
+    return oldest;
+}
+
+/**
  * If the current owner has rejected the event, deliver the
  * TouchOwnership/TouchBegin to the next item in the sprite stack.
  */
@@ -1123,8 +1165,16 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
         ti->listeners[0].state == LISTENER_EARLY_ACCEPT)
         DeliverTouchEvents(dev, ti, (InternalEvent *) ev,
                            ti->listeners[0].listener);
-    else if (ti->listeners[0].state == LISTENER_AWAITING_BEGIN)
+    else if (ti->listeners[0].state == LISTENER_AWAITING_BEGIN) {
+        /* We can't punt to a pointer listener unless all older pointer
+         * emulated touches have been seen already. */
+        if ((ti->listeners[0].type == LISTENER_POINTER_GRAB ||
+             ti->listeners[0].type == LISTENER_POINTER_REGULAR) &&
+            ti != FindOldestPointerEmulatedTouch(dev))
+            return;
+
         TouchEventHistoryReplay(ti, dev, ti->listeners[0].listener);
+    }
 
     /* If we've just removed the last grab and the touch has physically
      * ended, send a TouchEnd event too and finalise the touch. */
@@ -1139,6 +1189,25 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
 }
 
 /**
+ * Check the oldest touch to see if it needs to be replayed to its pointer
+ * owner.
+ *
+ * Touch event propagation is paused if it hits a pointer listener while an
+ * older touch with a pointer listener is waiting on accept or reject. This
+ * function will restart propagation of a paused touch if needed.
+ *
+ * @param dev The device to check touches for.
+ */
+static void
+CheckOldestTouch(DeviceIntPtr dev)
+{
+    TouchPointInfoPtr oldest = FindOldestPointerEmulatedTouch(dev);
+
+    if (oldest && oldest->listeners[0].state == LISTENER_AWAITING_BEGIN)
+        TouchPuntToNextOwner(dev, oldest, NULL);
+}
+
+/**
  * Process a touch rejection.
  *
  * @param sourcedev The source device of the touch sequence.
@@ -1169,6 +1238,7 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource,
      * finish, then we can just kill it now. */
     if (ti->num_listeners == 1 && ti->pending_finish) {
         TouchEndTouch(sourcedev, ti);
+        CheckOldestTouch(sourcedev);
         return;
     }
 
@@ -1184,6 +1254,8 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource,
      * the TouchOwnership or TouchBegin event to the new owner. */
     if (ev && ti->num_listeners > 0 && was_owner)
         TouchPuntToNextOwner(sourcedev, ti, ev);
+
+    CheckOldestTouch(sourcedev);
 }
 
 /**
@@ -1391,6 +1463,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
                 !dev->button->buttonsDown &&
                 dev->deviceGrab.fromPassiveGrab && GrabIsPointerGrab(grab)) {
                 (*dev->deviceGrab.DeactivateGrab) (dev);
+                CheckOldestTouch(dev);
                 return Success;
             }
         }
commit c341700139e3dbddfc48ba08262ab4d65c14f18c
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Tue Apr 10 17:12:41 2012 -0700

    Update event type when delivering end event to a pointer listener
    
    Just like when we deliver to a touch listener, we must convert a touch
    end event to an update event for further clients. This also ensures that
    the touch record is not deleted at the end of ProcessTouchEvent().
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 3117123..a843e03 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1757,6 +1757,13 @@ DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
         listener->type == LISTENER_POINTER_GRAB) {
         rc = DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win,
                                        grab, xi2mask);
+
+        if (ti->num_listeners > 1) {
+            ev->any.type = ET_TouchUpdate;
+            ev->device_event.flags |= TOUCH_PENDING_END;
+            ti->pending_finish = TRUE;
+        }
+
         goto out;
     }
 
commit f9fe7eadfb816cd230d3f6ab194ae259ec80ced6
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Tue Apr 10 17:12:40 2012 -0700

    Don't update listener after deactivating implicit pointer grab
    
    After the pointer grab is deactivated, the touch listener record is
    updated at the end of DeliverTouchEmulatedEvent. However, the touch
    record is ended when the grab is deactivated, so the update to the
    listener record is in an array of memory that has been freed.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index ff22240..3117123 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1389,8 +1389,10 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
 
             if (ev->any.type == ET_TouchEnd &&
                 !dev->button->buttonsDown &&
-                dev->deviceGrab.fromPassiveGrab && GrabIsPointerGrab(grab))
+                dev->deviceGrab.fromPassiveGrab && GrabIsPointerGrab(grab)) {
                 (*dev->deviceGrab.DeactivateGrab) (dev);
+                return Success;
+            }
         }
     }
     else {
commit 27289211180f20fa9d424c4762e158a22e661e6f
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 12 15:54:00 2012 +1000

    xfree86: after VT switching back, only enable previously enabled devices
    
    If a device was enabled before the VT switch, re-enabled it. Otherwise leave
    it as is, there was probably a reason why it was disabled.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 058057e..5896f22 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -449,6 +449,8 @@ xf86VTSwitch(void)
             xf86DisableInputHandler(ih);
         for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
             if (pInfo->dev) {
+                if (!pInfo->dev->enabled)
+                    pInfo->flags |= XI86_DEVICE_DISABLED;
                 xf86ReleaseKeys(pInfo->dev);
                 ProcessInputEvents();
                 DisableDevice(pInfo->dev, TRUE);
@@ -482,8 +484,9 @@ xf86VTSwitch(void)
 
             pInfo = xf86InputDevs;
             while (pInfo) {
-                if (pInfo->dev)
+                if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
                     EnableDevice(pInfo->dev, TRUE);
+                pInfo->flags &= ~XI86_DEVICE_DISABLED;
                 pInfo = pInfo->next;
             }
             for (ih = InputHandlers; ih; ih = ih->next)
@@ -537,8 +540,9 @@ xf86VTSwitch(void)
 
         pInfo = xf86InputDevs;
         while (pInfo) {
-            if (pInfo->dev)
+            if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
                 EnableDevice(pInfo->dev, TRUE);
+            pInfo->flags &= ~XI86_DEVICE_DISABLED;
             pInfo = pInfo->next;
         }
 
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 3731a34..1d4363a 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -61,6 +61,9 @@
 #define XI86_ALWAYS_CORE	0x04    /* device always controls the pointer */
 /* the device sends Xinput and core pointer events */
 #define XI86_SEND_CORE_EVENTS	XI86_ALWAYS_CORE
+/* 0x08 is reserved for legacy XI86_SEND_DRAG_EVENTS, do not use for now */
+/* server-internal only */
+#define XI86_DEVICE_DISABLED    0x10    /* device was disabled before vt switch */
 
 /* This holds the input driver entry and module information. */
 typedef struct _InputDriverRec {
commit c7812fe14e83964718eabee0fa7e3428da67c37b
Author: Daniel Kurtz <djkurtz at chromium.org>
Date:   Thu Apr 12 10:11:10 2012 +1000

    dix: don't BUG_WARN for button events from button-only device
    
    Events from button-only devices still need coordinates, and they get them
    from scale_to_desktop().  Therefore, a dev without valuators is not a bug.
    However, a dev with valuators, but less than two of them still is a bug.
    
    This was noticed when unplugging a "Creative Technology SB Arena Headset",
    which has some BTNs and some KEYs, but no REL or ABS valuators.
    It emits [BTN_3] = 0 on unplug, which would trigger the BUG_WARN.
    
    Signed-off-by: Daniel Kurtz <djkurtz at chromium.org>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index 3093786..23bbe06 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -848,7 +848,7 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
     ScreenPtr scr = miPointerGetScreen(dev);
     double x, y;
 
-    BUG_WARN(!dev->valuator || dev->valuator->numAxes < 2);
+    BUG_WARN(dev->valuator && dev->valuator->numAxes < 2);
     if (!dev->valuator || dev->valuator->numAxes < 2) {
         /* if we have no axes, last.valuators must be in screen coords
          * anyway */
commit 8a40c7aa8a029122b4a2d0ebefbbbb9378861ae6
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 11 09:43:23 2012 +1000

    Xi: fix XITouchClass sourceid assignment
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 749bc24..15c8b2a 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -430,7 +430,7 @@ ListTouchInfo(DeviceIntPtr dev, xXITouchInfo * touch)
 {
     touch->type = XITouchClass;
     touch->length = sizeof(xXITouchInfo) >> 2;
-    touch->sourceid = touch->sourceid;
+    touch->sourceid = dev->touch->sourceid;
     touch->mode = dev->touch->mode;
     touch->num_touches = dev->touch->num_touches;
 


More information about the Xquartz-changes mailing list