Unverified Commit 753535e3 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/simplify_nxevents' into 3.6.x

parents bdcb5a18 283e4523
......@@ -1216,10 +1216,14 @@ CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
ComputeFreezes();
}
#ifndef NXAGENT_SERVER
void
ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
#ifdef NXAGENT_SERVER
xorg_ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
TimeStamp time, Bool autoGrab)
#else
ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
TimeStamp time, Bool autoGrab)
#endif
{
WindowPtr oldWin = (mouse->grab) ? mouse->grab->window
: sprite.win;
......@@ -1246,7 +1250,11 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
}
void
#ifdef NXAGENT_SERVER
xorg_DeactivatePointerGrab(register DeviceIntPtr mouse)
#else
DeactivatePointerGrab(register DeviceIntPtr mouse)
#endif
{
register GrabPtr grab = mouse->grab;
register DeviceIntPtr dev;
......@@ -1268,7 +1276,6 @@ DeactivatePointerGrab(register DeviceIntPtr mouse)
FreeCursor(grab->cursor, (Cursor)0);
ComputeFreezes();
}
#endif /* NXAGENT_SERVER */
void
ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive)
......@@ -1429,7 +1436,11 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
}
int
#ifdef NXAGENT_SERVER
xorg_ProcAllowEvents(register ClientPtr client)
#else
ProcAllowEvents(register ClientPtr client)
#endif
{
TimeStamp time;
DeviceIntPtr mouse = inputInfo.pointer;
......@@ -1903,7 +1914,17 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
return FALSE;
}
#ifndef NXAGENT_SERVER
/* define XYWINDOWCALLBACK if your DDX provides this callback */
static WindowPtr GetXYStartWindow(WindowPtr pWin);
#ifndef XYWINDOWCALLBACK
static WindowPtr GetXYStartWindow(WindowPtr pWin)
{
return pWin;
}
#endif
static WindowPtr
XYToWindow(int x, int y)
{
......@@ -1911,7 +1932,7 @@ XYToWindow(int x, int y)
BoxRec box;
spriteTraceGood = 1; /* root window still there */
pWin = ROOT->firstChild;
pWin = GetXYStartWindow(ROOT->firstChild);
while (pWin)
{
if ((pWin->mapped) &&
......@@ -1949,7 +1970,6 @@ XYToWindow(int x, int y)
}
return spriteTrace[spriteTraceGood-1];
}
#endif /* NXAGENT_SERVER */
#ifndef NXAGENT_SERVER
static Bool
......@@ -2063,9 +2083,12 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
}
#endif
#ifndef NXAGENT_SERVER
void
#ifdef NXAGENT_SERVER
xorg_DefineInitialRootWindow(register WindowPtr win)
#else
DefineInitialRootWindow(register WindowPtr win)
#endif
{
register ScreenPtr pScreen = win->drawable.pScreen;
......@@ -2105,7 +2128,6 @@ DefineInitialRootWindow(register WindowPtr win)
}
#endif
}
#endif /* NXAGENT_SERVER */
/*
* This does not take any shortcuts, and even ignores its argument, since
......@@ -3940,9 +3962,12 @@ CloseDownEvents(void)
spriteTraceSize = 0;
}
#ifndef NXAGENT_SERVER
int
#ifdef NXAGENT_SERVER
xorg_ProcSendEvent(ClientPtr client)
#else
ProcSendEvent(ClientPtr client)
#endif
{
WindowPtr pWin;
WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
......@@ -4027,7 +4052,6 @@ ProcSendEvent(ClientPtr client)
NullGrab, 0);
return Success;
}
#endif /* NXAGENT_SERVER */
int
ProcUngrabKey(ClientPtr client)
......
......@@ -135,6 +135,7 @@ of the copyright holder.
#include <nx-X11/Xlib.h>
#define XYWINDOWCALLBACK
#include "../../dix/events.c"
#include "compext/Compext.h"
......@@ -161,28 +162,7 @@ void
ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
TimeStamp time, Bool autoGrab)
{
WindowPtr oldWin = (mouse->grab) ? mouse->grab->window
: sprite.win;
if (grab->confineTo)
{
if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
sprite.hotPhys.x = sprite.hotPhys.y = 0;
ConfineCursorToWindow(grab->confineTo, FALSE, TRUE);
}
DoEnterLeaveEvents(oldWin, grab->window, NotifyGrab);
mouse->valuator->motionHintWindow = NullWindow;
if (syncEvents.playingEvents)
mouse->grabTime = syncEvents.time;
else
mouse->grabTime = time;
if (grab->cursor)
grab->cursor->refcnt++;
mouse->activeGrab = *grab;
mouse->grab = &mouse->activeGrab;
mouse->fromPassiveGrab = autoGrab;
PostNewCursor();
CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
xorg_ActivatePointerGrab(mouse, grab, time, autoGrab);
#ifdef NXAGENT_SERVER
......@@ -212,9 +192,17 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
if (nxagentOption(Rootless) == 1)
{
/*
* FIXME: We should use the correct value
* for the cursor. Temporarily we set it
* to None.
* from nxagent-1.5.0-20 changelog:
* In rootless mode, grabs exported to X in
* ActivatePointerGrab() are always made asynchronous. The
* synchronous behaviour is implemented by the agent, so that
* requiring a further synchronous grab down to the real X
* server is of little use and potentially harmful.
*/
/*
* FIXME: We should use the correct value for the
* cursor. Temporarily we set it to None.
*/
int resource = nxagentWaitForResource(NXGetCollectGrabPointerResource,
......@@ -227,34 +215,25 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
None, CurrentTime);
}
#endif
#endif /* NXAGENT_SERVER */
}
void
DeactivatePointerGrab(register DeviceIntPtr mouse)
{
register GrabPtr grab = mouse->grab;
register DeviceIntPtr dev;
mouse->valuator->motionHintWindow = NullWindow;
mouse->grab = NullGrab;
mouse->sync.state = NOT_GRABBED;
mouse->fromPassiveGrab = FALSE;
for (dev = inputInfo.devices; dev; dev = dev->next)
{
if (dev->sync.other == grab)
dev->sync.other = NullGrab;
}
DoEnterLeaveEvents(grab->window, sprite.win, NotifyUngrab);
if (grab->confineTo)
ConfineCursorToWindow(ROOT, FALSE, FALSE);
PostNewCursor();
if (grab->cursor)
FreeCursor(grab->cursor, (Cursor)0);
ComputeFreezes();
xorg_DeactivatePointerGrab(mouse);
#ifdef NXAGENT_SERVER
/*
* excerpt from nxagent-1.5.0-20 changelog:
* In DeactivatePointerGrab() function, mouse button state is set
* to up if the window entered by the pointer is the root window
* and the agent is in rootless mode. This change is needed
* because the subsequent KeyRelease event could be not received
* by the agent (for example if the focus had left the window), so
* that agent could be unable to update the mouse button state.
*/
if (nxagentOption(Rootless) == 1)
{
XUngrabPointer(nxagentDisplay, CurrentTime);
......@@ -270,75 +249,56 @@ DeactivatePointerGrab(register DeviceIntPtr mouse)
#endif
}
// int
// ProcAllowEvents(register ClientPtr client)
// {
// TimeStamp time;
// DeviceIntPtr mouse = inputInfo.pointer;
// DeviceIntPtr keybd = inputInfo.keyboard;
// REQUEST(xAllowEventsReq);
//
// REQUEST_SIZE_MATCH(xAllowEventsReq);
// time = ClientTimeToServerTime(stuff->time);
// 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;
// }
//
// /*
// * This is not necessary if we export grab to X as asynchronous.
// *
// * if (nxagentOption(Rootless) && stuff -> mode != ReplayKeyboard &&
// * stuff -> mode != SyncKeyboard && stuff -> mode != AsyncKeyboard)
// * {
// * XAllowEvents(nxagentDisplay, stuff -> mode, CurrentTime);
// * }
// */
//
// return Success;
// }
int
ProcAllowEvents(register ClientPtr client)
{
int rc = xorg_ProcAllowEvents(client);
if (rc != Success)
return rc;
/*
* This is not necessary if we export grab to X as asynchronous.
*
* if (nxagentOption(Rootless) && stuff -> mode != ReplayKeyboard &&
* stuff -> mode != SyncKeyboard && stuff -> mode != AsyncKeyboard)
* {
* XAllowEvents(nxagentDisplay, stuff -> mode, CurrentTime);
* }
*/
return Success;
}
/*
* called from XYToWindow to determine where XYToWindow() should start
* going through the list.
*/
static WindowPtr
XYToWindow(int x, int y)
GetXYStartWindow(WindowPtr pWin)
{
register WindowPtr pWin;
BoxRec box;
spriteTraceGood = 1; /* root window still there */
if (nxagentOption(Rootless))
{
/*
* explanation from the original changelog for nxagent-1.5.0-20:
* Modified function XYToWindow() in order to manage the case
* that mouse pointer is located on the title bar of a top level
* window in rootless mode.
*/
if (nxagentLastEnteredWindow == NULL)
{
return ROOT;
}
/*
* explanation from the original changelog for nxagent-1.5.0-17:
* In rootless mode, now function XYToWindow() starts search from
* the last window originated an EnterNotify event. In this way, we
* can prevent shaded windows from getting mouse events.
*/
pWin = ROOT->lastChild;
while (pWin && pWin != ROOT->firstChild && pWin != nxagentLastEnteredWindow)
......@@ -346,47 +306,7 @@ XYToWindow(int x, int y)
pWin = pWin->prevSib;
}
}
else
{
pWin = ROOT->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))
#ifdef SHAPE
/* 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))
#endif
)
{
if (spriteTraceGood >= spriteTraceSize)
{
spriteTraceSize += 10;
spriteTrace = realloc(
spriteTrace, spriteTraceSize*sizeof(WindowPtr));
}
spriteTrace[spriteTraceGood++] = pWin;
pWin = pWin->firstChild;
}
else
pWin = pWin->nextSib;
}
return spriteTrace[spriteTraceGood-1];
return pWin;
}
static Bool
......@@ -476,41 +396,8 @@ void
DefineInitialRootWindow(register WindowPtr win)
{
register ScreenPtr pScreen = win->drawable.pScreen;
sprite.hotPhys.pScreen = pScreen;
sprite.hotPhys.x = pScreen->width / 2;
sprite.hotPhys.y = pScreen->height / 2;
sprite.hot = sprite.hotPhys;
sprite.hotLimits.x2 = pScreen->width;
sprite.hotLimits.y2 = pScreen->height;
sprite.win = win;
sprite.current = wCursor (win);
sprite.current->refcnt++;
spriteTraceGood = 1;
ROOT = win;
(*pScreen->CursorLimits) (
pScreen, sprite.current, &sprite.hotLimits, &sprite.physLimits);
sprite.confined = FALSE;
(*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;
#ifdef SHAPE
sprite.hotShape = NullRegion;
#endif
sprite.screen = pScreen;
/* gotta UNINIT these someplace */
RegionNull(&sprite.Reg1);
RegionNull(&sprite.Reg2);
}
#endif
xorg_DefineInitialRootWindow(win);
#ifdef VIEWPORT_FRAME
nxagentInitViewportFrame(pScreen, win);
......@@ -528,96 +415,17 @@ DefineInitialRootWindow(register WindowPtr win)
int
ProcSendEvent(ClientPtr client)
{
WindowPtr pWin;
WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
#ifdef NXAGENT_CLIPBOARD
REQUEST(xSendEventReq);
REQUEST_SIZE_MATCH(xSendEventReq);
/* The client's event type must be a core event type or one defined by an
extension. */
#ifdef NXAGENT_CLIPBOARD
if (stuff -> event.u.u.type == SelectionNotify)
{
if (nxagentSendNotify(&stuff->event) == 1)
return Success;
}
#endif
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;
}
if (stuff->eventMask & ~AllEventMasks)
{
client->errorValue = stuff->eventMask;
return BadValue;
}
if (stuff->destination == PointerWindow)
pWin = sprite.win;
else if (stuff->destination == InputFocus)
{
WindowPtr inputFocus = inputInfo.keyboard->focus->win;
if (inputFocus == NoneWin)
return Success;
/* If the input focus is PointerRootWin, send the event to where
the pointer is if possible, then perhaps propagate up to root. */
if (inputFocus == PointerRootWin)
inputFocus = ROOT;
if (IsParent(inputFocus, sprite.win))
{
effectiveFocus = inputFocus;
pWin = sprite.win;
}
else
effectiveFocus = pWin = inputFocus;
}
else
pWin = SecurityLookupWindow(stuff->destination, client,
DixReadAccess);
if (!pWin)
return BadWindow;
if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue))
{
client->errorValue = stuff->propagate;
return BadValue;
}
stuff->event.u.u.type |= 0x80;
if (stuff->propagate)
{
for (;pWin; pWin = pWin->parent)
{
if (DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
NullGrab, 0))
return Success;
if (pWin == effectiveFocus)
return Success;
stuff->eventMask &= ~wDontPropagateMask(pWin);
if (!stuff->eventMask)
break;
}
}
else
(void)DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
NullGrab, 0);
return Success;
return xorg_ProcSendEvent(client);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment