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>
20
#include <X11/Xproto.h>
21
#include "screenint.h"
24
#include "scrnintstr.h"
25
#include "windowstr.h"
28
#include "inpututils.h"
42
#include "mipointer.h"
44
CARD32 lastEventTime = 0;
47
ProcessInputEvents(void)
49
mieqProcessInputEvents();
53
TimeSinceLastInputEvent(void)
55
if (lastEventTime == 0)
56
lastEventTime = GetTimeInMillis();
57
return GetTimeInMillis() - lastEventTime;
61
SetTimeSinceLastInputEvent(void)
63
lastEventTime = GetTimeInMillis();
67
xnestExposurePredicate(Display * dpy, XEvent * event, char *args)
69
return event->type == Expose || event->type == ProcessedExpose;
73
xnestNotExposurePredicate(Display * dpy, XEvent * event, char *args)
75
return !xnestExposurePredicate(dpy, event, args);
79
xnestCollectExposures(void)
86
while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) {
87
pWin = xnestWindowPtr(X.xexpose.window);
89
if (pWin && X.xexpose.width && X.xexpose.height) {
90
Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x;
91
Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y;
92
Box.x2 = Box.x1 + X.xexpose.width;
93
Box.y2 = Box.y1 + X.xexpose.height;
95
RegionInit(&Rgn, &Box, 1);
97
miSendExposures(pWin, &Rgn, Box.x2, Box.y2);
103
xnestQueueKeyEvent(int type, unsigned int keycode)
105
lastEventTime = GetTimeInMillis();
106
QueueKeyboardEvents(xnestKeyboardDevice, type, keycode, NULL);
110
xnestCollectEvents(void)
117
while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
120
xnestUpdateModifierState(X.xkey.state);
121
xnestQueueKeyEvent(KeyPress, X.xkey.keycode);
125
xnestUpdateModifierState(X.xkey.state);
126
xnestQueueKeyEvent(KeyRelease, X.xkey.keycode);
130
valuator_mask_set_range(&mask, 0, 0, NULL);
131
xnestUpdateModifierState(X.xkey.state);
132
lastEventTime = GetTimeInMillis();
133
QueuePointerEvents(xnestPointerDevice, ButtonPress,
134
X.xbutton.button, POINTER_RELATIVE, &mask);
138
valuator_mask_set_range(&mask, 0, 0, NULL);
139
xnestUpdateModifierState(X.xkey.state);
140
lastEventTime = GetTimeInMillis();
141
QueuePointerEvents(xnestPointerDevice, ButtonRelease,
142
X.xbutton.button, POINTER_RELATIVE, &mask);
146
valuators[0] = X.xmotion.x;
147
valuators[1] = X.xmotion.y;
148
valuator_mask_set_range(&mask, 0, 2, valuators);
149
lastEventTime = GetTimeInMillis();
150
QueuePointerEvents(xnestPointerDevice, MotionNotify,
151
0, POINTER_ABSOLUTE, &mask);
155
if (X.xfocus.detail != NotifyInferior) {
156
pScreen = xnestScreen(X.xfocus.window);
158
xnestDirectInstallColormaps(pScreen);
163
if (X.xfocus.detail != NotifyInferior) {
164
pScreen = xnestScreen(X.xfocus.window);
166
xnestDirectUninstallColormaps(pScreen);
174
if (X.xcrossing.detail != NotifyInferior) {
175
pScreen = xnestScreen(X.xcrossing.window);
177
NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x,
179
valuators[0] = X.xcrossing.x;
180
valuators[1] = X.xcrossing.y;
181
valuator_mask_set_range(&mask, 0, 2, valuators);
182
lastEventTime = GetTimeInMillis();
183
QueuePointerEvents(xnestPointerDevice, MotionNotify,
184
0, POINTER_ABSOLUTE, &mask);
185
xnestDirectInstallColormaps(pScreen);
191
if (X.xcrossing.detail != NotifyInferior) {
192
pScreen = xnestScreen(X.xcrossing.window);
194
xnestDirectUninstallColormaps(pScreen);
200
if (xnestParentWindow != (Window) 0 &&
201
X.xdestroywindow.window == xnestParentWindow)
205
case CirculateNotify:
206
case ConfigureNotify:
214
ErrorF("xnest warning: unhandled event\n");