[PATCH 1/6] Add SetDeviceRedirectWindow

Daniel Stone daniel at fooishbar.org
Tue Nov 6 22:58:18 PST 2012


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);
+
+    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;
     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



More information about the xorg-devel mailing list