Merge remote-tracking branch 'whot/for-keith'

This commit is contained in:
Keith Packard 2012-06-14 11:05:22 -07:00
commit 6d86b64dba
12 changed files with 101 additions and 65 deletions

View File

@ -926,10 +926,10 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event)
else if (event->type == ET_ProximityOut) else if (event->type == ET_ProximityOut)
device->proximity->in_proximity = FALSE; device->proximity->in_proximity = FALSE;
else if (event->type == ET_TouchBegin) { else if (event->type == ET_TouchBegin) {
BUG_WARN(!b || !v); BUG_RETURN_VAL(!b || !v, DONT_PROCESS);
BUG_WARN(!t); BUG_RETURN_VAL(!t, DONT_PROCESS);
if (!b || !t || !b->map[key]) if (!b->map[key])
return DONT_PROCESS; return DONT_PROCESS;
if (!(event->flags & TOUCH_POINTER_EMULATED) || if (!(event->flags & TOUCH_POINTER_EMULATED) ||
@ -941,10 +941,10 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event)
UpdateDeviceMotionMask(device, t->state, DeviceButtonMotionMask); UpdateDeviceMotionMask(device, t->state, DeviceButtonMotionMask);
} }
else if (event->type == ET_TouchEnd) { else if (event->type == ET_TouchEnd) {
BUG_WARN(!b || !v); BUG_RETURN_VAL(!b || !v, DONT_PROCESS);
BUG_WARN(!t); BUG_RETURN_VAL(!t, DONT_PROCESS);
if (!b || !t || t->buttonsDown <= 0 || !b->map[key]) if (t->buttonsDown <= 0 || !b->map[key])
return DONT_PROCESS; return DONT_PROCESS;
if (!(event->flags & TOUCH_POINTER_EMULATED)) if (!(event->flags & TOUCH_POINTER_EMULATED))
@ -1356,9 +1356,8 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
wOtherInputMasks(*win)->inputClients, next) wOtherInputMasks(*win)->inputClients, next)
if (xi2mask_isset(iclients->xi2mask, dev, evtype)) if (xi2mask_isset(iclients->xi2mask, dev, evtype))
break; break;
BUG_WARN(!iclients);
if (!iclients) BUG_RETURN_VAL(!iclients, FALSE);
return FALSE;
*mask = iclients->xi2mask; *mask = iclients->xi2mask;
*client = rClient(iclients); *client = rClient(iclients);
@ -1371,9 +1370,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
wOtherInputMasks(*win)->inputClients, next) wOtherInputMasks(*win)->inputClients, next)
if (iclients->mask[dev->id] & xi_filter) if (iclients->mask[dev->id] & xi_filter)
break; break;
BUG_WARN(!iclients); BUG_RETURN_VAL(!iclients, FALSE);
if (!iclients)
return FALSE;
*client = rClient(iclients); *client = rClient(iclients);
} }
@ -1414,9 +1411,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
return Success; return Success;
nevents = TouchConvertToPointerEvent(ev, &motion, &button); nevents = TouchConvertToPointerEvent(ev, &motion, &button);
BUG_WARN(nevents == 0); BUG_RETURN_VAL(nevents == 0, BadValue);
if (nevents == 0)
return BadValue;
if (nevents > 1) if (nevents > 1)
ptrev = &button; ptrev = &button;

View File

@ -293,12 +293,6 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES])
} }
} }
/* can't disable until we removed pairing */
keybd->spriteInfo->paired = NULL;
ptr->spriteInfo->paired = NULL;
XTestptr->spriteInfo->paired = NULL;
XTestkeybd->spriteInfo->paired = NULL;
/* disable the remove the devices, XTest devices must be done first /* disable the remove the devices, XTest devices must be done first
else the sprites they rely on will be destroyed */ else the sprites they rely on will be destroyed */
DisableDevice(XTestptr, FALSE); DisableDevice(XTestptr, FALSE);

View File

