xserver: Branch 'mpx' - 2 commits
Peter Hutterer
whot at kemper.freedesktop.org
Mon Feb 5 03:10:54 EET 2007
Xi/Makefile.am | 2
Xi/chpkpair.c | 100 +++++++++++++++++++++++++++++++++++++++++
Xi/chpkpair.h | 40 ++++++++++++++++
Xi/exglobals.h | 4 +
Xi/extinit.c | 40 +++++++++++++---
Xi/warpdevp.c | 3 -
dix/devices.c | 15 ++----
dix/events.c | 10 ++--
dix/getevents.c | 2
hw/xfree86/common/xf86Xinput.c | 21 ++++++--
include/extinit.h | 8 ++-
include/input.h | 1
include/inputstr.h | 7 ++
mi/mieq.c | 8 ---
xkb/xkbUtils.c | 3 -
15 files changed, 228 insertions(+), 36 deletions(-)
New commits:
diff-tree a309c936bb79e2fea04a96ce33c7da99ed902484 (from 4aaaa70d1b52346213fad46777c006a93c4ece5d)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Mon Feb 5 11:38:44 2007 +1030
xkb: Daniel's patch to stop evdev keyboard segfaults.
mi: Remove quickfix from ba547d4f6a2707f51f0d826389d2d418fb62367a
diff --git a/mi/mieq.c b/mi/mieq.c
index 478b61e..6ed5ef3 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -244,14 +244,6 @@ mieqProcessInputEvents()
dev = e->pDev;
}
- /* FIXME: Keyboard extension devices do not have devPrivates
- * initialized, resulting in a segfault in XkbHandleActions. */
- if (e->event[0].u.u.type == DeviceKeyPress ||
- e->event[0].u.u.type == DeviceKeyRelease ||
- e->event[0].u.u.type == KeyPress ||
- e->event[0].u.u.type == KeyRelease)
- e->pDev = dev = inputInfo.keyboard;
-
/* MPX devices send both core and Xi events.
* Use dev to get the correct processing function but supply
* e->pDev to pass the correct device
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 400306a..e24c1f0 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1220,7 +1220,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
tmp = xalloc(src->max_key_code + 1);
if (!tmp)
return FALSE;
- dst->map->syms = tmp;
+ /*dst->map->syms = tmp;*/
+ dst->map->modmap = tmp;
}
memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1);
}
diff-tree 4aaaa70d1b52346213fad46777c006a93c4ece5d (from f3418b52dcf2ab4982504856ab9fae3e726ee6d2)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Mon Jan 29 18:23:24 2007 +1030
Xi: Adding ChangePointerKeyboardPairing request
Adding PointerKeyboardPairingChanged event
Correct error values for XWarpDevicePointer
dix: Adding device argument to SendMappingNotify
Adding spriteOwner flag to devices
diff --git a/Xi/Makefile.am b/Xi/Makefile.am
index 9e7d1c4..9000030 100644
--- a/Xi/Makefile.am
+++ b/Xi/Makefile.am
@@ -19,6 +19,8 @@ libXi_la_SOURCES = \
chgprop.h \
chgptr.c \
chgptr.h \
+ chpkpair.c \
+ chpkpair.h \
closedev.c \
closedev.h \
devbell.c \
diff --git a/Xi/chpkpair.c b/Xi/chpkpair.c
new file mode 100644
index 0000000..b862417
--- /dev/null
+++ b/Xi/chpkpair.c
@@ -0,0 +1,100 @@
+/*
+
+Copyright 2006 Peter Hutterer <peter at cs.unisa.edu.au>
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the author shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the author.
+
+*/
+
+/***********************************************************************
+ *
+ * Request change pairing between pointer and keyboard device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include "scrnintstr.h" /* screen structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exevents.h"
+#include "exglobals.h"
+
+
+#include "chpkpair.h"
+
+/***********************************************************************
+ *
+ * This procedure allows a client to change the pairing of a pointer with a
+ * a keyboard.
+ *
+ */
+
+int SProcXChangePointerKeyboardPairing(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xChangePointerKeyboardPairingReq);
+ swaps(&stuff->length, n);
+ return (ProcXChangePointerKeyboardPairing(client));
+}
+
+int
+ProcXChangePointerKeyboardPairing(register ClientPtr client)
+{
+ DeviceIntPtr pPointer, pKeyboard;
+
+ REQUEST(xChangePointerKeyboardPairingReq);
+ REQUEST_SIZE_MATCH(xChangePointerKeyboardPairingReq);
+
+ pPointer = LookupDeviceIntRec(stuff->pointer);
+ if (pPointer == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_ChangePointerKeyboardPairing,
+ stuff->pointer, BadDevice);
+ return Success;
+ }
+
+ pKeyboard = LookupDeviceIntRec(stuff->keyboard);
+ if (pKeyboard == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_ChangePointerKeyboardPairing,
+ stuff->keyboard, BadDevice);
+ return Success;
+ }
+
+ pKeyboard->pSprite = pPointer->pSprite;
+
+ /* TODO: generate event here... */
+ return Success;
+}
diff --git a/Xi/chpkpair.h b/Xi/chpkpair.h
new file mode 100644
index 0000000..1acf549
--- /dev/null
+++ b/Xi/chpkpair.h
@@ -0,0 +1,40 @@
+/************************************************************
+
+Copyright 2006 by Peter Hutterer <peter at cs.unisa.edu.au>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CHPKPAIR_H
+#define CHPKPAIR_H 1
+
+int SProcXChangePointerKeyboardPairing(ClientPtr /* client */
+ );
+
+int ProcXChangePointerKeyboardPairing(ClientPtr /* client */
+ );
+
+#endif /* WARPDEVP_H */
+
diff --git a/Xi/exglobals.h b/Xi/exglobals.h
index bc4a60d..811375e 100644
--- a/Xi/exglobals.h
+++ b/Xi/exglobals.h
@@ -52,6 +52,9 @@ extern Mask DeviceOwnerGrabButtonMask;
extern Mask DeviceButtonGrabMask;
extern Mask DeviceButtonMotionMask;
extern Mask DevicePresenceNotifyMask;
+extern Mask DeviceEnterWindowMask;
+extern Mask DeviceLeaveWindowMask;
+extern Mask PointerKeyboardPairingChangedNotifyMask;
extern Mask PropagateMask[];
extern int DeviceValuator;
@@ -72,6 +75,7 @@ extern int ChangeDeviceNotify;
extern int DevicePresenceNotify;
extern int DeviceEnterNotify;
extern int DeviceLeaveNotify;
+extern int PointerKeyboardPairingChangedNotify;
extern int RT_INPUTCLIENT;
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 8948e6c..a08ec77 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -80,6 +80,7 @@ SOFTWARE.
#include "chgkbd.h"
#include "chgprop.h"
#include "chgptr.h"
+#include "chpkpair.h"
#include "closedev.h"
#include "devbell.h"
#include "getbmap.h"
@@ -172,6 +173,7 @@ Mask DeviceButtonMotionMask;
Mask DevicePresenceNotifyMask;
Mask DeviceEnterWindowMask;
Mask DeviceLeaveWindowMask;
+Mask PointerKeyboardPairingChangedMask;
int DeviceValuator;
int DeviceKeyPress;
@@ -191,6 +193,7 @@ int ChangeDeviceNotify;
int DevicePresenceNotify;
int DeviceEnterNotify;
int DeviceLeaveNotify;
+int PointerKeyboardPairingChangedNotify;
int RT_INPUTCLIENT;
@@ -257,6 +260,7 @@ XInputExtensionInit(void)
EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
EventSwapVector[DeviceEnterNotify] = SEventIDispatch;
EventSwapVector[DeviceLeaveNotify] = SEventIDispatch;
+ EventSwapVector[PointerKeyboardPairingChangedNotify] = SEventIDispatch;
} else {
FatalError("IExtensionInit: AddExtensions failed\n");
}
@@ -349,6 +353,8 @@ ProcIDispatch(register ClientPtr client)
return (ProcXWarpDevicePointer(client));
else if (stuff->data == X_ChangeDeviceCursor)
return (ProcXChangeDeviceCursor(client));
+ else if (stuff->data == X_ChangePointerKeyboardPairing)
+ return (ProcXChangePointerKeyboardPairing(client));
else {
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
}
@@ -444,6 +450,8 @@ SProcIDispatch(register ClientPtr client
return (SProcXWarpDevicePointer(client));
else if (stuff->data == X_ChangeDeviceCursor)
return (SProcXChangeDeviceCursor(client));
+ else if (stuff->data == X_ChangePointerKeyboardPairing)
+ return (SProcXChangePointerKeyboardPairing(client));
else {
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
}
@@ -578,6 +586,8 @@ SEventIDispatch(xEvent * from, xEvent *
DO_SWAP(SDeviceEnterNotifyEvent, deviceEnterNotify);
else if (type == DeviceLeaveNotify)
DO_SWAP(SDeviceLeaveNotifyEvent, deviceLeaveNotify);
+ else if (type == PointerKeyboardPairingChangedNotify)
+ DO_SWAP(SPointerKeyboardPairingChangedNotifyEvent, pairingChangedNotify);
else {
FatalError("XInputExtension: Impossible event!\n");
}
@@ -708,6 +718,16 @@ void SDeviceLeaveNotifyEvent (deviceLeav
swaps(&to->eventY, n);
}
+void SPointerKeyboardPairingChangedNotifyEvent (pairingChangedNotify *from,
+ pairingChangedNotify *to)
+{
+ register char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber, n);
+ swapl(&to->time, n);
+}
+
/************************************************************************
*
* This function sets up extension event types and masks.
@@ -737,6 +757,7 @@ FixExtensionEvents(ExtensionEntry * extE
DevicePresenceNotify = DeviceButtonStateNotify + 1;
DeviceEnterNotify = DevicePresenceNotify + 1;
DeviceLeaveNotify = DeviceEnterNotify + 1;
+ PointerKeyboardPairingChangedNotify = DeviceLeaveNotify + 1;
event_base[KeyClass] = DeviceKeyPress;
event_base[ButtonClass] = DeviceButtonPress;
@@ -821,6 +842,11 @@ FixExtensionEvents(ExtensionEntry * extE
SetMaskForExtEvent(DeviceLeaveWindowMask, DeviceLeaveNotify);
AllowPropagateSuppress(DeviceLeaveWindowMask);
+ PointerKeyboardPairingChangedMask = GetNextExtEventMask();
+ SetMaskForExtEvent(PointerKeyboardPairingChangedMask,
+ PointerKeyboardPairingChangedNotify);
+ AllowPropagateSuppress(PointerKeyboardPairingChangedMask);
+
SetEventInfo(0, _noExtensionEvent);
}
@@ -864,6 +890,7 @@ RestoreExtensionEvents(void)
DevicePresenceNotify = 14;
DeviceEnterNotify = 15;
DeviceLeaveNotify = 16;
+ PointerKeyboardPairingChangedNotify = 17;
BadDevice = 0;
BadEvent = 1;
@@ -904,6 +931,7 @@ IResetProc(ExtensionEntry * unused)
EventSwapVector[DevicePresenceNotify] = NotImplemented;
EventSwapVector[DeviceEnterNotify] = NotImplemented;
EventSwapVector[DeviceLeaveNotify] = NotImplemented;
+ EventSwapVector[PointerKeyboardPairingChangedNotify] = NotImplemented;
RestoreExtensionEvents();
}
@@ -923,17 +951,17 @@ AssignTypeAndName(DeviceIntPtr dev, Atom
/***********************************************************************
*
- * Returns true if a device may require a pointer (is not a keyboard).
+ * Returns true if a device may require a pointer (is a mouse).
+ * FIXME: Other devices should be able to get a pointer too...
*
*/
_X_EXPORT Bool
-MayNeedPointer(DeviceIntPtr dev)
+IsPointerDevice(DeviceIntPtr dev)
{
- /* return false if device is a keyboard */
- if (dev_type[0].type == dev->type)
- return FALSE;
+ if (dev_type[1].type == dev->type)
+ return TRUE;
- return TRUE;
+ return FALSE;
}
/***********************************************************************
diff --git a/Xi/warpdevp.c b/Xi/warpdevp.c
index 2b558d1..a9ddb0b 100644
--- a/Xi/warpdevp.c
+++ b/Xi/warpdevp.c
@@ -85,7 +85,8 @@ ProcXWarpDevicePointer(register ClientPt
pDev = LookupDeviceIntRec(stuff->deviceid);
if (pDev == NULL) {
- SendErrorToClient(client, IReqCode, X_WarpDevicePointer, 0,
+ SendErrorToClient(client, IReqCode, X_WarpDevicePointer,
+ stuff->deviceid,
BadDevice);
return Success;
}
diff --git a/dix/devices.c b/dix/devices.c
index 41e8667..bc7ca89 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1072,8 +1072,8 @@ InitKeyboardDeviceStruct(DevicePtr devic
}
_X_EXPORT void
-SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count,
- ClientPtr client)
+SendMappingNotify(DeviceIntPtr pDev, unsigned request, unsigned firstKeyCode,
+ unsigned count, ClientPtr client)
{
int i;
xEvent event;
@@ -1088,8 +1088,7 @@ SendMappingNotify(unsigned request, unsi
#ifdef XKB
if (!noXkbExtension &&
((request == MappingKeyboard) || (request == MappingModifier))) {
- XkbApplyMappingChange(inputInfo.keyboard,request,firstKeyCode,count,
- client);
+ XkbApplyMappingChange(pDev,request,firstKeyCode,count, client);
}
#endif
@@ -1253,7 +1252,7 @@ ProcSetModifierMapping(ClientPtr client)
stuff->numKeyPerModifier);
/* FIXME: Send mapping notifies for all the extended devices as well. */
- SendMappingNotify(MappingModifier, 0, 0, client);
+ SendMappingNotify(inputInfo.keyboard, MappingModifier, 0, 0, client);
WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
return client->noClientException;
}
@@ -1324,8 +1323,8 @@ ProcChangeKeyboardMapping(ClientPtr clie
}
/* FIXME: Send mapping notifies for all the extended devices as well. */
- SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes,
- client);
+ SendMappingNotify(inputInfo.keyboard, MappingKeyboard,
+ stuff->firstKeyCode, stuff->keyCodes, client);
return client->noClientException;
}
@@ -1393,7 +1392,7 @@ ProcSetPointerMapping(ClientPtr client)
}
/* FIXME: Send mapping notifies for all the extended devices as well. */
- SendMappingNotify(MappingPointer, 0, 0, client);
+ SendMappingNotify(inputInfo.pointer, MappingPointer, 0, 0, client);
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
return Success;
}
diff --git a/dix/events.c b/dix/events.c
index 0380ad1..a931e41 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -242,15 +242,13 @@ static int spriteTraceGood;
/**
- * True for the core pointer and any MPX device.
- * False for any other device (including keyboards).
- * Does ID checking for sane range as well.
+ * True if device owns a cursor, false if device shares a cursor sprite with
+ * another device.
*/
_X_EXPORT Bool
DevHasCursor(DeviceIntPtr pDev)
{
- return (pDev == inputInfo.pointer ||
- (pDev->isMPDev && pDev->id < MAX_DEVICES));
+ return pDev->spriteOwner;
}
#ifdef XEVIE
@@ -4225,9 +4223,11 @@ InitSprite(DeviceIntPtr pDev, Bool hasCu
pSprite->confined = FALSE;
pDev->pSprite = pSprite;
+ pDev->spriteOwner = TRUE;
} else
{
pDev->pSprite = inputInfo.pointer->pSprite;
+ pDev->spriteOwner = FALSE;
}
}
diff --git a/dix/getevents.c b/dix/getevents.c
index 7e0b63f..8eaacf1 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -724,7 +724,7 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
}
#endif
- SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
+ SendMappingNotify(pDev, MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
(ckeyc->curKeySyms.maxKeyCode -
ckeyc->curKeySyms.minKeyCode),
serverClient);
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index dc07b3f..6218b35 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -171,11 +171,24 @@ xf86ActivateDevice(LocalDevicePtr local)
dev->public.devicePrivate = (pointer) local;
local->dev = dev;
- dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
- dev->isMPDev =
- MayNeedPointer(dev) && !(local->flags & XI86_SHARED_POINTER);
- InitSprite(dev, dev->isMPDev);
+ dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
+ dev->isMPDev = !(local->flags & XI86_SHARED_POINTER);
+#ifdef XKB
+ if (!IsPointerDevice(dev))
+ {
+ /* FIXME: that's not the nice way to do it. XKB wraps the previously
+ * set procs, so if we don't have them here, our event will disappear
+ * in a black hole.*/
+ dev->public.processInputProc = CoreProcessKeyboardEvent;
+ dev->public.realInputProc = CoreProcessKeyboardEvent;
+ if (!noXkbExtension)
+ XkbSetExtension(dev, ProcessKeyboardEvent);
+ }
+#endif
+
+ /* Only create a new sprite if it's a non-shared pointer */
+ InitSprite(dev, IsPointerDevice(dev) && dev->isMPDev);
RegisterOtherDevice(dev);
if (serverGeneration == 1)
diff --git a/include/extinit.h b/include/extinit.h
index 6cf7bf7..d7aa541 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -121,6 +121,12 @@ SDeviceLeaveNotifyEvent (
deviceLeaveNotify * /* to */
);
+void
+SPointerKeyboardPairingChangedNotifyEvent (
+ pairingChangedNotify * /* from */,
+ pairingChangedNotify * /* to */
+ );
+
void
FixExtensionEvents (
ExtensionEntry * /* extEntry */
@@ -143,7 +149,7 @@ AssignTypeAndName (
char * /* name */
);
-Bool MayNeedPointer(
+Bool IsPointerDevice(
DeviceIntPtr /* dev */
);
diff --git a/include/input.h b/include/input.h
index a1c21f8..96a28a5 100644
--- a/include/input.h
+++ b/include/input.h
@@ -323,6 +323,7 @@ extern Bool InitKeyboardDeviceStruct(
KbdCtrlProcPtr /*controlProc*/);
extern void SendMappingNotify(
+ DeviceIntPtr /* pDev */,
unsigned int /*request*/,
unsigned int /*firstKeyCode*/,
unsigned int /*count*/,
diff --git a/include/inputstr.h b/include/inputstr.h
index cc3280d..c4a2d18 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -178,7 +178,7 @@ typedef struct _ButtonClassRec {
} ButtonClassRec, *ButtonClassPtr;
typedef struct _FocusClassRec {
- WindowPtr win;
+ WindowPtr win; /* May be set to a int constant (e.g. PointerRootWin)! */
int revert;
TimeStamp time;
WindowPtr *trace;
@@ -355,7 +355,12 @@ typedef struct _DeviceIntRec {
int nPrivates;
DeviceUnwrapProc unwrapProc;
Bool isMPDev; /* TRUE if multipointer device */
+ /* Each devices has a sprite. However, keyboards and shared pointers do
+ not in fact own a sprite but rather have their pointer set to the
+ sprite of another device. pSprite always has to point to a valid
+ sprite. spriteOwner indicates whether it is the device's sprite. */
SpritePtr pSprite; /* sprite information */
+ Bool spriteOwner; /* FALSE if shared sprite, see above*/
} DeviceIntRec;
typedef struct {
More information about the xorg-commit
mailing list