diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-14 11:05:22 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-14 11:05:22 -0700 |
commit | 6d86b64dbaef5a16712fd1fdc3157f716d238877 (patch) | |
tree | 27350a2906ab3cb99e9e507f48ac5a9f4508659f /dix | |
parent | 812786f4d4306cb16f8ed57fa4a1a32bb1d13fe3 (diff) | |
parent | 4c68f5d395c66f28b56e488cb3cd12f36820357b (diff) |
Merge remote-tracking branch 'whot/for-keith'
Diffstat (limited to 'dix')
-rw-r--r-- | dix/devices.c | 61 | ||||
-rw-r--r-- | dix/events.c | 12 | ||||
-rw-r--r-- | dix/getevents.c | 5 | ||||
-rw-r--r-- | dix/main.c | 4 | ||||
-rw-r--r-- | dix/touch.c | 23 |
5 files changed, 64 insertions, 41 deletions
diff --git a/dix/devices.c b/dix/devices.c index 0c62a012d..08875bc3a 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -178,12 +178,9 @@ DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, /* Pair the keyboard to the pointer device. Keyboard events will follow the * 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 -PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd) +PairDevices(DeviceIntPtr ptr, DeviceIntPtr kbd) { if (!ptr) return BadDevice; @@ -365,13 +362,12 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent) /* mode doesn't matter */ EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor); } - else if ((other = NextFreePointerDevice()) == NULL) { - ErrorF("[dix] cannot find pointer to pair with. " - "This is a bug.\n"); - return FALSE; + else { + other = NextFreePointerDevice(); + BUG_RETURN_VAL_MSG(other == NULL, FALSE, + "[dix] cannot find pointer to pair with.\n"); + PairDevices(other, dev); } - else - PairDevices(NULL, other, dev); } else { if (dev->coreEvents) @@ -432,6 +428,9 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent) BOOL enabled; int flags[MAXDEVICES] = { 0 }; + if (!dev->enabled) + return TRUE; + for (prev = &inputInfo.devices; *prev && (*prev != dev); prev = &(*prev)->next); if (*prev != dev) @@ -458,18 +457,19 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent) } if (IsMaster(dev) && dev->spriteInfo->sprite) { - for (other = inputInfo.devices; other; other = other->next) { - if (other->spriteInfo->paired == dev) { - ErrorF("[dix] cannot disable device, still paired. " - "This is a bug. \n"); - return FALSE; - } - } + for (other = inputInfo.devices; other; other = other->next) + if (other->spriteInfo->paired == dev && !other->spriteInfo->spriteOwner) + DisableDevice(other, sendevent); } + if (dev->spriteInfo->paired) + dev->spriteInfo->paired = NULL; + (void) (*dev->deviceProc) (dev, DEVICE_OFF); dev->enabled = FALSE; + FreeSprite(dev); + /* now that the device is disabled, we can reset the signal handler's * last.slave */ OsBlockSignals(); @@ -501,6 +501,26 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent) 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 * new device. @@ -923,12 +943,7 @@ CloseDevice(DeviceIntPtr dev) free(classes); } - 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); - } + FreeSprite(dev); /* a client may have the device set as client pointer */ for (j = 0; j < currentMaxClients; j++) { diff --git a/dix/events.c b/dix/events.c index 83ae5c965..49894fa26 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3192,6 +3192,18 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) #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. * Otherwise, the pScreen of the mouse sprite is never updated when we switch diff --git a/dix/getevents.c b/dix/getevents.c index 4fbaa6c94..baa26c4b8 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1821,10 +1821,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid, if (flags & TOUCH_CLIENT_ID) { /* A DIX-submitted TouchEnd */ touchpoint.dix_ti = TouchFindByClientID(dev, ddx_touchid); - BUG_WARN(!touchpoint.dix_ti); - - if (!touchpoint.dix_ti) - return 0; + BUG_RETURN_VAL(!touchpoint.dix_ti, 0); if (!mask_in || !valuator_mask_isset(mask_in, 0) || diff --git a/dix/main.c b/dix/main.c index 83efa7d7f..e95ca1cc2 100644 --- a/dix/main.c +++ b/dix/main.c @@ -104,6 +104,7 @@ Equipment Corporation. #include "privates.h" #include "registry.h" #include "client.h" +#include "exevents.h" #ifdef PANORAMIX #include "panoramiXsrv.h" #else @@ -295,6 +296,7 @@ main(int argc, char *argv[], char *envp[]) #endif UndisplayDevices(); + DisableAllDevices(); /* Now free up whatever must be freed */ if (screenIsSaved == SCREEN_SAVER_ON) @@ -318,7 +320,9 @@ main(int argc, char *argv[], char *envp[]) for (i = 0; i < screenInfo.numScreens; i++) screenInfo.screens[i]->root = NullWindow; + CloseDownDevices(); + CloseDownEvents(); for (i = screenInfo.numScreens - 1; i >= 0; i--) { diff --git a/dix/touch.c b/dix/touch.c index 401cb981a..aa17faf28 100644 --- a/dix/touch.c +++ b/dix/touch.c @@ -103,11 +103,11 @@ TouchResizeQueue(ClientPtr client, pointer closure) tmp = realloc(dev->last.touches, size * sizeof(*dev->last.touches)); if (tmp) { - int i; + int j; dev->last.touches = tmp; - for (i = dev->last.num_touches; i < size; i++) - TouchInitDDXTouchPoint(dev, &dev->last.touches[i]); + for (j = dev->last.num_touches; j < size; j++) + TouchInitDDXTouchPoint(dev, &dev->last.touches[j]); dev->last.num_touches = size; } @@ -598,8 +598,8 @@ TouchConvertToPointerEvent(const InternalEvent *event, int ptrtype; int nevents = 0; - BUG_WARN(!event); - BUG_WARN(!motion_event); + BUG_RETURN_VAL(!event, 0); + BUG_RETURN_VAL(!motion_event, 0); switch (event->any.type) { case ET_TouchUpdate: @@ -627,7 +627,7 @@ TouchConvertToPointerEvent(const InternalEvent *event, motion_event->device_event.flags = XIPointerEmulated; if (nevents > 1) { - BUG_WARN(!button_event); + BUG_RETURN_VAL(!button_event, 0); *button_event = *event; button_event->any.type = ptrtype; button_event->device_event.flags = XIPointerEmulated; @@ -966,10 +966,8 @@ TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener, int nev; int i; - BUG_WARN(listener < 0); - BUG_WARN(listener >= ti->num_listeners); - if (listener < 0 || listener >= ti->num_listeners) - return BadMatch; + BUG_RETURN_VAL(listener < 0, BadMatch); + BUG_RETURN_VAL(listener >= ti->num_listeners, BadMatch); if (listener > 0) { if (mode == XIRejectTouch) @@ -981,10 +979,7 @@ TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener, } events = InitEventList(GetMaximumEventsNum()); - if (!events) { - BUG_WARN_MSG(TRUE, "Failed to allocate touch ownership events\n"); - return BadAlloc; - } + BUG_RETURN_VAL_MSG(!events, BadAlloc, "Failed to allocate touch ownership events\n"); nev = GetTouchOwnershipEvents(events, dev, ti, mode, ti->listeners[0].listener, 0); |