summaryrefslogtreecommitdiff
path: root/dix/events.c
diff options
context:
space:
mode:
Diffstat (limited to 'dix/events.c')
-rw-r--r--dix/events.c1174
1 files changed, 1047 insertions, 127 deletions
diff --git a/dix/events.c b/dix/events.c
index afadfe6a3..ce8e53f92 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.46 2002/09/17 01:15:09 dawes Exp $ */
/************************************************************
Copyright 1987, 1998 The Open Group
@@ -45,6 +46,27 @@ SOFTWARE.
********************************************************/
+/* The panoramix components contained the following notice */
+/****************************************************************
+* *
+* Copyright (c) Digital Equipment Corporation, 1991, 1997 *
+* *
+* All Rights Reserved. Unpublished rights reserved under *
+* the copyright laws of the United States. *
+* *
+* The software contained on this media is proprietary to *
+* and embodies the confidential technology of Digital *
+* Equipment Corporation. Possession, use, duplication or *
+* dissemination of the software and media is authorized only *
+* pursuant to a valid written license from Digital Equipment *
+* Corporation. *
+* *
+* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
+* by the U.S. Government is subject to restrictions as set *
+* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
+* or in FAR 52.227-19, as applicable. *
+* *
+*****************************************************************/
/* $Xorg: events.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
@@ -60,19 +82,33 @@ SOFTWARE.
#include "cursorstr.h"
#include "dixstruct.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#include "globals.h"
#ifdef XKB
#include "XKBsrv.h"
+#if NeedFunctionPrototypes
+extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
+#else
+extern Bool XkbFilterEvents();
+#endif
#endif
#ifdef XCSECURITY
#define _SECURITY_SERVER
-#include "extensions/security.h"
+#include "security.h"
#endif
-extern WindowPtr *WindowTable;
+#include "XIproto.h"
+#include "exevents.h"
+#include "extnsionst.h"
-extern void (* EventSwapVector[128]) ();
+#include "dixevents.h"
+#include "dixgrabs.h"
+#include "dispatch.h"
#define EXTENSION_EVENT_BASE 64
@@ -106,6 +142,9 @@ extern void (* EventSwapVector[128]) ();
#define WID(w) ((w) ? ((w)->drawable.id) : 0)
+#define XE_KBPTR (xE->u.keyButtonPointer)
+
+
#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
CallbackListPtr EventCallback;
@@ -148,13 +187,20 @@ static struct {
CursorPtr current;
BoxRec hotLimits; /* logical constraints of hot spot */
Bool confined; /* confined to screen */
-#ifdef SHAPE
+#if defined(SHAPE) || defined(PANORAMIX)
RegionPtr hotShape; /* additional logical shape constraint */
#endif
BoxRec physLimits; /* physical constraints of hot spot */
WindowPtr win; /* window of logical position */
HotSpot hot; /* logical pointer position */
HotSpot hotPhys; /* physical pointer position */
+#ifdef PANORAMIX
+ ScreenPtr screen; /* all others are in Screen 0 coordinates */
+ RegionRec Reg1; /* Region 1 for confining motion */
+ RegionRec Reg2; /* Region 2 for confining virtual motion */
+ WindowPtr windows[MAXSCREENS];
+ WindowPtr confineWin; /* confine window */
+#endif
} sprite; /* info about the cursor sprite */
static void DoEnterLeaveEvents(
@@ -172,27 +218,14 @@ static WindowPtr XYToWindow(
#endif
);
-void DeliverFocusedEvent();
-int DeliverDeviceEvents();
-void DoFocusEvents();
-Mask EventMaskForClient();
-Bool CheckDeviceGrabs();
-void EnqueueEvent();
+extern int lastEvent;
-extern GrabPtr CreateGrab(); /* Defined in grabs.c */
-extern Bool GrabMatchesSecond();
-extern Bool DeletePassiveGrabFromList();
-extern int AddPassiveGrabToList();
+static Mask lastEventMask;
-extern Bool permitOldBugs;
-extern Bool Must_have_memory;
-extern int lastEvent;
#ifdef XINPUT
-extern int DeviceMotionNotify, DeviceButtonPress, DeviceKeyPress;
+extern int DeviceMotionNotify;
#endif
-static Mask lastEventMask;
-
#define CantBeFiltered NoEventMask
static Mask filters[128] =
{
@@ -235,16 +268,331 @@ static Mask filters[128] =
static CARD8 criticalEvents[32] =
{
- 0x3c /* key and button events */
+ 0x7c /* key and button events */
};
-Mask
-GetNextEventMask()
+#ifdef PANORAMIX
+
+static void ConfineToShape(RegionPtr shape, int *px, int *py);
+static void SyntheticMotion(int x, int y);
+static void PostNewCursor(void);
+
+static Bool
+XineramaSetCursorPosition(
+ int x,
+ int y,
+ Bool generateEvent
+){
+ ScreenPtr pScreen;
+ BoxRec box;
+ int i;
+
+ /* x,y are in Screen 0 coordinates. We need to decide what Screen
+ to send the message too and what the coordinates relative to
+ that screen are. */
+
+ pScreen = sprite.screen;
+ x += panoramiXdataPtr[0].x;
+ y += panoramiXdataPtr[0].y;
+
+ if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+ x, y, &box))
+ {
+ FOR_NSCREENS(i)
+ {
+ if(i == pScreen->myNum)
+ continue;
+ if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], x, y, &box))
+ {
+ pScreen = screenInfo.screens[i];
+ break;
+ }
+ }
+ }
+
+ sprite.screen = pScreen;
+ sprite.hotPhys.x = x - panoramiXdataPtr[0].x;
+ sprite.hotPhys.y = y - panoramiXdataPtr[0].y;
+ x -= panoramiXdataPtr[pScreen->myNum].x;
+ y -= panoramiXdataPtr[pScreen->myNum].y;
+
+ return (*pScreen->SetCursorPosition)(pScreen, x, y, generateEvent);
+}
+
+
+static void
+XineramaConstrainCursor(void)
{
- lastEventMask <<= 1;
- return lastEventMask;
+ ScreenPtr pScreen = sprite.screen;
+ BoxRec newBox = sprite.physLimits;
+
+ /* Translate the constraining box to the screen
+ the sprite is actually on */
+ newBox.x1 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
+ newBox.x2 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
+ newBox.y1 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+ newBox.y2 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+
+ (* pScreen->ConstrainCursor)(pScreen, &newBox);
}
+static void
+XineramaCheckPhysLimits(
+ CursorPtr cursor,
+ Bool generateEvents
+){
+ HotSpot new;
+
+ if (!cursor)
+ return;
+
+ new = sprite.hotPhys;
+
+ /* I don't care what the DDX has to say about it */
+ sprite.physLimits = sprite.hotLimits;
+
+ /* constrain the pointer to those limits */
+ if (new.x < sprite.physLimits.x1)
+ new.x = sprite.physLimits.x1;
+ else
+ if (new.x >= sprite.physLimits.x2)
+ new.x = sprite.physLimits.x2 - 1;
+ if (new.y < sprite.physLimits.y1)
+ new.y = sprite.physLimits.y1;
+ else
+ if (new.y >= sprite.physLimits.y2)
+ new.y = sprite.physLimits.y2 - 1;
+
+ if (sprite.hotShape) /* more work if the shape is a mess */
+ ConfineToShape(sprite.hotShape, &new.x, &new.y);
+
+ if((new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
+ {
+ XineramaSetCursorPosition (new.x, new.y, generateEvents);
+ if (!generateEvents)
+ SyntheticMotion(new.x, new.y);
+ }
+
+ /* Tell DDX what the limits are */
+ XineramaConstrainCursor();
+}
+
+
+static Bool
+XineramaSetWindowPntrs(WindowPtr pWin)
+{
+ if(pWin == WindowTable[0]) {
+ memcpy(sprite.windows, WindowTable,
+ PanoramiXNumScreens*sizeof(WindowPtr));
+ } else {
+ PanoramiXRes *win;
+ int i;
+
+ win = (PanoramiXRes*)LookupIDByType(pWin->drawable.id, XRT_WINDOW);
+
+ if(!win)
+ return FALSE;
+
+ for(i = 0; i < PanoramiXNumScreens; i++) {
+ sprite.windows[i] = LookupIDByType(win->info[i].id, RT_WINDOW);
+ if(!sprite.windows[i]) /* window is being unmapped */
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+static void
+XineramaCheckVirtualMotion(
+ QdEventPtr qe,
+ WindowPtr pWin
+){
+
+ if (qe)
+ {
+ sprite.hot.pScreen = qe->pScreen; /* should always be Screen 0 */
+ sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
+ sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
+ pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
+ NullWindow;
+ }
+ if (pWin)
+ {
+ int x, y, off_x, off_y, i;
+ BoxRec lims;
+
+ if(!XineramaSetWindowPntrs(pWin))
+ return;
+
+ i = PanoramiXNumScreens - 1;
+
+ REGION_COPY(sprite.screen, &sprite.Reg2,
+ &sprite.windows[i]->borderSize);
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+
+ while(i--) {
+ x = off_x - panoramiXdataPtr[i].x;
+ y = off_y - panoramiXdataPtr[i].y;
+
+ if(x || y)
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg2, x, y);
+
+ REGION_UNION(sprite.screen, &sprite.Reg2, &sprite.Reg2,
+ &sprite.windows[i]->borderSize);
+
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+ }
+
+ lims = *REGION_EXTENTS(sprite.screen, &sprite.Reg2);
+
+ if (sprite.hot.x < lims.x1)
+ sprite.hot.x = lims.x1;
+ else if (sprite.hot.x >= lims.x2)
+ sprite.hot.x = lims.x2 - 1;
+ if (sprite.hot.y < lims.y1)
+ sprite.hot.y = lims.y1;
+ else if (sprite.hot.y >= lims.y2)
+ sprite.hot.y = lims.y2 - 1;
+
+ if (REGION_NUM_RECTS(&sprite.Reg2) > 1)
+ ConfineToShape(&sprite.Reg2, &sprite.hot.x, &sprite.hot.y);
+
+ if (qe)
+ {
+ qe->pScreen = sprite.hot.pScreen;
+ qe->event->u.keyButtonPointer.rootX = sprite.hot.x;
+ qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
+ }
+ }
+}
+
+
+static Bool
+XineramaCheckMotion(xEvent *xE)
+{
+ WindowPtr prevSpriteWin = sprite.win;
+
+ if (xE && !syncEvents.playingEvents)
+ {
+ /* Motion events entering DIX get translated to Screen 0
+ coordinates. Replayed events have already been
+ translated since they've entered DIX before */
+ XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x -
+ panoramiXdataPtr[0].x;
+ XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y -
+ panoramiXdataPtr[0].y;
+
+ sprite.hot.x = XE_KBPTR.rootX;
+ sprite.hot.y = XE_KBPTR.rootY;
+ if (sprite.hot.x < sprite.physLimits.x1)
+ sprite.hot.x = sprite.physLimits.x1;
+ else if (sprite.hot.x >= sprite.physLimits.x2)
+ sprite.hot.x = sprite.physLimits.x2 - 1;
+ if (sprite.hot.y < sprite.physLimits.y1)
+ sprite.hot.y = sprite.physLimits.y1;
+ else if (sprite.hot.y >= sprite.physLimits.y2)
+ sprite.hot.y = sprite.physLimits.y2 - 1;
+
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
+
+ sprite.hotPhys = sprite.hot;
+ if ((sprite.hotPhys.x != XE_KBPTR.rootX) ||
+ (sprite.hotPhys.y != XE_KBPTR.rootY))
+ {
+ XineramaSetCursorPosition(
+ sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
+ }
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
+ }
+
+ sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
+
+ if (sprite.win != prevSpriteWin)
+ {
+ if (prevSpriteWin != NullWindow) {
+ if (!xE)
+ UpdateCurrentTimeIf();
+ DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal);
+ }
+ PostNewCursor();
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+static void
+XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents)
+{
+
+ if (syncEvents.playingEvents)
+ {
+ XineramaCheckVirtualMotion((QdEventPtr)NULL, pWin);
+ SyntheticMotion(sprite.hot.x, sprite.hot.y);
+ }
+ else
+ {
+ int x, y, off_x, off_y, i;
+
+ if(!XineramaSetWindowPntrs(pWin))
+ return;
+
+ i = PanoramiXNumScreens - 1;
+
+ REGION_COPY(sprite.screen, &sprite.Reg1,
+ &sprite.windows[i]->borderSize);
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+
+ while(i--) {
+ x = off_x - panoramiXdataPtr[i].x;
+ y = off_y - panoramiXdataPtr[i].y;
+
+ if(x || y)
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg1, x, y);
+
+ REGION_UNION(sprite.screen, &sprite.Reg1, &sprite.Reg1,
+ &sprite.windows[i]->borderSize);
+
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+ }
+
+ sprite.hotLimits = *REGION_EXTENTS(sprite.screen, &sprite.Reg1);
+
+ if(REGION_NUM_RECTS(&sprite.Reg1) > 1)
+ sprite.hotShape = &sprite.Reg1;
+ else
+ sprite.hotShape = NullRegion;
+
+ sprite.confined = FALSE;
+ sprite.confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
+
+ XineramaCheckPhysLimits(sprite.current, generateEvents);
+ }
+}
+
+
+static void
+XineramaChangeToCursor(CursorPtr cursor)
+{
+ if (cursor != sprite.current)
+ {
+ if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
+ (sprite.current->bits->yhot != cursor->bits->yhot))
+ XineramaCheckPhysLimits(cursor, FALSE);
+ (*sprite.screen->DisplayCursor)(sprite.screen, cursor);
+ sprite.current = cursor;
+ }
+}
+
+
+#endif /* PANORAMIX */
+
void
SetMaskForEvent(mask, event)
Mask mask;
@@ -265,11 +613,24 @@ SetCriticalEvent(event)
}
static void
+#if NeedFunctionPrototypes
+SyntheticMotion(int x, int y)
+#else
SyntheticMotion(x, y)
int x, y;
+#endif
{
xEvent xE;
+#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) {
+ x += panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x;
+ y += panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y;
+ }
+#endif
xE.u.keyButtonPointer.rootX = x;
xE.u.keyButtonPointer.rootY = y;
if (syncEvents.playingEvents)
@@ -282,9 +643,13 @@ SyntheticMotion(x, y)
#ifdef SHAPE
static void
+#if NeedFunctionPrototypes
+ConfineToShape(RegionPtr shape, int *px, int *py)
+#else
ConfineToShape(shape, px, py)
RegionPtr shape;
int *px, *py;
+#endif
{
BoxRec box;
int x = *px, y = *py;
@@ -321,11 +686,19 @@ ConfineToShape(shape, px, py)
#endif
static void
+#if NeedFunctionPrototypes
+CheckPhysLimits(
+ CursorPtr cursor,
+ Bool generateEvents,
+ Bool confineToScreen,
+ ScreenPtr pScreen)
+#else
CheckPhysLimits(cursor, generateEvents, confineToScreen, pScreen)
CursorPtr cursor;
Bool generateEvents;
Bool confineToScreen;
ScreenPtr pScreen;
+#endif
{
HotSpot new;
@@ -352,7 +725,7 @@ CheckPhysLimits(cursor, generateEvents, confineToScreen, pScreen)
new.y = sprite.physLimits.y2 - 1;
#ifdef SHAPE
if (sprite.hotShape)
- ConfineToShape(sprite.hotShape, &new.x, &new.y);
+ ConfineToShape(sprite.hotShape, &new.x, &new.y);
#endif
if ((pScreen != sprite.hotPhys.pScreen) ||
(new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
@@ -366,11 +739,22 @@ CheckPhysLimits(cursor, generateEvents, confineToScreen, pScreen)
}
static void
+#if NeedFunctionPrototypes
+CheckVirtualMotion(
+ register QdEventPtr qe,
+ register WindowPtr pWin)
+#else
CheckVirtualMotion(qe, pWin)
register QdEventPtr qe;
register WindowPtr pWin;
+#endif
{
-
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XineramaCheckVirtualMotion(qe, pWin);
+ return;
+ }
+#endif
if (qe)
{
sprite.hot.pScreen = qe->pScreen;
@@ -411,14 +795,18 @@ CheckVirtualMotion(qe, pWin)
ROOT = WindowTable[sprite.hot.pScreen->myNum];
}
-void
-ConfineCursorToWindow(pWin, generateEvents, confineToScreen)
- WindowPtr pWin;
- Bool generateEvents;
- Bool confineToScreen;
+static void
+ConfineCursorToWindow(WindowPtr pWin, Bool generateEvents, Bool confineToScreen)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XineramaConfineCursorToWindow(pWin, generateEvents);
+ return;
+ }
+#endif
+
if (syncEvents.playingEvents)
{
CheckVirtualMotion((QdEventPtr)NULL, pWin);
@@ -443,14 +831,25 @@ PointerConfinedToScreen()
}
static void
+#if NeedFunctionPrototypes
+ChangeToCursor(CursorPtr cursor)
+#else
ChangeToCursor(cursor)
CursorPtr cursor;
+#endif
{
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XineramaChangeToCursor(cursor);
+ return;
+ }
+#endif
+
if (cursor != sprite.current)
{
if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
(sprite.current->bits->yhot != cursor->bits->yhot))
- CheckPhysLimits(cursor, FALSE, PointerConfinedToScreen(),
+ CheckPhysLimits(cursor, FALSE, sprite.confined,
(ScreenPtr)NULL);
(*sprite.hotPhys.pScreen->DisplayCursor) (sprite.hotPhys.pScreen,
cursor);
@@ -469,7 +868,11 @@ IsParent(a, b)
}
static void
+#if NeedFunctionPrototypes
+PostNewCursor(void)
+#else
PostNewCursor()
+#endif
{
register WindowPtr win;
register GrabPtr grab = inputInfo.pointer->grab;
@@ -524,20 +927,36 @@ GetSpritePosition(px, py)
*py = sprite.hotPhys.y;
}
+#ifdef PANORAMIX
+int
+XineramaGetCursorScreen()
+{
+ if(!noPanoramiXExtension) {
+ return sprite.screen->myNum;
+ } else {
+ return 0;
+ }
+}
+#endif /* PANORAMIX */
+
#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
static void
+#if NeedFunctionPrototypes
+MonthChangedOrBadTime(register xEvent *xE)
+#else
MonthChangedOrBadTime(xE)
register xEvent *xE;
+#endif
{
/* If the ddx/OS is careless about not processing timestamped events from
* different sources in sorted order, then it's possible for time to go
* backwards when it should not. Here we ensure a decent time.
*/
- if ((currentTime.milliseconds - xE->u.keyButtonPointer.time) > TIMESLOP)
+ if ((currentTime.milliseconds - XE_KBPTR.time) > TIMESLOP)
currentTime.months++;
else
- xE->u.keyButtonPointer.time = currentTime.milliseconds;
+ XE_KBPTR.time = currentTime.milliseconds;
}
#define NoticeTime(xE) { \
@@ -582,7 +1001,7 @@ EnqueueEvent(xE, device, count)
* updated yet.
*/
if (xE->u.u.type == MotionNotify)
- xE->u.keyButtonPointer.root =
+ XE_KBPTR.root =
WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
eventinfo.events = xE;
eventinfo.count = count;
@@ -590,8 +1009,16 @@ EnqueueEvent(xE, device, count)
}
if (xE->u.u.type == MotionNotify)
{
- sprite.hotPhys.x = xE->u.keyButtonPointer.rootX;
- sprite.hotPhys.y = xE->u.keyButtonPointer.rootY;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x -
+ panoramiXdataPtr[0].x;
+ XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y -
+ panoramiXdataPtr[0].y;
+ }
+#endif
+ sprite.hotPhys.x = XE_KBPTR.rootX;
+ sprite.hotPhys.y = XE_KBPTR.rootY;
/* do motion compression */
if (tail &&
(tail->event->u.u.type == MotionNotify) &&
@@ -599,7 +1026,7 @@ EnqueueEvent(xE, device, count)
{
tail->event->u.keyButtonPointer.rootX = sprite.hotPhys.x;
tail->event->u.keyButtonPointer.rootY = sprite.hotPhys.y;
- tail->event->u.keyButtonPointer.time = xE->u.keyButtonPointer.time;
+ tail->event->u.keyButtonPointer.time = XE_KBPTR.time;
tail->months = currentTime.months;
return;
}
@@ -621,7 +1048,11 @@ EnqueueEvent(xE, device, count)
}
static void
+#if NeedFunctionPrototypes
+PlayReleasedEvents(void)
+#else
PlayReleasedEvents()
+#endif
{
register QdEventPtr *prev, qe;
register DeviceIntPtr dev;
@@ -638,6 +1069,19 @@ PlayReleasedEvents()
CheckVirtualMotion(qe, NullWindow);
syncEvents.time.months = qe->months;
syncEvents.time.milliseconds = qe->event->u.keyButtonPointer.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) {
+ qe->event->u.keyButtonPointer.rootX +=
+ panoramiXdataPtr[0].x -
+ panoramiXdataPtr[sprite.screen->myNum].x;
+ qe->event->u.keyButtonPointer.rootY +=
+ panoramiXdataPtr[0].y -
+ panoramiXdataPtr[sprite.screen->myNum].y;
+ }
+#endif
(*qe->device->public.processInputProc)(qe->event, qe->device,
qe->evcount);
xfree(qe);
@@ -655,9 +1099,13 @@ PlayReleasedEvents()
}
static void
+#if NeedFunctionPrototypes
+FreezeThaw(register DeviceIntPtr dev, Bool frozen)
+#else
FreezeThaw(dev, frozen)
register DeviceIntPtr dev;
Bool frozen;
+#endif
{
dev->sync.frozen = frozen;
if (frozen)
@@ -687,19 +1135,22 @@ ComputeFreezes()
xE = replayDev->sync.event;
count = replayDev->sync.evcount;
syncEvents.replayDev = (DeviceIntPtr)NULL;
- w = XYToWindow(
- xE->u.keyButtonPointer.rootX, xE->u.keyButtonPointer.rootY);
+
+ w = XYToWindow( XE_KBPTR.rootX, XE_KBPTR.rootY);
for (i = 0; i < spriteTraceGood; i++)
+ {
if (syncEvents.replayWin == spriteTrace[i])
{
- if (!CheckDeviceGrabs(replayDev, xE, i+1, count))
+ if (!CheckDeviceGrabs(replayDev, xE, i+1, count)) {
if (replayDev->focus)
DeliverFocusedEvent(replayDev, xE, w, count);
else
DeliverDeviceEvents(w, xE, NullGrab, NullWindow,
- replayDev, count);
+ replayDev, count);
+ }
goto playmore;
}
+ }
/* must not still be in the same stack */
if (replayDev->focus)
DeliverFocusedEvent(replayDev, xE, w, count);
@@ -729,6 +1180,24 @@ playmore:
PostNewCursor();
}
+#ifdef RANDR
+void
+ScreenRestructured (ScreenPtr pScreen)
+{
+ GrabPtr grab;
+
+ if ((grab = inputInfo.pointer->grab) && grab->confineTo)
+ {
+ if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+ sprite.hotPhys.x = sprite.hotPhys.y = 0;
+ ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+ }
+ else
+ ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+ TRUE, FALSE);
+}
+#endif
+
void
CheckGrabForSyncs(thisDev, thisMode, otherMode)
register DeviceIntPtr thisDev;
@@ -793,8 +1262,7 @@ ActivatePointerGrab(mouse, grab, time, autoGrab)
mouse->grab = &mouse->activeGrab;
mouse->fromPassiveGrab = autoGrab;
PostNewCursor();
- CheckGrabForSyncs(mouse,
- (Bool)grab->pointerMode, (Bool)grab->keyboardMode);
+ CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
}
void
@@ -849,8 +1317,7 @@ ActivateKeyboardGrab(keybd, grab, time, passive)
keybd->activeGrab = *grab;
keybd->grab = &keybd->activeGrab;
keybd->fromPassiveGrab = passive;
- CheckGrabForSyncs(keybd,
- (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
+ CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
}
void
@@ -1092,6 +1559,7 @@ TryClientEvents (client, pEvents, count, mask, filter, grab)
{
#ifdef DEBUG
if (debug_events) ErrorF("\n");
+ fprintf(stderr,"motionHintWindow == keyButtonPointer.event\n");
#endif
return 1; /* don't send, but pretend we did */
}
@@ -1106,7 +1574,8 @@ TryClientEvents (client, pEvents, count, mask, filter, grab)
else
{
if ((type == DeviceMotionNotify) &&
- MaybeSendDeviceMotionNotifyHint (pEvents, mask) != 0)
+ MaybeSendDeviceMotionNotifyHint
+ ((deviceKeyButtonPointer*)pEvents, mask) != 0)
return 1;
}
#endif
@@ -1119,7 +1588,13 @@ TryClientEvents (client, pEvents, count, mask, filter, grab)
}
if (BitIsOn(criticalEvents, type))
+ {
+#ifdef SMART_SCHEDULE
+ if (client->smart_priority < SMART_MAX_PRIORITY)
+ client->smart_priority++;
+#endif
SetCriticalOutputPending();
+ }
WriteEventsToClient(client, count, pEvents);
#ifdef DEBUG
@@ -1149,7 +1624,7 @@ DeliverEventsToWindow(pWin, pEvents, count, filter, grab, mskidx)
int attempt;
register InputClients *other;
ClientPtr client = NullClient;
- Mask deliveryMask; /* If a grab occurs due to a button press, then
+ 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;
@@ -1224,8 +1699,9 @@ DeliverEventsToWindow(pWin, pEvents, count, filter, grab, mskidx)
{
if (((type == DeviceMotionNotify) || (type == DeviceButtonPress)) &&
deliveries)
- CheckDeviceGrabAndHintWindow (pWin, type, pEvents, grab, client,
- deliveryMask);
+ CheckDeviceGrabAndHintWindow (pWin, type,
+ (deviceKeyButtonPointer*) pEvents,
+ grab, client, deliveryMask);
}
#endif
if (deliveries)
@@ -1238,6 +1714,24 @@ DeliverEventsToWindow(pWin, pEvents, count, filter, grab, mskidx)
Only works for core events.
*/
+#ifdef PANORAMIX
+static int
+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;
+ }
+ return 0;
+}
+#endif
+
int
MaybeDeliverEventsToClient(pWin, pEvents, count, filter, dontClient)
register WindowPtr pWin;
@@ -1248,10 +1742,16 @@ MaybeDeliverEventsToClient(pWin, pEvents, count, filter, dontClient)
{
register OtherClients *other;
+
if (pWin->eventMask & filter)
{
if (wClient(pWin) == dontClient)
return 0;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return XineramaTryClientEventsResult(
+ wClient(pWin), NullGrab, pWin->eventMask, filter);
+#endif
return TryClientEvents(wClient(pWin), pEvents, count,
pWin->eventMask, filter, NullGrab);
}
@@ -1261,6 +1761,11 @@ MaybeDeliverEventsToClient(pWin, pEvents, count, filter, dontClient)
{
if (SameClient(other, dontClient))
return 0;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return XineramaTryClientEventsResult(
+ rClient(other), NullGrab, other->mask, filter);
+#endif
return TryClientEvents(rClient(other), pEvents, count,
other->mask, filter, NullGrab);
}
@@ -1269,16 +1774,23 @@ MaybeDeliverEventsToClient(pWin, pEvents, count, filter, dontClient)
}
static void
+#if NeedFunctionPrototypes
+FixUpEventFromWindow(
+ xEvent *xE,
+ WindowPtr pWin,
+ Window child,
+ Bool calcChild)
+#else
FixUpEventFromWindow(xE, pWin, child, calcChild)
xEvent *xE;
WindowPtr pWin;
Window child;
Bool calcChild;
+#endif
{
if (calcChild)
{
WindowPtr w=spriteTrace[spriteTraceGood-1];
-
/* If the search ends up past the root should the child field be
set to none or should the value in the argument be passed
through. It probably doesn't matter since everyone calls
@@ -1303,23 +1815,23 @@ FixUpEventFromWindow(xE, pWin, child, calcChild)
w = w->parent;
}
}
- xE->u.keyButtonPointer.root = ROOT->drawable.id;
- xE->u.keyButtonPointer.event = pWin->drawable.id;
+ XE_KBPTR.root = ROOT->drawable.id;
+ XE_KBPTR.event = pWin->drawable.id;
if (sprite.hot.pScreen == pWin->drawable.pScreen)
{
- xE->u.keyButtonPointer.sameScreen = xTrue;
- xE->u.keyButtonPointer.child = child;
- xE->u.keyButtonPointer.eventX =
- xE->u.keyButtonPointer.rootX - pWin->drawable.x;
- xE->u.keyButtonPointer.eventY =
- xE->u.keyButtonPointer.rootY - pWin->drawable.y;
+ 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;
}
else
{
- xE->u.keyButtonPointer.sameScreen = xFalse;
- xE->u.keyButtonPointer.child = None;
- xE->u.keyButtonPointer.eventX = 0;
- xE->u.keyButtonPointer.eventY = 0;
+ XE_KBPTR.sameScreen = xFalse;
+ XE_KBPTR.child = None;
+ XE_KBPTR.eventX = 0;
+ XE_KBPTR.eventY = 0;
}
}
@@ -1400,6 +1912,11 @@ DeliverEvents(pWin, xE, count, otherParent)
Mask filter;
int deliveries;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return count;
+#endif
+
if (!count)
return 0;
filter = filters[xE->u.u.type];
@@ -1426,14 +1943,41 @@ DeliverEvents(pWin, xE, count, otherParent)
return deliveries;
}
+
+static Bool
+PointInBorderSize(WindowPtr pWin, int x, int y)
+{
+ BoxRec box;
+
+ if(POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box))
+ return TRUE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
+ int i;
+
+ for(i = 1; i < PanoramiXNumScreens; i++) {
+ if(POINT_IN_REGION(sprite.screen,
+ &sprite.windows[i]->borderSize,
+ x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x,
+ y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y,
+ &box))
+ return TRUE;
+ }
+ }
+#endif
+ return FALSE;
+}
+
static WindowPtr
+#if NeedFunctionPrototypes
+XYToWindow(int x, int y)
+#else
XYToWindow(x, y)
int x, y;
+#endif
{
register WindowPtr pWin;
-#ifdef SHAPE
- BoxRec box;
-#endif
spriteTraceGood = 1; /* root window still there */
pWin = ROOT->firstChild;
@@ -1451,9 +1995,7 @@ XYToWindow(x, y)
* is made to see if the point is inside
* borderSize
*/
- && (!wBoundingShape(pWin) ||
- POINT_IN_REGION(pWin->drawable.pScreen,
- &pWin->borderSize, x, y, &box))
+ && (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
#endif
)
{
@@ -1475,11 +2017,20 @@ XYToWindow(x, y)
}
static Bool
+#if NeedFunctionPrototypes
+CheckMotion(xEvent *xE)
+#else
CheckMotion(xE)
xEvent *xE;
+#endif
{
WindowPtr prevSpriteWin = sprite.win;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return XineramaCheckMotion(xE);
+#endif
+
if (xE && !syncEvents.playingEvents)
{
if (sprite.hot.pScreen != sprite.hotPhys.pScreen)
@@ -1487,8 +2038,8 @@ CheckMotion(xE)
sprite.hot.pScreen = sprite.hotPhys.pScreen;
ROOT = WindowTable[sprite.hot.pScreen->myNum];
}
- sprite.hot.x = xE->u.keyButtonPointer.rootX;
- sprite.hot.y = xE->u.keyButtonPointer.rootY;
+ sprite.hot.x = XE_KBPTR.rootX;
+ sprite.hot.y = XE_KBPTR.rootY;
if (sprite.hot.x < sprite.physLimits.x1)
sprite.hot.x = sprite.physLimits.x1;
else if (sprite.hot.x >= sprite.physLimits.x2)
@@ -1502,13 +2053,15 @@ CheckMotion(xE)
ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
#endif
sprite.hotPhys = sprite.hot;
- if ((sprite.hotPhys.x != xE->u.keyButtonPointer.rootX) ||
- (sprite.hotPhys.y != xE->u.keyButtonPointer.rootY))
+ if ((sprite.hotPhys.x != XE_KBPTR.rootX) ||
+ (sprite.hotPhys.y != XE_KBPTR.rootY))
+ {
(*sprite.hotPhys.pScreen->SetCursorPosition)(
sprite.hotPhys.pScreen,
sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
- xE->u.keyButtonPointer.rootX = sprite.hot.x;
- xE->u.keyButtonPointer.rootY = sprite.hot.y;
+ }
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
}
sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
@@ -1561,6 +2114,21 @@ DefineInitialRootWindow(win)
(*pScreen->ConstrainCursor) (pScreen, &sprite.physLimits);
(*pScreen->SetCursorPosition) (pScreen, sprite.hot.x, sprite.hot.y, FALSE);
(*pScreen->DisplayCursor) (pScreen, sprite.current);
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ sprite.hotLimits.x1 = -panoramiXdataPtr[0].x;
+ sprite.hotLimits.y1 = -panoramiXdataPtr[0].y;
+ sprite.hotLimits.x2 = PanoramiXPixWidth - panoramiXdataPtr[0].x;
+ sprite.hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+ sprite.physLimits = sprite.hotLimits;
+ sprite.confineWin = NullWindow;
+ sprite.screen = pScreen;
+ /* gotta UNINIT these someplace */
+ REGION_INIT(pScreen, &sprite.Reg1, NullBox, 1);
+ REGION_INIT(pScreen, &sprite.Reg2, NullBox, 1);
+ }
+#endif
}
/*
@@ -1585,10 +2153,144 @@ NewCurrentScreen(newScreen, x, y)
{
sprite.hotPhys.x = x;
sprite.hotPhys.y = y;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ sprite.hotPhys.x += panoramiXdataPtr[newScreen->myNum].x -
+ panoramiXdataPtr[0].x;
+ sprite.hotPhys.y += panoramiXdataPtr[newScreen->myNum].y -
+ panoramiXdataPtr[0].y;
+ if (newScreen != sprite.screen) {
+ sprite.screen = newScreen;
+ /* Make sure we tell the DDX to update its copy of the screen */
+ if(sprite.confineWin)
+ XineramaConfineCursorToWindow(sprite.confineWin, TRUE);
+ else
+ XineramaConfineCursorToWindow(WindowTable[0], 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)
+ (*sprite.screen->SetCursorPosition)(sprite.screen,
+ sprite.hotPhys.x + panoramiXdataPtr[0].x -
+ panoramiXdataPtr[sprite.screen->myNum].x,
+ sprite.hotPhys.y + panoramiXdataPtr[0].y -
+ panoramiXdataPtr[sprite.screen->myNum].y, FALSE);
+ }
+ } else
+#endif
if (newScreen != sprite.hotPhys.pScreen)
ConfineCursorToWindow(WindowTable[newScreen->myNum], TRUE, FALSE);
}
+#ifdef PANORAMIX
+
+static Bool
+XineramaPointInWindowIsVisible(
+ WindowPtr pWin,
+ int x,
+ int y
+)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ BoxRec box;
+ int i, xoff, yoff;
+
+ if (!pWin->realized) return FALSE;
+
+ if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+ return TRUE;
+
+ if(!XineramaSetWindowPntrs(pWin)) return FALSE;
+
+ xoff = x + panoramiXdataPtr[0].x;
+ yoff = y + panoramiXdataPtr[0].y;
+
+ for(i = 1; i < PanoramiXNumScreens; i++) {
+ pWin = sprite.windows[i];
+ pScreen = pWin->drawable.pScreen;
+ x = xoff - panoramiXdataPtr[i].x;
+ y = yoff - panoramiXdataPtr[i].y;
+
+ if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+ return TRUE;
+
+ }
+
+ return FALSE;
+}
+
+static int
+XineramaWarpPointer(ClientPtr client)
+{
+ WindowPtr dest = NULL;
+ int x, y;
+
+ REQUEST(xWarpPointerReq);
+
+
+ if (stuff->dstWid != None)
+ {
+ dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
+ if (!dest)
+ return BadWindow;
+ }
+ x = sprite.hotPhys.x;
+ y = sprite.hotPhys.y;
+
+ if (stuff->srcWid != None)
+ {
+ int winX, winY;
+ XID winID = stuff->srcWid;
+ WindowPtr source;
+
+ source = SecurityLookupWindow(winID, client, SecurityReadAccess);
+ if (!source) return BadWindow;
+
+ winX = source->drawable.x;
+ winY = source->drawable.y;
+ if(source == WindowTable[0]) {
+ winX -= panoramiXdataPtr[0].x;
+ winY -= panoramiXdataPtr[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 == WindowTable[0]) {
+ x -= panoramiXdataPtr[0].x;
+ y -= panoramiXdataPtr[0].y;
+ }
+ }
+
+ x += stuff->dstX;
+ y += stuff->dstY;
+
+ if (x < sprite.physLimits.x1)
+ x = sprite.physLimits.x1;
+ else if (x >= sprite.physLimits.x2)
+ x = sprite.physLimits.x2 - 1;
+ if (y < sprite.physLimits.y1)
+ y = sprite.physLimits.y1;
+ else if (y >= sprite.physLimits.y2)
+ y = sprite.physLimits.y2 - 1;
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &x, &y);
+
+ XineramaSetCursorPosition(x, y, TRUE);
+
+ return Success;
+}
+
+#endif
+
+
int
ProcWarpPointer(client)
ClientPtr client;
@@ -1600,6 +2302,12 @@ ProcWarpPointer(client)
REQUEST(xWarpPointerReq);
REQUEST_SIZE_MATCH(xWarpPointerReq);
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return XineramaWarpPointer(client);
+#endif
+
if (stuff->dstWid != None)
{
dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
@@ -1608,13 +2316,16 @@ ProcWarpPointer(client)
}
x = sprite.hotPhys.x;
y = sprite.hotPhys.y;
+
if (stuff->srcWid != None)
{
int winX, winY;
- WindowPtr source = SecurityLookupWindow(stuff->srcWid, client,
- SecurityReadAccess);
- if (!source)
- return BadWindow;
+ XID winID = stuff->srcWid;
+ WindowPtr source;
+
+ source = SecurityLookupWindow(winID, client, SecurityReadAccess);
+ if (!source) return BadWindow;
+
winX = source->drawable.x;
winY = source->drawable.y;
if (source->drawable.pScreen != sprite.hotPhys.pScreen ||
@@ -1627,16 +2338,17 @@ ProcWarpPointer(client)
!PointInWindowIsVisible(source, x, y))
return Success;
}
- if (dest)
+ if (dest)
{
x = dest->drawable.x;
y = dest->drawable.y;
newScreen = dest->drawable.pScreen;
- }
- else
+ } else
newScreen = sprite.hotPhys.pScreen;
+
x += stuff->dstX;
y += stuff->dstY;
+
if (x < 0)
x = 0;
else if (x >= newScreen->width)
@@ -1656,7 +2368,7 @@ ProcWarpPointer(client)
y = sprite.physLimits.y1;
else if (y >= sprite.physLimits.y2)
y = sprite.physLimits.y2 - 1;
-#ifdef SHAPE
+#if defined(SHAPE)
if (sprite.hotShape)
ConfineToShape(sprite.hotShape, &x, &y);
#endif
@@ -1669,15 +2381,42 @@ ProcWarpPointer(client)
return Success;
}
+static Bool
+BorderSizeNotEmpty(WindowPtr pWin)
+{
+ if(REGION_NOTEMPTY(sprite.hotPhys.pScreen, &pWin->borderSize))
+ return TRUE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
+ int i;
+
+ for(i = 1; i < PanoramiXNumScreens; i++) {
+ if(REGION_NOTEMPTY(sprite.screen, &sprite.windows[i]->borderSize))
+ return TRUE;
+ }
+ }
+#endif
+ return FALSE;
+}
+
/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
passive grab set on the window to be activated. */
static Bool
+#if NeedFunctionPrototypes
+CheckPassiveGrabsOnWindow(
+ WindowPtr pWin,
+ register DeviceIntPtr device,
+ register xEvent *xE,
+ int count)
+#else
CheckPassiveGrabsOnWindow(pWin, device, xE, count)
WindowPtr pWin;
register DeviceIntPtr device;
register xEvent *xE;
int count;
+#endif
{
register GrabPtr grab = wPassiveGrabs(pWin);
GrabRec tempGrab;
@@ -1722,9 +2461,8 @@ CheckPassiveGrabsOnWindow(pWin, device, xE, count)
#endif
if (GrabMatchesSecond(&tempGrab, grab) &&
(!grab->confineTo ||
- (grab->confineTo->realized &&
- REGION_NOTEMPTY( grab->confineTo->drawable.pScreen,
- &grab->confineTo->borderSize))))
+ (grab->confineTo->realized &&
+ BorderSizeNotEmpty(grab->confineTo))))
{
#ifdef XCSECURITY
if (!SecurityCheckDeviceAccess(wClient(pWin), device, FALSE))
@@ -1732,8 +2470,8 @@ CheckPassiveGrabsOnWindow(pWin, device, xE, count)
#endif
#ifdef XKB
if (!noXkbExtension) {
- xE->u.keyButtonPointer.state &= 0x1f00;
- xE->u.keyButtonPointer.state |=
+ XE_KBPTR.state &= 0x1f00;
+ XE_KBPTR.state |=
tempGrab.modifiersDetail.exact&(~0x1f00);
}
#endif
@@ -1787,7 +2525,7 @@ CheckDeviceGrabs(device, xE, checkFirst, count)
int count;
{
register int i;
- register WindowPtr pWin;
+ register WindowPtr pWin = NULL;
register FocusClassPtr focus = device->focus;
if ((xE->u.u.type == ButtonPress
@@ -1814,7 +2552,7 @@ CheckDeviceGrabs(device, xE, checkFirst, count)
((i > checkFirst) && (pWin != spriteTrace[i-1])))
return FALSE;
}
-
+
for (; i < spriteTraceGood; i++)
{
pWin = spriteTrace[i];
@@ -1973,10 +2711,9 @@ ProcessKeyboardEvent (xE, keybd, count)
CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
}
}
- xE->u.keyButtonPointer.state = (keyc->state |
- inputInfo.pointer->button->state);
- xE->u.keyButtonPointer.rootX = sprite.hot.x;
- xE->u.keyButtonPointer.rootY = sprite.hot.y;
+ XE_KBPTR.state = (keyc->state | inputInfo.pointer->button->state);
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
key = xE->u.u.detail;
kptr = &keyc->down[key >> 3];
bit = 1 << (key & 7);
@@ -2053,6 +2790,44 @@ ProcessKeyboardEvent (xE, keybd, count)
(*keybd->DeactivateGrab)(keybd);
}
+#ifdef XKB
+/* This function is used to set the key pressed or key released state -
+ this is only used when the pressing of keys does not cause
+ CoreProcessKeyEvent to be called, as in for example Mouse Keys.
+*/
+void
+FixKeyState (xE, keybd)
+ register xEvent *xE;
+ register DeviceIntPtr keybd;
+{
+ int key, bit;
+ register BYTE *kptr;
+ register KeyClassPtr keyc = keybd->key;
+
+ key = xE->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+#ifdef DEBUG
+ if ((xkbDebugFlags&0x4)&&
+ ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+ ErrorF("FixKeyState: Key %d %s\n",key,
+ (xE->u.u.type==KeyPress?"down":"up"));
+ }
+#endif
+ switch (xE->u.u.type)
+ {
+ case KeyPress:
+ *kptr |= bit;
+ break;
+ case KeyRelease:
+ *kptr &= ~bit;
+ break;
+ default:
+ FatalError("Impossible keyboard event");
+ }
+}
+#endif
+
void
#ifdef XKB
CoreProcessPointerEvent (xE, mouse, count)
@@ -2072,7 +2847,7 @@ ProcessPointerEvent (xE, mouse, count)
if (!syncEvents.playingEvents)
NoticeTime(xE)
- xE->u.keyButtonPointer.state = (butc->state | (
+ XE_KBPTR.state = (butc->state | (
#ifdef XKB
(noXkbExtension ?
inputInfo.keyboard->key->state :
@@ -2088,7 +2863,7 @@ ProcessPointerEvent (xE, mouse, count)
DeviceEventInfoRec eventinfo;
/* see comment in EnqueueEvents regarding the next three lines */
if (xE->u.u.type == MotionNotify)
- xE->u.keyButtonPointer.root =
+ XE_KBPTR.root =
WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
eventinfo.events = xE;
eventinfo.count = count;
@@ -2101,8 +2876,9 @@ ProcessPointerEvent (xE, mouse, count)
register BYTE *kptr;
int bit;
- xE->u.keyButtonPointer.rootX = sprite.hot.x;
- xE->u.keyButtonPointer.rootY = sprite.hot.y;
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
+
key = xE->u.u.detail;
kptr = &butc->down[key >> 3];
bit = 1 << (key & 7);
@@ -2110,10 +2886,13 @@ ProcessPointerEvent (xE, mouse, count)
{
case ButtonPress:
mouse->valuator->motionHintWindow = NullWindow;
- butc->buttonsDown++;
+ if (!(*kptr & bit))
+ butc->buttonsDown++;
butc->motionMask = ButtonMotionMask;
*kptr |= bit;
+#if !defined(XFree86Server) || !defined(XINPUT)
xE->u.u.detail = butc->map[key];
+#endif
if (xE->u.u.detail == 0)
return;
if (xE->u.u.detail <= 5)
@@ -2125,10 +2904,14 @@ ProcessPointerEvent (xE, mouse, count)
break;
case ButtonRelease:
mouse->valuator->motionHintWindow = NullWindow;
- if (!--butc->buttonsDown)
+ if (*kptr & bit)
+ --butc->buttonsDown;
+ if (!butc->buttonsDown)
butc->motionMask = 0;
*kptr &= ~bit;
+#if !defined(XFree86Server) || !defined(XINPUT)
xE->u.u.detail = butc->map[key];
+#endif
if (xE->u.u.detail == 0)
return;
if (xE->u.u.detail <= 5)
@@ -2256,7 +3039,7 @@ EventSelectForWindow(pWin, client, mask)
if (wClient (pWin) == client)
{
check = pWin->eventMask;
-#if SGIMISC
+#ifdef SGIMISC
pWin->eventMask =
(mask & ~SGIMiscSpecialDestroyMask) | (pWin->eventMask & SGIMiscSpecialDestroyMask);
#else
@@ -2270,7 +3053,7 @@ EventSelectForWindow(pWin, client, mask)
if (SameClient(others, client))
{
check = others->mask;
-#if SGIMISC
+#ifdef SGIMISC
mask = (mask & ~SGIMiscSpecialDestroyMask) | (others->mask & SGIMiscSpecialDestroyMask);
#endif
if (mask == 0)
@@ -2367,8 +3150,14 @@ EventSuppressForWindow(pWin, client, mask, checkOptional)
}
static WindowPtr
+#if NeedFunctionPrototypes
+CommonAncestor(
+ register WindowPtr a,
+ register WindowPtr b)
+#else
CommonAncestor(a, b)
register WindowPtr a, b;
+#endif
{
for (b = b->parent; b; b = b->parent)
if (IsParent(b, a)) return b;
@@ -2376,10 +3165,19 @@ CommonAncestor(a, b)
}
static void
+#if NeedFunctionPrototypes
+EnterLeaveEvent(
+ int type,
+ int mode,
+ int detail,
+ register WindowPtr pWin,
+ Window child)
+#else
EnterLeaveEvent(type, mode, detail, pWin, child)
int type, mode, detail;
register WindowPtr pWin;
Window child;
+#endif
{
xEvent event;
register DeviceIntPtr keybd = inputInfo.keyboard;
@@ -2460,9 +3258,13 @@ EnterLeaveEvent(type, mode, detail, pWin, child)
}
static void
+#if NeedFunctionPrototypes
+EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail)
+#else
EnterNotifies(ancestor, child, mode, detail)
WindowPtr ancestor, child;
int mode, detail;
+#endif
{
WindowPtr parent = child->parent;
@@ -2473,9 +3275,13 @@ EnterNotifies(ancestor, child, mode, detail)
}
static void
+#if NeedFunctionPrototypes
+LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail)
+#else
LeaveNotifies(child, ancestor, mode, detail)
WindowPtr child, ancestor;
int detail, mode;
+#endif
{
register WindowPtr pWin;
@@ -2489,9 +3295,13 @@ LeaveNotifies(child, ancestor, mode, detail)
}
static void
+#if NeedFunctionPrototypes
+DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode)
+#else
DoEnterLeaveEvents(fromWin, toWin, mode)
WindowPtr fromWin, toWin;
int mode;
+#endif
{
if (fromWin == toWin)
return;
@@ -2519,10 +3329,14 @@ DoEnterLeaveEvents(fromWin, toWin, mode)
}
static void
+#if NeedFunctionPrototypes
+FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, register WindowPtr pWin)
+#else
FocusEvent(dev, type, mode, detail, pWin)
DeviceIntPtr dev;
int type, mode, detail;
register WindowPtr pWin;
+#endif
{
xEvent event;
@@ -2563,11 +3377,19 @@ FocusEvent(dev, type, mode, detail, pWin)
* no-op if child not descended from ancestor
*/
static Bool
+#if NeedFunctionPrototypes
+FocusInEvents(
+ DeviceIntPtr dev,
+ WindowPtr ancestor, WindowPtr child, WindowPtr skipChild,
+ int mode, int detail,
+ Bool doAncestor)
+#else
FocusInEvents(dev, ancestor, child, skipChild, mode, detail, doAncestor)
DeviceIntPtr dev;
WindowPtr ancestor, child, skipChild;
int mode, detail;
Bool doAncestor;
+#endif
{
if (child == NullWindow)
return ancestor == NullWindow;
@@ -2589,12 +3411,20 @@ FocusInEvents(dev, ancestor, child, skipChild, mode, detail, doAncestor)
/* dies horribly if ancestor is not an ancestor of child */
static void
+#if NeedFunctionPrototypes
+FocusOutEvents(
+ DeviceIntPtr dev,
+ WindowPtr child, WindowPtr ancestor,
+ int mode, int detail,
+ Bool doAncestor)
+#else
FocusOutEvents(dev, child, ancestor, mode, detail, doAncestor)
DeviceIntPtr dev;
WindowPtr child, ancestor;
int mode;
int detail;
Bool doAncestor;
+#endif
{
register WindowPtr pWin;
@@ -2628,8 +3458,13 @@ DoFocusEvents(dev, fromWin, toWin, mode)
FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
TRUE);
/* Notify all the roots */
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
+ else
+#endif
+ for (i=0; i<screenInfo.numScreens; i++)
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
}
else
{
@@ -2642,8 +3477,13 @@ DoFocusEvents(dev, fromWin, toWin, mode)
NotifyNonlinearVirtual, FALSE);
}
/* Notify all the roots */
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusIn, mode, in, WindowTable[i]);
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ FocusEvent(dev, FocusIn, mode, in, WindowTable[0]);
+ else
+#endif
+ for (i=0; i<screenInfo.numScreens; i++)
+ FocusEvent(dev, FocusIn, mode, in, WindowTable[i]);
if (toWin == PointerRootWin)
(void)FocusInEvents(dev, ROOT, sprite.win, NullWindow, mode,
NotifyPointer, TRUE);
@@ -2655,8 +3495,13 @@ DoFocusEvents(dev, fromWin, toWin, mode)
if (fromWin == PointerRootWin)
FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
TRUE);
- for (i=0; i<screenInfo.numScreens; i++)
- FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
+ else
+#endif
+ for (i=0; i<screenInfo.numScreens; i++)
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
if (toWin->parent != NullWindow)
(void)FocusInEvents(dev, ROOT, toWin, toWin, mode,
NotifyNonlinearVirtual, TRUE);
@@ -2719,6 +3564,15 @@ DoFocusEvents(dev, fromWin, toWin, mode)
}
int
+#if NeedFunctionPrototypes
+SetInputFocus(
+ ClientPtr client,
+ DeviceIntPtr dev,
+ Window focusID,
+ CARD8 revertTo,
+ Time ctime,
+ Bool followOK)
+#else
SetInputFocus(client, dev, focusID, revertTo, ctime, followOK)
ClientPtr client;
DeviceIntPtr dev;
@@ -2726,6 +3580,7 @@ SetInputFocus(client, dev, focusID, revertTo, ctime, followOK)
CARD8 revertTo;
Time ctime;
Bool followOK;
+#endif
{
register FocusClassPtr focus;
register WindowPtr focusWin;
@@ -2743,7 +3598,7 @@ SetInputFocus(client, dev, focusID, revertTo, ctime, followOK)
}
time = ClientTimeToServerTime(ctime);
if ((focusID == None) || (focusID == PointerRoot))
- focusWin = (WindowPtr)focusID;
+ focusWin = (WindowPtr)(long)focusID;
else if ((focusID == FollowKeyboard) && followOK)
focusWin = inputInfo.keyboard->focus->win;
else if (!(focusWin = SecurityLookupWindow(focusID, client,
@@ -2816,7 +3671,7 @@ ProcGetInputFocus(client)
ClientPtr client;
{
xGetInputFocusReply rep;
- REQUEST(xReq);
+ /* REQUEST(xReq); */
FocusClassPtr focus = inputInfo.keyboard->focus;
REQUEST_SIZE_MATCH(xReq);
@@ -2874,7 +3729,7 @@ ProcGrabPointer(client)
return BadWindow;
if (stuff->confineTo == None)
confineTo = NullWindow;
- else
+ else
{
confineTo = SecurityLookupWindow(stuff->confineTo, client,
SecurityReadAccess);
@@ -2902,10 +3757,8 @@ ProcGrabPointer(client)
if ((grab) && !SameClient(grab, client))
rep.status = AlreadyGrabbed;
else if ((!pWin->realized) ||
- (confineTo &&
- !(confineTo->realized &&
- REGION_NOTEMPTY( confineTo->drawable.pScreen,
- &confineTo->borderSize))))
+ (confineTo &&
+ !(confineTo->realized && BorderSizeNotEmpty(confineTo))))
rep.status = GrabNotViewable;
else if (device->sync.frozen &&
device->sync.other && !SameClient(device->sync.other, client))
@@ -3165,6 +4018,18 @@ ProcQueryPointer(client)
rep.winX = 0;
rep.winY = 0;
}
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ rep.rootX += panoramiXdataPtr[0].x;
+ rep.rootY += panoramiXdataPtr[0].y;
+ if(stuff->id == rep.root) {
+ rep.winX += panoramiXdataPtr[0].x;
+ rep.winY += panoramiXdataPtr[0].y;
+ }
+ }
+#endif
+
WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
return(Success);
@@ -3220,6 +4085,14 @@ InitEvents()
}
}
+void
+CloseDownEvents(void)
+{
+ xfree(spriteTrace);
+ spriteTrace = NULL;
+ spriteTraceSize = 0;
+}
+
int
ProcSendEvent(client)
ClientPtr client;
@@ -3322,6 +4195,7 @@ ProcUngrabKey(client)
pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
if (!pWin)
return BadWindow;
+
if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
(stuff->key < keybd->key->curKeySyms.minKeyCode))
&& (stuff->key != AnyKey))
@@ -3335,7 +4209,6 @@ ProcUngrabKey(client)
client->errorValue = stuff->modifiers;
return BadValue;
}
-
tempGrab.resource = client->clientAsMask;
tempGrab.device = keybd;
tempGrab.window = pWin;
@@ -3398,12 +4271,14 @@ ProcGrabKey(client)
grab = CreateGrab(client->index, keybd, pWin,
(Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents,
(Bool)stuff->keyboardMode, (Bool)stuff->pointerMode,
- keybd, stuff->modifiers, KeyPress, stuff->key, NullWindow, NullCursor);
+ keybd, stuff->modifiers, KeyPress, stuff->key,
+ NullWindow, NullCursor);
if (!grab)
return BadAlloc;
return AddPassiveGrabToList(grab);
}
+
int
ProcGrabButton(client)
ClientPtr client;
@@ -3446,9 +4321,8 @@ ProcGrabButton(client)
if (!pWin)
return BadWindow;
if (stuff->confineTo == None)
- confineTo = NullWindow;
- else
- {
+ confineTo = NullWindow;
+ else {
confineTo = SecurityLookupWindow(stuff->confineTo, client,
SecurityReadAccess);
if (!confineTo)
@@ -3467,8 +4341,9 @@ ProcGrabButton(client)
}
}
+
grab = CreateGrab(client->index, inputInfo.pointer, pWin,
- permitOldBugs ? (Mask)(stuff->eventMask |
+ permitOldBugs ? (Mask)(stuff->eventMask |
ButtonPressMask | ButtonReleaseMask) :
(Mask)stuff->eventMask,
(Bool)stuff->ownerEvents, (Bool) stuff->keyboardMode,
@@ -3497,7 +4372,6 @@ ProcUngrabButton(client)
pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
if (!pWin)
return BadWindow;
-
tempGrab.resource = client->clientAsMask;
tempGrab.device = inputInfo.pointer;
tempGrab.window = pWin;
@@ -3613,10 +4487,13 @@ CheckCursorConfinement(pWin)
GrabPtr grab = inputInfo.pointer->grab;
WindowPtr confineTo;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return;
+#endif
+
if (grab && (confineTo = grab->confineTo))
{
- if (!REGION_NOTEMPTY( confineTo->drawable.pScreen,
- &confineTo->borderSize))
+ if (!BorderSizeNotEmpty(confineTo))
(*inputInfo.pointer->DeactivateGrab)(inputInfo.pointer);
else if ((pWin == confineTo) || IsParent(pWin, confineTo))
ConfineCursorToWindow(confineTo, TRUE, TRUE);
@@ -3647,6 +4524,7 @@ ProcRecolorCursor(client)
CursorPtr pCursor;
int nscr;
ScreenPtr pscr;
+ Bool displayed;
REQUEST(xRecolorCursorReq);
REQUEST_SIZE_MATCH(xRecolorCursorReq);
@@ -3669,9 +4547,14 @@ ProcRecolorCursor(client)
for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
{
pscr = screenInfo.screens[nscr];
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ displayed = (pscr == sprite.screen);
+ else
+#endif
+ displayed = (pscr == sprite.hotPhys.pScreen);
( *pscr->RecolorCursor)(pscr, pCursor,
- (pCursor == sprite.current) &&
- (pscr == sprite.hotPhys.pScreen));
+ (pCursor == sprite.current) && displayed);
}
return (Success);
}
@@ -3682,6 +4565,9 @@ WriteEventsToClient(pClient, count, events)
int count;
xEvent *events;
{
+#ifdef PANORAMIX
+ xEvent eventCopy;
+#endif
xEvent eventTo, *eventFrom;
int i;
@@ -3690,6 +4576,40 @@ WriteEventsToClient(pClient, count, events)
return;
#endif
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension &&
+ (panoramiXdataPtr[0].x || panoramiXdataPtr[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 += panoramiXdataPtr[0].x;
+ eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y;
+ if(eventCopy.u.keyButtonPointer.event ==
+ eventCopy.u.keyButtonPointer.root)
+ {
+ eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x;
+ eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y;
+ }
+ events = &eventCopy;
+ break;
+ default: break;
+ }
+ }
+#endif
+
if (EventCallback)
{
EventInfoRec eventinfo;