diff options
author | marha <marha@users.sourceforge.net> | 2009-09-09 05:23:48 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-09-09 05:23:48 +0000 |
commit | 81f91c615982e50bb62708201569c33a3cd3d973 (patch) | |
tree | 4f32ecc48a3b7b5e76642f3792338263c53879bd /xorg-server/dix/grabs.c | |
parent | b571a562410f565af2bdde52d9f7f9a23ffae04f (diff) | |
parent | a915739887477b28d924ecc8417ee107d125bd6c (diff) | |
download | vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.gz vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.bz2 vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.zip |
svn merge https://vcxsrv.svn.sourceforge.net/svnroot/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/dix/grabs.c')
-rw-r--r-- | xorg-server/dix/grabs.c | 152 |
1 files changed, 101 insertions, 51 deletions
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c index b372d8f1b..4a351d647 100644 --- a/xorg-server/dix/grabs.c +++ b/xorg-server/dix/grabs.c @@ -52,13 +52,14 @@ SOFTWARE. #include <X11/X.h> #include "misc.h" -#define NEED_EVENTS #include <X11/Xproto.h> +#include <X11/extensions/XI2.h> #include "windowstr.h" #include "inputstr.h" #include "cursorstr.h" #include "dixgrabs.h" #include "xace.h" +#include "exevents.h" #define BITMASK(i) (((Mask)1) << ((i) & 31)) #define MASKIDX(i) ((i) >> 5) @@ -71,11 +72,11 @@ GrabPtr CreateGrab( int client, DeviceIntPtr device, - WindowPtr window, - Mask eventMask, - Bool ownerEvents, Bool keyboardMode, Bool pointerMode, DeviceIntPtr modDevice, - unsigned short modifiers, + WindowPtr window, + GrabType grabtype, + GrabMask *mask, + GrabParameters *param, int type, KeyCode keybut, /* key or button */ WindowPtr confineTo, @@ -83,30 +84,30 @@ CreateGrab( { GrabPtr grab; - grab = (GrabPtr)xalloc(sizeof(GrabRec)); + grab = xcalloc(1, sizeof(GrabRec)); if (!grab) return (GrabPtr)NULL; grab->resource = FakeClientID(client); grab->device = device; - grab->coreGrab = (type < LASTEvent); grab->window = window; - grab->eventMask = eventMask; + grab->eventMask = mask->core; /* same for XI */ grab->deviceMask = 0; - grab->ownerEvents = ownerEvents; - grab->keyboardMode = keyboardMode; - grab->pointerMode = pointerMode; - grab->modifiersDetail.exact = modifiers; + grab->ownerEvents = param->ownerEvents; + grab->keyboardMode = param->this_device_mode; + grab->pointerMode = param->other_devices_mode; + grab->modifiersDetail.exact = param->modifiers; grab->modifiersDetail.pMask = NULL; grab->modifierDevice = modDevice; - grab->coreMods = ((modDevice == inputInfo.keyboard) || - (modDevice == inputInfo.pointer)); grab->type = type; + grab->grabtype = grabtype; grab->detail.exact = keybut; grab->detail.pMask = NULL; grab->confineTo = confineTo; grab->cursor = cursor; - grab->genericMasks = NULL; grab->next = NULL; + + if (grabtype == GRABTYPE_XI2) + memcpy(grab->xi2mask, mask->xi2mask, sizeof(mask->xi2mask)); if (cursor) cursor->refcnt++; return grab; @@ -154,12 +155,12 @@ DeletePassiveGrab(pointer value, XID id) } static Mask * -DeleteDetailFromMask(Mask *pDetailMask, unsigned short detail) +DeleteDetailFromMask(Mask *pDetailMask, unsigned int detail) { Mask *mask; int i; - mask = (Mask *)xalloc(sizeof(Mask) * MasksPerDetailMask); + mask = xalloc(sizeof(Mask) * MasksPerDetailMask); if (mask) { if (pDetailMask) @@ -177,7 +178,7 @@ static Bool IsInGrabMask( DetailRec firstDetail, DetailRec secondDetail, - unsigned short exception) + unsigned int exception) { if (firstDetail.exact == exception) { @@ -197,9 +198,9 @@ IsInGrabMask( static Bool IdenticalExactDetails( - unsigned short firstExact, - unsigned short secondExact, - unsigned short exception) + unsigned int firstExact, + unsigned int secondExact, + unsigned int exception) { if ((firstExact == exception) || (secondExact == exception)) return FALSE; @@ -214,7 +215,7 @@ static Bool DetailSupersedesSecond( DetailRec firstDetail, DetailRec secondDetail, - unsigned short exception) + unsigned int exception) { if (IsInGrabMask(firstDetail, secondDetail, exception)) return TRUE; @@ -229,13 +230,16 @@ DetailSupersedesSecond( static Bool GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) { + unsigned int any_modifier = (pFirstGrab->grabtype == GRABTYPE_XI2) ? + (unsigned int)XIAnyModifier : + (unsigned int)AnyModifier; if (!DetailSupersedesSecond(pFirstGrab->modifiersDetail, pSecondGrab->modifiersDetail, - (unsigned short)AnyModifier)) + any_modifier)) return FALSE; if (DetailSupersedesSecond(pFirstGrab->detail, - pSecondGrab->detail, (unsigned short)AnyKey)) + pSecondGrab->detail, (unsigned int)AnyKey)) return TRUE; return FALSE; @@ -257,7 +261,32 @@ GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) Bool GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab, Bool ignoreDevice) { - if (!ignoreDevice && + unsigned int any_modifier = (pFirstGrab->grabtype == GRABTYPE_XI2) ? + (unsigned int)XIAnyModifier : + (unsigned int)AnyModifier; + + if (pFirstGrab->grabtype != pSecondGrab->grabtype) + return FALSE; + + if (pFirstGrab->grabtype == GRABTYPE_XI2) + { + if (pFirstGrab->device == inputInfo.all_devices || + pSecondGrab->device == inputInfo.all_devices) + { + /* do nothing */ + } else if (pFirstGrab->device == inputInfo.all_master_devices) + { + if (pSecondGrab->device != inputInfo.all_master_devices && + !IsMaster(pSecondGrab->device)) + return FALSE; + } else if (pSecondGrab->device == inputInfo.all_master_devices) + { + if (pFirstGrab->device != inputInfo.all_master_devices && + !IsMaster(pFirstGrab->device)) + return FALSE; + } else if (pSecondGrab->device != pFirstGrab->device) + return FALSE; + } else if (!ignoreDevice && ((pFirstGrab->device != pSecondGrab->device) || (pFirstGrab->modifierDevice != pSecondGrab->modifierDevice))) return FALSE; @@ -270,19 +299,19 @@ GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab, Bool ignoreDevice) return TRUE; if (DetailSupersedesSecond(pSecondGrab->detail, pFirstGrab->detail, - (unsigned short)AnyKey) + (unsigned int)AnyKey) && DetailSupersedesSecond(pFirstGrab->modifiersDetail, pSecondGrab->modifiersDetail, - (unsigned short)AnyModifier)) + any_modifier)) return TRUE; if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail, - (unsigned short)AnyKey) + (unsigned int)AnyKey) && DetailSupersedesSecond(pSecondGrab->modifiersDetail, pFirstGrab->modifiersDetail, - (unsigned short)AnyModifier)) + any_modifier)) return TRUE; return FALSE; @@ -291,6 +320,13 @@ GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab, Bool ignoreDevice) static Bool GrabsAreIdentical(GrabPtr pFirstGrab, GrabPtr pSecondGrab) { + unsigned int any_modifier = (pFirstGrab->grabtype == GRABTYPE_XI2) ? + (unsigned int)XIAnyModifier : + (unsigned int)AnyModifier; + + if (pFirstGrab->grabtype != pSecondGrab->grabtype) + return FALSE; + if (pFirstGrab->device != pSecondGrab->device || (pFirstGrab->modifierDevice != pSecondGrab->modifierDevice) || (pFirstGrab->type != pSecondGrab->type)) @@ -298,18 +334,19 @@ GrabsAreIdentical(GrabPtr pFirstGrab, GrabPtr pSecondGrab) if (!(DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail, - (unsigned short)AnyKey) && + (unsigned int)AnyKey) && DetailSupersedesSecond(pSecondGrab->detail, pFirstGrab->detail, - (unsigned short)AnyKey))) + (unsigned int)AnyKey))) return FALSE; + if (!(DetailSupersedesSecond(pFirstGrab->modifiersDetail, pSecondGrab->modifiersDetail, - (unsigned short)AnyModifier) && + any_modifier) && DetailSupersedesSecond(pSecondGrab->modifiersDetail, pFirstGrab->modifiersDetail, - (unsigned short)AnyModifier))) + any_modifier))) return FALSE; return TRUE; @@ -384,6 +421,8 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) Mask ***updates, **details; int i, ndels, nadds, nups; Bool ok; + unsigned int any_modifier; + unsigned int any_key; #define UPDATE(mask,exact) \ if (!(details[nups] = DeleteDetailFromMask(mask, exact))) \ @@ -396,10 +435,10 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) i++; if (!i) return TRUE; - deletes = (GrabPtr *)xalloc(i * sizeof(GrabPtr)); - adds = (GrabPtr *)xalloc(i * sizeof(GrabPtr)); - updates = (Mask ***)xalloc(i * sizeof(Mask **)); - details = (Mask **)xalloc(i * sizeof(Mask *)); + deletes = xalloc(i * sizeof(GrabPtr)); + adds = xalloc(i * sizeof(GrabPtr)); + updates = xalloc(i * sizeof(Mask **)); + details = xalloc(i * sizeof(Mask *)); if (!deletes || !adds || !updates || !details) { if (details) xfree(details); @@ -408,6 +447,11 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) if (deletes) xfree(deletes); return FALSE; } + + any_modifier = (pMinuendGrab->grabtype == GRABTYPE_XI2) ? + (unsigned int)XIAnyModifier : (unsigned int)AnyModifier; + any_key = (pMinuendGrab->grabtype == GRABTYPE_XI2) ? + (unsigned int)XIAnyKeycode : (unsigned int)AnyKey; ndels = nadds = nups = 0; ok = TRUE; for (grab = wPassiveGrabs(pMinuendGrab->window); @@ -415,37 +459,43 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) grab = grab->next) { if ((CLIENT_BITS(grab->resource) != CLIENT_BITS(pMinuendGrab->resource)) || - !GrabMatchesSecond(grab, pMinuendGrab, (grab->coreGrab))) + !GrabMatchesSecond(grab, pMinuendGrab, + (grab->grabtype == GRABTYPE_CORE))) continue; if (GrabSupersedesSecond(pMinuendGrab, grab)) { deletes[ndels++] = grab; } - else if ((grab->detail.exact == AnyKey) - && (grab->modifiersDetail.exact != AnyModifier)) + else if ((grab->detail.exact == any_key) + && (grab->modifiersDetail.exact != any_modifier)) { UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact); } - else if ((grab->modifiersDetail.exact == AnyModifier) - && (grab->detail.exact != AnyKey)) + else if ((grab->modifiersDetail.exact == any_modifier) + && (grab->detail.exact != any_key)) { UPDATE(grab->modifiersDetail.pMask, pMinuendGrab->modifiersDetail.exact); } - else if ((pMinuendGrab->detail.exact != AnyKey) - && (pMinuendGrab->modifiersDetail.exact != AnyModifier)) + else if ((pMinuendGrab->detail.exact != any_key) + && (pMinuendGrab->modifiersDetail.exact != any_modifier)) { GrabPtr pNewGrab; + GrabParameters param; UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact); + memset(¶m, 0, sizeof(param)); + param.ownerEvents = grab->ownerEvents; + param.this_device_mode = grab->keyboardMode; + param.other_devices_mode = grab->pointerMode; + param.modifiers = any_modifier; + pNewGrab = CreateGrab(CLIENT_ID(grab->resource), grab->device, - grab->window, (Mask)grab->eventMask, - (Bool)grab->ownerEvents, - (Bool)grab->keyboardMode, - (Bool)grab->pointerMode, - grab->modifierDevice, - AnyModifier, (int)grab->type, + grab->modifierDevice, grab->window, + grab->grabtype, + (GrabMask*)&grab->eventMask, + ¶m, (int)grab->type, pMinuendGrab->detail.exact, grab->confineTo, grab->cursor); if (!pNewGrab) @@ -466,7 +516,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) else adds[nadds++] = pNewGrab; } - else if (pMinuendGrab->detail.exact == AnyKey) + else if (pMinuendGrab->detail.exact == any_key) { UPDATE(grab->modifiersDetail.pMask, pMinuendGrab->modifiersDetail.exact); |