Xi: Adding ChangePointerKeyboardPairing request

Adding PointerKeyboardPairingChanged event
	Correct error values for XWarpDevicePointer

dix:	Adding device argument to SendMappingNotify
	Adding spriteOwner flag to devices
This commit is contained in:
Peter Hutterer 2007-01-29 18:23:24 +10:30 committed by Peter Hutterer
parent f3418b52dc
commit 4aaaa70d1b
13 changed files with 226 additions and 27 deletions

View File

@ -19,6 +19,8 @@ libXi_la_SOURCES = \
chgprop.h \
chgptr.c \
chgptr.h \
chpkpair.c \
chpkpair.h \
closedev.c \
closedev.h \
devbell.c \

100
Xi/chpkpair.c Normal file
View File

@ -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;
}

40
Xi/chpkpair.h Normal file
View File

@ -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 */

View File

@ -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;

View File

@ -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;
}
/***********************************************************************

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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)

View File

@ -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 */
);

View File

@ -323,6 +323,7 @@ extern Bool InitKeyboardDeviceStruct(
KbdCtrlProcPtr /*controlProc*/);
extern void SendMappingNotify(
DeviceIntPtr /* pDev */,
unsigned int /*request*/,
unsigned int /*firstKeyCode*/,
unsigned int /*count*/,

View File

@ -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 {