summaryrefslogtreecommitdiff
blob: 51355ef159ef51d9861d2ebfe1018875e21f2d0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Index: xorg-server/dix/events.c
===================================================================
--- xorg-server.orig/dix/events.c	2011-08-24 12:56:49.855650623 +0300
+++ xorg-server/dix/events.c	2011-08-24 12:57:14.725650980 +0300
@@ -6385,3 +6385,47 @@
     return FALSE;
 }
 
+WindowPtr
+CoordinatesToWindow(int x, int y, int screen)
+{
+    WindowPtr pWin;
+    WindowPtr ret = NullWindow;
+    BoxRec box;
+
+    pWin = screenInfo.screens[screen]->root;
+    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
+#endif
+	    )
+	{
+            ret = pWin;
+            pWin = pWin->firstChild;
+        }
+        else
+            pWin = pWin->nextSib;
+    }
+    return ret;
+}
+
Index: xorg-server/hw/xfree86/common/xf86Xinput.c
===================================================================
--- xorg-server.orig/hw/xfree86/common/xf86Xinput.c	2011-08-24 12:56:49.855650623 +0300
+++ xorg-server/hw/xfree86/common/xf86Xinput.c	2011-08-24 12:57:14.715650981 +0300
@@ -1465,4 +1465,10 @@
         mieqEnqueue(dev, (InternalEvent *)((xf86Events + i)->event));
 }
 
+WindowPtr
+xf86CoordinatesToWindow(int x, int y, int screen)
+{
+    return CoordinatesToWindow(x, y, screen);
+}
+
 /* end of xf86Xinput.c */
Index: xorg-server/hw/xfree86/common/xf86Xinput.h
===================================================================
--- xorg-server.orig/hw/xfree86/common/xf86Xinput.h	2011-08-24 12:56:49.865650624 +0300
+++ xorg-server/hw/xfree86/common/xf86Xinput.h	2011-08-24 12:56:49.875650625 +0300
@@ -184,4 +184,6 @@
 /* xf86Option.c */
 extern _X_EXPORT void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts);
 
+extern _X_EXPORT WindowPtr xf86CoordinatesToWindow(int x, int y, int screen);
+
 #endif /* _xf86Xinput_h */
Index: xorg-server/include/events.h
===================================================================
--- xorg-server.orig/include/events.h	2011-08-24 12:56:49.865650624 +0300
+++ xorg-server/include/events.h	2011-08-24 12:56:49.875650625 +0300
@@ -24,6 +24,7 @@
 
 #ifndef EVENTS_H
 #define EVENTS_H
+
 typedef struct _DeviceEvent DeviceEvent;
 typedef struct _DeviceChangedEvent DeviceChangedEvent;
 typedef struct _TouchOwnershipEvent TouchOwnershipEvent;
@@ -36,4 +37,6 @@
 #endif
 typedef union _InternalEvent InternalEvent;
 
+extern WindowPtr CoordinatesToWindow(int x, int y, int screen);
+
 #endif