xserver: Branch 'master' - 9 commits

Peter Hutterer whot at kemper.freedesktop.org
Mon Dec 1 21:52:51 PST 2008


 Xext/mbuf.c                    |    4 ++--
 Xi/exevents.c                  |   10 +++-------
 Xi/extinit.c                   |    2 +-
 Xi/queryst.c                   |    3 +--
 dix/devices.c                  |    2 +-
 dix/events.c                   |    3 +--
 dix/getevents.c                |   12 +-----------
 hw/xfree86/common/xf86InPriv.h |    2 +-
 hw/xfree86/common/xf86Init.c   |    4 +++-
 hw/xfree86/common/xf86Xinput.c |   29 ++++++++++++++++++++++++-----
 hw/xfree86/common/xf86Xinput.h |    2 +-
 include/inputstr.h             |    3 ---
 mi/mieq.c                      |    2 +-
 xkb/xkbActions.c               |    4 ++--
 xkb/xkbEvents.c                |   29 ++++++++++++++++++++++++-----
 15 files changed, 66 insertions(+), 45 deletions(-)

New commits:
commit 1dfed222e93f4684c2a450944a9a0ea9e085c43f
Author: Bernhard Rosenkraenzer <bero at arklinux.org>
Date:   Tue Dec 2 09:01:56 2008 +1000

    Xext: fix MultiBuffer compilation error with TryClientEvents. (#18835)
    
    X.Org Bug 18835 <http://bugs.freedesktop.org/show_bug.cgi?id=18835>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/Xext/mbuf.c b/Xext/mbuf.c
index a23a4fa..39b8ba1 100644
--- a/Xext/mbuf.c
+++ b/Xext/mbuf.c
@@ -1314,7 +1314,7 @@ DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter)
 
     /* maybe send event to owner */
     if ((attempt = TryClientEvents(
-	bClient(pMultibuffer), pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0)
+	bClient(pMultibuffer), NULL, pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0)
     {
 	if (attempt > 0)
 	    deliveries++;
@@ -1326,7 +1326,7 @@ DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter)
     for (other = pMultibuffer->otherClients; other; other=other->next)
     {
 	if ((attempt = TryClientEvents(
-	      rClient(other), pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0)
+	      rClient(other), NULL, pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0)
 	{
 	    if (attempt > 0)
 		deliveries++;
commit 9ce995373e4aa4b1bf51b4adafa2324f781ec1cd
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Mon Dec 1 21:32:39 2008 +1000

    mi: UpdateSprite only if the device is attached.

diff --git a/mi/mieq.c b/mi/mieq.c
index 8a4f5fc..41b632a 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -386,7 +386,7 @@ mieqProcessInputEvents(void)
         }
 
         /* Update the sprite now. Next event may be from different device. */
-        if (type == DeviceMotionNotify && dev->coreEvents)
+        if (type == DeviceMotionNotify && master)
             miPointerUpdateSprite(dev);
     }
 }
commit d507f60689f4e14383b0d24e63afc8cf836360d5
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Wed Nov 26 14:15:04 2008 +1000

    xfree86: don't FatalError on "too many input devices".
    
    Just ignore devices after MAXDEVICES has been reached, but warn the user that
    the devices are ignored.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/hw/xfree86/common/xf86InPriv.h b/hw/xfree86/common/xf86InPriv.h
index 62e4820..3838d69 100644
--- a/hw/xfree86/common/xf86InPriv.h
+++ b/hw/xfree86/common/xf86InPriv.h
@@ -38,7 +38,7 @@ extern InputDriverPtr *xf86InputDriverList;
 extern int xf86NumInputDrivers;
 
 /* xf86Xinput.c */
-void xf86ActivateDevice(InputInfoPtr pInfo);
+int xf86ActivateDevice(InputInfoPtr pInfo);
 
 /* xf86Helper.c */
 InputDriverPtr xf86LookupInputDriver(const char *name);
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index b2bf8db..01acb8e 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1322,7 +1322,9 @@ InitInput(argc, argv)
             strcpy((*pDev)->driver, "kbd");
         }
 
-        xf86NewInputDevice(*pDev, &dev, TRUE);
+        /* If one fails, the others will too */
+        if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
+            break;
     }
 
     mieqInit();
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 376af77..89a27c7 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -287,12 +287,13 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
 /***********************************************************************
  *
  * xf86ActivateDevice --
- * 
+ *
  *	Initialize an input device.
  *
+ * Returns TRUE on success, or FALSE otherwise.
  ***********************************************************************
  */
