aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/events.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix/events.c')
-rw-r--r--xorg-server/dix/events.c4213
1 files changed, 1972 insertions, 2241 deletions
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c
index 924479582..447094757 100644
--- a/xorg-server/dix/events.c
+++ b/xorg-server/dix/events.c
@@ -22,7 +22,6 @@ 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
@@ -130,6 +129,7 @@ Equipment Corporation.
#ifdef XSERVER_DTRACE
#include <sys/types.h>
typedef const char *string;
+
#include "Xserver-dtrace.h"
#endif
@@ -155,7 +155,7 @@ typedef const char *string;
#include "mi.h"
/* Extension events type numbering starts at EXTENSION_EVENT_BASE. */
-#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
+#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
#define StructureAndSubMask ( StructureNotifyMask | SubstructureNotifyMask )
#define AllButtonsMask ( \
Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
@@ -177,7 +177,6 @@ typedef const char *string;
#define LastEventMask OwnerGrabButtonMask
#define AllEventMasks (LastEventMask|(LastEventMask-1))
-
/* @return the core event type or 0 if the event is not a core event */
static inline int
core_get_type(const xEvent *event)
@@ -191,9 +190,10 @@ core_get_type(const xEvent *event)
static inline int
xi2_get_type(const xEvent *event)
{
- const xGenericEvent* e = (const xGenericEvent*)event;
+ const xGenericEvent *e = (const xGenericEvent *) event;
- return (e->type != GenericEvent || e->extension != IReqCode) ? 0 : e->evtype;
+ return (e->type != GenericEvent ||
+ e->extension != IReqCode) ? 0 : e->evtype;
}
/**
@@ -206,7 +206,6 @@ xi2_get_type(const xEvent *event)
#define XE_KBPTR (xE->u.keyButtonPointer)
-
CallbackListPtr EventCallback;
CallbackListPtr DeviceEventCallback;
@@ -215,11 +214,10 @@ CallbackListPtr DeviceEventCallback;
Mask DontPropagateMasks[DNPMCOUNT];
static int DontPropagateRefCnts[DNPMCOUNT];
-static void CheckVirtualMotion( DeviceIntPtr pDev, QdEventPtr qe, WindowPtr pWin);
-static void CheckPhysLimits(DeviceIntPtr pDev,
- CursorPtr cursor,
- Bool generateEvents,
- Bool confineToScreen,
+static void CheckVirtualMotion(DeviceIntPtr pDev, QdEventPtr qe,
+ WindowPtr pWin);
+static void CheckPhysLimits(DeviceIntPtr pDev, CursorPtr cursor,
+ Bool generateEvents, Bool confineToScreen,
ScreenPtr pScreen);
/** Key repeat hack. Do not use but in TryClientEvents */
@@ -266,7 +264,7 @@ EventSyncInfoRec syncEvents;
*/
#define RootWindow(sprite) sprite->spriteTrace[0]
-static xEvent* swapEvent = NULL;
+static xEvent *swapEvent = NULL;
static int swapEventLen = 0;
void
@@ -284,6 +282,7 @@ int
XItoCoreType(int xitype)
{
int coretype = 0;
+
if (xitype == DeviceMotionNotify)
coretype = MotionNotify;
else if (xitype == DeviceButtonPress)
@@ -316,8 +315,7 @@ Bool
IsPointerDevice(DeviceIntPtr dev)
{
return (dev->type == MASTER_POINTER) ||
- (dev->valuator && dev->button) ||
- (dev->valuator && !dev->key);
+ (dev->valuator && dev->button) || (dev->valuator && !dev->key);
}
/*
@@ -331,7 +329,7 @@ Bool
IsKeyboardDevice(DeviceIntPtr dev)
{
return (dev->type == MASTER_KEYBOARD) ||
- ((dev->key && dev->kbdfeed) && !IsPointerDevice(dev));
+ ((dev->key && dev->kbdfeed) && !IsPointerDevice(dev));
}
Bool
@@ -343,10 +341,9 @@ IsMaster(DeviceIntPtr dev)
Bool
IsFloating(DeviceIntPtr dev)
{
- return GetMaster(dev, MASTER_KEYBOARD) == NULL;
+ return !IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == NULL;
}
-
/**
* Max event opcode.
*/
@@ -370,43 +367,42 @@ extern int DeviceMotionNotify;
*/
Mask event_filters[MAXDEVICES][MAXEVENTS];
-static const Mask default_filter[MAXEVENTS] =
-{
- NoSuchEvent, /* 0 */
- NoSuchEvent, /* 1 */
- KeyPressMask, /* KeyPress */
- KeyReleaseMask, /* KeyRelease */
- ButtonPressMask, /* ButtonPress */
- ButtonReleaseMask, /* ButtonRelease */
- PointerMotionMask, /* MotionNotify (initial state) */
- EnterWindowMask, /* EnterNotify */
- LeaveWindowMask, /* LeaveNotify */
- FocusChangeMask, /* FocusIn */
- FocusChangeMask, /* FocusOut */
- KeymapStateMask, /* KeymapNotify */
- ExposureMask, /* Expose */
- CantBeFiltered, /* GraphicsExpose */
- CantBeFiltered, /* NoExpose */
- VisibilityChangeMask, /* VisibilityNotify */
- SubstructureNotifyMask, /* CreateNotify */
- StructureAndSubMask, /* DestroyNotify */
- StructureAndSubMask, /* UnmapNotify */
- StructureAndSubMask, /* MapNotify */
- SubstructureRedirectMask, /* MapRequest */
- StructureAndSubMask, /* ReparentNotify */
- StructureAndSubMask, /* ConfigureNotify */
- SubstructureRedirectMask, /* ConfigureRequest */
- StructureAndSubMask, /* GravityNotify */
- ResizeRedirectMask, /* ResizeRequest */
- StructureAndSubMask, /* CirculateNotify */
- SubstructureRedirectMask, /* CirculateRequest */
- PropertyChangeMask, /* PropertyNotify */
- CantBeFiltered, /* SelectionClear */
- CantBeFiltered, /* SelectionRequest */
- CantBeFiltered, /* SelectionNotify */
- ColormapChangeMask, /* ColormapNotify */
- CantBeFiltered, /* ClientMessage */
- CantBeFiltered /* MappingNotify */
+static const Mask default_filter[MAXEVENTS] = {
+ NoSuchEvent, /* 0 */
+ NoSuchEvent, /* 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask, /* MotionNotify (initial state) */
+ EnterWindowMask, /* EnterNotify */
+ LeaveWindowMask, /* LeaveNotify */
+ FocusChangeMask, /* FocusIn */
+ FocusChangeMask, /* FocusOut */
+ KeymapStateMask, /* KeymapNotify */
+ ExposureMask, /* Expose */
+ CantBeFiltered, /* GraphicsExpose */
+ CantBeFiltered, /* NoExpose */
+ VisibilityChangeMask, /* VisibilityNotify */
+ SubstructureNotifyMask, /* CreateNotify */
+ StructureAndSubMask, /* DestroyNotify */
+ StructureAndSubMask, /* UnmapNotify */
+ StructureAndSubMask, /* MapNotify */
+ SubstructureRedirectMask, /* MapRequest */
+ StructureAndSubMask, /* ReparentNotify */
+ StructureAndSubMask, /* ConfigureNotify */
+ SubstructureRedirectMask, /* ConfigureRequest */
+ StructureAndSubMask, /* GravityNotify */
+ ResizeRedirectMask, /* ResizeRequest */
+ StructureAndSubMask, /* CirculateNotify */
+ SubstructureRedirectMask, /* CirculateRequest */
+ PropertyChangeMask, /* PropertyNotify */
+ CantBeFiltered, /* SelectionClear */
+ CantBeFiltered, /* SelectionRequest */
+ CantBeFiltered, /* SelectionNotify */
+ ColormapChangeMask, /* ColormapNotify */
+ CantBeFiltered, /* ClientMessage */
+ CantBeFiltered /* MappingNotify */
};
/**
@@ -453,13 +449,12 @@ GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type)
return 0;
}
-
/**
* @return TRUE if the mask is set for this event from this device on the
* window, or FALSE otherwise.
*/
Bool
-WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
+WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent *ev)
{
OtherInputMasks *inputMasks = wOtherInputMasks(win);
int evtype;
@@ -467,34 +462,33 @@ WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
if (!inputMasks || xi2_get_type(ev) == 0)
return 0;
- evtype = ((xGenericEvent*)ev)->evtype;
+ evtype = ((xGenericEvent *) ev)->evtype;
return xi2mask_isset(inputMasks->xi2mask, dev, evtype);
}
Mask
-GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other)
+GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients * other)
{
int evtype;
/* XI2 filters are only ever 8 bit, so let's return a 8 bit mask */
- if ((evtype = xi2_get_type(event)))
- {
+ if ((evtype = xi2_get_type(event))) {
return GetXI2MaskByte(other->xi2mask, dev, evtype);
- } else if (core_get_type(event) != 0)
+ }
+ else if (core_get_type(event) != 0)
return other->mask[XIAllDevices];
else
return other->mask[dev->id];
}
-
-static CARD8 criticalEvents[32] =
-{
- 0x7c, 0x30, 0x40 /* key, button, expose, and configure events */
+static CARD8 criticalEvents[32] = {
+ 0x7c, 0x30, 0x40 /* key, button, expose, and configure events */
};
static void
-SyntheticMotion(DeviceIntPtr dev, int x, int y) {
+SyntheticMotion(DeviceIntPtr dev, int x, int y)
+{
int screenno = 0;
#ifdef PANORAMIX
@@ -502,7 +496,8 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) {
screenno = dev->spriteInfo->sprite->screen->myNum;
#endif
PostSyntheticMotion(dev, x, y, screenno,
- (syncEvents.playingEvents) ? syncEvents.time.milliseconds : currentTime.milliseconds);
+ (syncEvents.playingEvents) ? syncEvents.time.
+ milliseconds : currentTime.milliseconds);
}
@@ -510,12 +505,8 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) {
static void PostNewCursor(DeviceIntPtr pDev);
static Bool
-XineramaSetCursorPosition(
- DeviceIntPtr pDev,
- int x,
- int y,
- Bool generateEvent
-){
+XineramaSetCursorPosition(DeviceIntPtr pDev, int x, int y, Bool generateEvent)
+{
ScreenPtr pScreen;
int i;
SpritePtr pSprite = pDev->spriteInfo->sprite;
@@ -528,18 +519,15 @@ XineramaSetCursorPosition(
x += screenInfo.screens[0]->x;
y += screenInfo.screens[0]->y;
- if(!point_on_screen(pScreen, x, y))
- {
- FOR_NSCREENS(i)
- {
- if(i == pScreen->myNum)
- continue;
- if(point_on_screen(screenInfo.screens[i], x, y))
- {
- pScreen = screenInfo.screens[i];
- break;
- }
- }
+ if (!point_on_screen(pScreen, x, y)) {
+ FOR_NSCREENS(i) {
+ if (i == pScreen->myNum)
+ continue;
+ if (point_on_screen(screenInfo.screens[i], x, y)) {
+ pScreen = screenInfo.screens[i];
+ break;
+ }
+ }
}
pSprite->screen = pScreen;
@@ -548,10 +536,9 @@ XineramaSetCursorPosition(
x -= pScreen->x;
y -= pScreen->y;
- return (*pScreen->SetCursorPosition)(pDev, pScreen, x, y, generateEvent);
+ return (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
}
-
static void
XineramaConstrainCursor(DeviceIntPtr pDev)
{
@@ -569,66 +556,65 @@ XineramaConstrainCursor(DeviceIntPtr pDev)
newBox.y1 += screenInfo.screens[0]->y - pScreen->y;
newBox.y2 += screenInfo.screens[0]->y - pScreen->y;
- (* pScreen->ConstrainCursor)(pDev, pScreen, &newBox);
+ (*pScreen->ConstrainCursor) (pDev, pScreen, &newBox);
}
-
static Bool
XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
{
SpritePtr pSprite = pDev->spriteInfo->sprite;
- if(pWin == screenInfo.screens[0]->root) {
- int i;
- FOR_NSCREENS(i)
- pSprite->windows[i] = screenInfo.screens[i]->root;
- } else {
- PanoramiXRes *win;
- int rc, i;
-
- rc = dixLookupResourceByType((pointer *)&win, pWin->drawable.id,
- XRT_WINDOW, serverClient, DixReadAccess);
- if (rc != Success)
- return FALSE;
-
- FOR_NSCREENS(i) {
- rc = dixLookupWindow(pSprite->windows + i, win->info[i].id,
- serverClient, DixReadAccess);
- if (rc != Success) /* window is being unmapped */
- return FALSE;
- }
+ if (pWin == screenInfo.screens[0]->root) {
+ int i;
+
+ FOR_NSCREENS(i)
+ pSprite->windows[i] = screenInfo.screens[i]->root;
+ }
+ else {
+ PanoramiXRes *win;
+ int rc, i;
+
+ rc = dixLookupResourceByType((pointer *) &win, pWin->drawable.id,
+ XRT_WINDOW, serverClient, DixReadAccess);
+ if (rc != Success)
+ return FALSE;
+
+ FOR_NSCREENS(i) {
+ rc = dixLookupWindow(pSprite->windows + i, win->info[i].id,
+ serverClient, DixReadAccess);
+ if (rc != Success) /* window is being unmapped */
+ return FALSE;
+ }
}
return TRUE;
}
static void
XineramaConfineCursorToWindow(DeviceIntPtr pDev,
- WindowPtr pWin,
- Bool generateEvents)
+ WindowPtr pWin, Bool generateEvents)
{
SpritePtr pSprite = pDev->spriteInfo->sprite;
int x, y, off_x, off_y, i;
- if(!XineramaSetWindowPntrs(pDev, pWin))
+ if (!XineramaSetWindowPntrs(pDev, pWin))
return;
i = PanoramiXNumScreens - 1;
- RegionCopy(&pSprite->Reg1,
- &pSprite->windows[i]->borderSize);
+ RegionCopy(&pSprite->Reg1, &pSprite->windows[i]->borderSize);
off_x = screenInfo.screens[i]->x;
off_y = screenInfo.screens[i]->y;
- while(i--) {
+ while (i--) {
x = off_x - screenInfo.screens[i]->x;
y = off_y - screenInfo.screens[i]->y;
- if(x || y)
+ if (x || y)
RegionTranslate(&pSprite->Reg1, x, y);
RegionUnion(&pSprite->Reg1, &pSprite->Reg1,
- &pSprite->windows[i]->borderSize);
+ &pSprite->windows[i]->borderSize);
off_x = screenInfo.screens[i]->x;
off_y = screenInfo.screens[i]->y;
@@ -636,18 +622,19 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
pSprite->hotLimits = *RegionExtents(&pSprite->Reg1);
- if(RegionNumRects(&pSprite->Reg1) > 1)
+ if (RegionNumRects(&pSprite->Reg1) > 1)
pSprite->hotShape = &pSprite->Reg1;
else
pSprite->hotShape = NullRegion;
pSprite->confined = FALSE;
- pSprite->confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin;
+ pSprite->confineWin =
+ (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin;
CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL);
}
-#endif /* PANORAMIX */
+#endif /* PANORAMIX */
/**
* Modifies the filter for the given protocol event type to the given masks.
@@ -675,7 +662,7 @@ void
SetCriticalEvent(int event)
{
if (event >= MAXEVENTS)
- FatalError("SetCriticalEvent: bogus event number");
+ FatalError("SetCriticalEvent: bogus event number");
criticalEvents[event >> 3] |= 1 << (event & 7);
}
@@ -687,47 +674,40 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py)
int incx = 1, incy = 1;
if (RegionContainsPoint(shape, x, y, &box))
- return;
+ return;
box = *RegionExtents(shape);
/* this is rather crude */
do {
- x += incx;
- if (x >= box.x2)
- {
- incx = -1;
- x = *px - 1;
- }
- else if (x < box.x1)
- {
- incx = 1;
- x = *px;
- y += incy;
- if (y >= box.y2)
- {
- incy = -1;
- y = *py - 1;
- }
- else if (y < box.y1)
- return; /* should never get here! */
- }
+ x += incx;
+ if (x >= box.x2) {
+ incx = -1;
+ x = *px - 1;
+ }
+ else if (x < box.x1) {
+ incx = 1;
+ x = *px;
+ y += incy;
+ if (y >= box.y2) {
+ incy = -1;
+ y = *py - 1;
+ }
+ else if (y < box.y1)
+ return; /* should never get here! */
+ }
} while (!RegionContainsPoint(shape, x, y, &box));
*px = x;
*py = y;
}
static void
-CheckPhysLimits(
- DeviceIntPtr pDev,
- CursorPtr cursor,
- Bool generateEvents,
- Bool confineToScreen, /* unused if PanoramiX on */
- ScreenPtr pScreen) /* unused if PanoramiX on */
-{
+CheckPhysLimits(DeviceIntPtr pDev, CursorPtr cursor, Bool generateEvents, Bool confineToScreen, /* unused if PanoramiX on */
+ ScreenPtr pScreen)
+{ /* unused if PanoramiX on */
HotSpot new;
SpritePtr pSprite = pDev->spriteInfo->sprite;
if (!cursor)
- return;
+ return;
new = pSprite->hotPhys;
#ifdef PANORAMIX
if (!noPanoramiXExtension)
@@ -741,34 +721,31 @@ CheckPhysLimits(
else
pScreen = new.pScreen;
(*pScreen->CursorLimits) (pDev, pScreen, cursor, &pSprite->hotLimits,
- &pSprite->physLimits);
+ &pSprite->physLimits);
pSprite->confined = confineToScreen;
- (* pScreen->ConstrainCursor)(pDev, pScreen, &pSprite->physLimits);
+ (*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits);
}
/* constrain the pointer to those limits */
if (new.x < pSprite->physLimits.x1)
- new.x = pSprite->physLimits.x1;
- else
- if (new.x >= pSprite->physLimits.x2)
- new.x = pSprite->physLimits.x2 - 1;
+ new.x = pSprite->physLimits.x1;
+ else if (new.x >= pSprite->physLimits.x2)
+ new.x = pSprite->physLimits.x2 - 1;
if (new.y < pSprite->physLimits.y1)
- new.y = pSprite->physLimits.y1;
- else
- if (new.y >= pSprite->physLimits.y2)
- new.y = pSprite->physLimits.y2 - 1;
+ new.y = pSprite->physLimits.y1;
+ else if (new.y >= pSprite->physLimits.y2)
+ new.y = pSprite->physLimits.y2 - 1;
if (pSprite->hotShape)
- ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y);
+ ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y);
if ((
#ifdef PANORAMIX
noPanoramiXExtension &&
#endif
(pScreen != pSprite->hotPhys.pScreen)) ||
- (new.x != pSprite->hotPhys.x) || (new.y != pSprite->hotPhys.y))
- {
+ (new.x != pSprite->hotPhys.x) || (new.y != pSprite->hotPhys.y)) {
#ifdef PANORAMIX
if (!noPanoramiXExtension)
- XineramaSetCursorPosition (pDev, new.x, new.y, generateEvents);
+ XineramaSetCursorPosition(pDev, new.x, new.y, generateEvents);
else
#endif
{
@@ -789,94 +766,89 @@ CheckPhysLimits(
}
static void
-CheckVirtualMotion(
- DeviceIntPtr pDev,
- QdEventPtr qe,
- WindowPtr pWin)
+CheckVirtualMotion(DeviceIntPtr pDev, QdEventPtr qe, WindowPtr pWin)
{
SpritePtr pSprite = pDev->spriteInfo->sprite;
RegionPtr reg = NULL;
DeviceEvent *ev = NULL;
- if (qe)
- {
+ if (qe) {
ev = &qe->event->device_event;
- switch(ev->type)
- {
- case ET_Motion:
- case ET_ButtonPress:
- case ET_ButtonRelease:
- case ET_KeyPress:
- case ET_KeyRelease:
- case ET_ProximityIn:
- case ET_ProximityOut:
- pSprite->hot.pScreen = qe->pScreen;
- pSprite->hot.x = ev->root_x;
- pSprite->hot.y = ev->root_y;
- pWin = pDev->deviceGrab.grab ? pDev->deviceGrab.grab->confineTo : NullWindow;
- break;
- default:
- break;
+ switch (ev->type) {
+ case ET_Motion:
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ case ET_KeyPress:
+ case ET_KeyRelease:
+ case ET_ProximityIn:
+ case ET_ProximityOut:
+ pSprite->hot.pScreen = qe->pScreen;
+ pSprite->hot.x = ev->root_x;
+ pSprite->hot.y = ev->root_y;
+ pWin =
+ pDev->deviceGrab.grab ? pDev->deviceGrab.grab->
+ confineTo : NullWindow;
+ break;
+ default:
+ break;
}
}
- if (pWin)
- {
- BoxRec lims;
+ if (pWin) {
+ BoxRec lims;
#ifdef PANORAMIX
if (!noPanoramiXExtension) {
int x, y, off_x, off_y, i;
- if(!XineramaSetWindowPntrs(pDev, pWin))
+ if (!XineramaSetWindowPntrs(pDev, pWin))
return;
i = PanoramiXNumScreens - 1;
- RegionCopy(&pSprite->Reg2,
- &pSprite->windows[i]->borderSize);
+ RegionCopy(&pSprite->Reg2, &pSprite->windows[i]->borderSize);
off_x = screenInfo.screens[i]->x;
off_y = screenInfo.screens[i]->y;
- while(i--) {
+ while (i--) {
x = off_x - screenInfo.screens[i]->x;
y = off_y - screenInfo.screens[i]->y;
- if(x || y)
+ if (x || y)
RegionTranslate(&pSprite->Reg2, x, y);
RegionUnion(&pSprite->Reg2, &pSprite->Reg2,
- &pSprite->windows[i]->borderSize);
+ &pSprite->windows[i]->borderSize);
off_x = screenInfo.screens[i]->x;
off_y = screenInfo.screens[i]->y;
}
- } else
+ }
+ else
#endif
{
- if (pSprite->hot.pScreen != pWin->drawable.pScreen)
- {
+ if (pSprite->hot.pScreen != pWin->drawable.pScreen) {
pSprite->hot.pScreen = pWin->drawable.pScreen;
pSprite->hot.x = pSprite->hot.y = 0;
}
}
- lims = *RegionExtents(&pWin->borderSize);
- if (pSprite->hot.x < lims.x1)
- pSprite->hot.x = lims.x1;
- else if (pSprite->hot.x >= lims.x2)
- pSprite->hot.x = lims.x2 - 1;
- if (pSprite->hot.y < lims.y1)
- pSprite->hot.y = lims.y1;
- else if (pSprite->hot.y >= lims.y2)
- pSprite->hot.y = lims.y2 - 1;
+ lims = *RegionExtents(&pWin->borderSize);
+ if (pSprite->hot.x < lims.x1)
+ pSprite->hot.x = lims.x1;
+ else if (pSprite->hot.x >= lims.x2)
+ pSprite->hot.x = lims.x2 - 1;
+ if (pSprite->hot.y < lims.y1)
+ pSprite->hot.y = lims.y1;
+ else if (pSprite->hot.y >= lims.y2)
+ pSprite->hot.y = lims.y2 - 1;
#ifdef PANORAMIX
- if (!noPanoramiXExtension)
- {
+ if (!noPanoramiXExtension) {
if (RegionNumRects(&pSprite->Reg2) > 1)
reg = &pSprite->Reg2;
- } else
+ }
+ else
#endif
{
if (wBoundingShape(pWin))
@@ -886,40 +858,38 @@ CheckVirtualMotion(
if (reg)
ConfineToShape(pDev, reg, &pSprite->hot.x, &pSprite->hot.y);
- if (qe && ev)
- {
- qe->pScreen = pSprite->hot.pScreen;
- ev->root_x = pSprite->hot.x;
- ev->root_y = pSprite->hot.y;
- }
+ if (qe && ev) {
+ qe->pScreen = pSprite->hot.pScreen;
+ ev->root_x = pSprite->hot.x;
+ ev->root_y = pSprite->hot.y;
+ }
}
#ifdef PANORAMIX
- if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */
+ if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */
#endif
RootWindow(pDev->spriteInfo->sprite) = pSprite->hot.pScreen->root;
}
static void
-ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, Bool confineToScreen)
+ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents,
+ Bool confineToScreen)
{
SpritePtr pSprite = pDev->spriteInfo->sprite;
- if (syncEvents.playingEvents)
- {
- CheckVirtualMotion(pDev, (QdEventPtr)NULL, pWin);
- SyntheticMotion(pDev, pSprite->hot.x, pSprite->hot.y);
+ if (syncEvents.playingEvents) {
+ CheckVirtualMotion(pDev, (QdEventPtr) NULL, pWin);
+ SyntheticMotion(pDev, pSprite->hot.x, pSprite->hot.y);
}
- else
- {
+ else {
#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
+ if (!noPanoramiXExtension) {
XineramaConfineCursorToWindow(pDev, pWin, generateEvents);
return;
}
#endif
- pSprite->hotLimits = *RegionExtents(&pWin->borderSize);
- pSprite->hotShape = wBoundingShape(pWin) ? &pWin->borderSize
- : NullRegion;
+ pSprite->hotLimits = *RegionExtents(&pWin->borderSize);
+ pSprite->hotShape = wBoundingShape(pWin) ? &pWin->borderSize
+ : NullRegion;
CheckPhysLimits(pDev, pSprite->current, generateEvents,
confineToScreen, pWin->drawable.pScreen);
}
@@ -944,12 +914,11 @@ ChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor)
SpritePtr pSprite = pDev->spriteInfo->sprite;
ScreenPtr pScreen;
- if (cursor != pSprite->current)
- {
- if ((pSprite->current->bits->xhot != cursor->bits->xhot) ||
- (pSprite->current->bits->yhot != cursor->bits->yhot))
- CheckPhysLimits(pDev, cursor, FALSE, pSprite->confined,
- (ScreenPtr)NULL);
+ if (cursor != pSprite->current) {
+ if ((pSprite->current->bits->xhot != cursor->bits->xhot) ||
+ (pSprite->current->bits->yhot != cursor->bits->yhot))
+ CheckPhysLimits(pDev, cursor, FALSE, pSprite->confined,
+ (ScreenPtr) NULL);
#ifdef PANORAMIX
/* XXX: is this really necessary?? (whot) */
if (!noPanoramiXExtension)
@@ -958,10 +927,10 @@ ChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor)
#endif
pScreen = pSprite->hotPhys.pScreen;
- (*pScreen->DisplayCursor)(pDev, pScreen, cursor);
- FreeCursor(pSprite->current, (Cursor)0);
- pSprite->current = cursor;
- pSprite->current->refcnt++;
+ (*pScreen->DisplayCursor) (pDev, pScreen, cursor);
+ FreeCursor(pSprite->current, (Cursor) 0);
+ pSprite->current = cursor;
+ pSprite->current->refcnt++;
}
}
@@ -972,7 +941,8 @@ Bool
IsParent(WindowPtr a, WindowPtr b)
{
for (b = b->parent; b; b = b->parent)
- if (b == a) return TRUE;
+ if (b == a)
+ return TRUE;
return FALSE;
}
@@ -986,42 +956,36 @@ PostNewCursor(DeviceIntPtr pDev)
{
WindowPtr win;
GrabPtr grab = pDev->deviceGrab.grab;
- SpritePtr pSprite = pDev->spriteInfo->sprite;
- CursorPtr pCursor;
+ SpritePtr pSprite = pDev->spriteInfo->sprite;
+ CursorPtr pCursor;
if (syncEvents.playingEvents)
- return;
- if (grab)
- {
- if (grab->cursor)
- {
- ChangeToCursor(pDev, grab->cursor);
- return;
- }
- if (IsParent(grab->window, pSprite->win))
- win = pSprite->win;
- else
- win = grab->window;
+ return;
+ if (grab) {
+ if (grab->cursor) {
+ ChangeToCursor(pDev, grab->cursor);
+ return;
+ }
+ if (IsParent(grab->window, pSprite->win))
+ win = pSprite->win;
+ else
+ win = grab->window;
}
else
- win = pSprite->win;
- for (; win; win = win->parent)
- {
- if (win->optional)
- {
+ win = pSprite->win;
+ for (; win; win = win->parent) {
+ if (win->optional) {
pCursor = WindowGetDeviceCursor(win, pDev);
if (!pCursor && win->optional->cursor != NullCursor)
pCursor = win->optional->cursor;
- if (pCursor)
- {
+ if (pCursor) {
ChangeToCursor(pDev, pCursor);
return;
}
- }
+ }
}
}
-
/**
* @param dev device which you want to know its current root window
* @return root window where dev's sprite is located
@@ -1057,6 +1021,7 @@ void
GetSpritePosition(DeviceIntPtr pDev, int *px, int *py)
{
SpritePtr pSprite = pDev->spriteInfo->sprite;
+
*px = pSprite->hotPhys.x;
*py = pSprite->hotPhys.y;
}
@@ -1065,15 +1030,16 @@ GetSpritePosition(DeviceIntPtr pDev, int *px, int *py)
int
XineramaGetCursorScreen(DeviceIntPtr pDev)
{
- if(!noPanoramiXExtension) {
- return pDev->spriteInfo->sprite->screen->myNum;
- } else {
- return 0;
+ if (!noPanoramiXExtension) {
+ return pDev->spriteInfo->sprite->screen->myNum;
+ }
+ else {
+ return 0;
}
}
-#endif /* PANORAMIX */
+#endif /* PANORAMIX */
-#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
+#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
static void
MonthChangedOrBadTime(InternalEvent *ev)
@@ -1083,25 +1049,26 @@ MonthChangedOrBadTime(InternalEvent *ev)
* backwards when it should not. Here we ensure a decent time.
*/
if ((currentTime.milliseconds - ev->any.time) > TIMESLOP)
- currentTime.months++;
+ currentTime.months++;
else
ev->any.time = currentTime.milliseconds;
}
static void
-NoticeTime(InternalEvent *ev)
+NoticeTime(InternalEvent *ev, DeviceIntPtr dev)
{
if (ev->any.time < currentTime.milliseconds)
MonthChangedOrBadTime(ev);
currentTime.milliseconds = ev->any.time;
- lastDeviceEventTime = currentTime;
+ lastDeviceEventTime[XIAllDevices] = currentTime;
+ lastDeviceEventTime[dev->id] = currentTime;
}
void
-NoticeEventTime(InternalEvent *ev)
+NoticeEventTime(InternalEvent *ev, DeviceIntPtr dev)
{
if (!syncEvents.playingEvents)
- NoticeTime(ev);
+ NoticeTime(ev, dev);
}
/**************************************************************************
@@ -1116,78 +1083,76 @@ NoticeEventTime(InternalEvent *ev)
void
EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
{
- QdEventPtr tail = NULL;
- QdEventPtr qe;
- SpritePtr pSprite = device->spriteInfo->sprite;
- int eventlen;
+ QdEventPtr tail = NULL;
+ QdEventPtr qe;
+ SpritePtr pSprite = device->spriteInfo->sprite;
+ int eventlen;
DeviceEvent *event = &ev->device_event;
if (!xorg_list_is_empty(&syncEvents.pending))
tail = xorg_list_last_entry(&syncEvents.pending, QdEventRec, next);
- NoticeTime((InternalEvent*)event);
+ NoticeTime((InternalEvent *)event, device);
/* Fix for key repeating bug. */
if (device->key != NULL && device->key->xkbInfo != NULL &&
event->type == ET_KeyRelease)
- AccessXCancelRepeatKey(device->key->xkbInfo, event->detail.key);
+ AccessXCancelRepeatKey(device->key->xkbInfo, event->detail.key);
+
+ if (DeviceEventCallback) {
+ DeviceEventInfoRec eventinfo;
+
+ /* The RECORD spec says that the root window field of motion events
+ * must be valid. At this point, it hasn't been filled in yet, so
+ * we do it here. The long expression below is necessary to get
+ * the current root window; the apparently reasonable alternative
+ * GetCurrentRootWindow()->drawable.id doesn't give you the right
+ * answer on the first motion event after a screen change because
+ * the data that GetCurrentRootWindow relies on hasn't been
+ * updated yet.
+ */
+ if (ev->any.type == ET_Motion)
+ ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
- if (DeviceEventCallback)
- {
- DeviceEventInfoRec eventinfo;
-
- /* The RECORD spec says that the root window field of motion events
- * must be valid. At this point, it hasn't been filled in yet, so
- * we do it here. The long expression below is necessary to get
- * the current root window; the apparently reasonable alternative
- * GetCurrentRootWindow()->drawable.id doesn't give you the right
- * answer on the first motion event after a screen change because
- * the data that GetCurrentRootWindow relies on hasn't been
- * updated yet.
- */
- if (ev->any.type == ET_Motion)
- ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
-
- eventinfo.event = ev;
- eventinfo.device = device;
- CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
- }
-
- if (event->type == ET_Motion)
- {
+ eventinfo.event = ev;
+ eventinfo.device = device;
+ CallCallbacks(&DeviceEventCallback, (pointer) &eventinfo);
+ }
+
+ if (event->type == ET_Motion) {
#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
- event->root_x += pSprite->screen->x - screenInfo.screens[0]->x;
- event->root_y += pSprite->screen->y - screenInfo.screens[0]->y;
- }
+ if (!noPanoramiXExtension) {
+ event->root_x += pSprite->screen->x - screenInfo.screens[0]->x;
+ event->root_y += pSprite->screen->y - screenInfo.screens[0]->y;
+ }
#endif
- pSprite->hotPhys.x = event->root_x;
- pSprite->hotPhys.y = event->root_y;
- /* do motion compression, but not if from different devices */
- if (tail &&
- (tail->event->any.type == ET_Motion) &&
+ pSprite->hotPhys.x = event->root_x;
+ pSprite->hotPhys.y = event->root_y;
+ /* do motion compression, but not if from different devices */
+ if (tail &&
+ (tail->event->any.type == ET_Motion) &&
(tail->device == device) &&
- (tail->pScreen == pSprite->hotPhys.pScreen))
- {
+ (tail->pScreen == pSprite->hotPhys.pScreen)) {
DeviceEvent *tailev = &tail->event->device_event;
- tailev->root_x = pSprite->hotPhys.x;
- tailev->root_y = pSprite->hotPhys.y;
- tailev->time = event->time;
- tail->months = currentTime.months;
- return;
- }
+
+ tailev->root_x = pSprite->hotPhys.x;
+ tailev->root_y = pSprite->hotPhys.y;
+ tailev->time = event->time;
+ tail->months = currentTime.months;
+ return;
+ }
}
eventlen = event->length;
qe = malloc(sizeof(QdEventRec) + eventlen);
if (!qe)
- return;
+ return;
xorg_list_init(&qe->next);
qe->device = device;
qe->pScreen = pSprite->hotPhys.pScreen;
qe->months = currentTime.months;
- qe->event = (InternalEvent *)(qe + 1);
+ qe->event = (InternalEvent *) (qe + 1);
memcpy(qe->event, event, eventlen);
xorg_list_append(&qe->next, &syncEvents.pending);
}
@@ -1209,53 +1174,52 @@ PlayReleasedEvents(void)
DeviceIntPtr dev;
DeviceIntPtr pDev;
-restart:
+ restart:
xorg_list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next) {
- if (!qe->device->deviceGrab.sync.frozen)
- {
- xorg_list_del(&qe->next);
- pDev = qe->device;
- if (qe->event->any.type == ET_Motion)
- CheckVirtualMotion(pDev, qe, NullWindow);
- syncEvents.time.months = qe->months;
+ if (!qe->device->deviceGrab.sync.frozen) {
+ xorg_list_del(&qe->next);
+ pDev = qe->device;
+ if (qe->event->any.type == ET_Motion)
+ CheckVirtualMotion(pDev, qe, NullWindow);
+ syncEvents.time.months = qe->months;
syncEvents.time.milliseconds = qe->event->any.time;
#ifdef PANORAMIX
- /* Translate back to the sprite screen since processInputProc
- will translate from sprite screen to screen 0 upon reentry
- to the DIX layer */
- if(!noPanoramiXExtension) {
+ /* Translate back to the sprite screen since processInputProc
+ will translate from sprite screen to screen 0 upon reentry
+ to the DIX layer */
+ if (!noPanoramiXExtension) {
DeviceEvent *ev = &qe->event->device_event;
- switch(ev->type)
- {
- case ET_Motion:
- case ET_ButtonPress:
- case ET_ButtonRelease:
- case ET_KeyPress:
- case ET_KeyRelease:
- case ET_ProximityIn:
- case ET_ProximityOut:
- ev->root_x += screenInfo.screens[0]->x -
- pDev->spriteInfo->sprite->screen->x;
- ev->root_y += screenInfo.screens[0]->y -
- pDev->spriteInfo->sprite->screen->y;
- break;
- default:
- break;
+
+ switch (ev->type) {
+ case ET_Motion:
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ case ET_KeyPress:
+ case ET_KeyRelease:
+ case ET_ProximityIn:
+ case ET_ProximityOut:
+ ev->root_x += screenInfo.screens[0]->x -
+ pDev->spriteInfo->sprite->screen->x;
+ ev->root_y += screenInfo.screens[0]->y -
+ pDev->spriteInfo->sprite->screen->y;
+ break;
+ default:
+ break;
}
- }
+ }
#endif
- (*qe->device->public.processInputProc)(qe->event, qe->device);
- free(qe);
- for (dev = inputInfo.devices; dev && dev->deviceGrab.sync.frozen; dev = dev->next)
- ;
- if (!dev)
- break;
-
- /* Playing the event may have unfrozen another device. */
- /* So to play it safe, restart at the head of the queue */
- goto restart;
- }
+ (*qe->device->public.processInputProc) (qe->event, qe->device);
+ free(qe);
+ for (dev = inputInfo.devices; dev && dev->deviceGrab.sync.frozen;
+ dev = dev->next);
+ if (!dev)
+ break;
+
+ /* Playing the event may have unfrozen another device. */
+ /* So to play it safe, restart at the head of the queue */
+ goto restart;
+ }
}
}
@@ -1272,9 +1236,9 @@ FreezeThaw(DeviceIntPtr dev, Bool frozen)
{
dev->deviceGrab.sync.frozen = frozen;
if (frozen)
- dev->public.processInputProc = dev->public.enqueueInputProc;
+ dev->public.processInputProc = dev->public.enqueueInputProc;
else
- dev->public.processInputProc = dev->public.realInputProc;
+ dev->public.processInputProc = dev->public.realInputProc;
}
/**
@@ -1294,66 +1258,64 @@ ComputeFreezes(void)
DeviceIntPtr dev;
for (dev = inputInfo.devices; dev; dev = dev->next)
- FreezeThaw(dev, dev->deviceGrab.sync.other ||
- (dev->deviceGrab.sync.state >= FROZEN));
+ FreezeThaw(dev, dev->deviceGrab.sync.other ||
+ (dev->deviceGrab.sync.state >= FROZEN));
if (syncEvents.playingEvents ||
(!replayDev && xorg_list_is_empty(&syncEvents.pending)))
- return;
+ return;
syncEvents.playingEvents = TRUE;
- if (replayDev)
- {
- DeviceEvent* event = replayDev->deviceGrab.sync.event;
+ if (replayDev) {
+ DeviceEvent *event = replayDev->deviceGrab.sync.event;
- syncEvents.replayDev = (DeviceIntPtr)NULL;
+ syncEvents.replayDev = (DeviceIntPtr) NULL;
w = XYToWindow(replayDev->spriteInfo->sprite,
event->root_x, event->root_y);
- if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin))
- {
- if (IsTouchEvent((InternalEvent*)event))
- {
+ if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin)) {
+ if (IsTouchEvent((InternalEvent *) event)) {
InternalEvent *events = InitEventList(GetMaximumEventsNum());
int i, nev;
- TouchPointInfoPtr ti = TouchFindByClientID(replayDev, event->touchid);
+ TouchPointInfoPtr ti =
+ TouchFindByClientID(replayDev, event->touchid);
BUG_WARN(!ti);
- nev = GetTouchOwnershipEvents(events, replayDev, ti, XIRejectTouch, ti->listeners[0].listener, 0);
+ nev =
+ GetTouchOwnershipEvents(events, replayDev, ti,
+ XIRejectTouch,
+ ti->listeners[0].listener, 0);
for (i = 0; i < nev; i++)
mieqProcessDeviceEvent(replayDev, events + i, NULL);
ProcessInputEvents();
- } else if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
- DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
+ }
+ else if (replayDev->focus &&
+ !IsPointerEvent((InternalEvent *) event))
+ DeliverFocusedEvent(replayDev, (InternalEvent *) event, w);
else
- DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
+ DeliverDeviceEvents(w, (InternalEvent *) event, NullGrab,
NullWindow, replayDev);
}
}
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!dev->deviceGrab.sync.frozen)
- {
- PlayReleasedEvents();
- break;
- }
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (!dev->deviceGrab.sync.frozen) {
+ PlayReleasedEvents();
+ break;
+ }
}
syncEvents.playingEvents = FALSE;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (DevHasCursor(dev))
- {
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (DevHasCursor(dev)) {
/* the following may have been skipped during replay,
- so do it now */
- if ((grab = dev->deviceGrab.grab) && grab->confineTo)
- {
+ so do it now */
+ if ((grab = dev->deviceGrab.grab) && grab->confineTo) {
if (grab->confineTo->drawable.pScreen !=
- dev->spriteInfo->sprite->hotPhys.pScreen)
+ dev->spriteInfo->sprite->hotPhys.pScreen)
dev->spriteInfo->sprite->hotPhys.x =
dev->spriteInfo->sprite->hotPhys.y = 0;
ConfineCursorToWindow(dev, grab->confineTo, TRUE, TRUE);
}
else
ConfineCursorToWindow(dev,
- dev->spriteInfo->sprite->hotPhys.pScreen->root,
- TRUE, FALSE);
+ dev->spriteInfo->sprite->hotPhys.pScreen->
+ root, TRUE, FALSE);
PostNewCursor(dev);
}
}
@@ -1361,29 +1323,28 @@ ComputeFreezes(void)
#ifdef RANDR
void
-ScreenRestructured (ScreenPtr pScreen)
+ScreenRestructured(ScreenPtr pScreen)
{
GrabPtr grab;
DeviceIntPtr pDev;
- for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
- {
+ for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if (!IsFloating(pDev) && !DevHasCursor(pDev))
continue;
/* GrabDevice doesn't have a confineTo field, so we don't need to
* worry about it. */
- if ((grab = pDev->deviceGrab.grab) && grab->confineTo)
- {
+ if ((grab = pDev->deviceGrab.grab) && grab->confineTo) {
if (grab->confineTo->drawable.pScreen
- != pDev->spriteInfo->sprite->hotPhys.pScreen)
- pDev->spriteInfo->sprite->hotPhys.x = pDev->spriteInfo->sprite->hotPhys.y = 0;
+ != pDev->spriteInfo->sprite->hotPhys.pScreen)
+ pDev->spriteInfo->sprite->hotPhys.x =
+ pDev->spriteInfo->sprite->hotPhys.y = 0;
ConfineCursorToWindow(pDev, grab->confineTo, TRUE, TRUE);
}
else
ConfineCursorToWindow(pDev,
- pDev->spriteInfo->sprite->hotPhys.pScreen->root,
- TRUE, FALSE);
+ pDev->spriteInfo->sprite->hotPhys.pScreen->
+ root, TRUE, FALSE);
}
}
#endif
@@ -1395,26 +1356,23 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
DeviceIntPtr dev;
if (thisMode == GrabModeSync)
- thisDev->deviceGrab.sync.state = FROZEN_NO_EVENT;
- else
- { /* free both if same client owns both */
- thisDev->deviceGrab.sync.state = THAWED;
- if (thisDev->deviceGrab.sync.other &&
- (CLIENT_BITS(thisDev->deviceGrab.sync.other->resource) ==
- CLIENT_BITS(grab->resource)))
- thisDev->deviceGrab.sync.other = NullGrab;
+ thisDev->deviceGrab.sync.state = FROZEN_NO_EVENT;
+ else { /* free both if same client owns both */
+ thisDev->deviceGrab.sync.state = THAWED;
+ if (thisDev->deviceGrab.sync.other &&
+ (CLIENT_BITS(thisDev->deviceGrab.sync.other->resource) ==
+ CLIENT_BITS(grab->resource)))
+ thisDev->deviceGrab.sync.other = NullGrab;
}
- if (IsMaster(thisDev))
- {
+ if (IsMaster(thisDev)) {
dev = GetPairedDevice(thisDev);
if (otherMode == GrabModeSync)
dev->deviceGrab.sync.other = grab;
- else
- { /* free both if same client owns both */
+ else { /* free both if same client owns both */
if (dev->deviceGrab.sync.other &&
- (CLIENT_BITS(dev->deviceGrab.sync.other->resource) ==
- CLIENT_BITS(grab->resource)))
+ (CLIENT_BITS(dev->deviceGrab.sync.other->resource) ==
+ CLIENT_BITS(grab->resource)))
dev->deviceGrab.sync.other = NullGrab;
}
}
@@ -1451,10 +1409,9 @@ ReattachToOldMaster(DeviceIntPtr dev)
dixLookupDevice(&master, dev->saved_master_id, serverClient, DixUseAccess);
- if (master)
- {
+ if (master) {
AttachDevice(serverClient, dev, master);
- dev->saved_master_id = 0;
+ dev->saved_master_id = 0;
}
}
@@ -1479,8 +1436,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
{
GrabInfoPtr grabinfo = &mouse->deviceGrab;
WindowPtr oldWin = (grabinfo->grab) ?
- grabinfo->grab->window
- : mouse->spriteInfo->sprite->win;
+ grabinfo->grab->window : mouse->spriteInfo->sprite->win;
Bool isPassive = autoGrab & ~ImplicitGrabMask;
/* slave devices need to float for the duration of the grab. */
@@ -1488,28 +1444,28 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
!(autoGrab & ImplicitGrabMask) && !IsMaster(mouse))
DetachFromMaster(mouse);
- if (grab->confineTo)
- {
- if (grab->confineTo->drawable.pScreen
- != mouse->spriteInfo->sprite->hotPhys.pScreen)
- mouse->spriteInfo->sprite->hotPhys.x =
+ if (grab->confineTo) {
+ if (grab->confineTo->drawable.pScreen
+ != mouse->spriteInfo->sprite->hotPhys.pScreen)
+ mouse->spriteInfo->sprite->hotPhys.x =
mouse->spriteInfo->sprite->hotPhys.y = 0;
- ConfineCursorToWindow(mouse, grab->confineTo, FALSE, TRUE);
+ ConfineCursorToWindow(mouse, grab->confineTo, FALSE, TRUE);
}
DoEnterLeaveEvents(mouse, mouse->id, oldWin, grab->window, NotifyGrab);
mouse->valuator->motionHintWindow = NullWindow;
if (syncEvents.playingEvents)
grabinfo->grabTime = syncEvents.time;
else
- grabinfo->grabTime = time;
+ grabinfo->grabTime = time;
if (grab->cursor)
- grab->cursor->refcnt++;
+ grab->cursor->refcnt++;
CopyGrab(grabinfo->activeGrab, grab);
grabinfo->grab = grabinfo->activeGrab;
grabinfo->fromPassiveGrab = isPassive;
grabinfo->implicitGrab = autoGrab & ImplicitGrabMask;
PostNewCursor(mouse);
- CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
+ CheckGrabForSyncs(mouse, (Bool) grab->pointerMode,
+ (Bool) grab->keyboardMode);
}
/**
@@ -1532,18 +1488,17 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
mouse->deviceGrab.sync.state = NOT_GRABBED;
mouse->deviceGrab.fromPassiveGrab = FALSE;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->deviceGrab.sync.other == grab)
- dev->deviceGrab.sync.other = NullGrab;
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (dev->deviceGrab.sync.other == grab)
+ dev->deviceGrab.sync.other = NullGrab;
}
DoEnterLeaveEvents(mouse, mouse->id, grab->window,
mouse->spriteInfo->sprite->win, NotifyUngrab);
if (grab->confineTo)
- ConfineCursorToWindow(mouse, GetCurrentRootWindow(mouse), FALSE, FALSE);
+ ConfineCursorToWindow(mouse, GetCurrentRootWindow(mouse), FALSE, FALSE);
PostNewCursor(mouse);
if (grab->cursor)
- FreeCursor(grab->cursor, (Cursor)0);
+ FreeCursor(grab->cursor, (Cursor) 0);
if (!wasImplicit && grab->grabtype == XI2)
ReattachToOldMaster(mouse);
@@ -1557,37 +1512,38 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
* Extension devices have ActivateKeyboardGrab() set as their grabbing proc.
*/
void
-ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive)
+ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time,
+ Bool passive)
{
GrabInfoPtr grabinfo = &keybd->deviceGrab;
WindowPtr oldWin;
/* slave devices need to float for the duration of the grab. */
if (grab->grabtype == XI2 &&
- !(passive & ImplicitGrabMask) &&
- !IsMaster(keybd))
+ !(passive & ImplicitGrabMask) && !IsMaster(keybd))
DetachFromMaster(keybd);
if (grabinfo->grab)
- oldWin = grabinfo->grab->window;
+ oldWin = grabinfo->grab->window;
else if (keybd->focus)
- oldWin = keybd->focus->win;
+ oldWin = keybd->focus->win;
else
- oldWin = keybd->spriteInfo->sprite->win;
+ oldWin = keybd->spriteInfo->sprite->win;
if (oldWin == FollowKeyboardWin)
- oldWin = keybd->focus->win;
+ oldWin = keybd->focus->win;
if (keybd->valuator)
- keybd->valuator->motionHintWindow = NullWindow;
+ keybd->valuator->motionHintWindow = NullWindow;
DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);
if (syncEvents.playingEvents)
- grabinfo->grabTime = syncEvents.time;
+ grabinfo->grabTime = syncEvents.time;
else
- grabinfo->grabTime = time;
+ grabinfo->grabTime = time;
CopyGrab(grabinfo->activeGrab, grab);
grabinfo->grab = grabinfo->activeGrab;
grabinfo->fromPassiveGrab = passive;
grabinfo->implicitGrab = passive & ImplicitGrabMask;
- CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
+ CheckGrabForSyncs(keybd, (Bool) grab->keyboardMode,
+ (Bool) grab->pointerMode);
}
/**
@@ -1599,22 +1555,21 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd)
GrabPtr grab = keybd->deviceGrab.grab;
DeviceIntPtr dev;
WindowPtr focusWin = keybd->focus ? keybd->focus->win
- : keybd->spriteInfo->sprite->win;
+ : keybd->spriteInfo->sprite->win;
Bool wasImplicit = (keybd->deviceGrab.fromPassiveGrab &&
keybd->deviceGrab.implicitGrab);
if (focusWin == FollowKeyboardWin)
- focusWin = inputInfo.keyboard->focus->win;
+ focusWin = inputInfo.keyboard->focus->win;
if (keybd->valuator)
- keybd->valuator->motionHintWindow = NullWindow;
+ keybd->valuator->motionHintWindow = NullWindow;
keybd->deviceGrab.grab = NullGrab;
keybd->deviceGrab.sync.state = NOT_GRABBED;
keybd->deviceGrab.fromPassiveGrab = FALSE;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->deviceGrab.sync.other == grab)
- dev->deviceGrab.sync.other = NullGrab;
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (dev->deviceGrab.sync.other == grab)
+ dev->deviceGrab.sync.other = NullGrab;
}
DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
@@ -1625,124 +1580,106 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd)
}
void
-AllowSome(ClientPtr client,
- TimeStamp time,
- DeviceIntPtr thisDev,
- int newState)
+AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
{
Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced;
TimeStamp grabTime;
DeviceIntPtr dev;
- GrabInfoPtr devgrabinfo,
- grabinfo = &thisDev->deviceGrab;
+ GrabInfoPtr devgrabinfo, grabinfo = &thisDev->deviceGrab;
thisGrabbed = grabinfo->grab && SameClient(grabinfo->grab, client);
thisSynced = FALSE;
otherGrabbed = FALSE;
othersFrozen = FALSE;
grabTime = grabinfo->grabTime;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
devgrabinfo = &dev->deviceGrab;
- if (dev == thisDev)
- continue;
- if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client))
- {
- if (!(thisGrabbed || otherGrabbed) ||
- (CompareTimeStamps(devgrabinfo->grabTime, grabTime) == LATER))
- grabTime = devgrabinfo->grabTime;
- otherGrabbed = TRUE;
- if (grabinfo->sync.other == devgrabinfo->grab)
- thisSynced = TRUE;
- if (devgrabinfo->sync.state >= FROZEN)
- othersFrozen = TRUE;
- }
+ if (dev == thisDev)
+ continue;
+ if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client)) {
+ if (!(thisGrabbed || otherGrabbed) ||
+ (CompareTimeStamps(devgrabinfo->grabTime, grabTime) == LATER))
+ grabTime = devgrabinfo->grabTime;
+ otherGrabbed = TRUE;
+ if (grabinfo->sync.other == devgrabinfo->grab)
+ thisSynced = TRUE;
+ if (devgrabinfo->sync.state >= FROZEN)
+ othersFrozen = TRUE;
+ }
}
if (!((thisGrabbed && grabinfo->sync.state >= FROZEN) || thisSynced))
- return;
+ return;
if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, grabTime) == EARLIER))
- return;
- switch (newState)
- {
- case THAWED: /* Async */
- if (thisGrabbed)
- grabinfo->sync.state = THAWED;
- if (thisSynced)
- grabinfo->sync.other = NullGrab;
- ComputeFreezes();
- break;
- case FREEZE_NEXT_EVENT: /* Sync */
- if (thisGrabbed)
- {
- grabinfo->sync.state = FREEZE_NEXT_EVENT;
- if (thisSynced)
- grabinfo->sync.other = NullGrab;
- ComputeFreezes();
- }
- break;
- case THAWED_BOTH: /* AsyncBoth */
- if (othersFrozen)
- {
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- devgrabinfo = &dev->deviceGrab;
- if (devgrabinfo->grab
- && SameClient(devgrabinfo->grab, client))
- devgrabinfo->sync.state = THAWED;
- if (devgrabinfo->sync.other &&
- SameClient(devgrabinfo->sync.other, client))
- devgrabinfo->sync.other = NullGrab;
- }
- ComputeFreezes();
- }
- break;
- case FREEZE_BOTH_NEXT_EVENT: /* SyncBoth */
- if (othersFrozen)
- {
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- devgrabinfo = &dev->deviceGrab;
- if (devgrabinfo->grab
- && SameClient(devgrabinfo->grab, client))
- devgrabinfo->sync.state = FREEZE_BOTH_NEXT_EVENT;
- if (devgrabinfo->sync.other
- && SameClient(devgrabinfo->sync.other, client))
- devgrabinfo->sync.other = NullGrab;
- }
- ComputeFreezes();
- }
- break;
- case NOT_GRABBED: /* Replay */
- if (thisGrabbed && grabinfo->sync.state == FROZEN_WITH_EVENT)
- {
- if (thisSynced)
- grabinfo->sync.other = NullGrab;
- syncEvents.replayDev = thisDev;
- syncEvents.replayWin = grabinfo->grab->window;
- (*grabinfo->DeactivateGrab)(thisDev);
- syncEvents.replayDev = (DeviceIntPtr)NULL;
- }
- break;
- case THAW_OTHERS: /* AsyncOthers */
- if (othersFrozen)
- {
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev == thisDev)
- continue;
- devgrabinfo = &dev->deviceGrab;
- if (devgrabinfo->grab
- && SameClient(devgrabinfo->grab, client))
- devgrabinfo->sync.state = THAWED;
- if (devgrabinfo->sync.other
- && SameClient(devgrabinfo->sync.other, client))
- devgrabinfo->sync.other = NullGrab;
- }
- ComputeFreezes();
- }
- break;
+ (CompareTimeStamps(time, grabTime) == EARLIER))
+ return;
+ switch (newState) {
+ case THAWED: /* Async */
+ if (thisGrabbed)
+ grabinfo->sync.state = THAWED;
+ if (thisSynced)
+ grabinfo->sync.other = NullGrab;
+ ComputeFreezes();
+ break;
+ case FREEZE_NEXT_EVENT: /* Sync */
+ if (thisGrabbed) {
+ grabinfo->sync.state = FREEZE_NEXT_EVENT;
+ if (thisSynced)
+ grabinfo->sync.other = NullGrab;
+ ComputeFreezes();
+ }
+ break;
+ case THAWED_BOTH: /* AsyncBoth */
+ if (othersFrozen) {
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ devgrabinfo = &dev->deviceGrab;
+ if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client))
+ devgrabinfo->sync.state = THAWED;
+ if (devgrabinfo->sync.other &&
+ SameClient(devgrabinfo->sync.other, client))
+ devgrabinfo->sync.other = NullGrab;
+ }
+ ComputeFreezes();
+ }
+ break;
+ case FREEZE_BOTH_NEXT_EVENT: /* SyncBoth */
+ if (othersFrozen) {
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ devgrabinfo = &dev->deviceGrab;
+ if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client))
+ devgrabinfo->sync.state = FREEZE_BOTH_NEXT_EVENT;
+ if (devgrabinfo->sync.other
+ && SameClient(devgrabinfo->sync.other, client))
+ devgrabinfo->sync.other = NullGrab;
+ }
+ ComputeFreezes();
+ }
+ break;
+ case NOT_GRABBED: /* Replay */
+ if (thisGrabbed && grabinfo->sync.state == FROZEN_WITH_EVENT) {
+ if (thisSynced)
+ grabinfo->sync.other = NullGrab;
+ syncEvents.replayDev = thisDev;
+ syncEvents.replayWin = grabinfo->grab->window;
+ (*grabinfo->DeactivateGrab) (thisDev);
+ syncEvents.replayDev = (DeviceIntPtr) NULL;
+ }
+ break;
+ case THAW_OTHERS: /* AsyncOthers */
+ if (othersFrozen) {
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (dev == thisDev)
+ continue;
+ devgrabinfo = &dev->deviceGrab;
+ if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client))
+ devgrabinfo->sync.state = THAWED;
+ if (devgrabinfo->sync.other
+ && SameClient(devgrabinfo->sync.other, client))
+ devgrabinfo->sync.other = NullGrab;
+ }
+ ComputeFreezes();
+ }
+ break;
}
}
@@ -1754,9 +1691,10 @@ AllowSome(ClientPtr client,
int
ProcAllowEvents(ClientPtr client)
{
- TimeStamp time;
- DeviceIntPtr mouse = NULL;
- DeviceIntPtr keybd = NULL;
+ TimeStamp time;
+ DeviceIntPtr mouse = NULL;
+ DeviceIntPtr keybd = NULL;
+
REQUEST(xAllowEventsReq);
REQUEST_SIZE_MATCH(xAllowEventsReq);
@@ -1765,35 +1703,34 @@ ProcAllowEvents(ClientPtr client)
mouse = PickPointer(client);
keybd = PickKeyboard(client);
- switch (stuff->mode)
- {
- case ReplayPointer:
- AllowSome(client, time, mouse, NOT_GRABBED);
- break;
- case SyncPointer:
- AllowSome(client, time, mouse, FREEZE_NEXT_EVENT);
- break;
- case AsyncPointer:
- AllowSome(client, time, mouse, THAWED);
- break;
- case ReplayKeyboard:
- AllowSome(client, time, keybd, NOT_GRABBED);
- break;
- case SyncKeyboard:
- AllowSome(client, time, keybd, FREEZE_NEXT_EVENT);
- break;
- case AsyncKeyboard:
- AllowSome(client, time, keybd, THAWED);
- break;
- case SyncBoth:
- AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT);
- break;
- case AsyncBoth:
- AllowSome(client, time, keybd, THAWED_BOTH);
- break;
- default:
- client->errorValue = stuff->mode;
- return BadValue;
+ switch (stuff->mode) {
+ case ReplayPointer:
+ AllowSome(client, time, mouse, NOT_GRABBED);
+ break;
+ case SyncPointer:
+ AllowSome(client, time, mouse, FREEZE_NEXT_EVENT);
+ break;
+ case AsyncPointer:
+ AllowSome(client, time, mouse, THAWED);
+ break;
+ case ReplayKeyboard:
+ AllowSome(client, time, keybd, NOT_GRABBED);
+ break;
+ case SyncKeyboard:
+ AllowSome(client, time, keybd, FREEZE_NEXT_EVENT);
+ break;
+ case AsyncKeyboard:
+ AllowSome(client, time, keybd, THAWED);
+ break;
+ case SyncBoth:
+ AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT);
+ break;
+ case AsyncBoth:
+ AllowSome(client, time, keybd, THAWED_BOTH);
+ break;
+ default:
+ client->errorValue = stuff->mode;
+ return BadValue;
}
return Success;
}
@@ -1805,21 +1742,20 @@ void
ReleaseActiveGrabs(ClientPtr client)
{
DeviceIntPtr dev;
- Bool done;
+ Bool done;
/* XXX CloseDownClient should remove passive grabs before
* releasing active grabs.
*/
do {
- done = TRUE;
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->deviceGrab.grab && SameClient(dev->deviceGrab.grab, client))
- {
- (*dev->deviceGrab.DeactivateGrab)(dev);
- done = FALSE;
- }
- }
+ done = TRUE;
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (dev->deviceGrab.grab &&
+ SameClient(dev->deviceGrab.grab, client)) {
+ (*dev->deviceGrab.DeactivateGrab) (dev);
+ done = FALSE;
+ }
+ }
} while (!done);
}
@@ -1853,8 +1789,8 @@ ReleaseActiveGrabs(ClientPtr client)
* client.
*/
int
-TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
- int count, Mask mask, Mask filter, GrabPtr grab)
+TryClientEvents(ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
+ int count, Mask mask, Mask filter, GrabPtr grab)
{
int type;
@@ -1872,75 +1808,66 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
return 0;
}
- if (filter != CantBeFiltered && !(mask & filter))
- {
- #ifdef DEBUG_EVENTS
+ if (filter != CantBeFiltered && !(mask & filter)) {
+#ifdef DEBUG_EVENTS
ErrorF(" filtered\n");
- #endif
+#endif
return 0;
}
- if (grab && !SameClient(grab, client))
- {
+ if (grab && !SameClient(grab, client)) {
#ifdef DEBUG_EVENTS
ErrorF(" not delivered due to grab\n");
#endif
- return -1; /* don't send, but notify caller */
+ return -1; /* don't send, but notify caller */
}
type = pEvents->u.u.type;
- if (type == MotionNotify)
- {
- if (mask & PointerMotionHintMask)
- {
+ if (type == MotionNotify) {
+ if (mask & PointerMotionHintMask) {
if (WID(dev->valuator->motionHintWindow) ==
- pEvents->u.keyButtonPointer.event)
- {
+ pEvents->u.keyButtonPointer.event) {
#ifdef DEBUG_EVENTS
ErrorF("[dix] \n");
ErrorF("[dix] motionHintWindow == keyButtonPointer.event\n");
#endif
- return 1; /* don't send, but pretend we did */
+ return 1; /* don't send, but pretend we did */
}
pEvents->u.u.detail = NotifyHint;
}
- else
- {
+ else {
pEvents->u.u.detail = NotifyNormal;
}
}
- else if (type == DeviceMotionNotify)
- {
- if (MaybeSendDeviceMotionNotifyHint((deviceKeyButtonPointer*)pEvents,
+ else if (type == DeviceMotionNotify) {
+ if (MaybeSendDeviceMotionNotifyHint((deviceKeyButtonPointer *) pEvents,
mask) != 0)
return 1;
- } else if (type == KeyPress)
- {
- if (EventIsKeyRepeat(pEvents))
- {
- if (!_XkbWantsDetectableAutoRepeat(client))
- {
+ }
+ else if (type == KeyPress) {
+ if (EventIsKeyRepeat(pEvents)) {
+ if (!_XkbWantsDetectableAutoRepeat(client)) {
xEvent release = *pEvents;
+
release.u.u.type = KeyRelease;
WriteEventsToClient(client, 1, &release);
#ifdef DEBUG_EVENTS
ErrorF(" (plus fake core release for repeat)");
#endif
- } else
- {
+ }
+ else {
#ifdef DEBUG_EVENTS
ErrorF(" (detectable autorepeat for core)");
#endif
}
}
- } else if (type == DeviceKeyPress)
- {
- if (EventIsKeyRepeat(pEvents))
- {
- if (!_XkbWantsDetectableAutoRepeat(client))
- {
- deviceKeyButtonPointer release = *(deviceKeyButtonPointer *)pEvents;
+ }
+ else if (type == DeviceKeyPress) {
+ if (EventIsKeyRepeat(pEvents)) {
+ if (!_XkbWantsDetectableAutoRepeat(client)) {
+ deviceKeyButtonPointer release =
+ *(deviceKeyButtonPointer *) pEvents;
release.type = DeviceKeyRelease;
#ifdef DEBUG_EVENTS
ErrorF(" (plus fake xi1 release for repeat)");
@@ -1955,8 +1882,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
}
}
- if (BitIsOn(criticalEvents, type))
- {
+ if (BitIsOn(criticalEvents, type)) {
if (client->smart_priority < SMART_MAX_PRIORITY)
client->smart_priority++;
SetCriticalOutputPending();
@@ -2005,13 +1931,13 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
/* get the XI and XI2 device mask */
inputMasks = wOtherInputMasks(win);
- tempGrab->deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
+ tempGrab->deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id] : 0;
if (inputMasks)
xi2mask_merge(tempGrab->xi2mask, inputMasks->xi2mask);
- (*dev->deviceGrab.ActivateGrab)(dev, tempGrab,
- currentTime, TRUE | ImplicitGrabMask);
+ (*dev->deviceGrab.ActivateGrab) (dev, tempGrab,
+ currentTime, TRUE | ImplicitGrabMask);
FreeGrab(tempGrab);
return TRUE;
}
@@ -2021,22 +1947,21 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
*/
static enum EventDeliveryState
DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
- xEvent *events, int count, Mask filter,
- GrabPtr grab)
+ xEvent *events, int count, Mask filter, GrabPtr grab)
{
/* if nobody ever wants to see this event, skip some work */
if (filter != CantBeFiltered &&
- !((wOtherEventMasks(win)|win->eventMask) & filter))
+ !((wOtherEventMasks(win) | win->eventMask) & filter))
return EVENT_SKIP;
if (IsInterferingGrab(wClient(win), dev, events))
return EVENT_SKIP;
- if (!XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count))
- {
+ if (!XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count)) {
int attempt = TryClientEvents(wClient(win), dev, events,
count, win->eventMask,
filter, grab);
+
if (attempt > 0)
return EVENT_DELIVERED;
if (attempt < 0)
@@ -2046,7 +1971,6 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
return EVENT_NOT_DELIVERED;
}
-
/**
* Get the list of clients that should be tried for event delivery on the
* given window.
@@ -2056,31 +1980,32 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
*/
static Bool
GetClientsForDelivery(DeviceIntPtr dev, WindowPtr win,
- xEvent *events, Mask filter, InputClients **clients)
+ xEvent *events, Mask filter, InputClients ** clients)
{
int rc = 0;
if (core_get_type(events) != 0)
- *clients = (InputClients *)wOtherClients(win);
- else if (xi2_get_type(events) != 0)
- {
+ *clients = (InputClients *) wOtherClients(win);
+ else if (xi2_get_type(events) != 0) {
OtherInputMasks *inputMasks = wOtherInputMasks(win);
+
/* Has any client selected for the event? */
if (!WindowXI2MaskIsset(dev, win, events))
goto out;
*clients = inputMasks->inputClients;
- } else {
+ }
+ else {
OtherInputMasks *inputMasks = wOtherInputMasks(win);
+
/* Has any client selected for the event? */
- if (!inputMasks ||
- !(inputMasks->inputEvents[dev->id] & filter))
+ if (!inputMasks || !(inputMasks->inputEvents[dev->id] & filter))
goto out;
*clients = inputMasks->inputClients;
}
rc = 1;
-out:
+ out:
return rc;
}
@@ -2089,7 +2014,7 @@ out:
* accepts it and there is no interfering core grab..
*/
static enum EventDeliveryState
-DeliverEventToInputClients(DeviceIntPtr dev, InputClients *inputclients,
+DeliverEventToInputClients(DeviceIntPtr dev, InputClients * inputclients,
WindowPtr win, xEvent *events,
int count, Mask filter, GrabPtr grab,
ClientPtr *client_return, Mask *mask_return)
@@ -2097,8 +2022,7 @@ DeliverEventToInputClients(DeviceIntPtr dev, InputClients *inputclients,
int attempt;
enum EventDeliveryState rc = EVENT_NOT_DELIVERED;
- for (; inputclients; inputclients = inputclients->next)
- {
+ for (; inputclients; inputclients = inputclients->next) {
Mask mask;
ClientPtr client = rClient(inputclients);
@@ -2107,21 +2031,19 @@ DeliverEventToInputClients(DeviceIntPtr dev, InputClients *inputclients,
mask = GetEventMask(dev, events, inputclients);
- if (XaceHook(XACE_RECEIVE_ACCESS, client, win,
- events, count))
- /* do nothing */;
- else if ( (attempt = TryClientEvents(client, dev,
- events, count,
- mask, filter, grab)) )
- {
- if (attempt > 0)
- {
+ if (XaceHook(XACE_RECEIVE_ACCESS, client, win, events, count))
+ /* do nothing */ ;
+ else if ((attempt = TryClientEvents(client, dev,
+ events, count,
+ mask, filter, grab))) {
+ if (attempt > 0) {
rc = EVENT_DELIVERED;
*client_return = client;
*mask_return = mask;
/* Success overrides non-success, so if we've been
* successful on one client, return that */
- } else if (rc == EVENT_NOT_DELIVERED)
+ }
+ else if (rc == EVENT_NOT_DELIVERED)
rc = EVENT_REJECTED;
}
}
@@ -2129,7 +2051,6 @@ DeliverEventToInputClients(DeviceIntPtr dev, InputClients *inputclients,
return rc;
}
-
/**
* Deliver events to clients registered on the window.
*
@@ -2152,7 +2073,6 @@ DeliverEventToWindowMask(DeviceIntPtr dev, WindowPtr win, xEvent *events,
}
-
/**
* Deliver events to a window. At this point, we do not yet know if the event
* actually needs to be delivered. May activate a grab if the event is a
@@ -2177,77 +2097,73 @@ DeliverEventToWindowMask(DeviceIntPtr dev, WindowPtr win, xEvent *events,
*/
int
DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
- *pEvents, int count, Mask filter, GrabPtr grab)
+ *pEvents, int count, Mask filter, GrabPtr grab)
{
int deliveries = 0, nondeliveries = 0;
ClientPtr client = NullClient;
- Mask deliveryMask = 0; /* If a grab occurs due to a button press, then
- this mask is the mask of the grab. */
+ Mask deliveryMask = 0; /* If a grab occurs due to a button press, then
+ this mask is the mask of the grab. */
int type = pEvents->u.u.type;
/* Deliver to window owner */
- if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0)
- {
+ if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0) {
enum EventDeliveryState rc;
rc = DeliverToWindowOwner(pDev, pWin, pEvents, count, filter, grab);
- switch(rc)
- {
- case EVENT_SKIP:
- return 0;
- case EVENT_REJECTED:
- nondeliveries--;
- break;
- case EVENT_DELIVERED:
- /* We delivered to the owner, with our event mask */
- deliveries++;
- client = wClient(pWin);
- deliveryMask = pWin->eventMask;
- break;
- case EVENT_NOT_DELIVERED:
- break;
+ switch (rc) {
+ case EVENT_SKIP:
+ return 0;
+ case EVENT_REJECTED:
+ nondeliveries--;
+ break;
+ case EVENT_DELIVERED:
+ /* We delivered to the owner, with our event mask */
+ deliveries++;
+ client = wClient(pWin);
+ deliveryMask = pWin->eventMask;
+ break;
+ case EVENT_NOT_DELIVERED:
+ break;
}
}
/* CantBeFiltered means only window owner gets the event */
- if (filter != CantBeFiltered)
- {
+ if (filter != CantBeFiltered) {
enum EventDeliveryState rc;
rc = DeliverEventToWindowMask(pDev, pWin, pEvents, count, filter,
grab, &client, &deliveryMask);
- switch(rc)
- {
- case EVENT_SKIP:
- return 0;
- case EVENT_REJECTED:
- nondeliveries--;
- break;
- case EVENT_DELIVERED:
- deliveries++;
- break;
- case EVENT_NOT_DELIVERED:
- break;
+ switch (rc) {
+ case EVENT_SKIP:
+ return 0;
+ case EVENT_REJECTED:
+ nondeliveries--;
+ break;
+ case EVENT_DELIVERED:
+ deliveries++;
+ break;
+ case EVENT_NOT_DELIVERED:
+ break;
}
}
- if (deliveries)
- {
+ if (deliveries) {
/*
* Note that since core events are delivered first, an implicit grab may
* be activated on a core grab, stopping the XI events.
*/
- if (!grab && ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
- /* grab activated */;
+ if (!grab &&
+ ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
+ /* grab activated */ ;
else if (type == MotionNotify)
pDev->valuator->motionHintWindow = pWin;
else if (type == DeviceMotionNotify || type == DeviceButtonPress)
- CheckDeviceGrabAndHintWindow (pWin, type,
- (deviceKeyButtonPointer*) pEvents,
- grab, client, deliveryMask);
- return deliveries;
+ CheckDeviceGrabAndHintWindow(pWin, type,
+ (deviceKeyButtonPointer *) pEvents,
+ grab, client, deliveryMask);
+ return deliveries;
}
return nondeliveries;
}
@@ -2270,7 +2186,8 @@ FilterRawEvents(const ClientPtr client, const GrabPtr grab)
if (!grab)
return FALSE;
- client_xi_version = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
+ client_xi_version =
+ dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
cmp = version_compare(client_xi_version->major_version,
client_xi_version->minor_version, 2, 0);
@@ -2296,21 +2213,19 @@ DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
int i, rc;
int filter;
- rc = EventToXI2((InternalEvent*)ev, (xEvent**)&xi);
- if (rc != Success)
- {
+ rc = EventToXI2((InternalEvent *) ev, (xEvent **) &xi);
+ if (rc != Success) {
ErrorF("[Xi] %s: XI2 conversion failed in %s (%d)\n",
- __func__, device->name, rc);
+ __func__, device->name, rc);
return;
}
if (grab)
- DeliverGrabbedEvent((InternalEvent*)ev, device, FALSE);
+ DeliverGrabbedEvent((InternalEvent *) ev, device, FALSE);
filter = GetEventFilter(device, xi);
- for (i = 0; i < screenInfo.numScreens; i++)
- {
+ for (i = 0; i < screenInfo.numScreens; i++) {
WindowPtr root;
InputClients *inputclients;
@@ -2318,10 +2233,9 @@ DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
if (!GetClientsForDelivery(device, root, xi, filter, &inputclients))
continue;
- for (; inputclients; inputclients = inputclients->next)
- {
- ClientPtr c; /* unused */
- Mask m; /* unused */
+ for (; inputclients; inputclients = inputclients->next) {
+ ClientPtr c; /* unused */
+ Mask m; /* unused */
InputClients ic = *inputclients;
/* Because we run through the list manually, copy the actual
@@ -2348,17 +2262,15 @@ DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
#ifdef PANORAMIX
static int
-XineramaTryClientEventsResult(
- ClientPtr client,
- GrabPtr grab,
- Mask mask,
- Mask filter
-){
+XineramaTryClientEventsResult(ClientPtr client,
+ GrabPtr grab, Mask mask, Mask filter)
+{
if ((client) && (client != serverClient) && (!client->clientGone) &&
- ((filter == CantBeFiltered) || (mask & filter)))
- {
- if (grab && !SameClient(grab, client)) return -1;
- else return 1;
+ ((filter == CantBeFiltered) || (mask & filter))) {
+ if (grab && !SameClient(grab, client))
+ return -1;
+ else
+ return 1;
}
return 0;
}
@@ -2379,43 +2291,40 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
{
OtherClients *other;
-
- if (pWin->eventMask & filter)
- {
+ if (pWin->eventMask & filter) {
if (wClient(pWin) == dontClient)
- return 0;
+ return 0;
#ifdef PANORAMIX
- if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
- return XineramaTryClientEventsResult(
- wClient(pWin), NullGrab, pWin->eventMask, filter);
+ if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return XineramaTryClientEventsResult(wClient(pWin), NullGrab,
+ pWin->eventMask, filter);
#endif
- if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count))
- return 1; /* don't send, but pretend we did */
- return TryClientEvents(wClient(pWin), NULL, pEvents, count,
- pWin->eventMask, filter, NullGrab);
+ if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count))
+ return 1; /* don't send, but pretend we did */
+ return TryClientEvents(wClient(pWin), NULL, pEvents, count,
+ pWin->eventMask, filter, NullGrab);
}
- for (other = wOtherClients(pWin); other; other = other->next)
- {
- if (other->mask & filter)
- {
+ for (other = wOtherClients(pWin); other; other = other->next) {
+ if (other->mask & filter) {
if (SameClient(other, dontClient))
- return 0;
+ return 0;
#ifdef PANORAMIX
- if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
- return XineramaTryClientEventsResult(
- rClient(other), NullGrab, other->mask, filter);
+ if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return XineramaTryClientEventsResult(rClient(other), NullGrab,
+ other->mask, filter);
#endif
- if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin, pEvents,
- count))
- return 1; /* don't send, but pretend we did */
- return TryClientEvents(rClient(other), NULL, pEvents, count,
- other->mask, filter, NullGrab);
- }
+ if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin, pEvents,
+ count))
+ return 1; /* don't send, but pretend we did */
+ return TryClientEvents(rClient(other), NULL, pEvents, count,
+ other->mask, filter, NullGrab);
+ }
}
return 2;
}
-static Window FindChildForEvent(SpritePtr pSprite, WindowPtr event)
+static Window
+FindChildForEvent(SpritePtr pSprite, WindowPtr event)
{
WindowPtr w = DeepestSpriteWin(pSprite);
Window child = None;
@@ -2424,19 +2333,16 @@ static Window FindChildForEvent(SpritePtr pSprite, WindowPtr event)
set to none or should the value in the argument be passed
through. It probably doesn't matter since everyone calls
this function with child == None anyway. */
- while (w)
- {
+ while (w) {
/* If the source window is same as event window, child should be
none. Don't bother going all all the way back to the root. */
- if (w == event)
- {
+ if (w == event) {
child = None;
break;
}
- if (w->parent == event)
- {
+ if (w->parent == event) {
child = w->drawable.id;
break;
}
@@ -2454,56 +2360,48 @@ static Window FindChildForEvent(SpritePtr pSprite, WindowPtr event)
* @param calcChild If True, calculate the child window.
*/
void
-FixUpEventFromWindow(
- SpritePtr pSprite,
- xEvent *xE,
- WindowPtr pWin,
- Window child,
- Bool calcChild)
+FixUpEventFromWindow(SpritePtr pSprite,
+ xEvent *xE, WindowPtr pWin, Window child, Bool calcChild)
{
int evtype;
if (calcChild)
child = FindChildForEvent(pSprite, pWin);
- if ((evtype = xi2_get_type(xE)))
- {
- xXIDeviceEvent* event = (xXIDeviceEvent*)xE;
-
- switch (evtype)
- {
- case XI_RawKeyPress:
- case XI_RawKeyRelease:
- case XI_RawButtonPress:
- case XI_RawButtonRelease:
- case XI_RawMotion:
- case XI_RawTouchBegin:
- case XI_RawTouchUpdate:
- case XI_RawTouchEnd:
- case XI_DeviceChanged:
- case XI_HierarchyChanged:
- case XI_PropertyEvent:
- return;
- default:
- break;
+ if ((evtype = xi2_get_type(xE))) {
+ xXIDeviceEvent *event = (xXIDeviceEvent *) xE;
+
+ switch (evtype) {
+ case XI_RawKeyPress:
+ case XI_RawKeyRelease:
+ case XI_RawButtonPress:
+ case XI_RawButtonRelease:
+ case XI_RawMotion:
+ case XI_RawTouchBegin:
+ case XI_RawTouchUpdate:
+ case XI_RawTouchEnd:
+ case XI_DeviceChanged:
+ case XI_HierarchyChanged:
+ case XI_PropertyEvent:
+ return;
+ default:
+ break;
}
event->root = RootWindow(pSprite)->drawable.id;
event->event = pWin->drawable.id;
- if (evtype == XI_TouchOwnership)
- {
+ if (evtype == XI_TouchOwnership) {
event->child = child;
return;
}
- if (pSprite->hot.pScreen == pWin->drawable.pScreen)
- {
+ if (pSprite->hot.pScreen == pWin->drawable.pScreen) {
event->event_x = event->root_x - FP1616(pWin->drawable.x, 0);
event->event_y = event->root_y - FP1616(pWin->drawable.y, 0);
event->child = child;
- } else
- {
+ }
+ else {
event->event_x = 0;
event->event_y = 0;
event->child = None;
@@ -2511,24 +2409,20 @@ FixUpEventFromWindow(
if (event->evtype == XI_Enter || event->evtype == XI_Leave ||
event->evtype == XI_FocusIn || event->evtype == XI_FocusOut)
- ((xXIEnterEvent*)event)->same_screen =
+ ((xXIEnterEvent *) event)->same_screen =
(pSprite->hot.pScreen == pWin->drawable.pScreen);
- } else
- {
+ }
+ else {
XE_KBPTR.root = RootWindow(pSprite)->drawable.id;
XE_KBPTR.event = pWin->drawable.id;
- if (pSprite->hot.pScreen == pWin->drawable.pScreen)
- {
+ if (pSprite->hot.pScreen == pWin->drawable.pScreen) {
XE_KBPTR.sameScreen = xTrue;
XE_KBPTR.child = child;
- XE_KBPTR.eventX =
- XE_KBPTR.rootX - pWin->drawable.x;
- XE_KBPTR.eventY =
- XE_KBPTR.rootY - pWin->drawable.y;
+ XE_KBPTR.eventX = XE_KBPTR.rootX - pWin->drawable.x;
+ XE_KBPTR.eventY = XE_KBPTR.rootY - pWin->drawable.y;
}
- else
- {
+ else {
XE_KBPTR.sameScreen = xFalse;
XE_KBPTR.child = None;
XE_KBPTR.eventX = 0;
@@ -2558,14 +2452,12 @@ EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win)
int type;
OtherInputMasks *inputMasks = wOtherInputMasks(win);
- if ((type = GetXI2Type(evtype)) != 0)
- {
+ if ((type = GetXI2Type(evtype)) != 0) {
if (inputMasks && xi2mask_isset(inputMasks->xi2mask, dev, type))
rc |= EVENT_XI2_MASK;
}
- if ((type = GetXIType(evtype)) != 0)
- {
+ if ((type = GetXIType(evtype)) != 0) {
filter = event_get_filter_from_type(dev, type);
/* Check for XI mask */
@@ -2580,8 +2472,7 @@ EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win)
}
- if ((type = GetCoreType(evtype)) != 0)
- {
+ if ((type = GetCoreType(evtype)) != 0) {
filter = event_get_filter_from_type(dev, type);
/* Check for core mask */
@@ -2608,8 +2499,7 @@ DeliverEvent(DeviceIntPtr dev, xEvent *xE, int count,
if (XaceHook(XACE_SEND_ACCESS, NULL, dev, win, xE, count) == Success) {
filter = GetEventFilter(dev, xE);
FixUpEventFromWindow(pSprite, xE, win, child, FALSE);
- deliveries = DeliverEventsToWindow(dev, win, xE, count,
- filter, grab);
+ deliveries = DeliverEventsToWindow(dev, win, xE, count, filter, grab);
}
return deliveries;
@@ -2624,26 +2514,26 @@ DeliverOneEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel level,
int deliveries = 0;
int rc;
- switch(level)
- {
- case XI2:
- rc = EventToXI2(event, &xE);
- count = 1;
- break;
- case XI:
- rc = EventToXI(event, &xE, &count);
- break;
- case CORE:
- rc = EventToCore(event, &xE, &count);
- break;
+ switch (level) {
+ case XI2:
+ rc = EventToXI2(event, &xE);
+ count = 1;
+ break;
+ case XI:
+ rc = EventToXI(event, &xE, &count);
+ break;
+ case CORE:
+ rc = EventToCore(event, &xE, &count);
+ break;
}
- if (rc == Success)
- {
+ if (rc == Success) {
deliveries = DeliverEvent(dev, xE, count, win, child, grab);
free(xE);
- } else
- BUG_WARN_MSG(rc != BadMatch, "%s: conversion to level %d failed with rc %d\n",
+ }
+ else
+ BUG_WARN_MSG(rc != BadMatch,
+ "%s: conversion to level %d failed with rc %d\n",
dev->name, level, rc);
return deliveries;
}
@@ -2677,30 +2567,27 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
verify_internal_event(event);
- while (pWin)
- {
- if ((mask = EventIsDeliverable(dev, event->any.type, pWin)))
- {
+ while (pWin) {
+ if ((mask = EventIsDeliverable(dev, event->any.type, pWin))) {
/* XI2 events first */
- if (mask & EVENT_XI2_MASK)
- {
- deliveries = DeliverOneEvent(event, dev, XI2, pWin, child, grab);
+ if (mask & EVENT_XI2_MASK) {
+ deliveries =
+ DeliverOneEvent(event, dev, XI2, pWin, child, grab);
if (deliveries > 0)
break;
}
/* XI events */
- if (mask & EVENT_XI1_MASK)
- {
+ if (mask & EVENT_XI1_MASK) {
deliveries = DeliverOneEvent(event, dev, XI, pWin, child, grab);
if (deliveries > 0)
break;
}
/* Core event */
- if ((mask & EVENT_CORE_MASK) && IsMaster(dev) && dev->coreEvents)
- {
- deliveries = DeliverOneEvent(event, dev, CORE, pWin, child, grab);
+ if ((mask & EVENT_CORE_MASK) && IsMaster(dev) && dev->coreEvents) {
+ deliveries =
+ DeliverOneEvent(event, dev, CORE, pWin, child, grab);
if (deliveries > 0)
break;
}
@@ -2708,8 +2595,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
}
if ((deliveries < 0) || (pWin == stopAt) ||
- (mask & EVENT_DONT_PROPAGATE_MASK))
- {
+ (mask & EVENT_DONT_PROPAGATE_MASK)) {
deliveries = 0;
break;
}
@@ -2735,97 +2621,93 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
* @param otherParent Used for ReparentNotify events.
*/
int
-DeliverEvents(WindowPtr pWin, xEvent *xE, int count,
- WindowPtr otherParent)
+DeliverEvents(WindowPtr pWin, xEvent *xE, int count, WindowPtr otherParent)
{
DeviceIntRec dummy;
- int deliveries;
+ int deliveries;
#ifdef PANORAMIX
- if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
- return count;
+ if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return count;
#endif
if (!count)
- return 0;
+ return 0;
dummy.id = XIAllDevices;
- switch (xE->u.u.type)
- {
- case DestroyNotify:
- case UnmapNotify:
- case MapNotify:
- case MapRequest:
- case ReparentNotify:
- case ConfigureNotify:
- case ConfigureRequest:
- case GravityNotify:
- case CirculateNotify:
- case CirculateRequest:
- xE->u.destroyNotify.event = pWin->drawable.id;
- break;
+ switch (xE->u.u.type) {
+ case DestroyNotify:
+ case UnmapNotify:
+ case MapNotify:
+ case MapRequest:
+ case ReparentNotify:
+ case ConfigureNotify:
+ case ConfigureRequest:
+ case GravityNotify:
+ case CirculateNotify:
+ case CirculateRequest:
+ xE->u.destroyNotify.event = pWin->drawable.id;
+ break;
}
- switch (xE->u.u.type)
+ switch (xE->u.u.type) {
+ case DestroyNotify:
+ case UnmapNotify:
+ case MapNotify:
+ case ReparentNotify:
+ case ConfigureNotify:
+ case GravityNotify:
+ case CirculateNotify:
+ break;
+ default:
{
- case DestroyNotify:
- case UnmapNotify:
- case MapNotify:
- case ReparentNotify:
- case ConfigureNotify:
- case GravityNotify:
- case CirculateNotify:
- break;
- default:
- {
- Mask filter;
- filter = GetEventFilter(&dummy, xE);
- return DeliverEventsToWindow(&dummy, pWin, xE, count, filter,
- NullGrab);
- }
+ Mask filter;
+
+ filter = GetEventFilter(&dummy, xE);
+ return DeliverEventsToWindow(&dummy, pWin, xE, count, filter, NullGrab);
+ }
}
deliveries = DeliverEventsToWindow(&dummy, pWin, xE, count,
StructureNotifyMask, NullGrab);
- if (pWin->parent)
- {
- xE->u.destroyNotify.event = pWin->parent->drawable.id;
- deliveries += DeliverEventsToWindow(&dummy, pWin->parent, xE, count,
- SubstructureNotifyMask, NullGrab);
- if (xE->u.u.type == ReparentNotify)
- {
- xE->u.destroyNotify.event = otherParent->drawable.id;
+ if (pWin->parent) {
+ xE->u.destroyNotify.event = pWin->parent->drawable.id;
+ deliveries += DeliverEventsToWindow(&dummy, pWin->parent, xE, count,
+ SubstructureNotifyMask, NullGrab);
+ if (xE->u.u.type == ReparentNotify) {
+ xE->u.destroyNotify.event = otherParent->drawable.id;
deliveries += DeliverEventsToWindow(&dummy,
- otherParent, xE, count, SubstructureNotifyMask,
- NullGrab);
- }
+ otherParent, xE, count,
+ SubstructureNotifyMask,
+ NullGrab);
+ }
}
return deliveries;
}
-
static Bool
PointInBorderSize(WindowPtr pWin, int x, int y)
{
BoxRec box;
- if(RegionContainsPoint(&pWin->borderSize, x, y, &box))
- return TRUE;
+ if (RegionContainsPoint(&pWin->borderSize, x, y, &box))
+ return TRUE;
#ifdef PANORAMIX
- if(!noPanoramiXExtension &&
- XineramaSetWindowPntrs(inputInfo.pointer, pWin)) {
- SpritePtr pSprite = inputInfo.pointer->spriteInfo->sprite;
- int i;
-
- FOR_NSCREENS_FORWARD_SKIP(i) {
- if(RegionContainsPoint(&pSprite->windows[i]->borderSize,
- x + screenInfo.screens[0]->x - screenInfo.screens[i]->x,
- y + screenInfo.screens[0]->y - screenInfo.screens[i]->y,
- &box))
- return TRUE;
- }
+ if (!noPanoramiXExtension &&
+ XineramaSetWindowPntrs(inputInfo.pointer, pWin)) {
+ SpritePtr pSprite = inputInfo.pointer->spriteInfo->sprite;
+ int i;
+
+ FOR_NSCREENS_FORWARD_SKIP(i) {
+ if (RegionContainsPoint(&pSprite->windows[i]->borderSize,
+ x + screenInfo.screens[0]->x -
+ screenInfo.screens[i]->x,
+ y + screenInfo.screens[0]->y -
+ screenInfo.screens[i]->y, &box))
+ return TRUE;
+ }
}
#endif
return FALSE;
@@ -2845,49 +2727,47 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
WindowPtr
XYToWindow(SpritePtr pSprite, int x, int y)
{
- WindowPtr pWin;
- BoxRec box;
+ WindowPtr pWin;
+ BoxRec box;
- pSprite->spriteTraceGood = 1; /* root window still there */
+ pSprite->spriteTraceGood = 1; /* root window still there */
pWin = RootWindow(pSprite)->firstChild;
- while (pWin)
- {
- if ((pWin->mapped) &&
- (x >= pWin->drawable.x - wBorderWidth (pWin)) &&
- (x < pWin->drawable.x + (int)pWin->drawable.width +
- wBorderWidth(pWin)) &&
- (y >= pWin->drawable.y - wBorderWidth (pWin)) &&
- (y < pWin->drawable.y + (int)pWin->drawable.height +
- wBorderWidth (pWin))
- /* When a window is shaped, a further check
- * is made to see if the point is inside
- * borderSize
- */
- && (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
- && (!wInputShape(pWin) ||
- RegionContainsPoint(wInputShape(pWin),
- x - pWin->drawable.x,
- y - pWin->drawable.y, &box))
+ while (pWin) {
+ if ((pWin->mapped) &&
+ (x >= pWin->drawable.x - wBorderWidth(pWin)) &&
+ (x < pWin->drawable.x + (int) pWin->drawable.width +
+ wBorderWidth(pWin)) &&
+ (y >= pWin->drawable.y - wBorderWidth(pWin)) &&
+ (y < pWin->drawable.y + (int) pWin->drawable.height +
+ wBorderWidth(pWin))
+ /* When a window is shaped, a further check
+ * is made to see if the point is inside
+ * borderSize
+ */
+ && (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
+ && (!wInputShape(pWin) ||
+ RegionContainsPoint(wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box))
#ifdef ROOTLESS
- /* In rootless mode windows may be offscreen, even when
- * they're in X's stack. (E.g. if the native window system
- * implements some form of virtual desktop system).
- */
- && !pWin->rootlessUnhittable
+ /* In rootless mode windows may be offscreen, even when
+ * they're in X's stack. (E.g. if the native window system
+ * implements some form of virtual desktop system).
+ */
+ && !pWin->rootlessUnhittable
#endif
- )
- {
- if (pSprite->spriteTraceGood >= pSprite->spriteTraceSize)
- {
- pSprite->spriteTraceSize += 10;
- pSprite->spriteTrace = realloc(pSprite->spriteTrace,
- pSprite->spriteTraceSize*sizeof(WindowPtr));
- }
- pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
- pWin = pWin->firstChild;
- }
- else
- pWin = pWin->nextSib;
+ ) {
+ if (pSprite->spriteTraceGood >= pSprite->spriteTraceSize) {
+ pSprite->spriteTraceSize += 10;
+ pSprite->spriteTrace = realloc(pSprite->spriteTrace,
+ pSprite->spriteTraceSize *
+ sizeof(WindowPtr));
+ }
+ pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
+ pWin = pWin->firstChild;
+ }
+ else
+ pWin = pWin->nextSib;
}
return DeepestSpriteWin(pSprite);
}
@@ -2905,15 +2785,14 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
BOOL rc = FALSE;
DeviceEvent event;
- if (dev->deviceGrab.grab)
- {
+ if (dev->deviceGrab.grab) {
if (!dev->deviceGrab.fromPassiveGrab ||
dev->deviceGrab.grab->type != XI_Enter ||
dev->deviceGrab.grab->window == win ||
IsParent(dev->deviceGrab.grab->window, win))
return FALSE;
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
- (*dev->deviceGrab.DeactivateGrab)(dev);
+ (*dev->deviceGrab.DeactivateGrab) (dev);
}
if (win == NoneWin || win == PointerRootWin)
@@ -2946,15 +2825,14 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
BOOL rc = FALSE;
DeviceEvent event;
- if (dev->deviceGrab.grab)
- {
+ if (dev->deviceGrab.grab) {
if (!dev->deviceGrab.fromPassiveGrab ||
dev->deviceGrab.grab->type != XI_Enter ||
dev->deviceGrab.grab->window == win ||
IsParent(dev->deviceGrab.grab->window, win))
return FALSE;
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
- (*dev->deviceGrab.DeactivateGrab)(dev);
+ (*dev->deviceGrab.DeactivateGrab) (dev);
}
memset(&event, 0, sizeof(DeviceEvent));
@@ -2989,42 +2867,38 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
WindowPtr prevSpriteWin, newSpriteWin;
SpritePtr pSprite = pDev->spriteInfo->sprite;
- verify_internal_event((InternalEvent *)ev);
+ verify_internal_event((InternalEvent *) ev);
prevSpriteWin = pSprite->win;
- if (ev && !syncEvents.playingEvents)
- {
+ if (ev && !syncEvents.playingEvents) {
/* GetPointerEvents() guarantees that pointer events have the correct
rootX/Y set already. */
- switch (ev->type)
- {
- case ET_ButtonPress:
- case ET_ButtonRelease:
- case ET_Motion:
- case ET_TouchBegin:
- case ET_TouchUpdate:
- case ET_TouchEnd:
- break;
- default:
- /* all other events return FALSE */
- return FALSE;
+ switch (ev->type) {
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ case ET_Motion:
+ case ET_TouchBegin:
+ case ET_TouchUpdate:
+ case ET_TouchEnd:
+ break;
+ default:
+ /* all other events return FALSE */
+ return FALSE;
}
-
#ifdef PANORAMIX
- if (!noPanoramiXExtension)
- {
+ if (!noPanoramiXExtension) {
/* Motion events entering DIX get translated to Screen 0
coordinates. Replayed events have already been
translated since they've entered DIX before */
ev->root_x += pSprite->screen->x - screenInfo.screens[0]->x;
ev->root_y += pSprite->screen->y - screenInfo.screens[0]->y;
- } else
+ }
+ else
#endif
{
- if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen)
- {
+ if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen) {
pSprite->hot.pScreen = pSprite->hotPhys.pScreen;
RootWindow(pDev->spriteInfo->sprite) =
pSprite->hot.pScreen->root;
@@ -3041,43 +2915,49 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
pSprite->hot.y = pSprite->physLimits.y1;
else if (pSprite->hot.y >= pSprite->physLimits.y2)
pSprite->hot.y = pSprite->physLimits.y2 - 1;
- if (pSprite->hotShape)
- ConfineToShape(pDev, pSprite->hotShape, &pSprite->hot.x, &pSprite->hot.y);
- pSprite->hotPhys = pSprite->hot;
+ if (pSprite->hotShape)
+ ConfineToShape(pDev, pSprite->hotShape, &pSprite->hot.x,
+ &pSprite->hot.y);
+ pSprite->hotPhys = pSprite->hot;
- if ((pSprite->hotPhys.x != ev->root_x) ||
- (pSprite->hotPhys.y != ev->root_y))
- {
+ if ((pSprite->hotPhys.x != ev->root_x) ||
+ (pSprite->hotPhys.y != ev->root_y)) {
#ifdef PANORAMIX
- if (!noPanoramiXExtension)
- {
- XineramaSetCursorPosition(
- pDev, pSprite->hotPhys.x, pSprite->hotPhys.y, FALSE);
- } else
+ if (!noPanoramiXExtension) {
+ XineramaSetCursorPosition(pDev, pSprite->hotPhys.x,
+ pSprite->hotPhys.y, FALSE);
+ }
+ else
#endif
{
- (*pSprite->hotPhys.pScreen->SetCursorPosition)(
- pDev, pSprite->hotPhys.pScreen,
- pSprite->hotPhys.x, pSprite->hotPhys.y, FALSE);
+ (*pSprite->hotPhys.pScreen->SetCursorPosition) (pDev,
+ pSprite->
+ hotPhys.pScreen,
+ pSprite->
+ hotPhys.x,
+ pSprite->
+ hotPhys.y,
+ FALSE);
}
- }
+ }
- ev->root_x = pSprite->hot.x;
- ev->root_y = pSprite->hot.y;
+ ev->root_x = pSprite->hot.x;
+ ev->root_y = pSprite->hot.y;
}
newSpriteWin = XYToWindow(pSprite, pSprite->hot.x, pSprite->hot.y);
- if (newSpriteWin != prevSpriteWin)
- {
+ if (newSpriteWin != prevSpriteWin) {
int sourceid;
+
if (!ev) {
UpdateCurrentTimeIf();
- sourceid = pDev->id; /* when from WindowsRestructured */
- } else
+ sourceid = pDev->id; /* when from WindowsRestructured */
+ }
+ else
sourceid = ev->sourceid;
- if (prevSpriteWin != NullWindow) {
+ if (prevSpriteWin != NullWindow) {
if (!ActivateEnterGrab(pDev, prevSpriteWin, newSpriteWin))
DoEnterLeaveEvents(pDev, sourceid, prevSpriteWin,
newSpriteWin, NotifyNormal);
@@ -3100,8 +2980,8 @@ void
WindowsRestructured(void)
{
DeviceIntPtr pDev = inputInfo.devices;
- while(pDev)
- {
+
+ while (pDev) {
if (IsMaster(pDev) || IsFloating(pDev))
CheckMotion(NULL, pDev);
pDev = pDev->next;
@@ -3114,25 +2994,25 @@ WindowsRestructured(void)
* other than 0,0, the information in the private sprite structure must
* be updated accordingly, or XYToWindow (and other routines) will not
* compute correctly. */
-void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
+void
+ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
{
- GrabPtr grab;
+ GrabPtr grab;
DeviceIntPtr pDev;
SpritePtr pSprite;
- if (noPanoramiXExtension) return;
+ if (noPanoramiXExtension)
+ return;
pDev = inputInfo.devices;
- while(pDev)
- {
- if (DevHasCursor(pDev))
- {
+ while (pDev) {
+ if (DevHasCursor(pDev)) {
pSprite = pDev->spriteInfo->sprite;
- pSprite->hot.x -= xoff;
- pSprite->hot.y -= yoff;
+ pSprite->hot.x -= xoff;
+ pSprite->hot.y -= yoff;
- pSprite->hotPhys.x -= xoff;
- pSprite->hotPhys.y -= yoff;
+ pSprite->hotPhys.x -= xoff;
+ pSprite->hotPhys.y -= yoff;
pSprite->hotLimits.x1 -= xoff;
pSprite->hotLimits.y1 -= yoff;
@@ -3147,14 +3027,14 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
/* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
if ((grab = pDev->deviceGrab.grab) && grab->confineTo) {
if (grab->confineTo->drawable.pScreen
- != pSprite->hotPhys.pScreen)
+ != pSprite->hotPhys.pScreen)
pSprite->hotPhys.x = pSprite->hotPhys.y = 0;
ConfineCursorToWindow(pDev, grab->confineTo, TRUE, TRUE);
- } else
- ConfineCursorToWindow(
- pDev,
- pSprite->hotPhys.pScreen->root,
- TRUE, FALSE);
+ }
+ else
+ ConfineCursorToWindow(pDev,
+ pSprite->hotPhys.pScreen->root,
+ TRUE, FALSE);
}
pDev = pDev->next;
@@ -3184,11 +3064,10 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
ScreenPtr pScreen;
CursorPtr pCursor;
- if (!pDev->spriteInfo->sprite)
- {
+ if (!pDev->spriteInfo->sprite) {
DeviceIntPtr it;
- pDev->spriteInfo->sprite = (SpritePtr)calloc(1, sizeof(SpriteRec));
+ pDev->spriteInfo->sprite = (SpritePtr) calloc(1, sizeof(SpriteRec));
if (!pDev->spriteInfo->sprite)
FatalError("InitializeSprite: failed to allocate sprite struct");
@@ -3198,8 +3077,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
*
* The VCK is always paired with the VCP before the VCP has a sprite.
*/
- for (it = inputInfo.devices; it; it = it->next)
- {
+ for (it = inputInfo.devices; it; it = it->next) {
if (it->spriteInfo->paired == pDev)
it->spriteInfo->sprite = pDev->spriteInfo->sprite;
}
@@ -3210,11 +3088,10 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
pSprite = pDev->spriteInfo->sprite;
pDev->spriteInfo->spriteOwner = TRUE;
- pScreen = (pWin) ? pWin->drawable.pScreen : (ScreenPtr)NULL;
+ pScreen = (pWin) ? pWin->drawable.pScreen : (ScreenPtr) NULL;
pSprite->hot.pScreen = pScreen;
pSprite->hotPhys.pScreen = pScreen;
- if (pScreen)
- {
+ if (pScreen) {
pSprite->hotPhys.x = pScreen->width / 2;
pSprite->hotPhys.y = pScreen->height / 2;
pSprite->hotLimits.x2 = pScreen->width;
@@ -3224,53 +3101,50 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
pSprite->hot = pSprite->hotPhys;
pSprite->win = pWin;
- if (pWin)
- {
- pCursor = wCursor(pWin);
- pSprite->spriteTrace = (WindowPtr *)calloc(1, 32*sizeof(WindowPtr));
- if (!pSprite->spriteTrace)
- FatalError("Failed to allocate spriteTrace");
- pSprite->spriteTraceSize = 32;
+ if (pWin) {
+ pCursor = wCursor(pWin);
+ pSprite->spriteTrace = (WindowPtr *) calloc(1, 32 * sizeof(WindowPtr));
+ if (!pSprite->spriteTrace)
+ FatalError("Failed to allocate spriteTrace");
+ pSprite->spriteTraceSize = 32;
- RootWindow(pDev->spriteInfo->sprite) = pWin;
- pSprite->spriteTraceGood = 1;
+ RootWindow(pDev->spriteInfo->sprite) = pWin;
+ pSprite->spriteTraceGood = 1;
- pSprite->pEnqueueScreen = pScreen;
- pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
+ pSprite->pEnqueueScreen = pScreen;
+ pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
- } else {
+ }
+ else {
pCursor = NullCursor;
- pSprite->spriteTrace = NULL;
- pSprite->spriteTraceSize = 0;
- pSprite->spriteTraceGood = 0;
- pSprite->pEnqueueScreen = screenInfo.screens[0];
- pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
+ pSprite->spriteTrace = NULL;
+ pSprite->spriteTraceSize = 0;
+ pSprite->spriteTraceGood = 0;
+ pSprite->pEnqueueScreen = screenInfo.screens[0];
+ pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
}
if (pCursor)
- pCursor->refcnt++;
+ pCursor->refcnt++;
if (pSprite->current)
- FreeCursor(pSprite->current, None);
+ FreeCursor(pSprite->current, None);
pSprite->current = pCursor;
- if (pScreen)
- {
- (*pScreen->RealizeCursor) ( pDev, pScreen, pSprite->current);
- (*pScreen->CursorLimits) ( pDev, pScreen, pSprite->current,
- &pSprite->hotLimits, &pSprite->physLimits);
+ if (pScreen) {
+ (*pScreen->RealizeCursor) (pDev, pScreen, pSprite->current);
+ (*pScreen->CursorLimits) (pDev, pScreen, pSprite->current,
+ &pSprite->hotLimits, &pSprite->physLimits);
pSprite->confined = FALSE;
- (*pScreen->ConstrainCursor) (pDev, pScreen,
- &pSprite->physLimits);
+ (*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits);
(*pScreen->SetCursorPosition) (pDev, pScreen, pSprite->hot.x,
- pSprite->hot.y,
- FALSE);
+ pSprite->hot.y, FALSE);
(*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current);
}
#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
+ if (!noPanoramiXExtension) {
pSprite->hotLimits.x1 = -screenInfo.screens[0]->x;
pSprite->hotLimits.y1 = -screenInfo.screens[0]->y;
- pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x;
+ pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x;
pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y;
pSprite->physLimits = pSprite->hotLimits;
pSprite->confineWin = NullWindow;
@@ -3304,8 +3178,9 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
SpritePtr pSprite = NULL;
WindowPtr win = NULL;
CursorPtr pCursor;
+
if (!pScreen)
- return ;
+ return;
if (!pDev->spriteInfo->sprite)
return;
@@ -3321,26 +3196,25 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
pSprite->win = win;
pCursor = wCursor(win);
if (pCursor)
- pCursor->refcnt++;
+ pCursor->refcnt++;
if (pSprite->current)
- FreeCursor(pSprite->current, 0);
+ FreeCursor(pSprite->current, 0);
pSprite->current = pCursor;
pSprite->spriteTraceGood = 1;
pSprite->spriteTrace[0] = win;
(*pScreen->CursorLimits) (pDev,
pScreen,
pSprite->current,
- &pSprite->hotLimits,
- &pSprite->physLimits);
+ &pSprite->hotLimits, &pSprite->physLimits);
pSprite->confined = FALSE;
(*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits);
(*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current);
#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
+ if (!noPanoramiXExtension) {
pSprite->hotLimits.x1 = -screenInfo.screens[0]->x;
pSprite->hotLimits.y1 = -screenInfo.screens[0]->y;
- pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x;
+ pSprite->hotLimits.x2 = PanoramiXPixWidth - screenInfo.screens[0]->x;
pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y;
pSprite->physLimits = pSprite->hotLimits;
pSprite->screen = pScreen;
@@ -3360,7 +3234,7 @@ WindowHasNewCursor(WindowPtr pWin)
{
DeviceIntPtr pDev;
- for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
+ for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
if (DevHasCursor(pDev))
PostNewCursor(pDev);
}
@@ -3371,72 +3245,76 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
DeviceIntPtr ptr;
SpritePtr pSprite;
- ptr = IsFloating(pDev) ? pDev : GetXTestDevice(GetMaster(pDev, MASTER_POINTER));
+ ptr =
+ IsFloating(pDev) ? pDev :
+ GetXTestDevice(GetMaster(pDev, MASTER_POINTER));
pSprite = ptr->spriteInfo->sprite;
pSprite->hotPhys.x = x;
pSprite->hotPhys.y = y;
#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
- pSprite->hotPhys.x += newScreen->x - screenInfo.screens[0]->x;
- pSprite->hotPhys.y += newScreen->y - screenInfo.screens[0]->y;
- if (newScreen != pSprite->screen) {
- pSprite->screen = newScreen;
- /* Make sure we tell the DDX to update its copy of the screen */
- if(pSprite->confineWin)
- XineramaConfineCursorToWindow(ptr,
- pSprite->confineWin, TRUE);
- else
- XineramaConfineCursorToWindow(ptr, screenInfo.screens[0]->root, TRUE);
- /* if the pointer wasn't confined, the DDX won't get
- told of the pointer warp so we reposition it here */
- if(!syncEvents.playingEvents)
- (*pSprite->screen->SetCursorPosition)(
- ptr,
- pSprite->screen,
- pSprite->hotPhys.x + screenInfo.screens[0]->x -
- pSprite->screen->x,
- pSprite->hotPhys.y + screenInfo.screens[0]->y -
- pSprite->screen->y, FALSE);
- }
- } else
+ if (!noPanoramiXExtension) {
+ pSprite->hotPhys.x += newScreen->x - screenInfo.screens[0]->x;
+ pSprite->hotPhys.y += newScreen->y - screenInfo.screens[0]->y;
+ if (newScreen != pSprite->screen) {
+ pSprite->screen = newScreen;
+ /* Make sure we tell the DDX to update its copy of the screen */
+ if (pSprite->confineWin)
+ XineramaConfineCursorToWindow(ptr, pSprite->confineWin, TRUE);
+ else
+ XineramaConfineCursorToWindow(ptr, screenInfo.screens[0]->root,
+ TRUE);
+ /* if the pointer wasn't confined, the DDX won't get
+ told of the pointer warp so we reposition it here */
+ if (!syncEvents.playingEvents)
+ (*pSprite->screen->SetCursorPosition) (ptr,
+ pSprite->screen,
+ pSprite->hotPhys.x +
+ screenInfo.screens[0]->
+ x - pSprite->screen->x,
+ pSprite->hotPhys.y +
+ screenInfo.screens[0]->
+ y - pSprite->screen->y,
+ FALSE);
+ }
+ }
+ else
#endif
if (newScreen != pSprite->hotPhys.pScreen)
- ConfineCursorToWindow(ptr, newScreen->root, TRUE, FALSE);
+ ConfineCursorToWindow(ptr, newScreen->root, TRUE, FALSE);
}
#ifdef PANORAMIX
static Bool
-XineramaPointInWindowIsVisible(
- WindowPtr pWin,
- int x,
- int y
-)
+XineramaPointInWindowIsVisible(WindowPtr pWin, int x, int y)
{
BoxRec box;
int i, xoff, yoff;
- if (!pWin->realized) return FALSE;
+ if (!pWin->realized)
+ return FALSE;
if (RegionContainsPoint(&pWin->borderClip, x, y, &box))
return TRUE;
- if(!XineramaSetWindowPntrs(inputInfo.pointer, pWin)) return FALSE;
+ if (!XineramaSetWindowPntrs(inputInfo.pointer, pWin))
+ return FALSE;
xoff = x + screenInfo.screens[0]->x;
yoff = y + screenInfo.screens[0]->y;
FOR_NSCREENS_FORWARD_SKIP(i) {
- pWin = inputInfo.pointer->spriteInfo->sprite->windows[i];
- x = xoff - screenInfo.screens[i]->x;
- y = yoff - screenInfo.screens[i]->y;
-
- if(RegionContainsPoint(&pWin->borderClip, x, y, &box)
- && (!wInputShape(pWin) ||
- RegionContainsPoint(wInputShape(pWin),
- x - pWin->drawable.x,
- y - pWin->drawable.y, &box)))
+ pWin = inputInfo.pointer->spriteInfo->sprite->windows[i];
+
+ x = xoff - screenInfo.screens[i]->x;
+ y = yoff - screenInfo.screens[i]->y;
+
+ if (RegionContainsPoint(&pWin->borderClip, x, y, &box)
+ && (!wInputShape(pWin) ||
+ RegionContainsPoint(wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box)))
return TRUE;
}
@@ -3447,68 +3325,66 @@ XineramaPointInWindowIsVisible(
static int
XineramaWarpPointer(ClientPtr client)
{
- WindowPtr dest = NULL;
- int x, y, rc;
- SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite;
+ WindowPtr dest = NULL;
+ int x, y, rc;
+ SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite;
REQUEST(xWarpPointerReq);
-
if (stuff->dstWid != None) {
- rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
- if (rc != Success)
- return rc;
+ rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
}
x = pSprite->hotPhys.x;
y = pSprite->hotPhys.y;
- if (stuff->srcWid != None)
- {
- int winX, winY;
- XID winID = stuff->srcWid;
+ if (stuff->srcWid != None) {
+ int winX, winY;
+ XID winID = stuff->srcWid;
WindowPtr source;
- rc = dixLookupWindow(&source, winID, client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- winX = source->drawable.x;
- winY = source->drawable.y;
- if(source == screenInfo.screens[0]->root) {
- winX -= screenInfo.screens[0]->x;
- winY -= screenInfo.screens[0]->y;
- }
- if (x < winX + stuff->srcX ||
- y < winY + stuff->srcY ||
- (stuff->srcWidth != 0 &&
- winX + stuff->srcX + (int)stuff->srcWidth < x) ||
- (stuff->srcHeight != 0 &&
- winY + stuff->srcY + (int)stuff->srcHeight < y) ||
- !XineramaPointInWindowIsVisible(source, x, y))
- return Success;
+ rc = dixLookupWindow(&source, winID, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ winX = source->drawable.x;
+ winY = source->drawable.y;
+ if (source == screenInfo.screens[0]->root) {
+ winX -= screenInfo.screens[0]->x;
+ winY -= screenInfo.screens[0]->y;
+ }
+ if (x < winX + stuff->srcX ||
+ y < winY + stuff->srcY ||
+ (stuff->srcWidth != 0 &&
+ winX + stuff->srcX + (int) stuff->srcWidth < x) ||
+ (stuff->srcHeight != 0 &&
+ winY + stuff->srcY + (int) stuff->srcHeight < y) ||
+ !XineramaPointInWindowIsVisible(source, x, y))
+ return Success;
}
if (dest) {
- x = dest->drawable.x;
- y = dest->drawable.y;
- if(dest == screenInfo.screens[0]->root) {
- x -= screenInfo.screens[0]->x;
- y -= screenInfo.screens[0]->y;
- }
+ x = dest->drawable.x;
+ y = dest->drawable.y;
+ if (dest == screenInfo.screens[0]->root) {
+ x -= screenInfo.screens[0]->x;
+ y -= screenInfo.screens[0]->y;
+ }
}
x += stuff->dstX;
y += stuff->dstY;
if (x < pSprite->physLimits.x1)
- x = pSprite->physLimits.x1;
+ x = pSprite->physLimits.x1;
else if (x >= pSprite->physLimits.x2)
- x = pSprite->physLimits.x2 - 1;
+ x = pSprite->physLimits.x2 - 1;
if (y < pSprite->physLimits.y1)
- y = pSprite->physLimits.y1;
+ y = pSprite->physLimits.y1;
else if (y >= pSprite->physLimits.y2)
- y = pSprite->physLimits.y2 - 1;
+ y = pSprite->physLimits.y2 - 1;
if (pSprite->hotShape)
- ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y);
+ ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y);
XineramaSetCursorPosition(PickPointer(client), x, y, TRUE);
@@ -3517,7 +3393,6 @@ XineramaWarpPointer(ClientPtr client)
#endif
-
/**
* Server-side protocol handling for WarpPointer request.
* Warps the cursor position to the coordinates given in the request.
@@ -3525,11 +3400,11 @@ XineramaWarpPointer(ClientPtr client)
int
ProcWarpPointer(ClientPtr client)
{
- WindowPtr dest = NULL;
- int x, y, rc;
- ScreenPtr newScreen;
+ WindowPtr dest = NULL;
+ int x, y, rc;
+ ScreenPtr newScreen;
DeviceIntPtr dev, tmp;
- SpritePtr pSprite;
+ SpritePtr pSprite;
REQUEST(xWarpPointerReq);
REQUEST_SIZE_MATCH(xWarpPointerReq);
@@ -3538,10 +3413,10 @@ ProcWarpPointer(ClientPtr client)
for (tmp = inputInfo.devices; tmp; tmp = tmp->next) {
if (GetMaster(tmp, MASTER_ATTACHED) == dev) {
- rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess);
- if (rc != Success)
- return rc;
- }
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+ }
}
if (dev->lastSlave)
@@ -3549,77 +3424,74 @@ ProcWarpPointer(ClientPtr client)
pSprite = dev->spriteInfo->sprite;
#ifdef PANORAMIX
- if(!noPanoramiXExtension)
- return XineramaWarpPointer(client);
+ if (!noPanoramiXExtension)
+ return XineramaWarpPointer(client);
#endif
if (stuff->dstWid != None) {
- rc = dixLookupWindow(&dest, stuff->dstWid, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
+ rc = dixLookupWindow(&dest, stuff->dstWid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
}
x = pSprite->hotPhys.x;
y = pSprite->hotPhys.y;
- if (stuff->srcWid != None)
- {
- int winX, winY;
- XID winID = stuff->srcWid;
+ if (stuff->srcWid != None) {
+ int winX, winY;
+ XID winID = stuff->srcWid;
WindowPtr source;
- rc = dixLookupWindow(&source, winID, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- winX = source->drawable.x;
- winY = source->drawable.y;
- if (source->drawable.pScreen != pSprite->hotPhys.pScreen ||
- x < winX + stuff->srcX ||
- y < winY + stuff->srcY ||
- (stuff->srcWidth != 0 &&
- winX + stuff->srcX + (int)stuff->srcWidth < x) ||
- (stuff->srcHeight != 0 &&
- winY + stuff->srcY + (int)stuff->srcHeight < y) ||
- !PointInWindowIsVisible(source, x, y))
- return Success;
- }
- if (dest)
- {
- x = dest->drawable.x;
- y = dest->drawable.y;
- newScreen = dest->drawable.pScreen;
- } else
- newScreen = pSprite->hotPhys.pScreen;
+ rc = dixLookupWindow(&source, winID, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ winX = source->drawable.x;
+ winY = source->drawable.y;
+ if (source->drawable.pScreen != pSprite->hotPhys.pScreen ||
+ x < winX + stuff->srcX ||
+ y < winY + stuff->srcY ||
+ (stuff->srcWidth != 0 &&
+ winX + stuff->srcX + (int) stuff->srcWidth < x) ||
+ (stuff->srcHeight != 0 &&
+ winY + stuff->srcY + (int) stuff->srcHeight < y) ||
+ !PointInWindowIsVisible(source, x, y))
+ return Success;
+ }
+ if (dest) {
+ x = dest->drawable.x;
+ y = dest->drawable.y;
+ newScreen = dest->drawable.pScreen;
+ }
+ else
+ newScreen = pSprite->hotPhys.pScreen;
x += stuff->dstX;
y += stuff->dstY;
if (x < 0)
- x = 0;
+ x = 0;
else if (x >= newScreen->width)
- x = newScreen->width - 1;
+ x = newScreen->width - 1;
if (y < 0)
- y = 0;
+ y = 0;
else if (y >= newScreen->height)
- y = newScreen->height - 1;
-
- if (newScreen == pSprite->hotPhys.pScreen)
- {
- if (x < pSprite->physLimits.x1)
- x = pSprite->physLimits.x1;
- else if (x >= pSprite->physLimits.x2)
- x = pSprite->physLimits.x2 - 1;
- if (y < pSprite->physLimits.y1)
- y = pSprite->physLimits.y1;
- else if (y >= pSprite->physLimits.y2)
- y = pSprite->physLimits.y2 - 1;
- if (pSprite->hotShape)
- ConfineToShape(dev, pSprite->hotShape, &x, &y);
- (*newScreen->SetCursorPosition)(dev, newScreen, x, y, TRUE);
- }
- else if (!PointerConfinedToScreen(dev))
- {
- NewCurrentScreen(dev, newScreen, x, y);
+ y = newScreen->height - 1;
+
+ if (newScreen == pSprite->hotPhys.pScreen) {
+ if (x < pSprite->physLimits.x1)
+ x = pSprite->physLimits.x1;
+ else if (x >= pSprite->physLimits.x2)
+ x = pSprite->physLimits.x2 - 1;
+ if (y < pSprite->physLimits.y1)
+ y = pSprite->physLimits.y1;
+ else if (y >= pSprite->physLimits.y2)
+ y = pSprite->physLimits.y2 - 1;
+ if (pSprite->hotShape)
+ ConfineToShape(dev, pSprite->hotShape, &x, &y);
+ (*newScreen->SetCursorPosition) (dev, newScreen, x, y, TRUE);
+ }
+ else if (!PointerConfinedToScreen(dev)) {
+ NewCurrentScreen(dev, newScreen, x, y);
}
return Success;
}
@@ -3627,20 +3499,21 @@ ProcWarpPointer(ClientPtr client)
static Bool
BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
{
- if(RegionNotEmpty(&pWin->borderSize))
- return TRUE;
+ if (RegionNotEmpty(&pWin->borderSize))
+ return TRUE;
#ifdef PANORAMIX
- if(!noPanoramiXExtension && XineramaSetWindowPntrs(pDev, pWin)) {
- int i;
-
- FOR_NSCREENS_FORWARD_SKIP(i) {
- if(RegionNotEmpty(&pDev->spriteInfo->sprite->windows[i]->borderSize))
- return TRUE;
- }
- }
+ if (!noPanoramiXExtension && XineramaSetWindowPntrs(pDev, pWin)) {
+ int i;
+
+ FOR_NSCREENS_FORWARD_SKIP(i) {
+ if (RegionNotEmpty
+ (&pDev->spriteInfo->sprite->windows[i]->borderSize))
+ return TRUE;
+ }
+ }
#endif
- return FALSE;
+ return FALSE;
}
/**
@@ -3658,7 +3531,6 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
Bool
ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
InternalEvent *real_event)
-
{
SpritePtr pSprite = device->spriteInfo->sprite;
GrabInfoPtr grabinfo = &device->deviceGrab;
@@ -3668,8 +3540,7 @@ ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
/* The only consumers of corestate are Xi 1.x and core events, which
* are guaranteed to come from DeviceEvents. */
- if (grab->grabtype == XI || grab->grabtype == CORE)
- {
+ if (grab->grabtype == XI || grab->grabtype == CORE) {
DeviceIntPtr gdev;
event->device_event.corestate &= 0x1f00;
@@ -3684,43 +3555,38 @@ ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
gdev->key->xkbInfo->state.grab_mods & (~0x1f00);
}
- if (grab->grabtype == CORE)
- {
+ if (grab->grabtype == CORE) {
rc = EventToCore(event, &xE, &count);
- if (rc != Success)
- {
- BUG_WARN_MSG(rc != BadMatch,"[dix] %s: core conversion failed"
+ if (rc != Success) {
+ BUG_WARN_MSG(rc != BadMatch, "[dix] %s: core conversion failed"
"(%d, %d).\n", device->name, event->any.type, rc);
return FALSE;
}
- } else if (grab->grabtype == XI2)
- {
+ }
+ else if (grab->grabtype == XI2) {
rc = EventToXI2(event, &xE);
- if (rc != Success)
- {
+ if (rc != Success) {
if (rc != BadMatch)
- BUG_WARN_MSG(rc != BadMatch,"[dix] %s: XI2 conversion failed"
+ BUG_WARN_MSG(rc != BadMatch, "[dix] %s: XI2 conversion failed"
"(%d, %d).\n", device->name, event->any.type, rc);
return FALSE;
}
count = 1;
- } else
- {
+ }
+ else {
rc = EventToXI(event, &xE, &count);
- if (rc != Success)
- {
+ if (rc != Success) {
if (rc != BadMatch)
- BUG_WARN_MSG(rc != BadMatch,"[dix] %s: XI conversion failed"
+ BUG_WARN_MSG(rc != BadMatch, "[dix] %s: XI conversion failed"
"(%d, %d).\n", device->name, event->any.type, rc);
return FALSE;
}
}
- (*grabinfo->ActivateGrab)(device, grab,
- ClientTimeToServerTime(event->any.time), TRUE);
+ (*grabinfo->ActivateGrab) (device, grab,
+ ClientTimeToServerTime(event->any.time), TRUE);
- if (xE)
- {
+ if (xE) {
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
/* XXX: XACE? */
@@ -3743,16 +3609,15 @@ CoreGrabInterferes(DeviceIntPtr device, GrabPtr grab)
DeviceIntPtr other;
BOOL interfering = FALSE;
- for (other = inputInfo.devices; other; other = other->next)
- {
+ for (other = inputInfo.devices; other; other = other->next) {
GrabPtr othergrab = other->deviceGrab.grab;
+
if (othergrab && othergrab->grabtype == CORE &&
- SameClient(grab, rClient(othergrab)) &&
- ((IsPointerDevice(grab->device) &&
- IsPointerDevice(othergrab->device)) ||
- (IsKeyboardDevice(grab->device) &&
- IsKeyboardDevice(othergrab->device))))
- {
+ SameClient(grab, rClient(othergrab)) &&
+ ((IsPointerDevice(grab->device) &&
+ IsPointerDevice(othergrab->device)) ||
+ (IsKeyboardDevice(grab->device) &&
+ IsKeyboardDevice(othergrab->device)))) {
interfering = TRUE;
break;
}
@@ -3762,10 +3627,10 @@ CoreGrabInterferes(DeviceIntPtr device, GrabPtr grab)
}
enum MatchFlags {
- NO_MATCH = 0x0,
- CORE_MATCH = 0x1,
- XI_MATCH = 0x2,
- XI2_MATCH = 0x4,
+ NO_MATCH = 0x0,
+ CORE_MATCH = 0x1,
+ XI_MATCH = 0x2,
+ XI2_MATCH = 0x4,
};
/**
@@ -3780,32 +3645,32 @@ enum MatchFlags {
* @return The respective matched flag or 0 for no match
*/
static enum MatchFlags
-MatchForType(const GrabPtr grab, GrabPtr tmp, enum InputLevel level, int event_type)
+MatchForType(const GrabPtr grab, GrabPtr tmp, enum InputLevel level,
+ int event_type)
{
enum MatchFlags match;
BOOL ignore_device = FALSE;
int grabtype;
int evtype;
- switch(level)
- {
- case XI2:
- grabtype = XI2;
- evtype = GetXI2Type(event_type);
- BUG_WARN(!evtype);
- match = XI2_MATCH;
- break;
- case XI:
- grabtype = XI;
- evtype = GetXIType(event_type);
- match = XI_MATCH;
- break;
- case CORE:
- grabtype = CORE;
- evtype = GetCoreType(event_type);
- match = CORE_MATCH;
- ignore_device = TRUE;
- break;
+ switch (level) {
+ case XI2:
+ grabtype = XI2;
+ evtype = GetXI2Type(event_type);
+ BUG_WARN(!evtype);
+ match = XI2_MATCH;
+ break;
+ case XI:
+ grabtype = XI;
+ evtype = GetXIType(event_type);
+ match = XI_MATCH;
+ break;
+ case CORE:
+ grabtype = CORE;
+ evtype = GetCoreType(event_type);
+ match = CORE_MATCH;
+ ignore_device = TRUE;
+ break;
}
tmp->grabtype = grabtype;
@@ -3840,11 +3705,10 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
int emulated_type = 0;
gdev = grab->modifierDevice;
- if (grab->grabtype == CORE)
- {
+ if (grab->grabtype == CORE) {
gdev = GetMaster(device, KEYBOARD_OR_FLOAT);
- } else if (grab->grabtype == XI2)
- {
+ }
+ else if (grab->grabtype == XI2) {
/* if the device is an attached slave device, gdev must be the
* attached master keyboard. Since the slave may have been
* reattached after the grab, the modifier device may not be the
@@ -3854,15 +3718,15 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
}
if (gdev && gdev->key)
- xkbi= gdev->key->xkbInfo;
+ xkbi = gdev->key->xkbInfo;
tempGrab->modifierDevice = grab->modifierDevice;
tempGrab->modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
/* Check for XI2 and XI grabs first */
match = MatchForType(grab, tempGrab, XI2, event->any.type);
- if (!match && IsTouchEvent(event) && (event->device_event.flags & TOUCH_POINTER_EMULATED))
- {
+ if (!match && IsTouchEvent(event) &&
+ (event->device_event.flags & TOUCH_POINTER_EMULATED)) {
emulated_type = TouchGetPointerEventType(event);
match = MatchForType(grab, tempGrab, XI2, emulated_type);
}
@@ -3873,8 +3737,7 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
if (!match && emulated_type)
match = MatchForType(grab, tempGrab, XI, emulated_type);
- if (!match && checkCore)
- {
+ if (!match && checkCore) {
match = MatchForType(grab, tempGrab, CORE, event->any.type);
if (!match && emulated_type)
match = MatchForType(grab, tempGrab, CORE, emulated_type);
@@ -3891,8 +3754,7 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
* device.
*/
- if (grab->grabtype == CORE)
- {
+ if (grab->grabtype == CORE) {
/* A passive grab may have been created for a different device
than it is assigned to at this point in time.
Update the grab's device and modifier device to reflect the
@@ -3900,8 +3762,7 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
Since XGrabDeviceButton requires to specify the
modifierDevice explicitly, we don't override this choice.
*/
- if (grab->type < GenericEvent)
- {
+ if (grab->type < GenericEvent) {
grab->device = device;
grab->modifierDevice = GetMaster(device, MASTER_KEYBOARD);
}
@@ -3927,38 +3788,34 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
*/
GrabPtr
-CheckPassiveGrabsOnWindow(
- WindowPtr pWin,
- DeviceIntPtr device,
- InternalEvent *event,
- BOOL checkCore,
- BOOL activate)
+CheckPassiveGrabsOnWindow(WindowPtr pWin,
+ DeviceIntPtr device,
+ InternalEvent *event, BOOL checkCore, BOOL activate)
{
GrabPtr grab = wPassiveGrabs(pWin);
GrabPtr tempGrab;
if (!grab)
- return NULL;
+ return NULL;
tempGrab = AllocGrab();
/* Fill out the grab details, but leave the type for later before
* comparing */
- switch (event->any.type)
- {
- case ET_KeyPress:
- case ET_KeyRelease:
- tempGrab->detail.exact = event->device_event.detail.key;
- break;
- case ET_ButtonPress:
- case ET_ButtonRelease:
- case ET_TouchBegin:
- case ET_TouchEnd:
- tempGrab->detail.exact = event->device_event.detail.button;
- break;
- default:
- tempGrab->detail.exact = 0;
- break;
+ switch (event->any.type) {
+ case ET_KeyPress:
+ case ET_KeyRelease:
+ tempGrab->detail.exact = event->device_event.detail.key;
+ break;
+ case ET_ButtonPress:
+ case ET_ButtonRelease:
+ case ET_TouchBegin:
+ case ET_TouchEnd:
+ tempGrab->detail.exact = event->device_event.detail.button;
+ break;
+ default:
+ tempGrab->detail.exact = 0;
+ break;
}
tempGrab->window = pWin;
tempGrab->device = device;
@@ -3966,8 +3823,7 @@ CheckPassiveGrabsOnWindow(
tempGrab->modifiersDetail.pMask = NULL;
tempGrab->next = NULL;
- for (; grab; grab = grab->next)
- {
+ for (; grab; grab = grab->next) {
if (!CheckPassiveGrab(device, grab, event, checkCore, tempGrab))
continue;
@@ -4012,24 +3868,22 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
{
int i;
WindowPtr pWin = NULL;
- FocusClassPtr focus = IsPointerEvent((InternalEvent*)event) ? NULL : device->focus;
+ FocusClassPtr focus =
+ IsPointerEvent((InternalEvent *) event) ? NULL : device->focus;
BOOL sendCore = (IsMaster(device) && device->coreEvents);
Bool ret = FALSE;
- if (event->type != ET_ButtonPress &&
- event->type != ET_KeyPress)
+ if (event->type != ET_ButtonPress && event->type != ET_KeyPress)
return FALSE;
- if (event->type == ET_ButtonPress
- && (device->button->buttonsDown != 1))
- return FALSE;
+ if (event->type == ET_ButtonPress && (device->button->buttonsDown != 1))
+ return FALSE;
if (device->deviceGrab.grab)
return FALSE;
i = 0;
- if (ancestor)
- {
+ if (ancestor) {
while (i < device->spriteInfo->sprite->spriteTraceGood)
if (device->spriteInfo->sprite->spriteTrace[i++] == ancestor)
break;
@@ -4037,37 +3891,32 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
goto out;
}
- if (focus)
- {
- for (; i < focus->traceGood; i++)
- {
- pWin = focus->trace[i];
- if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
- sendCore, TRUE))
- {
- ret = TRUE;
- goto out;
- }
- }
-
- if ((focus->win == NoneWin) ||
- (i >= device->spriteInfo->sprite->spriteTraceGood) ||
- (pWin && pWin != device->spriteInfo->sprite->spriteTrace[i-1]))
- goto out;
- }
-
- for (; i < device->spriteInfo->sprite->spriteTraceGood; i++)
- {
- pWin = device->spriteInfo->sprite->spriteTrace[i];
- if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
- sendCore, TRUE))
- {
- ret = TRUE;
- goto out;
- }
+ if (focus) {
+ for (; i < focus->traceGood; i++) {
+ pWin = focus->trace[i];
+ if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
+ sendCore, TRUE)) {
+ ret = TRUE;
+ goto out;
+ }
+ }
+
+ if ((focus->win == NoneWin) ||
+ (i >= device->spriteInfo->sprite->spriteTraceGood) ||
+ (pWin && pWin != device->spriteInfo->sprite->spriteTrace[i - 1]))
+ goto out;
+ }
+
+ for (; i < device->spriteInfo->sprite->spriteTraceGood; i++) {
+ pWin = device->spriteInfo->sprite->spriteTrace[i];
+ if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
+ sendCore, TRUE)) {
+ ret = TRUE;
+ goto out;
+ }
}
-out:
+ out:
if (ret == TRUE && event->type == ET_KeyPress)
device->deviceGrab.activatingKey = event->detail.key;
return ret;
@@ -4095,78 +3944,81 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
int deliveries = 0;
if (focus == FollowKeyboardWin)
- focus = inputInfo.keyboard->focus->win;
+ focus = inputInfo.keyboard->focus->win;
if (!focus)
- return;
- if (focus == PointerRootWin)
- {
- DeliverDeviceEvents(window, event, NullGrab, NullWindow, keybd);
- return;
+ return;
+ if (focus == PointerRootWin) {
+ DeliverDeviceEvents(window, event, NullGrab, NullWindow, keybd);
+ return;
}
- if ((focus == window) || IsParent(focus, window))
- {
- if (DeliverDeviceEvents(window, event, NullGrab, focus, keybd))
- return;
+ if ((focus == window) || IsParent(focus, window)) {
+ if (DeliverDeviceEvents(window, event, NullGrab, focus, keybd))
+ return;
}
/* just deliver it to the focus window */
ptr = GetMaster(keybd, POINTER_OR_FLOAT);
rc = EventToXI2(event, &xi2);
- if (rc == Success)
- {
+ if (rc == Success) {
/* XXX: XACE */
int filter = GetEventFilter(keybd, xi2);
+
FixUpEventFromWindow(ptr->spriteInfo->sprite, xi2, focus, None, FALSE);
deliveries = DeliverEventsToWindow(keybd, focus, xi2, 1,
filter, NullGrab);
if (deliveries > 0)
goto unwind;
- } else if (rc != BadMatch)
- ErrorF("[dix] %s: XI2 conversion failed in DFE (%d, %d). Skipping delivery.\n",
- keybd->name, event->any.type, rc);
+ }
+ else if (rc != BadMatch)
+ ErrorF
+ ("[dix] %s: XI2 conversion failed in DFE (%d, %d). Skipping delivery.\n",
+ keybd->name, event->any.type, rc);
rc = EventToXI(event, &xE, &count);
if (rc == Success &&
- XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, xE, count) == Success)
- {
+ XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, xE, count) == Success) {
FixUpEventFromWindow(ptr->spriteInfo->sprite, xE, focus, None, FALSE);
deliveries = DeliverEventsToWindow(keybd, focus, xE, count,
- GetEventFilter(keybd, xE),
- NullGrab);
+ GetEventFilter(keybd, xE), NullGrab);
if (deliveries > 0)
goto unwind;
- } else if (rc != BadMatch)
- ErrorF("[dix] %s: XI conversion failed in DFE (%d, %d). Skipping delivery.\n",
- keybd->name, event->any.type, rc);
+ }
+ else if (rc != BadMatch)
+ ErrorF
+ ("[dix] %s: XI conversion failed in DFE (%d, %d). Skipping delivery.\n",
+ keybd->name, event->any.type, rc);
- if (sendCore)
- {
+ if (sendCore) {
rc = EventToCore(event, &core, &count);
if (rc == Success) {
- if (XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, core, count) == Success) {
+ if (XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, core, count) ==
+ Success) {
FixUpEventFromWindow(keybd->spriteInfo->sprite, core, focus,
None, FALSE);
- deliveries = DeliverEventsToWindow(keybd, focus, core, count,
- GetEventFilter(keybd, core),
- NullGrab);
+ deliveries =
+ DeliverEventsToWindow(keybd, focus, core, count,
+ GetEventFilter(keybd, core),
+ NullGrab);
}
- } else if (rc != BadMatch)
- ErrorF("[dix] %s: core conversion failed DFE (%d, %d). Skipping delivery.\n",
- keybd->name, event->any.type, rc);
+ }
+ else if (rc != BadMatch)
+ ErrorF
+ ("[dix] %s: core conversion failed DFE (%d, %d). Skipping delivery.\n",
+ keybd->name, event->any.type, rc);
}
-unwind:
+ unwind:
free(core);
free(xE);
free(xi2);
return;
}
-
int
-DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel level)
+DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev,
+ enum InputLevel level)
{
SpritePtr pSprite = dev->spriteInfo->sprite;
int rc;
@@ -4178,61 +4030,58 @@ DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel l
GrabPtr grab = grabinfo->grab;
Mask filter;
- switch(level)
- {
- case XI2:
- rc = EventToXI2(event, &xE);
- count = 1;
- if (rc == Success)
- {
- int evtype = xi2_get_type(xE);
- mask = GetXI2MaskByte(grab->xi2mask, dev, evtype);
- filter = GetEventFilter(dev, xE);
- }
- break;
- case XI:
- if (grabinfo->fromPassiveGrab && grabinfo->implicitGrab)
- mask = grab->deviceMask;
- else
- mask = grab->eventMask;
- rc = EventToXI(event, &xE, &count);
- if (rc == Success)
- filter = GetEventFilter(dev, xE);
- break;
- case CORE:
- rc = EventToCore(event, &xE, &count);
+ switch (level) {
+ case XI2:
+ rc = EventToXI2(event, &xE);
+ count = 1;
+ if (rc == Success) {
+ int evtype = xi2_get_type(xE);
+
+ mask = GetXI2MaskByte(grab->xi2mask, dev, evtype);
+ filter = GetEventFilter(dev, xE);
+ }
+ break;
+ case XI:
+ if (grabinfo->fromPassiveGrab && grabinfo->implicitGrab)
+ mask = grab->deviceMask;
+ else
mask = grab->eventMask;
- if (rc == Success)
- filter = GetEventFilter(dev, xE);
- break;
- default:
- BUG_WARN_MSG(1, "Invalid input level %d\n", level);
- return 0;
+ rc = EventToXI(event, &xE, &count);
+ if (rc == Success)
+ filter = GetEventFilter(dev, xE);
+ break;
+ case CORE:
+ rc = EventToCore(event, &xE, &count);
+ mask = grab->eventMask;
+ if (rc == Success)
+ filter = GetEventFilter(dev, xE);
+ break;
+ default:
+ BUG_WARN_MSG(1, "Invalid input level %d\n", level);
+ return 0;
}
- if (rc == Success)
- {
+ if (rc == Success) {
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
if (XaceHook(XACE_SEND_ACCESS, 0, dev,
- grab->window, xE, count) ||
- XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
- grab->window, xE, count))
- deliveries = 1; /* don't send, but pretend we did */
- else if (level != CORE || !IsInterferingGrab(rClient(grab), dev, xE))
- {
+ grab->window, xE, count) ||
+ XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
+ grab->window, xE, count))
+ deliveries = 1; /* don't send, but pretend we did */
+ else if (level != CORE || !IsInterferingGrab(rClient(grab), dev, xE)) {
deliveries = TryClientEvents(rClient(grab), dev,
- xE, count, mask, filter,
- grab);
+ xE, count, mask, filter, grab);
}
- } else
- BUG_WARN_MSG(rc != BadMatch, "%s: conversion to mode %d failed on %d with %d\n",
- dev->name, level, event->any.type, rc);
+ }
+ else
+ BUG_WARN_MSG(rc != BadMatch,
+ "%s: conversion to mode %d failed on %d with %d\n",
+ dev->name, level, event->any.type, rc);
free(xE);
return deliveries;
}
-
/**
* Deliver an event from a device that is currently grabbed. Uses
* DeliverDeviceEvents() for further delivery if a ownerEvents is set on the
@@ -4256,9 +4105,8 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
grabinfo = &thisDev->deviceGrab;
grab = grabinfo->grab;
- if (grab->ownerEvents)
- {
- WindowPtr focus;
+ if (grab->ownerEvents) {
+ WindowPtr focus;
/* Hack: Some pointer device have a focus class. So we need to check
* for the type of event, to see if we really want to deliver it to
@@ -4266,27 +4114,25 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
*/
if (IsPointerEvent(event))
focus = PointerRootWin;
- else if (thisDev->focus)
- {
- focus = thisDev->focus->win;
- if (focus == FollowKeyboardWin)
- focus = inputInfo.keyboard->focus->win;
- }
- else
- focus = PointerRootWin;
- if (focus == PointerRootWin)
- deliveries = DeliverDeviceEvents(pSprite->win, event, grab,
+ else if (thisDev->focus) {
+ focus = thisDev->focus->win;
+ if (focus == FollowKeyboardWin)
+ focus = inputInfo.keyboard->focus->win;
+ }
+ else
+ focus = PointerRootWin;
+ if (focus == PointerRootWin)
+ deliveries = DeliverDeviceEvents(pSprite->win, event, grab,
NullWindow, thisDev);
- else if (focus && (focus == pSprite->win ||
- IsParent(focus, pSprite->win)))
- deliveries = DeliverDeviceEvents(pSprite->win, event, grab, focus,
- thisDev);
- else if (focus)
- deliveries = DeliverDeviceEvents(focus, event, grab, focus,
- thisDev);
- }
- if (!deliveries)
- {
+ else if (focus && (focus == pSprite->win ||
+ IsParent(focus, pSprite->win)))
+ deliveries = DeliverDeviceEvents(pSprite->win, event, grab, focus,
+ thisDev);
+ else if (focus)
+ deliveries = DeliverDeviceEvents(focus, event, grab, focus,
+ thisDev);
+ }
+ if (!deliveries) {
/* XXX: In theory, we could pass the internal events through to
* everything and only convert just before hitting the wire. We can't
* do that yet, so DGE is the last stop for internal events. From here
@@ -4295,47 +4141,41 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
sendCore = (IsMaster(thisDev) && thisDev->coreEvents);
/* try core event */
- if (sendCore && grab->grabtype == CORE)
- {
+ if (sendCore && grab->grabtype == CORE) {
deliveries = DeliverOneGrabbedEvent(event, thisDev, CORE);
}
- if (!deliveries)
- {
+ if (!deliveries) {
deliveries = DeliverOneGrabbedEvent(event, thisDev, XI2);
}
- if (!deliveries)
- {
+ if (!deliveries) {
deliveries = DeliverOneGrabbedEvent(event, thisDev, XI);
}
if (deliveries && (event->any.type == ET_Motion))
thisDev->valuator->motionHintWindow = grab->window;
}
- if (deliveries && !deactivateGrab && event->any.type != ET_Motion)
- {
- switch (grabinfo->sync.state)
- {
- case FREEZE_BOTH_NEXT_EVENT:
- dev = GetPairedDevice(thisDev);
- if (dev)
- {
- FreezeThaw(dev, TRUE);
- if ((dev->deviceGrab.sync.state == FREEZE_BOTH_NEXT_EVENT) &&
- (CLIENT_BITS(grab->resource) ==
- CLIENT_BITS(dev->deviceGrab.grab->resource)))
- dev->deviceGrab.sync.state = FROZEN_NO_EVENT;
- else
+ if (deliveries && !deactivateGrab && event->any.type != ET_Motion) {
+ switch (grabinfo->sync.state) {
+ case FREEZE_BOTH_NEXT_EVENT:
+ dev = GetPairedDevice(thisDev);
+ if (dev) {
+ FreezeThaw(dev, TRUE);
+ if ((dev->deviceGrab.sync.state == FREEZE_BOTH_NEXT_EVENT) &&
+ (CLIENT_BITS(grab->resource) ==
+ CLIENT_BITS(dev->deviceGrab.grab->resource)))
+ dev->deviceGrab.sync.state = FROZEN_NO_EVENT;
+ else
dev->deviceGrab.sync.other = grab;
- }
- /* fall through */
- case FREEZE_NEXT_EVENT:
- grabinfo->sync.state = FROZEN_WITH_EVENT;
- FreezeThaw(thisDev, TRUE);
- *grabinfo->sync.event = event->device_event;
- break;
- }
+ }
+ /* fall through */
+ case FREEZE_NEXT_EVENT:
+ grabinfo->sync.state = FROZEN_WITH_EVENT;
+ FreezeThaw(thisDev, TRUE);
+ *grabinfo->sync.event = event->device_event;
+ break;
+ }
}
return deliveries;
@@ -4346,12 +4186,12 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
the device's processInputProc to be called, as in for example Mouse Keys.
*/
void
-FixKeyState (DeviceEvent *event, DeviceIntPtr keybd)
+FixKeyState(DeviceEvent *event, DeviceIntPtr keybd)
{
int key = event->detail.key;
if (event->type == ET_KeyPress) {
- DebugF("FixKeyState: Key %d %s\n",key,
+ DebugF("FixKeyState: Key %d %s\n", key,
((event->type == ET_KeyPress) ? "down" : "up"));
}
@@ -4387,32 +4227,28 @@ RecalculateDeliverableEvents(WindowPtr pWin)
WindowPtr pChild;
pChild = pWin;
- while (1)
- {
- if (pChild->optional)
- {
- pChild->optional->otherEventMasks = 0;
- for (others = wOtherClients(pChild); others; others = others->next)
- {
- pChild->optional->otherEventMasks |= others->mask;
- }
- }
- pChild->deliverableEvents = pChild->eventMask|
- wOtherEventMasks(pChild);
- if (pChild->parent)
- pChild->deliverableEvents |=
- (pChild->parent->deliverableEvents &
- ~wDontPropagateMask(pChild) & PropagateMask);
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- while (!pChild->nextSib && (pChild != pWin))
- pChild = pChild->parent;
- if (pChild == pWin)
- break;
- pChild = pChild->nextSib;
+ while (1) {
+ if (pChild->optional) {
+ pChild->optional->otherEventMasks = 0;
+ for (others = wOtherClients(pChild); others; others = others->next) {
+ pChild->optional->otherEventMasks |= others->mask;
+ }
+ }
+ pChild->deliverableEvents = pChild->eventMask |
+ wOtherEventMasks(pChild);
+ if (pChild->parent)
+ pChild->deliverableEvents |=
+ (pChild->parent->deliverableEvents &
+ ~wDontPropagateMask(pChild) & PropagateMask);
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
}
}
@@ -4424,107 +4260,93 @@ int
OtherClientGone(pointer value, XID id)
{
OtherClientsPtr other, prev;
- WindowPtr pWin = (WindowPtr)value;
+ WindowPtr pWin = (WindowPtr) value;
prev = 0;
- for (other = wOtherClients(pWin); other; other = other->next)
- {
- if (other->resource == id)
- {
- if (prev)
- prev->next = other->next;
- else
- {
- if (!(pWin->optional->otherClients = other->next))
- CheckWindowOptionalNeed (pWin);
- }
- free(other);
- RecalculateDeliverableEvents(pWin);
- return Success;
- }
- prev = other;
+ for (other = wOtherClients(pWin); other; other = other->next) {
+ if (other->resource == id) {
+ if (prev)
+ prev->next = other->next;
+ else {
+ if (!(pWin->optional->otherClients = other->next))
+ CheckWindowOptionalNeed(pWin);
+ }
+ free(other);
+ RecalculateDeliverableEvents(pWin);
+ return Success;
+ }
+ prev = other;
}
FatalError("client not on event list");
- /*NOTREACHED*/
- return -1; /* make compiler happy */
+ /*NOTREACHED*/ return -1; /* make compiler happy */
}
int
EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
{
Mask check;
- OtherClients * others;
+ OtherClients *others;
DeviceIntPtr dev;
int rc;
- if (mask & ~AllEventMasks)
- {
- client->errorValue = mask;
- return BadValue;
+ if (mask & ~AllEventMasks) {
+ client->errorValue = mask;
+ return BadValue;
}
check = (mask & ManagerMask);
if (check) {
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id,
- RT_WINDOW, pWin, RT_NONE, NULL, DixManageAccess);
- if (rc != Success)
- return rc;
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id,
+ RT_WINDOW, pWin, RT_NONE, NULL, DixManageAccess);
+ if (rc != Success)
+ return rc;
}
check = (mask & AtMostOneClient);
- if (check & (pWin->eventMask|wOtherEventMasks(pWin)))
- { /* It is illegal for two different
- clients to select on any of the
- events for AtMostOneClient. However,
- it is OK, for some client to
- continue selecting on one of those
- events. */
- if ((wClient(pWin) != client) && (check & pWin->eventMask))
- return BadAccess;
- for (others = wOtherClients (pWin); others; others = others->next)
- {
- if (!SameClient(others, client) && (check & others->mask))
- return BadAccess;
- }
- }
- if (wClient (pWin) == client)
- {
- check = pWin->eventMask;
- pWin->eventMask = mask;
+ if (check & (pWin->eventMask | wOtherEventMasks(pWin))) { /* It is illegal for two different
+ clients to select on any of the
+ events for AtMostOneClient. However,
+ it is OK, for some client to
+ continue selecting on one of those
+ events. */
+ if ((wClient(pWin) != client) && (check & pWin->eventMask))
+ return BadAccess;
+ for (others = wOtherClients(pWin); others; others = others->next) {
+ if (!SameClient(others, client) && (check & others->mask))
+ return BadAccess;
+ }
}
- else
- {
- for (others = wOtherClients (pWin); others; others = others->next)
- {
- if (SameClient(others, client))
- {
- check = others->mask;
- if (mask == 0)
- {
- FreeResource(others->resource, RT_NONE);
- return Success;
- }
- else
- others->mask = mask;
- goto maskSet;
- }
- }
- check = 0;
- if (!pWin->optional && !MakeWindowOptional (pWin))
- return BadAlloc;
- others = malloc(sizeof(OtherClients));
- if (!others)
- return BadAlloc;
- others->mask = mask;
- others->resource = FakeClientID(client->index);
- others->next = pWin->optional->otherClients;
- pWin->optional->otherClients = others;
- if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer)pWin))
- return BadAlloc;
- }
-maskSet:
- if ((mask & PointerMotionHintMask) && !(check & PointerMotionHintMask))
- {
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
+ if (wClient(pWin) == client) {
+ check = pWin->eventMask;
+ pWin->eventMask = mask;
+ }
+ else {
+ for (others = wOtherClients(pWin); others; others = others->next) {
+ if (SameClient(others, client)) {
+ check = others->mask;
+ if (mask == 0) {
+ FreeResource(others->resource, RT_NONE);
+ return Success;
+ }
+ else
+ others->mask = mask;
+ goto maskSet;
+ }
+ }
+ check = 0;
+ if (!pWin->optional && !MakeWindowOptional(pWin))
+ return BadAlloc;
+ others = malloc(sizeof(OtherClients));
+ if (!others)
+ return BadAlloc;
+ others->mask = mask;
+ others->resource = FakeClientID(client->index);
+ others->next = pWin->optional->otherClients;
+ pWin->optional->otherClients = others;
+ if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer) pWin))
+ return BadAlloc;
+ }
+ maskSet:
+ if ((mask & PointerMotionHintMask) && !(check & PointerMotionHintMask)) {
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
if (dev->valuator && dev->valuator->motionHintWindow == pWin)
dev->valuator->motionHintWindow = NullWindow;
}
@@ -4539,50 +4361,42 @@ EventSuppressForWindow(WindowPtr pWin, ClientPtr client,
{
int i, free;
- if (mask & ~PropagateMask)
- {
- client->errorValue = mask;
- return BadValue;
+ if (mask & ~PropagateMask) {
+ client->errorValue = mask;
+ return BadValue;
}
if (pWin->dontPropagate)
- DontPropagateRefCnts[pWin->dontPropagate]--;
+ DontPropagateRefCnts[pWin->dontPropagate]--;
if (!mask)
- i = 0;
- else
- {
- for (i = DNPMCOUNT, free = 0; --i > 0; )
- {
- if (!DontPropagateRefCnts[i])
- free = i;
- else if (mask == DontPropagateMasks[i])
- break;
- }
- if (!i && free)
- {
- i = free;
- DontPropagateMasks[i] = mask;
- }
- }
- if (i || !mask)
- {
- pWin->dontPropagate = i;
- if (i)
- DontPropagateRefCnts[i]++;
- if (pWin->optional)
- {
- pWin->optional->dontPropagateMask = mask;
- *checkOptional = TRUE;
- }
+ i = 0;
+ else {
+ for (i = DNPMCOUNT, free = 0; --i > 0;) {
+ if (!DontPropagateRefCnts[i])
+ free = i;
+ else if (mask == DontPropagateMasks[i])
+ break;
+ }
+ if (!i && free) {
+ i = free;
+ DontPropagateMasks[i] = mask;
+ }
}
- else
- {
- if (!pWin->optional && !MakeWindowOptional (pWin))
- {
- if (pWin->dontPropagate)
- DontPropagateRefCnts[pWin->dontPropagate]++;
- return BadAlloc;
- }
- pWin->dontPropagate = 0;
+ if (i || !mask) {
+ pWin->dontPropagate = i;
+ if (i)
+ DontPropagateRefCnts[i]++;
+ if (pWin->optional) {
+ pWin->optional->dontPropagateMask = mask;
+ *checkOptional = TRUE;
+ }
+ }
+ else {
+ if (!pWin->optional && !MakeWindowOptional(pWin)) {
+ if (pWin->dontPropagate)
+ DontPropagateRefCnts[pWin->dontPropagate]++;
+ return BadAlloc;
+ }
+ pWin->dontPropagate = 0;
pWin->optional->dontPropagateMask = mask;
}
RecalculateDeliverableEvents(pWin);
@@ -4594,34 +4408,28 @@ EventSuppressForWindow(WindowPtr pWin, ClientPtr client,
* Uses the paired keyboard to get some additional information.
*/
void
-CoreEnterLeaveEvent(
- DeviceIntPtr mouse,
- int type,
- int mode,
- int detail,
- WindowPtr pWin,
- Window child)
+CoreEnterLeaveEvent(DeviceIntPtr mouse,
+ int type,
+ int mode, int detail, WindowPtr pWin, Window child)
{
- xEvent event;
- WindowPtr focus;
- DeviceIntPtr keybd;
- GrabPtr grab = mouse->deviceGrab.grab;
- Mask mask;
+ xEvent event;
+ WindowPtr focus;
+ DeviceIntPtr keybd;
+ GrabPtr grab = mouse->deviceGrab.grab;
+ Mask mask;
keybd = GetMaster(mouse, KEYBOARD_OR_FLOAT);
if ((pWin == mouse->valuator->motionHintWindow) &&
- (detail != NotifyInferior))
- mouse->valuator->motionHintWindow = NullWindow;
- if (grab)
- {
- mask = (pWin == grab->window) ? grab->eventMask : 0;
- if (grab->ownerEvents)
- mask |= EventMaskForClient(pWin, rClient(grab));
+ (detail != NotifyInferior))
+ mouse->valuator->motionHintWindow = NullWindow;
+ if (grab) {
+ mask = (pWin == grab->window) ? grab->eventMask : 0;
+ if (grab->ownerEvents)
+ mask |= EventMaskForClient(pWin, rClient(grab));
}
- else
- {
- mask = pWin->eventMask | wOtherEventMasks(pWin);
+ else {
+ mask = pWin->eventMask | wOtherEventMasks(pWin);
}
memset(&event, 0, sizeof(xEvent));
@@ -4636,62 +4444,56 @@ CoreEnterLeaveEvent(
event.u.enterLeave.child = child;
event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ?
ELFlagSameScreen : 0;
- event.u.enterLeave.state = mouse->button ? (mouse->button->state & 0x1f00) : 0;
+ event.u.enterLeave.state =
+ mouse->button ? (mouse->button->state & 0x1f00) : 0;
if (keybd)
event.u.enterLeave.state |=
- XkbGrabStateFromRec(&keybd->key->xkbInfo->state);
+ XkbGrabStateFromRec(&keybd->key->xkbInfo->state);
event.u.enterLeave.mode = mode;
focus = (keybd) ? keybd->focus->win : None;
if ((focus != NoneWin) &&
- ((pWin == focus) || (focus == PointerRootWin) ||
- IsParent(focus, pWin)))
+ ((pWin == focus) || (focus == PointerRootWin) || IsParent(focus, pWin)))
event.u.enterLeave.flags |= ELFlagFocus;
- if ((mask & GetEventFilter(mouse, &event)))
- {
+ if ((mask & GetEventFilter(mouse, &event))) {
if (grab)
TryClientEvents(rClient(grab), mouse, &event, 1, mask,
GetEventFilter(mouse, &event), grab);
else
DeliverEventsToWindow(mouse, pWin, &event, 1,
- GetEventFilter(mouse, &event),
- NullGrab);
+ GetEventFilter(mouse, &event), NullGrab);
}
- if ((type == EnterNotify) && (mask & KeymapStateMask))
- {
+ if ((type == EnterNotify) && (mask & KeymapStateMask)) {
xKeymapEvent ke;
ClientPtr client = grab ? rClient(grab) : wClient(pWin);
+
if (XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess))
- memset((char *)&ke.map[0], 0, 31);
+ memset((char *) &ke.map[0], 0, 31);
else
- memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31);
+ memmove((char *) &ke.map[0], (char *) &keybd->key->down[1], 31);
ke.type = KeymapNotify;
if (grab)
- TryClientEvents(rClient(grab), keybd, (xEvent *)&ke, 1,
+ TryClientEvents(rClient(grab), keybd, (xEvent *) &ke, 1,
mask, KeymapStateMask, grab);
else
- DeliverEventsToWindow(mouse, pWin, (xEvent *)&ke, 1,
+ DeliverEventsToWindow(mouse, pWin, (xEvent *) &ke, 1,
KeymapStateMask, NullGrab);
}
}
void
-DeviceEnterLeaveEvent(
- DeviceIntPtr mouse,
- int sourceid,
- int type,
- int mode,
- int detail,
- WindowPtr pWin,
- Window child)
+DeviceEnterLeaveEvent(DeviceIntPtr mouse,
+ int sourceid,
+ int type,
+ int mode, int detail, WindowPtr pWin, Window child)
{
- GrabPtr grab = mouse->deviceGrab.grab;
- xXIEnterEvent *event;
- int filter;
- int btlen, len, i;
- DeviceIntPtr kbd;
+ GrabPtr grab = mouse->deviceGrab.grab;
+ xXIEnterEvent *event;
+ int filter;
+ int btlen, len, i;
+ DeviceIntPtr kbd;
if ((mode == XINotifyPassiveGrab && type == XI_Leave) ||
(mode == XINotifyPassiveUngrab && type == XI_Enter))
@@ -4702,26 +4504,25 @@ DeviceEnterLeaveEvent(
len = sizeof(xXIEnterEvent) + btlen * 4;
event = calloc(1, len);
- event->type = GenericEvent;
- event->extension = IReqCode;
- event->evtype = type;
- event->length = (len - sizeof(xEvent))/4;
- event->buttons_len = btlen;
- event->detail = detail;
- event->time = currentTime.milliseconds;
- event->deviceid = mouse->id;
- event->sourceid = sourceid;
- event->mode = mode;
- event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
- event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
+ event->type = GenericEvent;
+ event->extension = IReqCode;
+ event->evtype = type;
+ event->length = (len - sizeof(xEvent)) / 4;
+ event->buttons_len = btlen;
+ event->detail = detail;
+ event->time = currentTime.milliseconds;
+ event->deviceid = mouse->id;
+ event->sourceid = sourceid;
+ event->mode = mode;
+ event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
+ event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
if (BitIsOn(mouse->button->down, i))
SetBit(&event[1], i);
kbd = GetMaster(mouse, MASTER_KEYBOARD);
- if (kbd && kbd->key)
- {
+ if (kbd && kbd->key) {
event->mods.base_mods = kbd->key->xkbInfo->state.base_mods;
event->mods.latched_mods = kbd->key->xkbInfo->state.latched_mods;
event->mods.locked_mods = kbd->key->xkbInfo->state.locked_mods;
@@ -4731,24 +4532,26 @@ DeviceEnterLeaveEvent(
event->group.locked_group = kbd->key->xkbInfo->state.locked_group;
}
- FixUpEventFromWindow(mouse->spriteInfo->sprite, (xEvent*)event, pWin,
+ FixUpEventFromWindow(mouse->spriteInfo->sprite, (xEvent *) event, pWin,
None, FALSE);
- filter = GetEventFilter(mouse, (xEvent*)event);
+ filter = GetEventFilter(mouse, (xEvent *) event);
- if (grab)
- {
+ if (grab) {
Mask mask;
+
mask = xi2mask_isset(grab->xi2mask, mouse, type);
- TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask, 1, grab);
- } else {
- if (!WindowXI2MaskIsset(mouse, pWin, (xEvent*)event))
+ TryClientEvents(rClient(grab), mouse, (xEvent *) event, 1, mask, 1,
+ grab);
+ }
+ else {
+ if (!WindowXI2MaskIsset(mouse, pWin, (xEvent *) event))
goto out;
- DeliverEventsToWindow(mouse, pWin, (xEvent*)event, 1, filter,
+ DeliverEventsToWindow(mouse, pWin, (xEvent *) event, 1, filter,
NullGrab);
}
-out:
+ out:
free(event);
}
@@ -4766,18 +4569,18 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
DeliverEventsToWindow(dev, pWin, &event, 1,
GetEventFilter(dev, &event), NullGrab);
if ((type == FocusIn) &&
- ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask))
- {
+ ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask)) {
xKeymapEvent ke;
ClientPtr client = wClient(pWin);
+
if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess))
- memset((char *)&ke.map[0], 0, 31);
+ memset((char *) &ke.map[0], 0, 31);
else
- memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31);
+ memmove((char *) &ke.map[0], (char *) &dev->key->down[1], 31);
ke.type = KeymapNotify;
- DeliverEventsToWindow(dev, pWin, (xEvent *)&ke, 1,
- KeymapStateMask, NullGrab);
+ DeliverEventsToWindow(dev, pWin, (xEvent *) &ke, 1,
+ KeymapStateMask, NullGrab);
}
}
@@ -4799,90 +4602,81 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
* @param followOK True if pointer is allowed to follow the keyboard.
*/
int
-SetInputFocus(
- ClientPtr client,
- DeviceIntPtr dev,
- Window focusID,
- CARD8 revertTo,
- Time ctime,
- Bool followOK)
+SetInputFocus(ClientPtr client,
+ DeviceIntPtr dev,
+ Window focusID, CARD8 revertTo, Time ctime, Bool followOK)
{
FocusClassPtr focus;
WindowPtr focusWin;
int mode, rc;
TimeStamp time;
- DeviceIntPtr keybd; /* used for FollowKeyboard or FollowKeyboardWin */
-
+ DeviceIntPtr keybd; /* used for FollowKeyboard or FollowKeyboardWin */
UpdateCurrentTime();
if ((revertTo != RevertToParent) &&
- (revertTo != RevertToPointerRoot) &&
- (revertTo != RevertToNone) &&
- ((revertTo != RevertToFollowKeyboard) || !followOK))
- {
- client->errorValue = revertTo;
- return BadValue;
+ (revertTo != RevertToPointerRoot) &&
+ (revertTo != RevertToNone) &&
+ ((revertTo != RevertToFollowKeyboard) || !followOK)) {
+ client->errorValue = revertTo;
+ return BadValue;
}
time = ClientTimeToServerTime(ctime);
keybd = GetMaster(dev, KEYBOARD_OR_FLOAT);
if ((focusID == None) || (focusID == PointerRoot))
- focusWin = (WindowPtr)(long)focusID;
- else if ((focusID == FollowKeyboard) && followOK)
- {
- focusWin = keybd->focus->win;
+ focusWin = (WindowPtr) (long) focusID;
+ else if ((focusID == FollowKeyboard) && followOK) {
+ focusWin = keybd->focus->win;
}
else {
- rc = dixLookupWindow(&focusWin, focusID, client, DixSetAttrAccess);
- if (rc != Success)
- return rc;
- /* It is a match error to try to set the input focus to an
- unviewable window. */
- if(!focusWin->realized)
- return BadMatch;
+ rc = dixLookupWindow(&focusWin, focusID, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ /* It is a match error to try to set the input focus to an
+ unviewable window. */
+ if (!focusWin->realized)
+ return BadMatch;
}
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixSetFocusAccess);
if (rc != Success)
- return Success;
+ return Success;
focus = dev->focus;
if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, focus->time) == EARLIER))
- return Success;
+ (CompareTimeStamps(time, focus->time) == EARLIER))
+ return Success;
mode = (dev->deviceGrab.grab) ? NotifyWhileGrabbed : NotifyNormal;
- if (focus->win == FollowKeyboardWin)
- {
+ if (focus->win == FollowKeyboardWin) {
if (!ActivateFocusInGrab(dev, keybd->focus->win, focusWin))
DoFocusEvents(dev, keybd->focus->win, focusWin, mode);
- } else
- {
+ }
+ else {
if (!ActivateFocusInGrab(dev, focus->win, focusWin))
DoFocusEvents(dev, focus->win, focusWin, mode);
}
focus->time = time;
focus->revert = revertTo;
if (focusID == FollowKeyboard)
- focus->win = FollowKeyboardWin;
+ focus->win = FollowKeyboardWin;
else
- focus->win = focusWin;
+ focus->win = focusWin;
if ((focusWin == NoneWin) || (focusWin == PointerRootWin))
- focus->traceGood = 0;
- else
- {
+ focus->traceGood = 0;
+ else {
int depth = 0;
- WindowPtr pWin;
-
- for (pWin = focusWin; pWin; pWin = pWin->parent) depth++;
- if (depth > focus->traceSize)
- {
- focus->traceSize = depth+1;
- focus->trace = realloc(focus->trace,
- focus->traceSize * sizeof(WindowPtr));
- }
- focus->traceGood = depth;
+ WindowPtr pWin;
+
+ for (pWin = focusWin; pWin; pWin = pWin->parent)
+ depth++;
+ if (depth > focus->traceSize) {
+ focus->traceSize = depth + 1;
+ focus->trace = realloc(focus->trace,
+ focus->traceSize * sizeof(WindowPtr));
+ }
+ focus->traceGood = depth;
for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--)
- focus->trace[depth] = pWin;
+ focus->trace[depth] = pWin;
}
return Success;
}
@@ -4896,12 +4690,13 @@ int
ProcSetInputFocus(ClientPtr client)
{
DeviceIntPtr kbd = PickKeyboard(client);
+
REQUEST(xSetInputFocusReq);
REQUEST_SIZE_MATCH(xSetInputFocusReq);
return SetInputFocus(client, kbd, stuff->focus,
- stuff->revertTo, stuff->time, FALSE);
+ stuff->revertTo, stuff->time, FALSE);
}
/**
@@ -4917,22 +4712,24 @@ ProcGetInputFocus(ClientPtr client)
xGetInputFocusReply rep;
FocusClassPtr focus = kbd->focus;
int rc;
+
/* REQUEST(xReq); */
REQUEST_SIZE_MATCH(xReq);
rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetFocusAccess);
if (rc != Success)
- return rc;
+ return rc;
memset(&rep, 0, sizeof(xGetInputFocusReply));
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (focus->win == NoneWin)
- rep.focus = None;
+ rep.focus = None;
else if (focus->win == PointerRootWin)
- rep.focus = PointerRoot;
- else rep.focus = focus->win->drawable.id;
+ rep.focus = PointerRoot;
+ else
+ rep.focus = focus->win->drawable.id;
rep.revertTo = focus->revert;
WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
return Success;
@@ -4953,34 +4750,32 @@ ProcGrabPointer(ClientPtr client)
GrabMask mask;
WindowPtr confineTo;
CursorPtr oldCursor;
+
REQUEST(xGrabPointerReq);
int rc;
REQUEST_SIZE_MATCH(xGrabPointerReq);
UpdateCurrentTime();
- if (stuff->eventMask & ~PointerGrabMask)
- {
- client->errorValue = stuff->eventMask;
+ if (stuff->eventMask & ~PointerGrabMask) {
+ client->errorValue = stuff->eventMask;
return BadValue;
}
if (stuff->confineTo == None)
- confineTo = NullWindow;
- else
- {
- rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
- DixSetAttrAccess);
- if (rc != Success)
- return rc;
+ confineTo = NullWindow;
+ else {
+ rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
+ DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
}
memset(&rep, 0, sizeof(xGrabPointerReply));
oldCursor = NullCursor;
grab = device->deviceGrab.grab;
- if (grab)
- {
+ if (grab) {
if (grab->confineTo && !confineTo)
ConfineCursorToWindow(device, GetCurrentRootWindow(device), FALSE,
FALSE);
@@ -4991,13 +4786,12 @@ ProcGrabPointer(ClientPtr client)
rc = GrabDevice(client, device, stuff->pointerMode, stuff->keyboardMode,
stuff->grabWindow, stuff->ownerEvents, stuff->time,
- &mask, CORE, stuff->cursor,
- stuff->confineTo, &rep.status);
+ &mask, CORE, stuff->cursor, stuff->confineTo, &rep.status);
if (rc != Success)
return rc;
if (oldCursor && rep.status == GrabSuccess)
- FreeCursor (oldCursor, (Cursor)0);
+ FreeCursor(oldCursor, (Cursor) 0);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
@@ -5016,48 +4810,47 @@ int
ProcChangeActivePointerGrab(ClientPtr client)
{
DeviceIntPtr device;
- GrabPtr grab;
+ GrabPtr grab;
CursorPtr newCursor, oldCursor;
+
REQUEST(xChangeActivePointerGrabReq);
TimeStamp time;
REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
- if (stuff->eventMask & ~PointerGrabMask)
- {
- client->errorValue = stuff->eventMask;
+ if (stuff->eventMask & ~PointerGrabMask) {
+ client->errorValue = stuff->eventMask;
return BadValue;
}
if (stuff->cursor == None)
- newCursor = NullCursor;
- else
- {
- int rc = dixLookupResourceByType((pointer *)&newCursor, stuff->cursor,
- RT_CURSOR, client, DixUseAccess);
- if (rc != Success)
- {
- client->errorValue = stuff->cursor;
- return rc;
- }
+ newCursor = NullCursor;
+ else {
+ int rc = dixLookupResourceByType((pointer *) &newCursor, stuff->cursor,
+ RT_CURSOR, client, DixUseAccess);
+
+ if (rc != Success) {
+ client->errorValue = stuff->cursor;
+ return rc;
+ }
}
device = PickPointer(client);
grab = device->deviceGrab.grab;
if (!grab)
- return Success;
+ return Success;
if (!SameClient(grab, client))
- return Success;
+ return Success;
time = ClientTimeToServerTime(stuff->time);
if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER))
- return Success;
+ (CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER))
+ return Success;
oldCursor = grab->cursor;
grab->cursor = newCursor;
if (newCursor)
- newCursor->refcnt++;
+ newCursor->refcnt++;
PostNewCursor(device);
if (oldCursor)
- FreeCursor(oldCursor, (Cursor)0);
+ FreeCursor(oldCursor, (Cursor) 0);
grab->eventMask = stuff->eventMask;
return Success;
}
@@ -5073,6 +4866,7 @@ ProcUngrabPointer(ClientPtr client)
DeviceIntPtr device = PickPointer(client);
GrabPtr grab;
TimeStamp time;
+
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
@@ -5081,9 +4875,9 @@ ProcUngrabPointer(ClientPtr client)
time = ClientTimeToServerTime(stuff->id);
if ((CompareTimeStamps(time, currentTime) != LATER) &&
- (CompareTimeStamps(time, device->deviceGrab.grabTime) != EARLIER) &&
- (grab) && SameClient(grab, client))
- (*device->deviceGrab.DeactivateGrab)(device);
+ (CompareTimeStamps(time, device->deviceGrab.grabTime) != EARLIER) &&
+ (grab) && SameClient(grab, client))
+ (*device->deviceGrab.DeactivateGrab) (device);
return Success;
}
@@ -5120,99 +4914,91 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
CursorPtr cursor;
UpdateCurrentTime();
- if ((keyboard_mode != GrabModeSync) && (keyboard_mode != GrabModeAsync))
- {
- client->errorValue = keyboard_mode;
+ if ((keyboard_mode != GrabModeSync) && (keyboard_mode != GrabModeAsync)) {
+ client->errorValue = keyboard_mode;
return BadValue;
}
- if ((pointer_mode != GrabModeSync) && (pointer_mode != GrabModeAsync))
- {
- client->errorValue = pointer_mode;
+ if ((pointer_mode != GrabModeSync) && (pointer_mode != GrabModeAsync)) {
+ client->errorValue = pointer_mode;
return BadValue;
}
- if ((ownerEvents != xFalse) && (ownerEvents != xTrue))
- {
- client->errorValue = ownerEvents;
+ if ((ownerEvents != xFalse) && (ownerEvents != xTrue)) {
+ client->errorValue = ownerEvents;
return BadValue;
}
rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
if (rc != Success)
- return rc;
+ return rc;
if (confineToWin == None)
- confineTo = NullWindow;
- else
- {
- rc = dixLookupWindow(&confineTo, confineToWin, client,
- DixSetAttrAccess);
- if (rc != Success)
- return rc;
+ confineTo = NullWindow;
+ else {
+ rc = dixLookupWindow(&confineTo, confineToWin, client,
+ DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
}
if (curs == None)
- cursor = NullCursor;
- else
- {
- rc = dixLookupResourceByType((pointer *)&cursor, curs, RT_CURSOR,
- client, DixUseAccess);
- if (rc != Success)
- {
- client->errorValue = curs;
- return rc;
- }
- access_mode |= DixForceAccess;
+ cursor = NullCursor;
+ else {
+ rc = dixLookupResourceByType((pointer *) &cursor, curs, RT_CURSOR,
+ client, DixUseAccess);
+ if (rc != Success) {
+ client->errorValue = curs;
+ return rc;
+ }
+ access_mode |= DixForceAccess;
}
if (keyboard_mode == GrabModeSync || pointer_mode == GrabModeSync)
- access_mode |= DixFreezeAccess;
+ access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
- return rc;
+ return rc;
time = ClientTimeToServerTime(ctime);
grab = grabInfo->grab;
if (grab && grab->grabtype != grabtype)
*status = AlreadyGrabbed;
if (grab && !SameClient(grab, client))
- *status = AlreadyGrabbed;
+ *status = AlreadyGrabbed;
else if ((!pWin->realized) ||
(confineTo &&
- !(confineTo->realized
- && BorderSizeNotEmpty(dev, confineTo))))
- *status = GrabNotViewable;
+ !(confineTo->realized && BorderSizeNotEmpty(dev, confineTo))))
+ *status = GrabNotViewable;
else if ((CompareTimeStamps(time, currentTime) == LATER) ||
- (CompareTimeStamps(time, grabInfo->grabTime) == EARLIER))
- *status = GrabInvalidTime;
+ (CompareTimeStamps(time, grabInfo->grabTime) == EARLIER))
+ *status = GrabInvalidTime;
else if (grabInfo->sync.frozen &&
- grabInfo->sync.other && !SameClient(grabInfo->sync.other, client))
- *status = GrabFrozen;
- else
- {
- GrabPtr tempGrab;
-
- tempGrab = AllocGrab();
-
- tempGrab->next = NULL;
- tempGrab->window = pWin;
- tempGrab->resource = client->clientAsMask;
- tempGrab->ownerEvents = ownerEvents;
- tempGrab->keyboardMode = keyboard_mode;
- tempGrab->pointerMode = pointer_mode;
- if (grabtype == CORE)
- tempGrab->eventMask = mask->core;
- else if (grabtype == XI)
- tempGrab->eventMask = mask->xi;
- else
+ grabInfo->sync.other && !SameClient(grabInfo->sync.other, client))
+ *status = GrabFrozen;
+ else {
+ GrabPtr tempGrab;
+
+ tempGrab = AllocGrab();
+
+ tempGrab->next = NULL;
+ tempGrab->window = pWin;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->ownerEvents = ownerEvents;
+ tempGrab->keyboardMode = keyboard_mode;
+ tempGrab->pointerMode = pointer_mode;
+ if (grabtype == CORE)
+ tempGrab->eventMask = mask->core;
+ else if (grabtype == XI)
+ tempGrab->eventMask = mask->xi;
+ else
xi2mask_merge(tempGrab->xi2mask, mask->xi2mask);
- tempGrab->device = dev;
- tempGrab->cursor = cursor;
- tempGrab->confineTo = confineTo;
- tempGrab->grabtype = grabtype;
- (*grabInfo->ActivateGrab)(dev, tempGrab, time, FALSE);
- *status = GrabSuccess;
+ tempGrab->device = dev;
+ tempGrab->cursor = cursor;
+ tempGrab->confineTo = confineTo;
+ tempGrab->grabtype = grabtype;
+ (*grabInfo->ActivateGrab) (dev, tempGrab, time, FALSE);
+ *status = GrabSuccess;
- FreeGrab(tempGrab);
+ FreeGrab(tempGrab);
}
return Success;
}
@@ -5226,6 +5012,7 @@ int
ProcGrabKeyboard(ClientPtr client)
{
xGrabKeyboardReply rep;
+
REQUEST(xGrabKeyboardReq);
int result;
DeviceIntPtr keyboard = PickKeyboard(client);
@@ -5237,12 +5024,12 @@ ProcGrabKeyboard(ClientPtr client)
mask.core = KeyPressMask | KeyReleaseMask;
result = GrabDevice(client, keyboard, stuff->pointerMode,
- stuff->keyboardMode, stuff->grabWindow, stuff->ownerEvents,
- stuff->time, &mask, CORE, None, None,
- &rep.status);
+ stuff->keyboardMode, stuff->grabWindow,
+ stuff->ownerEvents, stuff->time, &mask, CORE, None,
+ None, &rep.status);
if (result != Success)
- return result;
+ return result;
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
@@ -5261,6 +5048,7 @@ ProcUngrabKeyboard(ClientPtr client)
DeviceIntPtr device = PickKeyboard(client);
GrabPtr grab;
TimeStamp time;
+
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
@@ -5270,9 +5058,9 @@ ProcUngrabKeyboard(ClientPtr client)
time = ClientTimeToServerTime(stuff->id);
if ((CompareTimeStamps(time, currentTime) != LATER) &&
- (CompareTimeStamps(time, device->deviceGrab.grabTime) != EARLIER) &&
- (grab) && SameClient(grab, client) && grab->grabtype == CORE)
- (*device->deviceGrab.DeactivateGrab)(device);
+ (CompareTimeStamps(time, device->deviceGrab.grabTime) != EARLIER) &&
+ (grab) && SameClient(grab, client) && grab->grabtype == CORE)
+ (*device->deviceGrab.DeactivateGrab) (device);
return Success;
}
@@ -5291,21 +5079,22 @@ ProcQueryPointer(ClientPtr client)
DeviceIntPtr keyboard;
SpritePtr pSprite;
int rc;
+
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
- return rc;
+ return rc;
rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess);
if (rc != Success && rc != BadAccess)
- return rc;
+ return rc;
keyboard = GetMaster(mouse, MASTER_KEYBOARD);
pSprite = mouse->spriteInfo->sprite;
if (mouse->valuator->motionHintWindow)
- MaybeStopHint(mouse, client);
+ MaybeStopHint(mouse, client);
memset(&rep, 0, sizeof(xQueryPointerReply));
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
@@ -5316,43 +5105,40 @@ ProcQueryPointer(ClientPtr client)
rep.rootX = pSprite->hot.x;
rep.rootY = pSprite->hot.y;
rep.child = None;
- if (pSprite->hot.pScreen == pWin->drawable.pScreen)
- {
- rep.sameScreen = xTrue;
- rep.winX = pSprite->hot.x - pWin->drawable.x;
- rep.winY = pSprite->hot.y - pWin->drawable.y;
- for (t = pSprite->win; t; t = t->parent)
- if (t->parent == pWin)
- {
- rep.child = t->drawable.id;
- break;
- }
+ if (pSprite->hot.pScreen == pWin->drawable.pScreen) {
+ rep.sameScreen = xTrue;
+ rep.winX = pSprite->hot.x - pWin->drawable.x;
+ rep.winY = pSprite->hot.y - pWin->drawable.y;
+ for (t = pSprite->win; t; t = t->parent)
+ if (t->parent == pWin) {
+ rep.child = t->drawable.id;
+ break;
+ }
}
- else
- {
- rep.sameScreen = xFalse;
- rep.winX = 0;
- rep.winY = 0;
+ else {
+ rep.sameScreen = xFalse;
+ rep.winX = 0;
+ rep.winY = 0;
}
#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
- rep.rootX += screenInfo.screens[0]->x;
- rep.rootY += screenInfo.screens[0]->y;
- if(stuff->id == rep.root) {
- rep.winX += screenInfo.screens[0]->x;
- rep.winY += screenInfo.screens[0]->y;
- }
+ if (!noPanoramiXExtension) {
+ rep.rootX += screenInfo.screens[0]->x;
+ rep.rootY += screenInfo.screens[0]->y;
+ if (stuff->id == rep.root) {
+ rep.winX += screenInfo.screens[0]->x;
+ rep.winY += screenInfo.screens[0]->y;
+ }
}
#endif
if (rc == BadAccess) {
- rep.mask = 0;
- rep.child = None;
- rep.rootX = 0;
- rep.rootY = 0;
- rep.winX = 0;
- rep.winY = 0;
+ rep.mask = 0;
+ rep.child = None;
+ rep.rootX = 0;
+ rep.rootY = 0;
+ rep.winX = 0;
+ rep.winY = 0;
}
WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
@@ -5371,16 +5157,17 @@ InitEvents(void)
QdEventPtr qe, tmp;
inputInfo.numDevices = 0;
- inputInfo.devices = (DeviceIntPtr)NULL;
- inputInfo.off_devices = (DeviceIntPtr)NULL;
- inputInfo.keyboard = (DeviceIntPtr)NULL;
- inputInfo.pointer = (DeviceIntPtr)NULL;
- for (i = 0; i < MAXDEVICES; i++)
- {
+ inputInfo.devices = (DeviceIntPtr) NULL;
+ inputInfo.off_devices = (DeviceIntPtr) NULL;
+ inputInfo.keyboard = (DeviceIntPtr) NULL;
+ inputInfo.pointer = (DeviceIntPtr) NULL;
+
+ for (i = 0; i < MAXDEVICES; i++) {
memcpy(&event_filters[i], default_filter, sizeof(default_filter));
+ lastDeviceEventTime[i] = currentTime;
}
- syncEvents.replayDev = (DeviceIntPtr)NULL;
+ syncEvents.replayDev = (DeviceIntPtr) NULL;
syncEvents.replayWin = NullWindow;
if (syncEvents.pending.next)
xorg_list_for_each_entry_safe(qe, tmp, &syncEvents.pending, next)
@@ -5388,14 +5175,12 @@ InitEvents(void)
xorg_list_init(&syncEvents.pending);
syncEvents.playingEvents = FALSE;
syncEvents.time.months = 0;
- syncEvents.time.milliseconds = 0; /* hardly matters */
+ syncEvents.time.milliseconds = 0; /* hardly matters */
currentTime.months = 0;
currentTime.milliseconds = GetTimeInMillis();
- lastDeviceEventTime = currentTime;
- for (i = 0; i < DNPMCOUNT; i++)
- {
- DontPropagateMasks[i] = 0;
- DontPropagateRefCnts[i] = 0;
+ for (i = 0; i < DNPMCOUNT; i++) {
+ DontPropagateMasks[i] = 0;
+ DontPropagateRefCnts[i] = 0;
}
InputEventList = InitEventList(GetMaximumEventsNum());
@@ -5421,10 +5206,11 @@ int
ProcSendEvent(ClientPtr client)
{
WindowPtr pWin;
- WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
+ WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
DeviceIntPtr dev = PickPointer(client);
DeviceIntPtr keybd = GetMaster(dev, MASTER_KEYBOARD);
SpritePtr pSprite = dev->spriteInfo->sprite;
+
REQUEST(xSendEventReq);
REQUEST_SIZE_MATCH(xSendEventReq);
@@ -5440,83 +5226,75 @@ ProcSendEvent(ClientPtr client)
stuff->event.u.u.type &= ~(SEND_EVENT_BIT);
/* The client's event type must be a core event type or one defined by an
- extension. */
+ extension. */
- if ( ! ((stuff->event.u.u.type > X_Reply &&
- stuff->event.u.u.type < LASTEvent) ||
- (stuff->event.u.u.type >= EXTENSION_EVENT_BASE &&
- stuff->event.u.u.type < (unsigned)lastEvent)))
- {
- client->errorValue = stuff->event.u.u.type;
- return BadValue;
+ if (!((stuff->event.u.u.type > X_Reply &&
+ stuff->event.u.u.type < LASTEvent) ||
+ (stuff->event.u.u.type >= EXTENSION_EVENT_BASE &&
+ stuff->event.u.u.type < (unsigned) lastEvent))) {
+ client->errorValue = stuff->event.u.u.type;
+ return BadValue;
}
if (stuff->event.u.u.type == ClientMessage &&
- stuff->event.u.u.detail != 8 &&
- stuff->event.u.u.detail != 16 &&
- stuff->event.u.u.detail != 32)
- {
- client->errorValue = stuff->event.u.u.detail;
- return BadValue;
+ stuff->event.u.u.detail != 8 &&
+ stuff->event.u.u.detail != 16 && stuff->event.u.u.detail != 32) {
+ client->errorValue = stuff->event.u.u.detail;
+ return BadValue;
}
- if (stuff->eventMask & ~AllEventMasks)
- {
- client->errorValue = stuff->eventMask;
- return BadValue;
+ if (stuff->eventMask & ~AllEventMasks) {
+ client->errorValue = stuff->eventMask;
+ return BadValue;
}
if (stuff->destination == PointerWindow)
- pWin = pSprite->win;
- else if (stuff->destination == InputFocus)
- {
- WindowPtr inputFocus = (keybd) ? keybd->focus->win : NoneWin;
+ pWin = pSprite->win;
+ else if (stuff->destination == InputFocus) {
+ WindowPtr inputFocus = (keybd) ? keybd->focus->win : NoneWin;
- if (inputFocus == NoneWin)
- return Success;
+ if (inputFocus == NoneWin)
+ return Success;
- /* If the input focus is PointerRootWin, send the event to where
- the pointer is if possible, then perhaps propogate up to root. */
- if (inputFocus == PointerRootWin)
- inputFocus = GetCurrentRootWindow(dev);
+ /* If the input focus is PointerRootWin, send the event to where
+ the pointer is if possible, then perhaps propogate up to root. */
+ if (inputFocus == PointerRootWin)
+ inputFocus = GetCurrentRootWindow(dev);
- if (IsParent(inputFocus, pSprite->win))
- {
- effectiveFocus = inputFocus;
- pWin = pSprite->win;
- }
- else
- effectiveFocus = pWin = inputFocus;
+ if (IsParent(inputFocus, pSprite->win)) {
+ effectiveFocus = inputFocus;
+ pWin = pSprite->win;
+ }
+ else
+ effectiveFocus = pWin = inputFocus;
}
else
- dixLookupWindow(&pWin, stuff->destination, client, DixSendAccess);
+ dixLookupWindow(&pWin, stuff->destination, client, DixSendAccess);
if (!pWin)
- return BadWindow;
- if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue))
- {
- client->errorValue = stuff->propagate;
- return BadValue;
+ return BadWindow;
+ if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue)) {
+ client->errorValue = stuff->propagate;
+ return BadValue;
}
stuff->event.u.u.type |= SEND_EVENT_BIT;
- if (stuff->propagate)
- {
- for (;pWin; pWin = pWin->parent)
- {
- if (XaceHook(XACE_SEND_ACCESS, client, NULL, pWin,
- &stuff->event, 1))
- return Success;
+ if (stuff->propagate) {
+ for (; pWin; pWin = pWin->parent) {
+ if (XaceHook(XACE_SEND_ACCESS, client, NULL, pWin,
+ &stuff->event, 1))
+ return Success;
if (DeliverEventsToWindow(dev, pWin,
- &stuff->event, 1, stuff->eventMask, NullGrab))
- return Success;
- if (pWin == effectiveFocus)
- return Success;
- stuff->eventMask &= ~wDontPropagateMask(pWin);
- if (!stuff->eventMask)
- break;
- }
+ &stuff->event, 1, stuff->eventMask,
+ NullGrab))
+ return Success;
+ if (pWin == effectiveFocus)
+ return Success;
+ stuff->eventMask &= ~wDontPropagateMask(pWin);
+ if (!stuff->eventMask)
+ break;
+ }
}
else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, &stuff->event, 1))
DeliverEventsToWindow(dev, pWin, &stuff->event,
- 1, stuff->eventMask, NullGrab);
+ 1, stuff->eventMask, NullGrab);
return Success;
}
@@ -5538,20 +5316,18 @@ ProcUngrabKey(ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabKeyReq);
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixGetAttrAccess);
if (rc != Success)
- return rc;
+ return rc;
if (((stuff->key > keybd->key->xkbInfo->desc->max_key_code) ||
- (stuff->key < keybd->key->xkbInfo->desc->min_key_code))
- && (stuff->key != AnyKey))
- {
- client->errorValue = stuff->key;
+ (stuff->key < keybd->key->xkbInfo->desc->min_key_code))
+ && (stuff->key != AnyKey)) {
+ client->errorValue = stuff->key;
return BadValue;
}
if ((stuff->modifiers != AnyModifier) &&
- (stuff->modifiers & ~AllModifiersMask))
- {
- client->errorValue = stuff->modifiers;
- return BadValue;
+ (stuff->modifiers & ~AllModifiersMask)) {
+ client->errorValue = stuff->modifiers;
+ return BadValue;
}
tempGrab = AllocGrab();
if (!tempGrab)
@@ -5586,6 +5362,7 @@ int
ProcGrabKey(ClientPtr client)
{
WindowPtr pWin;
+
REQUEST(xGrabKeyReq);
GrabPtr grab;
DeviceIntPtr keybd = PickKeyboard(client);
@@ -5607,27 +5384,24 @@ ProcGrabKey(ClientPtr client)
return rc;
if (((stuff->key > keybd->key->xkbInfo->desc->max_key_code) ||
- (stuff->key < keybd->key->xkbInfo->desc->min_key_code))
- && (stuff->key != AnyKey))
- {
- client->errorValue = stuff->key;
+ (stuff->key < keybd->key->xkbInfo->desc->min_key_code))
+ && (stuff->key != AnyKey)) {
+ client->errorValue = stuff->key;
return BadValue;
}
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
- return rc;
-
+ return rc;
mask.core = (KeyPressMask | KeyReleaseMask);
grab = CreateGrab(client->index, keybd, keybd, pWin, CORE, &mask,
&param, KeyPress, stuff->key, NullWindow, NullCursor);
if (!grab)
- return BadAlloc;
+ return BadAlloc;
return AddPassiveGrabToList(client, grab);
}
-
/**
* Server-side protocol handling for GrabButton request.
*
@@ -5638,6 +5412,7 @@ int
ProcGrabButton(ClientPtr client)
{
WindowPtr pWin, confineTo;
+
REQUEST(xGrabButtonReq);
CursorPtr cursor;
GrabPtr grab;
@@ -5649,66 +5424,59 @@ ProcGrabButton(ClientPtr client)
REQUEST_SIZE_MATCH(xGrabButtonReq);
if ((stuff->pointerMode != GrabModeSync) &&
- (stuff->pointerMode != GrabModeAsync))
- {
- client->errorValue = stuff->pointerMode;
+ (stuff->pointerMode != GrabModeAsync)) {
+ client->errorValue = stuff->pointerMode;
return BadValue;
}
if ((stuff->keyboardMode != GrabModeSync) &&
- (stuff->keyboardMode != GrabModeAsync))
- {
- client->errorValue = stuff->keyboardMode;
+ (stuff->keyboardMode != GrabModeAsync)) {
+ client->errorValue = stuff->keyboardMode;
return BadValue;
}
if ((stuff->modifiers != AnyModifier) &&
- (stuff->modifiers & ~AllModifiersMask))
- {
- client->errorValue = stuff->modifiers;
- return BadValue;
+ (stuff->modifiers & ~AllModifiersMask)) {
+ client->errorValue = stuff->modifiers;
+ return BadValue;
}
- if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue))
- {
- client->errorValue = stuff->ownerEvents;
- return BadValue;
+ if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue)) {
+ client->errorValue = stuff->ownerEvents;
+ return BadValue;
}
- if (stuff->eventMask & ~PointerGrabMask)
- {
- client->errorValue = stuff->eventMask;
+ if (stuff->eventMask & ~PointerGrabMask) {
+ client->errorValue = stuff->eventMask;
return BadValue;
}
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
- return rc;
+ return rc;
if (stuff->confineTo == None)
- confineTo = NullWindow;
+ confineTo = NullWindow;
else {
- rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
- DixSetAttrAccess);
- if (rc != Success)
- return rc;
+ rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
+ DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
}
if (stuff->cursor == None)
- cursor = NullCursor;
- else
- {
- rc = dixLookupResourceByType((pointer *)&cursor, stuff->cursor, RT_CURSOR,
- client, DixUseAccess);
- if (rc != Success)
- {
- client->errorValue = stuff->cursor;
- return rc;
- }
- access_mode |= DixForceAccess;
+ cursor = NullCursor;
+ else {
+ rc = dixLookupResourceByType((pointer *) &cursor, stuff->cursor,
+ RT_CURSOR, client, DixUseAccess);
+ if (rc != Success) {
+ client->errorValue = stuff->cursor;
+ return rc;
+ }
+ access_mode |= DixForceAccess;
}
ptr = PickPointer(client);
modifierDevice = GetMaster(ptr, MASTER_KEYBOARD);
if (stuff->pointerMode == GrabModeSync ||
- stuff->keyboardMode == GrabModeSync)
- access_mode |= DixFreezeAccess;
+ stuff->keyboardMode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, access_mode);
if (rc != Success)
- return rc;
+ return rc;
memset(&param, 0, sizeof(param));
param.grabtype = CORE;
@@ -5723,7 +5491,7 @@ ProcGrabButton(ClientPtr client)
CORE, &mask, &param, ButtonPress,
stuff->button, confineTo, cursor);
if (!grab)
- return BadAlloc;
+ return BadAlloc;
return AddPassiveGrabToList(client, grab);
}
@@ -5743,14 +5511,13 @@ ProcUngrabButton(ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabButtonReq);
if ((stuff->modifiers != AnyModifier) &&
- (stuff->modifiers & ~AllModifiersMask))
- {
- client->errorValue = stuff->modifiers;
- return BadValue;
+ (stuff->modifiers & ~AllModifiersMask)) {
+ client->errorValue = stuff->modifiers;
+ return BadValue;
}
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
if (rc != Success)
- return rc;
+ return rc;
ptr = PickPointer(client);
@@ -5790,48 +5557,40 @@ ProcUngrabButton(ClientPtr client)
void
DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
{
- WindowPtr parent;
- DeviceIntPtr mouse = inputInfo.pointer;
- DeviceIntPtr keybd = inputInfo.keyboard;
- FocusClassPtr focus;
- OtherClientsPtr oc;
- GrabPtr passive;
- GrabPtr grab;
-
+ WindowPtr parent;
+ DeviceIntPtr mouse = inputInfo.pointer;
+ DeviceIntPtr keybd = inputInfo.keyboard;
+ FocusClassPtr focus;
+ OtherClientsPtr oc;
+ GrabPtr passive;
+ GrabPtr grab;
/* Deactivate any grabs performed on this window, before making any
- input focus changes. */
+ input focus changes. */
grab = mouse->deviceGrab.grab;
- if (grab &&
- ((grab->window == pWin) || (grab->confineTo == pWin)))
- (*mouse->deviceGrab.DeactivateGrab)(mouse);
-
+ if (grab && ((grab->window == pWin) || (grab->confineTo == pWin)))
+ (*mouse->deviceGrab.DeactivateGrab) (mouse);
/* Deactivating a keyboard grab should cause focus events. */
grab = keybd->deviceGrab.grab;
if (grab && (grab->window == pWin))
- (*keybd->deviceGrab.DeactivateGrab)(keybd);
+ (*keybd->deviceGrab.DeactivateGrab) (keybd);
/* And now the real devices */
- for (mouse = inputInfo.devices; mouse; mouse = mouse->next)
- {
+ for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
grab = mouse->deviceGrab.grab;
if (grab && ((grab->window == pWin) || (grab->confineTo == pWin)))
- (*mouse->deviceGrab.DeactivateGrab)(mouse);
+ (*mouse->deviceGrab.DeactivateGrab) (mouse);
}
-
- for (keybd = inputInfo.devices; keybd; keybd = keybd->next)
- {
- if (IsKeyboardDevice(keybd))
- {
+ for (keybd = inputInfo.devices; keybd; keybd = keybd->next) {
+ if (IsKeyboardDevice(keybd)) {
focus = keybd->focus;
/* If the focus window is a root window (ie. has no parent) then don't
delete the focus from it. */
- if ((pWin == focus->win) && (pWin->parent != NullWindow))
- {
+ if ((pWin == focus->win) && (pWin->parent != NullWindow)) {
int focusEventMode = NotifyNormal;
/* If a grab is in progress, then alter the mode of focus events. */
@@ -5839,61 +5598,58 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
if (keybd->deviceGrab.grab)
focusEventMode = NotifyWhileGrabbed;
- switch (focus->revert)
- {
- case RevertToNone:
- DoFocusEvents(keybd, pWin, NoneWin, focusEventMode);
- focus->win = NoneWin;
- focus->traceGood = 0;
- break;
- case RevertToParent:
- parent = pWin;
- do
- {
- parent = parent->parent;
- focus->traceGood--;
- } while (!parent->realized
- /* This would be a good protocol change -- windows being reparented
- during SaveSet processing would cause the focus to revert to the
- nearest enclosing window which will survive the death of the exiting
- client, instead of ending up reverting to a dying window and thence
- to None
- */
+ switch (focus->revert) {
+ case RevertToNone:
+ DoFocusEvents(keybd, pWin, NoneWin, focusEventMode);
+ focus->win = NoneWin;
+ focus->traceGood = 0;
+ break;
+ case RevertToParent:
+ parent = pWin;
+ do {
+ parent = parent->parent;
+ focus->traceGood--;
+ } while (!parent->realized
+ /* This would be a good protocol change -- windows being reparented
+ during SaveSet processing would cause the focus to revert to the
+ nearest enclosing window which will survive the death of the exiting
+ client, instead of ending up reverting to a dying window and thence
+ to None
+ */
#ifdef NOTDEF
- || wClient(parent)->clientGone
+ || wClient(parent)->clientGone
#endif
- );
- if (!ActivateFocusInGrab(keybd, pWin, parent))
- DoFocusEvents(keybd, pWin, parent, focusEventMode);
- focus->win = parent;
- focus->revert = RevertToNone;
- break;
- case RevertToPointerRoot:
- if (!ActivateFocusInGrab(keybd, pWin, PointerRootWin))
- DoFocusEvents(keybd, pWin, PointerRootWin, focusEventMode);
- focus->win = PointerRootWin;
- focus->traceGood = 0;
- break;
+ );
+ if (!ActivateFocusInGrab(keybd, pWin, parent))
+ DoFocusEvents(keybd, pWin, parent, focusEventMode);
+ focus->win = parent;
+ focus->revert = RevertToNone;
+ break;
+ case RevertToPointerRoot:
+ if (!ActivateFocusInGrab(keybd, pWin, PointerRootWin))
+ DoFocusEvents(keybd, pWin, PointerRootWin,
+ focusEventMode);
+ focus->win = PointerRootWin;
+ focus->traceGood = 0;
+ break;
}
}
}
- if (IsPointerDevice(keybd))
- {
+ if (IsPointerDevice(keybd)) {
if (keybd->valuator->motionHintWindow == pWin)
keybd->valuator->motionHintWindow = NullWindow;
}
}
- if (freeResources)
- {
- if (pWin->dontPropagate)
- DontPropagateRefCnts[pWin->dontPropagate]--;
- while ( (oc = wOtherClients(pWin)) )
- FreeResource(oc->resource, RT_NONE);
- while ( (passive = wPassiveGrabs(pWin)) )
- FreeResource(passive->resource, RT_NONE);
- }
+ if (freeResources) {
+ if (pWin->dontPropagate)
+ DontPropagateRefCnts[pWin->dontPropagate]--;
+ while ((oc = wOtherClients(pWin)))
+ FreeResource(oc->resource, RT_NONE);
+ while ((passive = wPassiveGrabs(pWin)))
+ FreeResource(passive->resource, RT_NONE);
+ }
DeleteWindowFromAnyExtEvents(pWin, freeResources);
}
@@ -5911,18 +5667,16 @@ CheckCursorConfinement(WindowPtr pWin)
DeviceIntPtr pDev;
#ifdef PANORAMIX
- if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return;
+ if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return;
#endif
- for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
- {
- if (DevHasCursor(pDev))
- {
+ for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+ if (DevHasCursor(pDev)) {
grab = pDev->deviceGrab.grab;
- if (grab && (confineTo = grab->confineTo))
- {
+ if (grab && (confineTo = grab->confineTo)) {
if (!BorderSizeNotEmpty(pDev, confineTo))
- (*pDev->deviceGrab.DeactivateGrab)(pDev);
+ (*pDev->deviceGrab.DeactivateGrab) (pDev);
else if ((pWin == confineTo) || IsParent(pWin, confineTo))
ConfineCursorToWindow(pDev, confineTo, TRUE, TRUE);
}
@@ -5933,14 +5687,13 @@ CheckCursorConfinement(WindowPtr pWin)
Mask
EventMaskForClient(WindowPtr pWin, ClientPtr client)
{
- OtherClientsPtr other;
+ OtherClientsPtr other;
- if (wClient (pWin) == client)
- return pWin->eventMask;
- for (other = wOtherClients(pWin); other; other = other->next)
- {
- if (SameClient(other, client))
- return other->mask;
+ if (wClient(pWin) == client)
+ return pWin->eventMask;
+ for (other = wOtherClients(pWin); other; other = other->next) {
+ if (SameClient(other, client))
+ return other->mask;
}
return 0;
}
@@ -5952,19 +5705,19 @@ int
ProcRecolorCursor(ClientPtr client)
{
CursorPtr pCursor;
- int rc, nscr;
- ScreenPtr pscr;
- Bool displayed;
- SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite;
+ int rc, nscr;
+ ScreenPtr pscr;
+ Bool displayed;
+ SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite;
+
REQUEST(xRecolorCursorReq);
REQUEST_SIZE_MATCH(xRecolorCursorReq);
- rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
- client, DixWriteAccess);
- if (rc != Success)
- {
- client->errorValue = stuff->cursor;
- return rc;
+ rc = dixLookupResourceByType((pointer *) &pCursor, stuff->cursor, RT_CURSOR,
+ client, DixWriteAccess);
+ if (rc != Success) {
+ client->errorValue = stuff->cursor;
+ return rc;
}
pCursor->foreRed = stuff->foreRed;
@@ -5975,17 +5728,16 @@ ProcRecolorCursor(ClientPtr client)
pCursor->backGreen = stuff->backGreen;
pCursor->backBlue = stuff->backBlue;
- for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
- {
- pscr = screenInfo.screens[nscr];
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
+ pscr = screenInfo.screens[nscr];
#ifdef PANORAMIX
- if(!noPanoramiXExtension)
- displayed = (pscr == pSprite->screen);
- else
+ if (!noPanoramiXExtension)
+ displayed = (pscr == pSprite->screen);
+ else
#endif
- displayed = (pscr == pSprite->hotPhys.pScreen);
- ( *pscr->RecolorCursor)(PickPointer(client), pscr, pCursor,
- (pCursor == pSprite->current) && displayed);
+ displayed = (pscr == pSprite->hotPhys.pScreen);
+ (*pscr->RecolorCursor) (PickPointer(client), pscr, pCursor,
+ (pCursor == pSprite->current) && displayed);
}
return Success;
}
@@ -6008,120 +5760,109 @@ void
WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
{
#ifdef PANORAMIX
- xEvent eventCopy;
+ xEvent eventCopy;
#endif
- xEvent *eventTo, *eventFrom;
- int i,
- eventlength = sizeof(xEvent);
+ xEvent *eventTo, *eventFrom;
+ int i, eventlength = sizeof(xEvent);
if (!pClient || pClient == serverClient || pClient->clientGone)
- return;
+ return;
for (i = 0; i < count; i++)
- if ((events[i].u.u.type & 0x7f) != KeymapNotify)
- events[i].u.u.sequenceNumber = pClient->sequence;
+ if ((events[i].u.u.type & 0x7f) != KeymapNotify)
+ events[i].u.u.sequenceNumber = pClient->sequence;
/* Let XKB rewrite the state, as it depends on client preferences. */
XkbFilterEvents(pClient, count, events);
#ifdef PANORAMIX
- if(!noPanoramiXExtension &&
- (screenInfo.screens[0]->x || screenInfo.screens[0]->y))
- {
- switch(events->u.u.type) {
- case MotionNotify:
- case ButtonPress:
- case ButtonRelease:
- case KeyPress:
- case KeyRelease:
- case EnterNotify:
- case LeaveNotify:
- /*
- When multiple clients want the same event DeliverEventsToWindow
- passes the same event structure multiple times so we can't
- modify the one passed to us
- */
- count = 1; /* should always be 1 */
- memcpy(&eventCopy, events, sizeof(xEvent));
- eventCopy.u.keyButtonPointer.rootX += screenInfo.screens[0]->x;
- eventCopy.u.keyButtonPointer.rootY += screenInfo.screens[0]->y;
- if(eventCopy.u.keyButtonPointer.event ==
- eventCopy.u.keyButtonPointer.root)
- {
- eventCopy.u.keyButtonPointer.eventX += screenInfo.screens[0]->x;
- eventCopy.u.keyButtonPointer.eventY += screenInfo.screens[0]->y;
- }
- events = &eventCopy;
- break;
- default: break;
- }
+ if (!noPanoramiXExtension &&
+ (screenInfo.screens[0]->x || screenInfo.screens[0]->y)) {
+ switch (events->u.u.type) {
+ case MotionNotify:
+ case ButtonPress:
+ case ButtonRelease:
+ case KeyPress:
+ case KeyRelease:
+ case EnterNotify:
+ case LeaveNotify:
+ /*
+ When multiple clients want the same event DeliverEventsToWindow
+ passes the same event structure multiple times so we can't
+ modify the one passed to us
+ */
+ count = 1; /* should always be 1 */
+ memcpy(&eventCopy, events, sizeof(xEvent));
+ eventCopy.u.keyButtonPointer.rootX += screenInfo.screens[0]->x;
+ eventCopy.u.keyButtonPointer.rootY += screenInfo.screens[0]->y;
+ if (eventCopy.u.keyButtonPointer.event ==
+ eventCopy.u.keyButtonPointer.root) {
+ eventCopy.u.keyButtonPointer.eventX += screenInfo.screens[0]->x;
+ eventCopy.u.keyButtonPointer.eventY += screenInfo.screens[0]->y;
+ }
+ events = &eventCopy;
+ break;
+ default:
+ break;
+ }
}
#endif
- if (EventCallback)
- {
- EventInfoRec eventinfo;
- eventinfo.client = pClient;
- eventinfo.events = events;
- eventinfo.count = count;
- CallCallbacks(&EventCallback, (pointer)&eventinfo);
+ if (EventCallback) {
+ EventInfoRec eventinfo;
+
+ eventinfo.client = pClient;
+ eventinfo.events = events;
+ eventinfo.count = count;
+ CallCallbacks(&EventCallback, (pointer) &eventinfo);
}
#ifdef XSERVER_DTRACE
if (XSERVER_SEND_EVENT_ENABLED()) {
- for (i = 0; i < count; i++)
- {
- XSERVER_SEND_EVENT(pClient->index, events[i].u.u.type, &events[i]);
- }
+ for (i = 0; i < count; i++) {
+ XSERVER_SEND_EVENT(pClient->index, events[i].u.u.type, &events[i]);
+ }
}
#endif
/* Just a safety check to make sure we only have one GenericEvent, it just
* makes things easier for me right now. (whot) */
- for (i = 1; i < count; i++)
- {
- if (events[i].u.u.type == GenericEvent)
- {
+ for (i = 1; i < count; i++) {
+ if (events[i].u.u.type == GenericEvent) {
ErrorF("[dix] TryClientEvents: Only one GenericEvent at a time.\n");
return;
}
}
- if (events->u.u.type == GenericEvent)
- {
- eventlength += ((xGenericEvent*)events)->length * 4;
+ if (events->u.u.type == GenericEvent) {
+ eventlength += ((xGenericEvent *) events)->length * 4;
}
- if(pClient->swapped)
- {
- if (eventlength > swapEventLen)
- {
+ if (pClient->swapped) {
+ if (eventlength > swapEventLen) {
swapEventLen = eventlength;
swapEvent = realloc(swapEvent, swapEventLen);
- if (!swapEvent)
- {
+ if (!swapEvent) {
FatalError("WriteEventsToClient: Out of memory.\n");
return;
}
}
- for(i = 0; i < count; i++)
- {
- eventFrom = &events[i];
+ for (i = 0; i < count; i++) {
+ eventFrom = &events[i];
eventTo = swapEvent;
- /* Remember to strip off the leading bit of type in case
- this event was sent with "SendEvent." */
- (*EventSwapVector[eventFrom->u.u.type & 0177])
- (eventFrom, eventTo);
+ /* Remember to strip off the leading bit of type in case
+ this event was sent with "SendEvent." */
+ (*EventSwapVector[eventFrom->u.u.type & 0177])
+ (eventFrom, eventTo);
- WriteToClient(pClient, eventlength, (char *)eventTo);
- }
+ WriteToClient(pClient, eventlength, (char *) eventTo);
+ }
}
- else
- {
+ else {
/* only one GenericEvent, remember? that means either count is 1 and
* eventlength is arbitrary or eventlength is 32 and count doesn't
* matter. And we're all set. Woohoo. */
- WriteToClient(pClient, count * eventlength, (char *) events);
+ WriteToClient(pClient, count * eventlength, (char *) events);
}
}
@@ -6138,17 +5879,17 @@ int
SetClientPointer(ClientPtr client, DeviceIntPtr device)
{
int rc = XaceHook(XACE_DEVICE_ACCESS, client, device, DixUseAccess);
+
if (rc != Success)
- return rc;
+ return rc;
- if (!IsMaster(device))
- {
+ if (!IsMaster(device)) {
ErrorF("[dix] Need master device for ClientPointer. This is a bug.\n");
return BadDevice;
- } else if (!device->spriteInfo->spriteOwner)
- {
+ }
+ else if (!device->spriteInfo->spriteOwner) {
ErrorF("[dix] Device %d does not have a sprite. "
- "Cannot be ClientPointer\n", device->id);
+ "Cannot be ClientPointer\n", device->id);
return BadDevice;
}
client->clientPtr = device;
@@ -6169,23 +5910,19 @@ PickPointer(ClientPtr client)
/* First, check if the client currently has a grab on a device. Even
* keyboards count. */
- for(it = inputInfo.devices; it; it = it->next)
- {
+ for (it = inputInfo.devices; it; it = it->next) {
GrabPtr grab = it->deviceGrab.grab;
- if (grab && grab->grabtype == CORE && SameClient(grab, client))
- {
+
+ if (grab && grab->grabtype == CORE && SameClient(grab, client)) {
it = GetMaster(it, MASTER_POINTER);
- return it; /* Always return a core grabbed device */
+ return it; /* Always return a core grabbed device */
}
}
- if (!client->clientPtr)
- {
+ if (!client->clientPtr) {
it = inputInfo.devices;
- while (it)
- {
- if (IsMaster(it) && it->spriteInfo->spriteOwner)
- {
+ while (it) {
+ if (IsMaster(it) && it->spriteInfo->spriteOwner) {
client->clientPtr = it;
break;
}
@@ -6205,10 +5942,9 @@ PickKeyboard(ClientPtr client)
DeviceIntPtr ptr = PickPointer(client);
DeviceIntPtr kbd = GetMaster(ptr, MASTER_KEYBOARD);
- if (!kbd)
- {
+ if (!kbd) {
ErrorF("[dix] ClientPointer not paired with a keyboard. This "
- "is a bug.\n");
+ "is a bug.\n");
}
return kbd;
@@ -6223,36 +5959,32 @@ PickKeyboard(ClientPtr client)
* be delivered.
*/
Bool
-IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent* event)
+IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent *event)
{
DeviceIntPtr it = inputInfo.devices;
- switch(event->u.u.type)
- {
- case KeyPress:
- case KeyRelease:
- case ButtonPress:
- case ButtonRelease:
- case MotionNotify:
- case EnterNotify:
- case LeaveNotify:
- break;
- default:
- return FALSE;
+ switch (event->u.u.type) {
+ case KeyPress:
+ case KeyRelease:
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ case EnterNotify:
+ case LeaveNotify:
+ break;
+ default:
+ return FALSE;
}
if (dev->deviceGrab.grab && SameClient(dev->deviceGrab.grab, client))
return FALSE;
- while(it)
- {
- if (it != dev)
- {
+ while (it) {
+ if (it != dev) {
if (it->deviceGrab.grab && SameClient(it->deviceGrab.grab, client)
- && !it->deviceGrab.fromPassiveGrab)
- {
+ && !it->deviceGrab.fromPassiveGrab) {
if ((IsPointerDevice(it) && IsPointerDevice(dev)) ||
- (IsKeyboardDevice(it) && IsKeyboardDevice(dev)))
+ (IsKeyboardDevice(it) && IsKeyboardDevice(dev)))
return TRUE;
}
}
@@ -6261,4 +5993,3 @@ IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent* event)
return FALSE;
}
-