diff options
Diffstat (limited to 'xorg-server/dix/events.c')
-rwxr-xr-x[-rw-r--r--] | xorg-server/dix/events.c | 89 |
1 files changed, 45 insertions, 44 deletions
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c index 6c249b01c..0296b7865 100644..100755 --- a/xorg-server/dix/events.c +++ b/xorg-server/dix/events.c @@ -934,8 +934,7 @@ ChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor) (*pScreen->DisplayCursor) (pDev, pScreen, cursor); FreeCursor(pSprite->current, (Cursor) 0); - pSprite->current = cursor; - pSprite->current->refcnt++; + pSprite->current = RefCursor(cursor); } } @@ -1430,21 +1429,23 @@ UpdateTouchesForGrab(DeviceIntPtr mouse) for (i = 0; i < mouse->touch->num_touches; i++) { TouchPointInfoPtr ti = mouse->touch->touches + i; + TouchListener *listener = &ti->listeners[0]; GrabPtr grab = mouse->deviceGrab.grab; if (ti->active && - CLIENT_BITS(ti->listeners[0].listener) == grab->resource) { - ti->listeners[0].listener = grab->resource; - ti->listeners[0].level = grab->grabtype; - ti->listeners[0].state = LISTENER_IS_OWNER; - ti->listeners[0].window = grab->window; + CLIENT_BITS(listener->listener) == grab->resource) { + listener->listener = grab->resource; + listener->level = grab->grabtype; + listener->state = LISTENER_IS_OWNER; + listener->window = grab->window; if (grab->grabtype == CORE || grab->grabtype == XI || !xi2mask_isset(grab->xi2mask, mouse, XI_TouchBegin)) - ti->listeners[0].type = LISTENER_POINTER_GRAB; + listener->type = LISTENER_POINTER_GRAB; else - ti->listeners[0].type = LISTENER_GRAB; - ti->listeners[0].grab = grab; + listener->type = LISTENER_GRAB; + FreeGrab(listener->grab); + listener->grab = AllocGrab(grab); } } } @@ -1469,6 +1470,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, TimeStamp time, Bool autoGrab) { GrabInfoPtr grabinfo = &mouse->deviceGrab; + GrabPtr oldgrab = grabinfo->grab; WindowPtr oldWin = (grabinfo->grab) ? grabinfo->grab->window : mouse->spriteInfo->sprite->win; Bool isPassive = autoGrab & ~ImplicitGrabMask; @@ -1491,16 +1493,15 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, grabinfo->grabTime = syncEvents.time; else grabinfo->grabTime = time; - if (grab->cursor) - grab->cursor->refcnt++; - CopyGrab(grabinfo->activeGrab, grab); - grabinfo->grab = grabinfo->activeGrab; + grabinfo->grab = AllocGrab(grab); grabinfo->fromPassiveGrab = isPassive; grabinfo->implicitGrab = autoGrab & ImplicitGrabMask; PostNewCursor(mouse); UpdateTouchesForGrab(mouse); CheckGrabForSyncs(mouse, (Bool) grab->pointerMode, (Bool) grab->keyboardMode); + if (oldgrab) + FreeGrab(oldgrab); } /** @@ -1550,13 +1551,13 @@ DeactivatePointerGrab(DeviceIntPtr mouse) if (grab->confineTo) ConfineCursorToWindow(mouse, GetCurrentRootWindow(mouse), FALSE, FALSE); PostNewCursor(mouse); - if (grab->cursor) - FreeCursor(grab->cursor, (Cursor) 0); if (!wasImplicit && grab->grabtype == XI2) ReattachToOldMaster(mouse); ComputeFreezes(); + + FreeGrab(grab); } /** @@ -1569,6 +1570,7 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive) { GrabInfoPtr grabinfo = &keybd->deviceGrab; + GrabPtr oldgrab = grabinfo->grab; WindowPtr oldWin; /* slave devices need to float for the duration of the grab. */ @@ -1594,12 +1596,13 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, grabinfo->grabTime = syncEvents.time; else grabinfo->grabTime = time; - CopyGrab(grabinfo->activeGrab, grab); - grabinfo->grab = grabinfo->activeGrab; + grabinfo->grab = AllocGrab(grab); grabinfo->fromPassiveGrab = passive; grabinfo->implicitGrab = passive & ImplicitGrabMask; CheckGrabForSyncs(keybd, (Bool) grab->keyboardMode, (Bool) grab->pointerMode); + if (oldgrab) + FreeGrab(oldgrab); } /** @@ -1641,6 +1644,8 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd) ReattachToOldMaster(keybd); ComputeFreezes(); + + FreeGrab(grab); } void @@ -1745,6 +1750,16 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) } break; } + + /* We've unfrozen the grab. If the grab was a touch grab, we're now the + * owner and expected to accept/reject it. Reject == ReplayPointer which + * we've handled in ComputeFreezes() (during DeactivateGrab) above, + * anything else is accept. + */ + if (newState != NOT_GRABBED /* Replay */ && + IsTouchEvent((InternalEvent*)grabinfo->sync.event)) { + TouchAcceptAndEnd(thisDev, grabinfo->sync.event->touchid); + } } /** @@ -1977,7 +1992,7 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win, else return FALSE; - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); if (!tempGrab) return FALSE; tempGrab->next = NULL; @@ -3198,11 +3213,10 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) pSprite->pEnqueueScreen = screenInfo.screens[0]; pSprite->pDequeueScreen = pSprite->pEnqueueScreen; } - if (pCursor) - pCursor->refcnt++; + pCursor = RefCursor(pCursor); if (pSprite->current) FreeCursor(pSprite->current, None); - pSprite->current = pCursor; + pSprite->current = RefCursor(pCursor); if (pScreen) { (*pScreen->RealizeCursor) (pDev, pScreen, pSprite->current); @@ -3281,9 +3295,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen) pSprite->hotLimits.x2 = pScreen->width; pSprite->hotLimits.y2 = pScreen->height; pSprite->win = win; - pCursor = wCursor(win); - if (pCursor) - pCursor->refcnt++; + pCursor = RefCursor(wCursor(win)); if (pSprite->current) FreeCursor(pSprite->current, 0); pSprite->current = pCursor; @@ -3885,7 +3897,7 @@ CheckPassiveGrabsOnWindow(WindowPtr pWin, if (!grab) return NULL; - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); /* Fill out the grab details, but leave the type for later before * comparing */ @@ -4845,7 +4857,6 @@ ProcGrabPointer(ClientPtr client) GrabPtr grab; GrabMask mask; WindowPtr confineTo; - CursorPtr oldCursor; BYTE status; REQUEST(xGrabPointerReq); @@ -4868,15 +4879,10 @@ ProcGrabPointer(ClientPtr client) return rc; } - oldCursor = NullCursor; grab = device->deviceGrab.grab; - if (grab) { - if (grab->confineTo && !confineTo) - ConfineCursorToWindow(device, GetCurrentRootWindow(device), FALSE, - FALSE); - oldCursor = grab->cursor; - } + if (grab && grab->confineTo && !confineTo) + ConfineCursorToWindow(device, GetCurrentRootWindow(device), FALSE, FALSE); mask.core = stuff->eventMask; @@ -4886,9 +4892,6 @@ ProcGrabPointer(ClientPtr client) if (rc != Success) return rc; - if (oldCursor && status == GrabSuccess) - FreeCursor(oldCursor, (Cursor) 0); - memset(&rep, 0, sizeof(xGrabPointerReply)); rep.type = X_Reply; rep.status = status; @@ -4943,9 +4946,7 @@ ProcChangeActivePointerGrab(ClientPtr client) (CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER)) return Success; oldCursor = grab->cursor; - grab->cursor = newCursor; - if (newCursor) - newCursor->refcnt++; + grab->cursor = RefCursor(newCursor); PostNewCursor(device); if (oldCursor) FreeCursor(oldCursor, (Cursor) 0); @@ -5075,7 +5076,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev, else { GrabPtr tempGrab; - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); tempGrab->next = NULL; tempGrab->window = pWin; @@ -5090,7 +5091,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev, else xi2mask_merge(tempGrab->xi2mask, mask->xi2mask); tempGrab->device = dev; - tempGrab->cursor = cursor; + tempGrab->cursor = RefCursor(cursor); tempGrab->confineTo = confineTo; tempGrab->grabtype = grabtype; (*grabInfo->ActivateGrab) (dev, tempGrab, time, FALSE); @@ -5431,7 +5432,7 @@ ProcUngrabKey(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); if (!tempGrab) return BadAlloc; tempGrab->resource = client->clientAsMask; @@ -5623,7 +5624,7 @@ ProcUngrabButton(ClientPtr client) ptr = PickPointer(client); - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); if (!tempGrab) return BadAlloc; tempGrab->resource = client->clientAsMask; |