aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Events.h
blob: 3e04222a2d39afd6923d768cae10237d11dab4c5 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/**************************************************************************/
/*                                                                        */
/* Copyright (c) 2001, 2009 NoMachine, http://www.nomachine.com/.         */
/*                                                                        */
/* NXAGENT, NX protocol compression and NX extensions to this software    */
/* are copyright of NoMachine. Redistribution and use of the present      */
/* software is allowed according to terms specified in the file LICENSE   */
/* which comes in the source distribution.                                */
/*                                                                        */
/* Check http://www.nomachine.com/licensing.html for applicability.       */
/*                                                                        */
/* NX and NoMachine are trademarks of Medialogic S.p.A.                   */
/*                                                                        */
/* All rights reserved.                                                   */
/*                                                                        */
/**************************************************************************/

#ifndef __Events_H__
#define __Events_H__

#include <X11/Xmd.h>

#define ProcessedExpose (LASTEvent + 1)
#define ProcessedNotify (LASTEvent + 2)

#define EXPOSED_SIZE 256

enum HandleEventResult
{
  doNothing = 0,
  doMinimize,
  doCloseSession,
  doStartKbd,
  doSwitchFullscreen,
  doViewportLeft,
  doViewportUp,
  doViewportRight,
  doViewportDown,
  doSwitchResizeMode,
  doSwitchDeferMode
};

extern CARD32 nxagentLastEventTime;

/*
 * Manage incoming events.
 */

typedef Bool (*PredicateFuncPtr)(Display*, XEvent*, XPointer);

extern void nxagentDispatchEvents(PredicateFuncPtr);

typedef int (*GetResourceFuncPtr)(Display*);

int nxagentWaitForResource(GetResourceFuncPtr, PredicateFuncPtr);

Bool nxagentCollectGrabPointerPredicate(Display *display, XEvent *X, XPointer ptr);

int nxagentInputEventPredicate(Display *display, XEvent *event, XPointer parameter);

/*
 * Enable and disable notification of
 * remote X server events.
 */

extern void nxagentEnableKeyboardEvents(void);
extern void nxagentEnablePointerEvents(void);

extern void nxagentDisableKeyboardEvents(void);
extern void nxagentDisablePointerEvents(void);

/*
 * Manage default event mask.
 */

extern void nxagentInitDefaultEventMask(void);
extern void nxagentGetDefaultEventMask(Mask *mask_return);
extern void nxagentSetDefaultEventMask(Mask mask);
extern void nxagentGetEventMask(WindowPtr pWin, Mask *mask_return);

/*
 * Bring keyboard device in known state. It needs
 * a round-trip so it only gets called if a pre-
 * vious XKB event did not implicitly initialized
 * the internal state. This is unlikely to happen.
 */

extern int nxagentInitKeyboardState(void);

/*
 * Update the keyboard state according
 * to focus and XKB events received
 * from the remote X server.
 */

extern int nxagentHandleKeyboardEvent(XEvent *X);

/*
 * Handle sync and karma messages and
 * other notification event coming
 * from proxy.
 */

extern int nxagentHandleProxyEvent(XEvent *X);

/*
 * Other functions providing the ad-hoc
 * handling of the remote X events.
 */

extern int nxagentHandleExposeEvent(XEvent *X);
extern int nxagentHandleGraphicsExposeEvent(XEvent *X);
extern int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult*);
extern int nxagentHandlePropertyNotify(XEvent *X);
extern int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult*);
extern int nxagentHandleReparentNotify(XEvent *X);
extern int nxagentHandleConfigureNotify(XEvent *X);
extern int nxagentHandleXFixesSelectionNotify(XEvent *X);

/*
 * Send a fake keystroke to the remote
 * X server.
 */

extern void nxagentSendFakeKey(int key);

/*
 * Called to manage grab of pointer and
 * keyboard when running in fullscreen
 * mode.
 */

extern void nxagentGrabPointerAndKeyboard(XEvent *X);
extern void nxagentUngrabPointerAndKeyboard(XEvent *X);

extern void nxagentDeactivatePointerGrab(void);

/*
 * Handle the selection property received
 * in the event loop.
 */

void nxagentCollectPropertyEvent(int resource);

/*
 * Synchronize expose events between agent and
 * the real X server.
 */

typedef struct _ExposuresRec
{
  WindowPtr pWindow;
  RegionPtr localRegion;
  RegionPtr remoteRegion;
  Bool remoteRegionIsCompleted;
  int serial;
  int synchronize;

} ExposuresRec;

extern RegionPtr nxagentRemoteExposeRegion;

typedef struct _ExposeQueue
{
  unsigned int start;
  int length;
  ExposuresRec exposures[EXPOSED_SIZE];
} ExposeQueue;

extern void nxagentSynchronizeExpose(void);
extern int nxagentLookupByWindow(WindowPtr pWin);
extern void nxagentUpdateExposeArray(void);

extern ExposeQueue nxagentExposeQueue;

/*
 * Handle the split related notifications.
 */

int nxagentWaitSplitEvent(int resource);

void nxagentHandleNoSplitEvent(int resource);
void nxagentHandleStartSplitEvent(int resource);
void nxagentHandleCommitSplitEvent(int resource, int request, int position);
void nxagentHandleEndSplitEvent(int resource);
void nxagentHandleEmptySplitEvent(void);

void nxagentInitRemoteExposeRegion(void);
void nxagentAddRectToRemoteExposeRegion(BoxPtr);

extern int nxagentUserInput(void *p);

/*
* We have to check these before launching the terminate
 * dialog in rootless mode.
 */

extern Bool nxagentLastWindowDestroyed;
extern Time nxagentLastWindowDestroyedTime;

/*
 * Set this flag if an user input event is received.
 */

extern int nxagentInputEvent;

/*
 * Event-handling utilities.
 */

Bool nxagentPendingEvents(Display *dpy);

#define nxagentQueuedEvents(display) \
    XQLength((display))

#define nxagentReadEvents(display) \
    XEventsQueued((display), QueuedAfterReading)

#define nxagentCheckEvents(display, event, predicate, argument) \
    XCheckIfEventNoFlush((display), (event), (predicate), (argument)) 

int nxagentWaitEvents(Display *, struct timeval *);

#endif /* __Events_H__ */