3 Copyright 1993 by Davor Matic
5 Permission to use, copy, modify, distribute, and sell this software
6 and its documentation for any purpose is hereby granted without fee,
7 provided that the above copyright notice appear in all copies and that
8 both that copyright notice and this permission notice appear in
9 supporting documentation. Davor Matic makes no representations about
10 the suitability of this software for any purpose. It is provided "as
11 is" without express or implied warranty.
15 #ifdef HAVE_XNEST_CONFIG_H
16 #include <xnest-config.h>
21 #include <X11/Xproto.h>
22 #include "screenint.h"
25 #include "scrnintstr.h"
26 #include "windowstr.h"
41 #include "mipointer.h"
43 CARD32 lastEventTime
= 0;
45 extern xEvent
*xnestEvents
;
50 mieqProcessInputEvents();
55 TimeSinceLastInputEvent(void)
57 if (lastEventTime
== 0)
58 lastEventTime
= GetTimeInMillis();
59 return GetTimeInMillis() - lastEventTime
;
63 SetTimeSinceLastInputEvent(void)
65 lastEventTime
= GetTimeInMillis();
69 xnestExposurePredicate(Display
*display
, XEvent
*event
, char *args
)
71 return (event
->type
== Expose
|| event
->type
== ProcessedExpose
);
75 xnestNotExposurePredicate(Display
*display
, XEvent
*event
, char *args
)
77 return !xnestExposurePredicate(display
, event
, args
);
81 xnestCollectExposures(void)
88 while (XCheckIfEvent(xnestDisplay
, &X
, xnestExposurePredicate
, NULL
)) {
89 pWin
= xnestWindowPtr(X
.xexpose
.window
);
92 Box
.x1
= pWin
->drawable
.x
+ wBorderWidth(pWin
) + X
.xexpose
.x
;
93 Box
.y1
= pWin
->drawable
.y
+ wBorderWidth(pWin
) + X
.xexpose
.y
;
94 Box
.x2
= Box
.x1
+ X
.xexpose
.width
;
95 Box
.y2
= Box
.y1
+ X
.xexpose
.height
;
97 REGION_INIT(pWin
->drawable
.pScreen
, &Rgn
, &Box
, 1);
99 miWindowExposures(pWin
, &Rgn
, NullRegion
);
105 xnestQueueKeyEvent(int type
, unsigned int keycode
)
109 lastEventTime
= GetTimeInMillis();
110 n
= GetKeyboardEvents(xnestEvents
, xnestKeyboardDevice
, type
, keycode
);
111 for (i
= 0; i
< n
; i
++)
112 mieqEnqueue(xnestKeyboardDevice
, xnestEvents
+ i
);
116 xnestCollectEvents(void)
120 int i
, n
, valuators
[2];
123 while (XCheckIfEvent(xnestDisplay
, &X
, xnestNotExposurePredicate
, NULL
)) {
126 xnestUpdateModifierState(X
.xkey
.state
);
127 xnestQueueKeyEvent(KeyPress
, X
.xkey
.keycode
);
131 xnestUpdateModifierState(X
.xkey
.state
);
132 xnestQueueKeyEvent(KeyRelease
, X
.xkey
.keycode
);
136 xnestUpdateModifierState(X
.xkey
.state
);
137 lastEventTime
= GetTimeInMillis();
138 n
= GetPointerEvents(xnestEvents
, xnestPointerDevice
, ButtonPress
,
139 X
.xbutton
.button
, POINTER_RELATIVE
, 0, 0, NULL
);
140 for (i
= 0; i
< n
; i
++)
141 mieqEnqueue(xnestPointerDevice
, xnestEvents
+ i
);
145 xnestUpdateModifierState(X
.xkey
.state
);
146 lastEventTime
= GetTimeInMillis();
147 n
= GetPointerEvents(xnestEvents
, xnestPointerDevice
, ButtonRelease
,
148 X
.xbutton
.button
, POINTER_RELATIVE
, 0, 0, NULL
);
149 for (i
= 0; i
< n
; i
++)
150 mieqEnqueue(xnestPointerDevice
, xnestEvents
+ i
);
154 valuators
[0] = X
.xmotion
.x
;
155 valuators
[1] = X
.xmotion
.y
;
156 lastEventTime
= GetTimeInMillis();
157 n
= GetPointerEvents(xnestEvents
, xnestPointerDevice
, MotionNotify
,
158 0, POINTER_ABSOLUTE
, 0, 2, valuators
);
159 for (i
= 0; i
< n
; i
++)
160 mieqEnqueue(xnestPointerDevice
, xnestEvents
+ i
);
164 if (X
.xfocus
.detail
!= NotifyInferior
) {
165 pScreen
= xnestScreen(X
.xfocus
.window
);
167 xnestDirectInstallColormaps(pScreen
);
172 if (X
.xfocus
.detail
!= NotifyInferior
) {
173 pScreen
= xnestScreen(X
.xfocus
.window
);
175 xnestDirectUninstallColormaps(pScreen
);
183 if (X
.xcrossing
.detail
!= NotifyInferior
) {
184 pScreen
= xnestScreen(X
.xcrossing
.window
);
186 NewCurrentScreen(pScreen
, X
.xcrossing
.x
, X
.xcrossing
.y
);
187 valuators
[0] = X
.xcrossing
.x
;
188 valuators
[1] = X
.xcrossing
.y
;
189 lastEventTime
= GetTimeInMillis();
190 n
= GetPointerEvents(xnestEvents
, xnestPointerDevice
, MotionNotify
,
191 0, POINTER_ABSOLUTE
, 0, 2, valuators
);
192 for (i
= 0; i
< n
; i
++)
193 mieqEnqueue(xnestPointerDevice
, xnestEvents
+ i
);
194 xnestDirectInstallColormaps(pScreen
);
200 if (X
.xcrossing
.detail
!= NotifyInferior
) {
201 pScreen
= xnestScreen(X
.xcrossing
.window
);
203 xnestDirectUninstallColormaps(pScreen
);
209 if (xnestParentWindow
!= (Window
) 0 &&
210 X
.xdestroywindow
.window
== xnestParentWindow
)
214 case CirculateNotify
:
215 case ConfigureNotify
:
223 ErrorF("xnest warning: unhandled event\n");