[PATCH 1/6] Add SetDeviceRedirectWindow
Peter Hutterer
peter.hutterer at who-t.net
Wed Nov 7 16:24:04 PST 2012
On Wed, Nov 07, 2012 at 05:58:18PM +1100, Daniel Stone wrote:
> From: Kristian Høgsberg <krh at redhat.com>
>
> SetDeviceRedirectWindow confines the sprite and the focus for a given
> device to a given window tree, for use in rootless servers.
>
> Signed-off-by: Kristian Høgsberg <krh at redhat.com>
> ---
> Xi/exevents.c | 13 +++++++++++++
> dix/events.c | 11 ++++++++++-
> include/exevents.h | 4 ++++
> include/inputstr.h | 2 ++
> 4 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/Xi/exevents.c b/Xi/exevents.c
> index 4248b9a..fe6c82a 100644
> --- a/Xi/exevents.c
> +++ b/Xi/exevents.c
> @@ -1989,6 +1989,19 @@ DeliverTouchEvents(DeviceIntPtr dev, TouchPointInfoPtr ti,
> }
> }
>
> +void
> +SetDeviceRedirectWindow(DeviceIntPtr dev, WindowPtr window)
> +{
> + SpritePtr pSprite = dev->spriteInfo->sprite;
> + DeviceIntPtr mouse;
> +
> + mouse = IsMaster(dev) ? dev : GetMaster(dev, MASTER_POINTER);
mouse = GetMaster(dev, POINTER_OR_FLOAT);
and you need some sanity check to make sure the device is enabled, otherwise
it won't have a sprite and you get a crash on the next line.
> +
> + pSprite->redirectWindow = window;
> +
> + CheckMotion(NULL, mouse);
> +}
> +
> int
> InitProximityClassDeviceStruct(DeviceIntPtr dev)
> {
> diff --git a/dix/events.c b/dix/events.c
> index e790bfc..e122234 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -2778,7 +2778,16 @@ XYToWindow(SpritePtr pSprite, int x, int y)
> BoxRec box;
>
> pSprite->spriteTraceGood = 1; /* root window still there */
> - pWin = RootWindow(pSprite)->firstChild;
> + if (pSprite->redirectWindow == PointerRootWin) {
> + return RootWindow(pSprite);
> + }
> + else if (pSprite->redirectWindow) {
> + pWin = pSprite->redirectWindow;
> + pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
> + pWin = pWin->firstChild;
> + }
> + else
> + pWin = RootWindow(pSprite)->firstChild;
what happens if the redirectWindow disappears. Is this handled elsewhere or
is there a check needed for this?
Cheers,
Peter
> while (pWin) {
> if ((pWin->mapped) &&
> (x >= pWin->drawable.x - wBorderWidth(pWin)) &&
> diff --git a/include/exevents.h b/include/exevents.h
> index 321fc42..4b49a0f 100644
> --- a/include/exevents.h
> +++ b/include/exevents.h
> @@ -158,6 +158,10 @@ extern int
> UpdateDeviceState(DeviceIntPtr /* device */ ,
> DeviceEvent * /* xE */ );
>
> +extern _X_EXPORT void
> +SetDeviceRedirectWindow(DeviceIntPtr /* dev */ ,
> + WindowPtr /* window */ );
> +
> extern void
> ProcessOtherEvent(InternalEvent * /* ev */ ,
> DeviceIntPtr /* other */ );
> diff --git a/include/inputstr.h b/include/inputstr.h
> index 5a38924..c4930aa 100644
> --- a/include/inputstr.h
> +++ b/include/inputstr.h
> @@ -246,6 +246,8 @@ typedef struct _SpriteRec {
> ScreenPtr pEnqueueScreen;
> ScreenPtr pDequeueScreen;
>
> + WindowPtr redirectWindow;
> +
> } SpriteRec;
>
> typedef struct _KeyClassRec {
> --
> 1.7.10.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list