dix: require PointerProc and KeyboardProc to be passed into AllocDevicePair.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-08-05 09:32:50 +10:00
parent 6a500fdd4d
commit 26b83ad4a2
3 changed files with 23 additions and 8 deletions

View File

@ -54,6 +54,10 @@
#include "xichangehierarchy.h" #include "xichangehierarchy.h"
extern DeviceProc CorePointerProc;
extern DeviceProc CoreKeyboardProc;
/** /**
* Send the current state of the device hierarchy to all clients. * Send the current state of the device hierarchy to all clients.
*/ */
@ -176,7 +180,9 @@ ProcXIChangeHierarchy(ClientPtr client)
strncpy(name, (char*)&c[1], c->name_len); strncpy(name, (char*)&c[1], c->name_len);
rc = AllocDevicePair(client, name, &ptr, &keybd, TRUE); rc = AllocDevicePair(client, name, &ptr, &keybd,
CorePointerProc, CoreKeyboardProc,
TRUE);
if (rc != Success) if (rc != Success)
{ {
xfree(name); xfree(name);

View File

@ -98,6 +98,9 @@ DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKeyIndex;
static int XTstDevicePrivateKeyIndex; static int XTstDevicePrivateKeyIndex;
DevPrivateKey XTstDevicePrivateKey = &XTstDevicePrivateKeyIndex; DevPrivateKey XTstDevicePrivateKey = &XTstDevicePrivateKeyIndex;
int CorePointerProc(DeviceIntPtr, int);
int CoreKeyboardProc(DeviceIntPtr, int);
/** /**
* vxtstpointer * vxtstpointer
* is the virtual pointer for XTest. It is the first slave * is the virtual pointer for XTest. It is the first slave
@ -531,7 +534,7 @@ CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
/** /**
* Device control function for the Virtual Core Keyboard. * Device control function for the Virtual Core Keyboard.
*/ */
static int int
CoreKeyboardProc(DeviceIntPtr pDev, int what) CoreKeyboardProc(DeviceIntPtr pDev, int what)
{ {
@ -560,7 +563,7 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what)
/** /**
* Device control function for the Virtual Core Pointer. * Device control function for the Virtual Core Pointer.
*/ */
static int int
CorePointerProc(DeviceIntPtr pDev, int what) CorePointerProc(DeviceIntPtr pDev, int what)
{ {
#define NBUTTONS 7 #define NBUTTONS 7
@ -627,6 +630,7 @@ InitCoreDevices(void)
{ {
if (AllocDevicePair(serverClient, "Virtual core", if (AllocDevicePair(serverClient, "Virtual core",
&inputInfo.pointer, &inputInfo.keyboard, &inputInfo.pointer, &inputInfo.keyboard,
CorePointerProc, CoreKeyboardProc,
TRUE) != Success) TRUE) != Success)
FatalError("Failed to allocate core devices"); FatalError("Failed to allocate core devices");
@ -2491,15 +2495,18 @@ GetMaster(DeviceIntPtr dev, int which)
*/ */
int int
AllocDevicePair (ClientPtr client, char* name, AllocDevicePair (ClientPtr client, char* name,
DeviceIntPtr* ptr, DeviceIntPtr* keybd, DeviceIntPtr* ptr,
Bool master) DeviceIntPtr* keybd,
DeviceProc ptr_proc,
DeviceProc keybd_proc,
Bool master)
{ {
DeviceIntPtr pointer; DeviceIntPtr pointer;
DeviceIntPtr keyboard; DeviceIntPtr keyboard;
ClassesPtr classes; ClassesPtr classes;
*ptr = *keybd = NULL; *ptr = *keybd = NULL;
pointer = AddInputDevice(client, CorePointerProc, TRUE); pointer = AddInputDevice(client, ptr_proc, TRUE);
if (!pointer) if (!pointer)
return BadAlloc; return BadAlloc;
@ -2519,7 +2526,7 @@ AllocDevicePair (ClientPtr client, char* name,
pointer->last.slave = NULL; pointer->last.slave = NULL;
pointer->type = (master) ? MASTER_POINTER : SLAVE; pointer->type = (master) ? MASTER_POINTER : SLAVE;
keyboard = AddInputDevice(client, CoreKeyboardProc, TRUE); keyboard = AddInputDevice(client, keybd_proc, TRUE);
if (!keyboard) if (!keyboard)
{ {
RemoveDevice(pointer, FALSE); RemoveDevice(pointer, FALSE);
@ -2587,7 +2594,7 @@ int AllocXtstDevice (ClientPtr client, char* name,
strncpy( xtstname, name, len); strncpy( xtstname, name, len);
strncat( xtstname, " Xtst", 5 ); strncat( xtstname, " Xtst", 5 );
retval = AllocDevicePair( client, xtstname, ptr, keybd, FALSE); retval = AllocDevicePair( client, xtstname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
if ( retval == Success ){ if ( retval == Success ){
dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)master_ptr->id); dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)master_ptr->id);
dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey, (void *)master_keybd->id); dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey, (void *)master_keybd->id);

View File

@ -482,6 +482,8 @@ extern int AllocDevicePair(ClientPtr client,
char* name, char* name,
DeviceIntPtr* ptr, DeviceIntPtr* ptr,
DeviceIntPtr* keybd, DeviceIntPtr* keybd,
DeviceProc ptr_proc,
DeviceProc keybd_proc,
Bool master); Bool master);
extern void DeepCopyDeviceClasses(DeviceIntPtr from, extern void DeepCopyDeviceClasses(DeviceIntPtr from,
DeviceIntPtr to, DeviceIntPtr to,