xserver: Branch 'mpx' - 6 commits

Peter Hutterer whot at kemper.freedesktop.org
Tue Oct 2 18:20:53 PDT 2007


 Xi/exevents.c                       |   56 +----------------------------------
 dix/grabs.c                         |    2 -
 hw/xfree86/common/xf86Cursor.c      |   53 +++++++++++++++++++++++++++++++--
 hw/xfree86/common/xf86DGA.c         |   31 +++++++++----------
 hw/xfree86/common/xf86Xinput.c      |   57 ++++++++++++++++--------------------
 hw/xfree86/dixmods/extmod/dgaproc.h |    7 ++--
 mi/mieq.c                           |   10 +++---
 7 files changed, 104 insertions(+), 112 deletions(-)

New commits:
diff-tree f965a5f3454a95ddffb2faf9b291feff46305adf (from 2b075e97ec913ebe19290181e36bb169410b820b)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Oct 2 16:20:27 2007 +0930

    dix: Ignore devices when deleting passive core grabs.

diff --git a/dix/grabs.c b/dix/grabs.c
index f1d0086..d51511c 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -406,7 +406,7 @@ DeletePassiveGrabFromList(GrabPtr pMinue
 	 grab = grab->next)
     {
 	if ((CLIENT_BITS(grab->resource) != CLIENT_BITS(pMinuendGrab->resource)) ||
-	    !GrabMatchesSecond(grab, pMinuendGrab, FALSE))
+	    !GrabMatchesSecond(grab, pMinuendGrab, (grab->coreGrab)))
 	    continue;
 	if (GrabSupersedesSecond(pMinuendGrab, grab))
 	{
diff-tree 2b075e97ec913ebe19290181e36bb169410b820b (from 45ec6cd1fb242363c91ad8af1fd4a27a7f02621a)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Oct 2 13:28:40 2007 +0930

    mi: switch core keyboard on XI events, not only on core events.
    
    We only get core events through the EQ in exceptional cases, so make sure we
    actually swap the core keymap for XI events as well. Gives us back the ability
    to have multiple keyboard layouts simultaneously.

diff --git a/mi/mieq.c b/mi/mieq.c
index 9e0f5be..f5e119e 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -267,10 +267,12 @@ mieqProcessInputEvents(void)
                 return;
             }
 
-            /* If this is a core event, make sure our keymap, et al, is
-             * changed to suit. */
-            if (e->events->event[0].u.u.type == KeyPress ||
-                e->events->event[0].u.u.type == KeyRelease) {
+            /* Make sure our keymap, et al, is changed to suit. */
+            if ((e->events->event[0].u.u.type == DeviceKeyPress ||
+                e->events->event[0].u.u.type == DeviceKeyRelease ||
+                e->events->event[0].u.u.type == KeyPress ||
+                e->events->event[0].u.u.type == KeyRelease) && 
+                    e->pDev->coreEvents) {
                 SwitchCoreKeyboard(e->pDev);
             }
 
diff-tree 45ec6cd1fb242363c91ad8af1fd4a27a7f02621a (from 122ae65ed90195c584a770027b4d14ef65f72492)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Oct 2 13:19:07 2007 +0930

    xfree86: fix DGA to use the correct devices.
    
    DGAStealXXXEvent modified to take in device argument.
    
    The evdev driver only sends one valuator when only one axis changed. We need
    to check for DGA either way (xf86PostMotionEventP), otherwise we lose purely
    horizontal/vertical movements.
    
    Note that DGA does not do XI events.

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index ea8baaf..553679d 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -916,7 +916,7 @@ DGAVTSwitch(void)
 }
 
 Bool
