2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall
|
|
|
|
not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
other dealings in this Software without prior written authorization
|
|
|
|
from The Open Group.
|
|
|
|
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN action OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/Xproto.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "windowstr.h"
|
|
|
|
#include "inputstr.h"
|
|
|
|
#include "cursorstr.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "dixgrabs.h"
|
2007-08-28 21:10:20 +02:00
|
|
|
#include "xace.h"
|
2009-04-28 08:49:45 +02:00
|
|
|
#include "exevents.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#define BITMASK(i) (((Mask)1) << ((i) & 31))
|
|
|
|
#define MASKIDX(i) ((i) >> 5)
|
|
|
|
#define MASKWORD(buf, i) buf[MASKIDX(i)]
|
|
|
|
#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
|
|
|
|
#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
|
|
|
|
#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
GrabPtr
|
2003-11-14 17:49:22 +01:00
|
|
|
CreateGrab(
|
|
|
|
int client,
|
|
|
|
DeviceIntPtr device,
|
|
|
|
DeviceIntPtr modDevice,
|
2009-04-28 08:49:45 +02:00
|
|
|
WindowPtr window,
|
|
|
|
GrabType grabtype,
|
|
|
|
GrabMask *mask,
|
|
|
|
GrabParameters *param,
|
2003-11-14 17:49:22 +01:00
|
|
|
int type,
|
|
|
|
KeyCode keybut, /* key or button */
|
|
|
|
WindowPtr confineTo,
|
|
|
|
CursorPtr cursor)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
GrabPtr grab;
|
|
|
|
|
2009-03-09 07:36:07 +01:00
|
|
|
grab = xcalloc(1, sizeof(GrabRec));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!grab)
|
|
|
|
return (GrabPtr)NULL;
|
|
|
|
grab->resource = FakeClientID(client);
|
|
|
|
grab->device = device;
|
|
|
|
grab->window = window;
|
2009-04-28 08:49:45 +02:00
|
|
|
grab->eventMask = mask->core; /* same for XI */
|
2007-06-12 09:25:26 +02:00
|
|
|
grab->deviceMask = 0;
|
2009-04-28 08:49:45 +02:00
|
|
|
grab->ownerEvents = param->ownerEvents;
|
|
|
|
grab->keyboardMode = param->this_device_mode;
|
|
|
|
grab->pointerMode = param->other_devices_mode;
|
|
|
|
grab->modifiersDetail.exact = param->modifiers;
|
2003-11-14 16:54:54 +01:00
|
|
|
grab->modifiersDetail.pMask = NULL;
|
|
|
|
grab->modifierDevice = modDevice;
|
|
|
|
grab->type = type;
|
2009-04-12 08:19:45 +02:00
|
|
|
grab->grabtype = grabtype;
|
2003-11-14 16:54:54 +01:00
|
|
|
grab->detail.exact = keybut;
|
|
|
|
grab->detail.pMask = NULL;
|
|
|
|
grab->confineTo = confineTo;
|
|
|
|
grab->cursor = cursor;
|
2007-06-27 03:46:55 +02:00
|
|
|
grab->next = NULL;
|
2009-05-04 09:38:02 +02:00
|
|
|
|
|
|
|
if (grabtype == GRABTYPE_XI2)
|
|
|
|
memcpy(grab->xi2mask, mask->xi2mask, sizeof(mask->xi2mask));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (cursor)
|
|
|
|
cursor->refcnt++;
|
|
|
|
return grab;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-14 17:49:22 +01:00
|
|
|
FreeGrab(GrabPtr pGrab)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (pGrab->modifiersDetail.pMask != NULL)
|
|
|
|
xfree(pGrab->modifiersDetail.pMask);
|
|
|
|
|
|
|
|
if (pGrab->detail.pMask != NULL)
|
|
|
|
xfree(pGrab->detail.pMask);
|
|
|
|
|
|
|
|
if (pGrab->cursor)
|
|
|
|
FreeCursor(pGrab->cursor, (Cursor)0);
|
|
|
|
|
|
|
|
xfree(pGrab);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
DeletePassiveGrab(pointer value, XID id)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
GrabPtr g, prev;
|
2003-11-14 16:54:54 +01:00
|
|
|
GrabPtr pGrab = (GrabPtr)value;
|
|
|
|
|
|
|
|
/* it is OK if the grab isn't found */
|
|
|
|
prev = 0;
|
|
|
|
for (g = (wPassiveGrabs (pGrab->window)); g; g = g->next)
|
|
|
|
{
|
|
|
|
if (pGrab == g)
|
|
|
|
{
|
|
|
|
if (prev)
|
|
|
|
prev->next = g->next;
|
|
|
|
else
|
|
|
|
if (!(pGrab->window->optional->passiveGrabs = g->next))
|
|
|
|
CheckWindowOptionalNeed (pGrab->window);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
prev = g;
|
|
|
|
}
|
|
|
|
FreeGrab(pGrab);
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Mask *
|
2003-11-14 17:49:22 +01:00
|
|
|
DeleteDetailFromMask(Mask *pDetailMask, unsigned short detail)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
Mask *mask;
|
|
|
|
int i;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2009-01-22 08:11:16 +01:00
|
|
|
mask = xalloc(sizeof(Mask) * MasksPerDetailMask);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
if (pDetailMask)
|
|
|
|
for (i = 0; i < MasksPerDetailMask; i++)
|
|
|
|
mask[i]= pDetailMask[i];
|
|
|
|
else
|
|
|
|
for (i = 0; i < MasksPerDetailMask; i++)
|
|
|
|
mask[i]= ~0L;
|
|
|
|
BITCLEAR(mask, detail);
|
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2003-11-14 17:49:22 +01:00
|
|
|
IsInGrabMask(
|
|
|
|
DetailRec firstDetail,
|
|
|
|
DetailRec secondDetail,
|
|
|
|
unsigned short exception)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (firstDetail.exact == exception)
|
|
|
|
{
|
|
|
|
if (firstDetail.pMask == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* (at present) never called with two non-null pMasks */
|
|
|
|
if (secondDetail.exact == exception)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (GETBIT(firstDetail.pMask, secondDetail.exact))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2003-11-14 17:49:22 +01:00
|
|
|
IdenticalExactDetails(
|
|
|
|
unsigned short firstExact,
|
|
|
|
unsigned short secondExact,
|
|
|
|
unsigned short exception)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if ((firstExact == exception) || (secondExact == exception))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (firstExact == secondExact)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2003-11-14 17:49:22 +01:00
|
|
|
DetailSupersedesSecond(
|
|
|
|
DetailRec firstDetail,
|
|
|
|
DetailRec secondDetail,
|
|
|
|
unsigned short exception)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (IsInGrabMask(firstDetail, secondDetail, exception))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (IdenticalExactDetails(firstDetail.exact, secondDetail.exact,
|
|
|
|
exception))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2003-11-14 17:49:22 +01:00
|
|
|
GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (!DetailSupersedesSecond(pFirstGrab->modifiersDetail,
|
|
|
|
pSecondGrab->modifiersDetail,
|
|
|
|
(unsigned short)AnyModifier))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (DetailSupersedesSecond(pFirstGrab->detail,
|
|
|
|
pSecondGrab->detail, (unsigned short)AnyKey))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-08-08 05:40:00 +02:00
|
|
|
/**
|
|
|
|
* Compares two grabs and returns TRUE if the first grab matches the second
|
|
|
|
* grab.
|
|
|
|
*
|
|
|
|
* A match is when
|
|
|
|
* - the devices set for the grab are equal (this is optional).
|
|
|
|
* - the event types for both grabs are equal.
|
|
|
|
* - XXX
|
|
|
|
*
|
|
|
|
* @param ignoreDevice TRUE if the device settings on the grabs are to be
|
|
|
|
* ignored.
|
|
|
|
* @return TRUE if the grabs match or FALSE otherwise.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2007-08-08 05:40:00 +02:00
|
|
|
GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab, Bool ignoreDevice)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2009-05-04 07:58:15 +02:00
|
|
|
|
|
|
|
if (pFirstGrab->grabtype != pSecondGrab->grabtype)
|
|
|
|
return FALSE;
|
|
|
|
|
2007-08-08 05:40:00 +02:00
|
|
|
if (!ignoreDevice &&
|
|
|
|
((pFirstGrab->device != pSecondGrab->device) ||
|
|
|
|
(pFirstGrab->modifierDevice != pSecondGrab->modifierDevice)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (pFirstGrab->type != pSecondGrab->type)
|
2003-11-14 16:54:54 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (GrabSupersedesSecond(pFirstGrab, pSecondGrab) ||
|
|
|
|
GrabSupersedesSecond(pSecondGrab, pFirstGrab))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (DetailSupersedesSecond(pSecondGrab->detail, pFirstGrab->detail,
|
|
|
|
(unsigned short)AnyKey)
|
|
|
|
&&
|
|
|
|
DetailSupersedesSecond(pFirstGrab->modifiersDetail,
|
|
|
|
pSecondGrab->modifiersDetail,
|
|
|
|
(unsigned short)AnyModifier))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail,
|
|
|
|
(unsigned short)AnyKey)
|
|
|
|
&&
|
|
|
|
DetailSupersedesSecond(pSecondGrab->modifiersDetail,
|
|
|
|
pFirstGrab->modifiersDetail,
|
|
|
|
(unsigned short)AnyModifier))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-06-13 07:56:03 +02:00
|
|
|
static Bool
|
|
|
|
GrabsAreIdentical(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
|
|
|
|
{
|
2009-05-04 07:58:15 +02:00
|
|
|
if (pFirstGrab->grabtype != pSecondGrab->grabtype)
|
|
|
|
return FALSE;
|
|
|
|
|
2007-06-13 07:56:03 +02:00
|
|
|
if (pFirstGrab->device != pSecondGrab->device ||
|
|
|
|
(pFirstGrab->modifierDevice != pSecondGrab->modifierDevice) ||
|
|
|
|
(pFirstGrab->type != pSecondGrab->type))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!(DetailSupersedesSecond(pFirstGrab->detail,
|
|
|
|
pSecondGrab->detail,
|
|
|
|
(unsigned short)AnyKey) &&
|
|
|
|
DetailSupersedesSecond(pSecondGrab->detail,
|
|
|
|
pFirstGrab->detail,
|
|
|
|
(unsigned short)AnyKey)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!(DetailSupersedesSecond(pFirstGrab->modifiersDetail,
|
|
|
|
pSecondGrab->modifiersDetail,
|
|
|
|
(unsigned short)AnyModifier) &&
|
|
|
|
DetailSupersedesSecond(pSecondGrab->modifiersDetail,
|
|
|
|
pFirstGrab->modifiersDetail,
|
|
|
|
(unsigned short)AnyModifier)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepend the new grab to the list of passive grabs on the window.
|
|
|
|
* Any previously existing grab that matches the new grab will be removed.
|
|
|
|
* Adding a new grab that would override another client's grab will result in
|
|
|
|
* a BadAccess.
|
|
|
|
*
|
|
|
|
* @return Success or X error code on failure.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2007-10-18 18:24:55 +02:00
|
|
|
AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
GrabPtr grab;
|
2007-08-28 21:10:20 +02:00
|
|
|
Mask access_mode = DixGrabAccess;
|
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
|
|
|
|
{
|
2007-08-08 05:40:00 +02:00
|
|
|
if (GrabMatchesSecond(pGrab, grab, FALSE))
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource))
|
|
|
|
{
|
|
|
|
FreeGrab(pGrab);
|
|
|
|
return BadAccess;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-18 18:31:14 +02:00
|
|
|
if (pGrab->keyboardMode == GrabModeSync||pGrab->pointerMode == GrabModeSync)
|
2007-08-28 21:10:20 +02:00
|
|
|
access_mode |= DixFreezeAccess;
|
2007-10-18 18:31:14 +02:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, pGrab->device, access_mode);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2007-06-13 07:56:03 +02:00
|
|
|
/* Remove all grabs that match the new one exactly */
|
|
|
|
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
|
|
|
|
{
|
|
|
|
if (GrabsAreIdentical(pGrab, grab))
|
|
|
|
{
|
|
|
|
DeletePassiveGrabFromList(grab);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window))
|
|
|
|
{
|
|
|
|
FreeGrab(pGrab);
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
2007-06-29 04:26:18 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
pGrab->next = pGrab->window->optional->passiveGrabs;
|
|
|
|
pGrab->window->optional->passiveGrabs = pGrab;
|
|
|
|
if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (pointer)pGrab))
|
|
|
|
return Success;
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the following is kinda complicated, because we need to be able to back out
|
|
|
|
* if any allocation fails
|
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2005-03-08 00:02:59 +01:00
|
|
|
DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
GrabPtr grab;
|
2003-11-14 16:54:54 +01:00
|
|
|
GrabPtr *deletes, *adds;
|
|
|
|
Mask ***updates, **details;
|
|
|
|
int i, ndels, nadds, nups;
|
|
|
|
Bool ok;
|
|
|
|
|
|
|
|
#define UPDATE(mask,exact) \
|
|
|
|
if (!(details[nups] = DeleteDetailFromMask(mask, exact))) \
|
|
|
|
ok = FALSE; \
|
|
|
|
else \
|
|
|
|
updates[nups++] = &(mask)
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
for (grab = wPassiveGrabs(pMinuendGrab->window); grab; grab = grab->next)
|
|
|
|
i++;
|
|
|
|
if (!i)
|
|
|
|
return TRUE;
|
2009-01-22 08:11:16 +01:00
|
|
|
deletes = xalloc(i * sizeof(GrabPtr));
|
|
|
|
adds = xalloc(i * sizeof(GrabPtr));
|
|
|
|
updates = xalloc(i * sizeof(Mask **));
|
|
|
|
details = xalloc(i * sizeof(Mask *));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!deletes || !adds || !updates || !details)
|
|
|
|
{
|
2007-11-05 15:12:59 +01:00
|
|
|
if (details) xfree(details);
|
|
|
|
if (updates) xfree(updates);
|
|
|
|
if (adds) xfree(adds);
|
|
|
|
if (deletes) xfree(deletes);
|
2003-11-14 16:54:54 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ndels = nadds = nups = 0;
|
|
|
|
ok = TRUE;
|
|
|
|
for (grab = wPassiveGrabs(pMinuendGrab->window);
|
|
|
|
grab && ok;
|
|
|
|
grab = grab->next)
|
|
|
|
{
|
|
|
|
if ((CLIENT_BITS(grab->resource) != CLIENT_BITS(pMinuendGrab->resource)) ||
|
2009-04-12 08:19:45 +02:00
|
|
|
!GrabMatchesSecond(grab, pMinuendGrab,
|
|
|
|
(grab->grabtype == GRABTYPE_CORE)))
|
2003-11-14 16:54:54 +01:00
|
|
|
continue;
|
|
|
|
if (GrabSupersedesSecond(pMinuendGrab, grab))
|
|
|
|
{
|
|
|
|
deletes[ndels++] = grab;
|
|
|
|
}
|
|
|
|
else if ((grab->detail.exact == AnyKey)
|
|
|
|
&& (grab->modifiersDetail.exact != AnyModifier))
|
|
|
|
{
|
|
|
|
UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
|
|
|
|
}
|
|
|
|
else if ((grab->modifiersDetail.exact == AnyModifier)
|
|
|
|
&& (grab->detail.exact != AnyKey))
|
|
|
|
{
|
|
|
|
UPDATE(grab->modifiersDetail.pMask,
|
|
|
|
pMinuendGrab->modifiersDetail.exact);
|
|
|
|
}
|
|
|
|
else if ((pMinuendGrab->detail.exact != AnyKey)
|
|
|
|
&& (pMinuendGrab->modifiersDetail.exact != AnyModifier))
|
|
|
|
{
|
|
|
|
GrabPtr pNewGrab;
|
2009-04-28 08:49:45 +02:00
|
|
|
GrabParameters param;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
|
|
|
|
|
2009-04-28 08:49:45 +02:00
|
|
|
memset(¶m, 0, sizeof(param));
|
|
|
|
param.ownerEvents = grab->ownerEvents;
|
|
|
|
param.this_device_mode = grab->keyboardMode;
|
|
|
|
param.other_devices_mode = grab->pointerMode;
|
|
|
|
param.modifiers = AnyModifier;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
pNewGrab = CreateGrab(CLIENT_ID(grab->resource), grab->device,
|
2009-04-28 08:49:45 +02:00
|
|
|
grab->modifierDevice, grab->window,
|
2009-04-12 08:19:45 +02:00
|
|
|
grab->grabtype,
|
2009-04-28 08:49:45 +02:00
|
|
|
(GrabMask*)grab->eventMask,
|
|
|
|
¶m, (int)grab->type,
|
2003-11-14 16:54:54 +01:00
|
|
|
pMinuendGrab->detail.exact,
|
|
|
|
grab->confineTo, grab->cursor);
|
|
|
|
if (!pNewGrab)
|
|
|
|
ok = FALSE;
|
|
|
|
else if (!(pNewGrab->modifiersDetail.pMask =
|
|
|
|
DeleteDetailFromMask(grab->modifiersDetail.pMask,
|
|
|
|
pMinuendGrab->modifiersDetail.exact))
|
|
|
|
||
|
|
|
|
(!pNewGrab->window->optional &&
|
|
|
|
!MakeWindowOptional(pNewGrab->window)))
|
|
|
|
{
|
|
|
|
FreeGrab(pNewGrab);
|
|
|
|
ok = FALSE;
|
|
|
|
}
|
|
|
|
else if (!AddResource(pNewGrab->resource, RT_PASSIVEGRAB,
|
|
|
|
(pointer)pNewGrab))
|
|
|
|
ok = FALSE;
|
|
|
|
else
|
|
|
|
adds[nadds++] = pNewGrab;
|
|
|
|
}
|
|
|
|
else if (pMinuendGrab->detail.exact == AnyKey)
|
|
|
|
{
|
|
|
|
UPDATE(grab->modifiersDetail.pMask,
|
|
|
|
pMinuendGrab->modifiersDetail.exact);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
for (i = 0; i < nadds; i++)
|
|
|
|
FreeResource(adds[i]->resource, RT_NONE);
|
|
|
|
for (i = 0; i < nups; i++)
|
|
|
|
xfree(details[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < ndels; i++)
|
|
|
|
FreeResource(deletes[i]->resource, RT_NONE);
|
|
|
|
for (i = 0; i < nadds; i++)
|
|
|
|
{
|
|
|
|
grab = adds[i];
|
|
|
|
grab->next = grab->window->optional->passiveGrabs;
|
|
|
|
grab->window->optional->passiveGrabs = grab;
|
|
|
|
}
|
|
|
|
for (i = 0; i < nups; i++)
|
|
|
|
{
|
|
|
|
xfree(*updates[i]);
|
|
|
|
*updates[i] = details[i];
|
|
|
|
}
|
|
|
|
}
|
2007-11-05 15:12:59 +01:00
|
|
|
xfree(details);
|
|
|
|
xfree(updates);
|
|
|
|
xfree(adds);
|
|
|
|
xfree(deletes);
|
2003-11-14 16:54:54 +01:00
|
|
|
return ok;
|
|
|
|
|
|
|
|
#undef UPDATE
|
|
|
|
}
|