diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-01-29 18:23:24 +1030 |
---|---|---|
committer | Peter Hutterer <whot@hyena.localdomain> | 2007-01-29 18:23:24 +1030 |
commit | 4aaaa70d1b52346213fad46777c006a93c4ece5d (patch) | |
tree | 580ddae0d47b8902b9afb2312c65dbf92635f889 | |
parent | f3418b52dcf2ab4982504856ab9fae3e726ee6d2 (diff) |
Xi: Adding ChangePointerKeyboardPairing request
Adding PointerKeyboardPairingChanged event
Correct error values for XWarpDevicePointer
dix: Adding device argument to SendMappingNotify
Adding spriteOwner flag to devices
-rw-r--r-- | Xi/Makefile.am | 2 | ||||
-rw-r--r-- | Xi/chpkpair.c | 100 | ||||
-rw-r--r-- | Xi/chpkpair.h | 40 | ||||
-rw-r--r-- | Xi/exglobals.h | 4 | ||||
-rw-r--r-- | Xi/extinit.c | 40 | ||||
-rw-r--r-- | Xi/warpdevp.c | 3 | ||||
-rw-r--r-- | dix/devices.c | 15 | ||||
-rw-r--r-- | dix/events.c | 10 | ||||
-rw-r--r-- | dix/getevents.c | 2 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Xinput.c | 21 | ||||
-rw-r--r-- | include/extinit.h | 8 | ||||
-rw-r--r-- | include/input.h | 1 | ||||
-rw-r--r-- | include/inputstr.h | 7 |
13 files changed, 226 insertions, 27 deletions
diff --git a/Xi/Makefile.am b/Xi/Makefile.am index 9e7d1c43e..90000308d 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 000000000..b8624178d --- /dev/null +++ b/Xi/chpkpair.c @@ -0,0 +1,100 @@ +/* + +Copyright 2006 Peter Hutterer <peter@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 000000000..1acf54921 --- /dev/null +++ b/Xi/chpkpair.h @@ -0,0 +1,40 @@ +/************************************************************ + +Copyright 2006 by Peter Hutterer <peter@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 bc4a60d85..811375e25 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 8948e6c6a..a08ec77fa 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 * to) 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 (deviceLeaveNotify *from, deviceLeaveNotify *to) 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 * extEntry) 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 * extEntry) 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 type, char *name) /*********************************************************************** * - * 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 2b558d103..a9ddb0b6b 100644 --- a/Xi/warpdevp.c +++ b/Xi/warpdevp.c @@ -85,7 +85,8 @@ ProcXWarpDevicePointer(register ClientPtr client) 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 41e866717..bc7ca892c 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1072,8 +1072,8 @@ InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms, } _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, unsigned firstKeyCode, unsigned count, #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 client) } /* 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 0380ad1b7..a931e410e 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 hasCursor) 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 7e0b63fc9..8eaacf146 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 dc07b3f07..6218b3572 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 6cf7bf737..d7aa54137 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 a1c21f8a1..96a28a5a1 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 cc3280dc2..c4a2d1855 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 { |