-DGAStealKeyEvent(int index, int key_code, int is_down)
+DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
 {
    DGAScreenPtr pScreenPriv;
    dgaEvent    de;
@@ -932,7 +932,7 @@ DGAStealKeyEvent(int index, int key_code
     de.u.u.type = *XDGAEventBase + (is_down ? KeyPress : KeyRelease);
     de.u.u.detail = key_code;
     de.u.event.time = GetTimeInMillis();
-    mieqEnqueue (inputInfo.keyboard, (xEvent *) &de);
+    mieqEnqueue (dev, (xEvent *) &de);
 
    return TRUE;
 }  
@@ -940,7 +940,7 @@ DGAStealKeyEvent(int index, int key_code
 static int  DGAMouseX, DGAMouseY;
 
 Bool
-DGAStealMotionEvent(int index, int dx, int dy)
+DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
 {
    DGAScreenPtr pScreenPriv;
     dgaEvent    de;
@@ -970,12 +970,12 @@ DGAStealMotionEvent(int index, int dx, i
     de.u.event.dy = dy;
     de.u.event.pad1 = DGAMouseX;
     de.u.event.pad2 = DGAMouseY;
-    mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
+    mieqEnqueue (dev, (xEvent *) &de);
     return TRUE;
 }
 
 Bool
-DGAStealButtonEvent(int index, int button, int is_down)
+DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
 {
     DGAScreenPtr pScreenPriv;
     dgaEvent de;
@@ -995,7 +995,7 @@ DGAStealButtonEvent(int index, int butto
     de.u.event.dy = 0;
     de.u.event.pad1 = DGAMouseX;
     de.u.event.pad2 = DGAMouseY;
-    mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
+    mieqEnqueue (dev, (xEvent *) &de);
 
     return TRUE;
 }
@@ -1038,6 +1038,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScre
     xEvent	    core;
     KeyClassPtr	    keyc = keybd->key;
     DGAScreenPtr    pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+    DeviceIntPtr    pointer = GetPairedPointer(keybd);
     
     coreEquiv = de->u.u.type - *XDGAEventBase;
 
@@ -1047,7 +1048,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScre
     de->u.event.dx = 0;
     de->u.event.dy = 0;
     de->u.event.screen = pScreen->myNum;
-    de->u.event.state = keyc->state | (inputInfo.pointer)->button->state;
+    de->u.event.state = keyc->state | pointer->button->state;
 
     /*
      * Keep the core state in sync by duplicating what
@@ -1060,7 +1061,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScre
     switch (coreEquiv)
     {
     case KeyPress:
-	inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+        pointer->valuator->motionHintWindow = NullWindow;
 	*kptr |= bit;
 	keyc->prev_state = keyc->state;
 #ifdef XKB
@@ -1081,7 +1082,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScre
 	}
 	break;
     case KeyRelease:
-	inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+	pointer->valuator->motionHintWindow = NullWindow;
 	*kptr &= ~bit;
 	keyc->prev_state = keyc->state;
 #ifdef XKB
@@ -1197,8 +1198,6 @@ DGAProcessPointerEvent (ScreenPtr pScree
 	/* If the pointer is actively grabbed, deliver a grabbed core event */
 	if (mouse->deviceGrab.grab && !mouse->deviceGrab.fromPassiveGrab)
 	{
-            /* I've got no clue if that is correct but only working on core
-             * grabs seems the right thing here. (whot) */
 	    core.u.u.type		    = coreEquiv;
 	    core.u.u.detail		    = de->u.u.detail;
 	    core.u.keyButtonPointer.time    = de->u.event.time;
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index a458c11..c6df92c 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -539,7 +539,7 @@ xf86PostMotionEventP(DeviceIntPtr	device
                     int			*valuators)
 {
     int i = 0, nevents = 0;
-    int dx, dy;
+    int dx = 0, dy = 0;
     Bool drag = xf86SendDragEvents(device);
     xEvent *xE = NULL;
     int index;
@@ -551,18 +551,25 @@ xf86PostMotionEventP(DeviceIntPtr	device
         flags = POINTER_RELATIVE | POINTER_ACCELERATE;
 
 #if XFreeXDGA
-    if (first_valuator == 0 && num_valuators >= 2) {
-        if (miPointerGetScreen(inputInfo.pointer)) {
-            index = miPointerGetScreen(inputInfo.pointer)->myNum;
-            if (is_absolute) {
-                dx = valuators[0] - device->valuator->lastx;
-                dy = valuators[1] - device->valuator->lasty;
-            }
-            else {
+    /* The evdev driver may not always send all axes across. */
+    if (num_valuators >= 1 && first_valuator <= 1) {
+        if (miPointerGetScreen(device)) {
+            index = miPointerGetScreen(device)->myNum;
+            if (first_valuator == 0)
+            {
                 dx = valuators[0];
-                dy = valuators[1];
+                if (is_absolute)
+                    dx -= device->valuator->lastx;
+            }
+
+            if (first_valuator == 1 || num_valuators >= 2)
+            {
+                dy = valuators[1 - first_valuator];
+                if (is_absolute)
+                    dy -= device->valuator->lasty;
             }
-            if (DGAStealMotionEvent(index, dx, dy))
+
+            if (DGAStealMotionEvent(device, index, dx, dy))
                 return;
         }
     }
@@ -633,9 +640,9 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     int index;
 
 #if XFreeXDGA
-    if (miPointerGetScreen(inputInfo.pointer)) {
-        index = miPointerGetScreen(inputInfo.pointer)->myNum;
-        if (DGAStealButtonEvent(index, button, is_down))
+    if (miPointerGetScreen(device)) {
+        index = miPointerGetScreen(device)->myNum;
+        if (DGAStealButtonEvent(device, index, button, is_down))
             return;
     }
 #endif
@@ -716,9 +723,11 @@ xf86PostKeyboardEvent(DeviceIntPtr      
     int index;
 
 #if XFreeXDGA
-    if (miPointerGetScreen(inputInfo.pointer)) {
-        index = miPointerGetScreen(inputInfo.pointer)->myNum;
-        if (DGAStealKeyEvent(index, key_code, is_down))
+    DeviceIntPtr pointer = GetPairedPointer(device);
+
+    if (miPointerGetScreen(pointer)) {
+        index = miPointerGetScreen(pointer)->myNum;
+        if (DGAStealKeyEvent(device, index, key_code, is_down))
             return;
     }
 #endif
diff --git a/hw/xfree86/dixmods/extmod/dgaproc.h b/hw/xfree86/dixmods/extmod/dgaproc.h
index aaea4e2..f4d3fe4 100644
--- a/hw/xfree86/dixmods/extmod/dgaproc.h
+++ b/hw/xfree86/dixmods/extmod/dgaproc.h
@@ -120,9 +120,10 @@ int DGAGetOldDGAMode(int Index);
 int DGAGetModeInfo(int Index, XDGAModePtr mode, int num);
 
 Bool DGAVTSwitch(void);
-Bool DGAStealButtonEvent(int Index, int button, int is_down);
-Bool DGAStealMotionEvent(int Index, int dx, int dy);
-Bool DGAStealKeyEvent(int Index, int key_code, int is_down);
+Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index, int button, 
+                         int is_down);
+Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx, int dy);
+Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index, int key_code, int is_down);
 Bool DGAIsDgaEvent (xEvent *e);
 
 Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e);
diff-tree 122ae65ed90195c584a770027b4d14ef65f72492 (from 54ce7436b2579bb20728eab7c8d460b531c378af)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Oct 2 10:50:59 2007 +0930

    xfree86: xf86DGA: some cleanup to use the correct devices instead of VCP/VCK.

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 074c1c7..ea8baaf 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1144,15 +1144,15 @@ DGAProcessPointerEvent (ScreenPtr pScree
      * Fill in remaining event state
      */
     de->u.event.screen = pScreen->myNum;
-    de->u.event.state = butc->state | inputInfo.keyboard->key->state;
+    de->u.event.state = butc->state | GetPairedKeyboard(mouse)->key->state;
     /*
      * Keep the core state in sync by duplicating what
      * CoreProcessPointerEvent does
      */
     if (coreEquiv != MotionNotify)
     {
-	register int  key;
-	register BYTE *kptr;
+	int           key;
+	BYTE          *kptr;
 	int           bit;
 	
 	key = de->u.u.detail;
@@ -1295,10 +1295,10 @@ DGAHandleEvent(int screen_num, xEvent *e
     switch (coreEquiv) {
     case KeyPress:
     case KeyRelease:
-	DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
+	DGAProcessKeyboardEvent (pScreen, de, device);
 	break;
     default:
-	DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
+	DGAProcessPointerEvent (pScreen, de, device);
 	break;
     }
 }
diff-tree 54ce7436b2579bb20728eab7c8d460b531c378af (from 113011221a4fcbd70bc592930b35f20d55809f1e)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Oct 2 10:49:46 2007 +0930

    xfree86: update all pointers when calling xf86SwitchMode
    
    Center the frame around the first pointer found and then update all pointers
    on the same screen to move to the edges (if necessary).
    
    Note: xf86WarpCursor needs to be modified, is using deprecated
    miPointerWarpCursor and will kill the server when called with
    inputInfo.pointer.

diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 38bd38c..d6fa604 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -206,6 +206,7 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
   ScreenPtr   pCursorScreen;
   Bool        Switched;
   int         px, py;
+  DeviceIntPtr dev, it;
 
   if (!pScr->vtSema || !mode || !pScr->SwitchMode)
     return FALSE;
@@ -221,9 +222,20 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
   if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
     return FALSE;
 
-  pCursorScreen = miPointerGetScreen(inputInfo.pointer);
+  /* Let's take an educated guess for which pointer to take here. And about as
+     educated as it gets is to take the first pointer we find.
+   */
+  for (dev = inputInfo.devices; dev; dev = dev->next)
+  {
+      if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner)
+          break;
+  }
+  if (!dev)
+      dev = inputInfo.pointer;
+
+  pCursorScreen = miPointerGetScreen(dev);
   if (pScreen == pCursorScreen)
-    miPointerGetPosition(inputInfo.pointer, &px, &py);
+    miPointerGetPosition(dev, &px, &py);
 
   xf86EnterServerState(SETUP);
   Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
@@ -232,6 +244,7 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
 
     /*
      * Adjust frame for new display size.
+     * Frame is centered around cursor position if cursor is on same screen.
      */
     if (pScreen == pCursorScreen)
       pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
@@ -266,8 +279,42 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
   if (pScr->AdjustFrame)
     (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
 
+  /* The original code centered the frame around the cursor if possible.
+   * Since this is hard to achieve with multiple cursors, we do the following:
+   *   - center around the first pointer
+   *   - move all other pointers to the nearest edge on the screen (or leave
+   *   them unmodified if they are within the boundaries).
+   */
   if (pScreen == pCursorScreen)
-    xf86WarpCursor(inputInfo.pointer, pScreen, px, py);
+  {
+      xf86WarpCursor(dev, pScreen, px, py);
+  }
+
+  for (it = inputInfo.devices; it; it = it->next)
+  {
+      if (it == dev)
+          continue;
+
+      if (IsPointerDevice(it) && it->spriteInfo->spriteOwner)
+      {
+          pCursorScreen = miPointerGetScreen(it);
+          if (pScreen == pCursorScreen)
+          {
+              miPointerGetPosition(it, &px, &py);
+              if (px < pScr->frameX0)
+                  px = pScr->frameX0;
+              else if (px > pScr->frameX1)
+                  px = pScr->frameX1;
+
+              if(py < pScr->frameY0)
+                  py = pScr->frameY0;
+              else if(py > pScr->frameY1)
+                  py = pScr->frameY1;
+
+              xf86WarpCursor(it, pScreen, px, py);
+          }
+      }
+  }
 
   return Switched;
 }
diff-tree 113011221a4fcbd70bc592930b35f20d55809f1e (from a511c445debbd13e8c48146ecd2d7c97e793f788)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Mon Oct 1 21:42:01 2007 +0930

    Xi, xfree86: Remove leftovers of the XI wrapper code.

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 3566906..1bcc101 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -89,64 +89,12 @@ Bool ShouldFreeInputMasks(WindowPtr /* p
 static Bool MakeInputMasks(WindowPtr	/* pWin */
     );
 
-static int xiDevPrivateIndex = 0;
-static int _xiServerGeneration = -1;
-
-typedef struct {
-    ProcessInputProc processInputProc;
-    ProcessInputProc realInputProc;
-} xiDevPrivateRec, *xiDevPrivatePtr;
-
-/**************************************************************************
- *
- * Procedures for extension device event routing.
- *
- */
-
-#define WRAP_PROCESS_INPUT_PROC(device, saveprocs, newproc) \
-    saveprocs->processInputProc = \
-    saveprocs->realInputProc = device->public.realInputProc; \
-    device->public.processInputProc = newproc; \
-    device->public.realInputProc = newproc 
-
-#define UNWRAP_PROCESS_INPUT_PROC(device, saveprocs, backupproc) \
-    backupproc = device->public.processInputProc; \
-    device->public.processInputProc = saveprocs->processInputProc; \
-    device->public.realInputProc = saveprocs->realInputProc; 
-
-#define REWRAP_PROCESS_INPUT_PROC(device, saveprocs, newproc) \
-    if (device->public.processInputProc == device->public.realInputProc) \
-        device->public.processInputProc = newproc; \
-    saveprocs->processInputProc = \
-    saveprocs->realInputProc = device->public.realInputProc; \
-    device->public.realInputProc = newproc;
 
 void
 RegisterOtherDevice(DeviceIntPtr device)
 {
-    xiDevPrivatePtr xiPrivPtr;
-
-    if (serverGeneration != _xiServerGeneration)
-    {
-        xiDevPrivateIndex = AllocateDevicePrivateIndex();
-        if (xiDevPrivateIndex == 1)
-        {
-            FatalError("[Xi] Could not allocate private index.\n"); 
-        }
-        _xiServerGeneration = serverGeneration;
-    }
-
-    if (!AllocateDevicePrivate(device, xiDevPrivateIndex))
-        FatalError("[Xi] Dev private allocation failed.\n");
-
-
-    xiPrivPtr = (xiDevPrivatePtr)xcalloc(1, sizeof(xiDevPrivateRec));
-    if (!xiPrivPtr)
-        FatalError("[Xi] Cannot get memory for dev private.\n");
-
-    device->devPrivates[xiDevPrivateIndex].ptr = xiPrivPtr;
-
-    WRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, ProcessOtherEvent);
+    device->public.processInputProc = ProcessOtherEvent;
+    device->public.realInputProc = ProcessOtherEvent;
 }
 
 /**
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index a43230e..a458c11 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -181,24 +181,10 @@ xf86ActivateDevice(LocalDevicePtr local)
 
         if (DeviceIsPointerType(dev))
         {
-#ifdef XKB
-            dev->public.processInputProc = CoreProcessPointerEvent;
-            dev->public.realInputProc = CoreProcessPointerEvent;
-#else
-            dev->public.processInputProc = ProcessPointerEvent;
-            dev->public.realInputProc = ProcessPointerEvent;
-#endif
             dev->deviceGrab.ActivateGrab = ActivatePointerGrab;
             dev->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
         } else 
         {
-#ifdef XKB
-            dev->public.processInputProc = CoreProcessKeyboardEvent;
-            dev->public.realInputProc = CoreProcessKeyboardEvent;
-#else
-            dev->public.processInputProc = ProcessKeyboardEvent;
-            dev->public.realInputProc = ProcessKeyboardEvent;
-#endif
             dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
             dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
         }


More information about the xorg-commit mailing list