-_X_EXPORT void
+_X_EXPORT int
 xf86ActivateDevice(LocalDevicePtr local)
 {
     DeviceIntPtr	dev;
@@ -301,8 +302,13 @@ xf86ActivateDevice(LocalDevicePtr local)
         dev = AddInputDevice(serverClient, local->device_control, TRUE);
 
         if (dev == NULL)
-            FatalError("Too many input devices");
-        
+        {
+            xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
+                    local->name);
+            local->dev = NULL;
+            return FALSE;
+        }
+
         local->atom = MakeAtom(local->type_name,
                                strlen(local->type_name),
                                TRUE);
@@ -334,6 +340,8 @@ xf86ActivateDevice(LocalDevicePtr local)
             xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
                     local->name, local->type_name);
     }
+
+    return TRUE;
 }
 
 
@@ -470,6 +478,13 @@ AddOtherInputDevices()
 /**
  * Create a new input device, activate and enable it.
  *
+ * Possible return codes:
+ *    BadName .. a bad driver name was supplied.
+ *    BadImplementation ... The driver does not have a PreInit function. This
+ *                          is a driver bug.
+ *    BadMatch .. device initialization failed.
+ *    BadAlloc .. too many input devices
+ *
  * @param idev The device, already set up with identifier, driver, and the
  * options.
  * @param pdev Pointer to the new device, if Success was reported.
@@ -519,7 +534,11 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
         goto unwind;
     }
 
-    xf86ActivateDevice(pInfo);
+    if (!xf86ActivateDevice(pInfo))
+    {
+        rval = BadAlloc;
+        goto unwind;
+    }
 
     dev = pInfo->dev;
     ActivateDevice(dev);
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index d7f50e0..bfd7f89 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -169,7 +169,7 @@ void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down,
 		      ...);
 void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
                            int is_down);
-void xf86ActivateDevice(LocalDevicePtr local);
+int xf86ActivateDevice(LocalDevicePtr local);
 LocalDevicePtr xf86FirstLocalDevice(void);
 int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow);
 void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y);
commit 9bf761468fa3baf4c5fa40efa717b4b581d920f9
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Fri Nov 28 11:44:58 2008 +1000

    Xi: fix xi_filters size.

diff --git a/Xi/extinit.c b/Xi/extinit.c
index 76fed76..07508c8 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -133,7 +133,7 @@ Mask ExtExclusiveMasks[EMASKSIZE];
  * Filters for various generic events.
  * Evtype is index, mask is value at index.
  */