@ -178,12 +178,9 @@ DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
/* Pair the keyboard to the pointer device. Keyboard events will follow the /* Pair the keyboard to the pointer device. Keyboard events will follow the
* pointer sprite. Only applicable for master devices. * pointer sprite. Only applicable for master devices.
* If the client is set, the request to pair comes from some client. In this
* case, we need to check for access. If the client is NULL, it's from an
* internal automatic pairing, we must always permit this.
*/ */
static int static int
PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd) PairDevices(DeviceIntPtr ptr, DeviceIntPtr kbd)
{ {
if (!ptr) if (!ptr)
return BadDevice; return BadDevice;
@ -365,13 +362,12 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
/* mode doesn't matter */ /* mode doesn't matter */
EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor); EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor);
} }
else if ((other = NextFreePointerDevice()) == NULL) { else {
ErrorF("[dix] cannot find pointer to pair with. " other = NextFreePointerDevice();
"This is a bug.\n"); BUG_RETURN_VAL_MSG(other == NULL, FALSE,
return FALSE; "[dix] cannot find pointer to pair with.\n");
PairDevices(other, dev);
} }
else
PairDevices(NULL, other, dev);
} }
else { else {
if (dev->coreEvents) if (dev->coreEvents)
@ -432,6 +428,9 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
BOOL enabled; BOOL enabled;
int flags[MAXDEVICES] = { 0 }; int flags[MAXDEVICES] = { 0 };
if (!dev->enabled)
return TRUE;
for (prev = &inputInfo.devices; for (prev = &inputInfo.devices;
*prev && (*prev != dev); prev = &(*prev)->next); *prev && (*prev != dev); prev = &(*prev)->next);
if (*prev != dev) if (*prev != dev)
@ -458,18 +457,19 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
} }
if (IsMaster(dev) && dev->spriteInfo->sprite) { if (IsMaster(dev) && dev->spriteInfo->sprite) {
for (other = inputInfo.devices; other; other = other->next) { for (other = inputInfo.devices; other; other = other->next)
if (other->spriteInfo->paired == dev) { if (other->spriteInfo->paired == dev && !other->spriteInfo->spriteOwner)
ErrorF("[dix] cannot disable device, still paired. " DisableDevice(other, sendevent);
"This is a bug. \n");
return FALSE;
}
}
} }
if (dev->spriteInfo->paired)
dev->spriteInfo->paired = NULL;
(void) (*dev->deviceProc) (dev, DEVICE_OFF); (void) (*dev->deviceProc) (dev, DEVICE_OFF);
dev->enabled = FALSE; dev->enabled = FALSE;
FreeSprite(dev);
/* now that the device is disabled, we can reset the signal handler's /* now that the device is disabled, we can reset the signal handler's
* last.slave */ * last.slave */
OsBlockSignals(); OsBlockSignals();
@ -501,6 +501,26 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
return TRUE; return TRUE;
} }
void
DisableAllDevices(void)
{
DeviceIntPtr dev, tmp;
nt_list_for_each_entry_safe(dev, tmp, inputInfo.devices, next) {
if (!IsMaster(dev))
DisableDevice(dev, FALSE);
}
/* master keyboards need to be disabled first */
nt_list_for_each_entry_safe(dev, tmp, inputInfo.devices, next) {
if (dev->enabled && IsMaster(dev) && IsKeyboardDevice(dev))
DisableDevice(dev, FALSE);
}
nt_list_for_each_entry_safe(dev, tmp, inputInfo.devices, next) {
if (dev->enabled)
DisableDevice(dev, FALSE);
}
}
/** /**
* Initialise a new device through the driver and tell all clients about the * Initialise a new device through the driver and tell all clients about the
* new device. * new device.
@ -923,12 +943,7 @@ CloseDevice(DeviceIntPtr dev)
free(classes); free(classes);
} }
if (DevHasCursor(dev) && dev->spriteInfo->sprite) { FreeSprite(dev);
if (dev->spriteInfo->sprite->current)
FreeCursor(dev->spriteInfo->sprite->current, None);
free(dev->spriteInfo->sprite->spriteTrace);
free(dev->spriteInfo->sprite);
}
/* a client may have the device set as client pointer */ /* a client may have the device set as client pointer */
for (j = 0; j < currentMaxClients; j++) { for (j = 0; j < currentMaxClients; j++) {

View File

@ -3192,6 +3192,18 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
#endif #endif
} }
void FreeSprite(DeviceIntPtr dev)
{
if (DevHasCursor(dev) && dev->spriteInfo->sprite) {
if (dev->spriteInfo->sprite->current)
FreeCursor(dev->spriteInfo->sprite->current, None);
free(dev->spriteInfo->sprite->spriteTrace);
free(dev->spriteInfo->sprite);
}
dev->spriteInfo->sprite = NULL;
}
/** /**
* Update the mouse sprite info when the server switches from a pScreen to another. * Update the mouse sprite info when the server switches from a pScreen to another.
* Otherwise, the pScreen of the mouse sprite is never updated when we switch * Otherwise, the pScreen of the mouse sprite is never updated when we switch

View File

@ -1821,10 +1821,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
if (flags & TOUCH_CLIENT_ID) { /* A DIX-submitted TouchEnd */ if (flags & TOUCH_CLIENT_ID) { /* A DIX-submitted TouchEnd */
touchpoint.dix_ti = TouchFindByClientID(dev, ddx_touchid); touchpoint.dix_ti = TouchFindByClientID(dev, ddx_touchid);
BUG_WARN(!touchpoint.dix_ti); BUG_RETURN_VAL(!touchpoint.dix_ti, 0);
if (!touchpoint.dix_ti)
return 0;
if (!mask_in || if (!mask_in ||
!valuator_mask_isset(mask_in, 0) || !valuator_mask_isset(mask_in, 0) ||

View File

@ -104,6 +104,7 @@ Equipment Corporation.
#include "privates.h" #include "privates.h"
#include "registry.h" #include "registry.h"
#include "client.h" #include "client.h"
#include "exevents.h"
#ifdef PANORAMIX #ifdef PANORAMIX
#include "panoramiXsrv.h" #include "panoramiXsrv.h"
#else #else
@ -295,6 +296,7 @@ main(int argc, char *argv[], char *envp[])
#endif #endif
UndisplayDevices(); UndisplayDevices();
DisableAllDevices();
/* Now free up whatever must be freed */ /* Now free up whatever must be freed */
if (screenIsSaved == SCREEN_SAVER_ON) if (screenIsSaved == SCREEN_SAVER_ON)
@ -318,7 +320,9 @@ main(int argc, char *argv[], char *envp[])
for (i = 0; i < screenInfo.numScreens; i++) for (i = 0; i < screenInfo.numScreens; i++)
screenInfo.screens[i]->root = NullWindow; screenInfo.screens[i]->root = NullWindow;
CloseDownDevices(); CloseDownDevices();
CloseDownEvents(); CloseDownEvents();
for (i = screenInfo.numScreens - 1; i >= 0; i--) { for (i = screenInfo.numScreens - 1; i >= 0; i--) {

View File

@ -103,11 +103,11 @@ TouchResizeQueue(ClientPtr client, pointer closure)
tmp = realloc(dev->last.touches, size * sizeof(*dev->last.touches)); tmp = realloc(dev->last.touches, size * sizeof(*dev->last.touches));
if (tmp) { if (tmp) {
int i; int j;
dev->last.touches = tmp; dev->last.touches = tmp;
for (i = dev->last.num_touches; i < size; i++) for (j = dev->last.num_touches; j < size; j++)
TouchInitDDXTouchPoint(dev, &dev->last.touches[i]); TouchInitDDXTouchPoint(dev, &dev->last.touches[j]);
dev->last.num_touches = size; dev->last.num_touches = size;
} }
@ -598,8 +598,8 @@ TouchConvertToPointerEvent(const InternalEvent *event,
int ptrtype; int ptrtype;
int nevents = 0; int nevents = 0;
BUG_WARN(!event); BUG_RETURN_VAL(!event, 0);
BUG_WARN(!motion_event); BUG_RETURN_VAL(!motion_event, 0);
switch (event->any.type) { switch (event->any.type) {
case ET_TouchUpdate: case ET_TouchUpdate:
@ -627,7 +627,7 @@ TouchConvertToPointerEvent(const InternalEvent *event,
motion_event->device_event.flags = XIPointerEmulated; motion_event->device_event.flags = XIPointerEmulated;
if (nevents > 1) { if (nevents > 1) {
BUG_WARN(!button_event); BUG_RETURN_VAL(!button_event, 0);
*button_event = *event; *button_event = *event;
button_event->any.type = ptrtype; button_event->any.type = ptrtype;
button_event->device_event.flags = XIPointerEmulated; button_event->device_event.flags = XIPointerEmulated;
@ -966,10 +966,8 @@ TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener,
int nev; int nev;
int i; int i;
BUG_WARN(listener < 0); BUG_RETURN_VAL(listener < 0, BadMatch);
BUG_WARN(listener >= ti->num_listeners); BUG_RETURN_VAL(listener >= ti->num_listeners, BadMatch);
if (listener < 0 || listener >= ti->num_listeners)
return BadMatch;
if (listener > 0) { if (listener > 0) {
if (mode == XIRejectTouch) if (mode == XIRejectTouch)
@ -981,10 +979,7 @@ TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener,
} }
events = InitEventList(GetMaximumEventsNum()); events = InitEventList(GetMaximumEventsNum());
if (!events) { BUG_RETURN_VAL_MSG(!events, BadAlloc, "Failed to allocate touch ownership events\n");
BUG_WARN_MSG(TRUE, "Failed to allocate touch ownership events\n");
return BadAlloc;
}
nev = GetTouchOwnershipEvents(events, dev, ti, mode, nev = GetTouchOwnershipEvents(events, dev, ti, mode,
ti->listeners[0].listener, 0); ti->listeners[0].listener, 0);

View File

@ -395,6 +395,8 @@ DeliverTouchEvents(DeviceIntPtr /* dev */ ,
extern void extern void
InitializeSprite(DeviceIntPtr /* pDev */ , InitializeSprite(DeviceIntPtr /* pDev */ ,
WindowPtr /* pWin */ ); WindowPtr /* pWin */ );
extern void
FreeSprite(DeviceIntPtr pDev);
extern void extern void
UpdateSpriteForScreen(DeviceIntPtr /* pDev */ , UpdateSpriteForScreen(DeviceIntPtr /* pDev */ ,

View File

@ -264,7 +264,7 @@ extern _X_EXPORT Bool ActivateDevice(DeviceIntPtr /*device */ ,
extern _X_EXPORT Bool DisableDevice(DeviceIntPtr /*device */ , extern _X_EXPORT Bool DisableDevice(DeviceIntPtr /*device */ ,
BOOL /* sendevent */ ); BOOL /* sendevent */ );
extern void DisableAllDevices(void);
extern int InitAndStartDevices(void); extern int InitAndStartDevices(void);
extern void CloseDownDevices(void); extern void CloseDownDevices(void);

View File

@ -381,4 +381,16 @@ extern _X_EXPORT unsigned long serverGeneration;
#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL) #define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL)
#define BUG_RETURN(cond) \
do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return; } } while(0)
#define BUG_RETURN_MSG(cond, ...) \
do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return; } } while(0)
#define BUG_RETURN_VAL(cond, val) \
do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return (val); } } while(0)
#define BUG_RETURN_VAL_MSG(cond, val, ...) \
do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return (val); } } while(0)
#endif /* MISC_H */ #endif /* MISC_H */

View File

@ -40,6 +40,7 @@ touch_grow_queue(void)
int i; int i;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device";
dev.id = 2; dev.id = 2;
dev.valuator = &val; dev.valuator = &val;
val.numAxes = 5; val.numAxes = 5;
@ -94,6 +95,7 @@ touch_find_ddxid(void)
int i; int i;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device";
dev.id = 2; dev.id = 2;
dev.valuator = &val; dev.valuator = &val;
val.numAxes = 5; val.numAxes = 5;
@ -162,6 +164,7 @@ touch_begin_ddxtouch(void)
int size = 5; int size = 5;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device";
dev.id = 2; dev.id = 2;
dev.valuator = &val; dev.valuator = &val;
val.numAxes = 5; val.numAxes = 5;
@ -209,6 +212,7 @@ touch_begin_touch(void)
screenInfo.screens[0] = &screen; screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device";
dev.id = 2; dev.id = 2;
memset(&sprite, 0, sizeof(sprite)); memset(&sprite, 0, sizeof(sprite));
@ -247,6 +251,7 @@ touch_init(void)
screenInfo.screens[0] = &screen; screenInfo.screens[0] = &screen;
memset(&dev, 0, sizeof(dev)); memset(&dev, 0, sizeof(dev));
dev.name = "test device";
memset(&sprite, 0, sizeof(sprite)); memset(&sprite, 0, sizeof(sprite));
dev.spriteInfo = &sprite; dev.spriteInfo = &sprite;

View File

@ -295,10 +295,15 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg)
cn.eventType = 0; cn.eventType = 0;
cn.requestMajor = 0; cn.requestMajor = 0;
cn.requestMinor = 0; cn.requestMinor = 0;
if (xkbi->desc->ctrls->enabled_ctrls & XkbSlowKeysMask) if (xkbi->desc->ctrls->enabled_ctrls & XkbSlowKeysMask) {
AccessXKRGTurnOff((DeviceIntPtr) arg, &cn); AccessXKRGTurnOff((DeviceIntPtr) arg, &cn);
else LogMessage(X_INFO, "XKB SlowKeys are disabled.\n");
}
else {
AccessXKRGTurnOn((DeviceIntPtr) arg, XkbSlowKeysMask, &cn); AccessXKRGTurnOn((DeviceIntPtr) arg, XkbSlowKeysMask, &cn);
LogMessage(X_INFO, "XKB SlowKeys are now enabled. Hold shift to disable.\n");
}
return 0; return 0;
} }