-static Mask xi_filters[4] = {
+static Mask xi_filters[] = {
     XI_DeviceHierarchyChangedMask,
     XI_DeviceClassesChangedMask,
 };
commit 260e48c252c95fd1b1ba9ad7478791f6b9a67e2d
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Fri Nov 28 11:29:06 2008 +1000

    dix: remove confusing (and wrong) comment. VCP is not the only pointer.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/dix/events.c b/dix/events.c
index 3f57a78..de85caf 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -223,8 +223,7 @@ static int DontPropagateRefCnts[DNPMCOUNT];
  * Main input device struct.
  *     inputInfo.pointer
  *     is the core pointer. Referred to as "virtual core pointer", "VCP",
- *     "core pointer" or inputInfo.pointer. There is exactly one core pointer,
- *     but multiple devices may send core events. The VCP is the first master
+ *     "core pointer" or inputInfo.pointer. The VCP is the first master
  *     pointer device and cannot be deleted.
  *
  *     inputInfo.keyboard
commit 5d02e580d7c4144ea6f0984240fc913e05fec877
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Fri Nov 28 11:46:15 2008 +1000

    dix: use UpdateFromMaster in GetProximityEvents.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index 3d00492..1671a24 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1079,7 +1079,6 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type,
 {
     int num_events = 1;
     deviceKeyButtonPointer *kbp;
-    DeviceIntPtr master;
 
     /* Sanity checks. */
     if (type != ProximityIn && type != ProximityOut)
@@ -1101,16 +1100,7 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type,
         (num_valuators + first_valuator) > pDev->valuator->numAxes)
         return 0;
 
-    master = pDev->u.master;
-    if (master && master->u.lastSlave != pDev)
-    {
-        CreateClassesChangedEvent(events, master, pDev);
-        updateSlaveDeviceCoords(master, pDev);
-        master->u.lastSlave = pDev;
-        master->last.numValuators = pDev->last.numValuators;
-        num_events++;
-        events++;
-    }
+    events = updateFromMaster(events, pDev, &num_events);
 
     kbp = (deviceKeyButtonPointer *) events->event;
     kbp->type = type;
commit 95fc59a199f99bf167fbb09297a9bb0e33e31869
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Fri Nov 28 14:55:15 2008 +1000

    xkb: Extra sanity checks to prevent dev->key == NULL dereferencing.

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index c06b852..8b30d11 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -110,7 +110,7 @@ Time 		time;
 register CARD16	changed,bState;
 
     interest = kbd->xkb_interest;
-    if (!interest)
+    if (!interest || !kbd->key || !kbd->key->xkbInfo)
 	return;
     xkbi = kbd->key->xkbInfo;
     state= &xkbi->state;
@@ -169,6 +169,9 @@ XkbSrvInfoPtr	xkbi;
 unsigned	time = 0,initialized;
 CARD16		changed;
 
+    if (!kbd->key || !kbd->key->xkbInfo)
+        return;
+
     xkbi = kbd->key->xkbInfo;
     initialized= 0;
 
@@ -292,7 +295,7 @@ XkbInterestPtr		interest;
 Time 		 	time = 0;
 
     interest = kbd->xkb_interest;
-    if (!interest)
+    if (!interest || !kbd->key || !kbd->key->xkbInfo)
 	return;
     xkbi = kbd->key->xkbInfo;
  
@@ -402,6 +405,9 @@ CARD16		pitch,duration;
 Time 		time = 0;
 XID		winID = 0;
 
+    if (!kbd->key || !kbd->key->xkbInfo)
+        return;
+
     xkbi = kbd->key->xkbInfo;
 
     if ((force||(xkbi->desc->ctrls->enabled_ctrls&XkbAudibleBellMask))&&
@@ -617,11 +623,12 @@ XkbSrvInfoPtr	 xkbi;
 XkbInterestPtr	 interest;
 Time 		 time = 0;
 
-    xkbi = kbd->key->xkbInfo;
     interest = kbd->xkb_interest;
-    if (!interest)
+    if (!interest || !kbd->key || !kbd->key->xkbInfo)
 	return;
  
+    xkbi = kbd->key->xkbInfo;
+
     initialized = 0;
     pEv->mods= xkbi->state.mods;
     pEv->group= xkbi->state.group;
@@ -1016,6 +1023,10 @@ unsigned long	autoCtrls,autoValues;
 ClientPtr	client = NULL;
 
     found= False;
+
+    if (!dev->key || !dev->key->xkbInfo)
+        return found;
+
     autoCtrls= autoValues= 0;
     if ( dev->xkb_interest ) {
 	interest = dev->xkb_interest;
commit a425abf0eaa61ee5ccb2f32a1af24edd190f7889
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Wed Nov 26 12:20:00 2008 +1000

    xkb: don't attempt to filter events for devices without key classes.
    
    Reported by Magnus Kessler.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index fe44ee9..c06b852 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -819,7 +819,8 @@ XkbSrvInfoPtr	xkbi;
             pXDev = inputInfo.keyboard;
     }
 
-    xkbi= pXDev->key->xkbInfo;
+    xkbi= (pXDev->key) ? pXDev->key->xkbInfo : NULL;
+
     if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
 	if ((xkbDebugFlags&0x10)&&
 		((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)||
@@ -841,6 +842,10 @@ XkbSrvInfoPtr	xkbi;
 	     	(_XkbIsReleaseEvent(xE[0].u.u.type)) ) {
 	    return False;
 	}
+
+        if (!xkbi)
+            return True;
+
 	if ((pXDev->deviceGrab.grab != NullGrab) 
                 && pXDev->deviceGrab.fromPassiveGrab &&
 	    ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)||
@@ -884,6 +889,9 @@ XkbSrvInfoPtr	xkbi;
     else {
 	register CARD8 	type;
 
+        if (!xkbi)
+            return True;
+
 	for (i=0;i<nEvents;i++) {
 	    type= xE[i].u.u.type;
 	    if ((xkbDebugFlags&0x4)&&
commit a85f0d6b98237d8a196de624207acf1983a1859a
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Wed Nov 26 11:15:05 2008 +1000

    Xi: fix use of button->down - bitflags instead of int arrays.
    
    The device's button down state array was changed to use DOWN_LENGTH and thus
    bitflags for each button in cfcb3da7.
    
    Update the DBSN events to copy this bit-wise state.
    Update xkb and Xi to check for the bit flag instead of the array value.
    
    Reported by ajax.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 025dcd7..6797f50 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1183,11 +1183,9 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
     ev->num_valuators = 0;
 
     if (b) {
-	int i;
 	ev->classes_reported |= (1 << ButtonClass);
 	ev->num_buttons = b->numButtons;
-	for (i = 0; i < 32; i++)
-	    SetBitIf(ev->buttons, b->down, i);
+	memcpy((char*)ev->buttons, (char*)b->down, 4);
     } else if (k) {
 	ev->classes_reported |= (1 << KeyClass);
 	ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode;
@@ -1302,13 +1300,11 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
 	    first += 3;
 	    nval -= 3;
 	    if (nbuttons > 32) {
-		int i;
 		(ev - 1)->deviceid |= MORE_EVENTS;
 		bev = (deviceButtonStateNotify *) ev++;
 		bev->type = DeviceButtonStateNotify;
 		bev->deviceid = dev->id;
-		for (i = 32; i < MAP_LENGTH; i++)
-		    SetBitIf(bev->buttons, b->down, i);
+		memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4);
 	    }
 	    if (nval > 0) {
 		(ev - 1)->deviceid |= MORE_EVENTS;
@@ -1723,7 +1719,7 @@ SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map)
     if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue))
 	return BadValue;
     for (i = 0; i < nElts; i++)
-	if ((b->map[i + 1] != map[i]) && (b->down[i + 1]))
+	if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1))
 	    return MappingBusy;
     for (i = 0; i < nElts; i++)
 	b->map[i + 1] = map[i];
diff --git a/Xi/queryst.c b/Xi/queryst.c
index 268bdd7..21de843 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -139,8 +139,7 @@ ProcXQueryDeviceState(ClientPtr client)
 	tb->class = ButtonClass;
 	tb->length = sizeof(xButtonState);
 	tb->num_buttons = b->numButtons;
-	for (i = 0; i < MAP_LENGTH; i++)
-            SetBitIf(tb->buttons, b->down, i);
+	memcpy(tb->buttons, b->down, sizeof(b->down));
 	buf += sizeof(xButtonState);
     }
 
diff --git a/dix/devices.c b/dix/devices.c
index 220b895..6b8cecb 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1847,7 +1847,7 @@ DoSetPointerMapping(ClientPtr client, DeviceIntPtr device, BYTE *map, int n)
         if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
             for (i = 0; i < n; i++) {
                 if ((device->button->map[i + 1] != map[i]) &&
-                        device->button->down[i + 1]) {
+                        BitIsOn(device->button->down, i + 1)) {
                     return MappingBusy;
                 }
             }
diff --git a/include/inputstr.h b/include/inputstr.h
index 9591d2f..4719d37 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -57,9 +57,6 @@ SOFTWARE.
 #include "privates.h"
 
 #define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
-/* If byte[i] in src is non-zero, set bit i in dst, otherwise set bit to 0 */
-#define SetBitIf(dst, src, i) \
-    (src[i]) ? (dst[i/8] |= (1 << (i % 8))) : (dst[i/8] &= ~(1 << (i % 8)));
 
 #define SameClient(obj,client) \
 	(CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index a260629..c268795 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1043,7 +1043,7 @@ int		button;
 	switch (pAction->type) {
 	    case XkbSA_LockDeviceBtn:
 		if ((pAction->devbtn.flags&XkbSA_LockNoLock)||
-		    (dev->button->down[button]))
+		    BitIsOn(dev->button->down, button))
 		    return 0;
 		XkbDDXFakeDeviceButton(dev,True,button);
 		filter->upAction.type= XkbSA_NoAction;
@@ -1075,7 +1075,7 @@ int		button;
 	switch (filter->upAction.type) {
 	    case XkbSA_LockDeviceBtn:
 		if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)||
-		    ((dev->button->down[button])==0))
+		    BitIsOn(dev->button->down, button))
 		    return 0;
 		XkbDDXFakeDeviceButton(dev,False,button);
 		break;


More information about the xorg-commit mailing list