FreeRDP
xfreerdp.h
1 
22 #ifndef FREERDP_CLIENT_X11_FREERDP_H
23 #define FREERDP_CLIENT_X11_FREERDP_H
24 
25 #include <freerdp/config.h>
26 
27 typedef struct xf_context xfContext;
28 
29 #ifdef WITH_XCURSOR
30 #include <X11/Xcursor/Xcursor.h>
31 #endif
32 
33 #ifdef WITH_XI
34 #include <X11/extensions/XInput2.h>
35 #endif
36 
37 #include <freerdp/api.h>
38 
39 #include "xf_window.h"
40 #include "xf_monitor.h"
41 #include "xf_channels.h"
42 
43 #if defined(CHANNEL_TSMF_CLIENT)
44 #include <freerdp/client/tsmf.h>
45 #endif
46 
47 #include <freerdp/gdi/gdi.h>
48 #include <freerdp/codec/rfx.h>
49 #include <freerdp/codec/nsc.h>
50 #include <freerdp/codec/clear.h>
51 #include <freerdp/codec/color.h>
52 #include <freerdp/codec/bitmap.h>
53 #include <freerdp/codec/h264.h>
54 #include <freerdp/codec/progressive.h>
55 #include <freerdp/codec/region.h>
56 
57 #if !defined(XcursorUInt)
58 typedef unsigned int XcursorUInt;
59 #endif
60 
61 #if !defined(XcursorPixel)
62 typedef XcursorUInt XcursorPixel;
63 #endif
64 
66 {
67  UINT32 top;
68  UINT32 bottom;
69  UINT32 left;
70  UINT32 right;
71 };
72 typedef struct xf_FullscreenMonitors xfFullscreenMonitors;
73 
75 {
76  UINT32 x;
77  UINT32 y;
78  UINT32 width;
79  UINT32 height;
80 };
81 typedef struct xf_WorkArea xfWorkArea;
82 
83 struct xf_pointer
84 {
85  rdpPointer pointer;
86  XcursorPixel* cursorPixels;
87  UINT32 nCursors;
88  UINT32 mCursors;
89  UINT32* cursorWidths;
90  UINT32* cursorHeights;
91  Cursor* cursors;
92  Cursor cursor;
93 };
94 typedef struct xf_pointer xfPointer;
95 
96 struct xf_bitmap
97 {
98  rdpBitmap bitmap;
99  Pixmap pixmap;
100  XImage* image;
101 };
102 typedef struct xf_bitmap xfBitmap;
103 
104 struct xf_glyph
105 {
106  rdpGlyph glyph;
107  Pixmap pixmap;
108 };
109 typedef struct xf_glyph xfGlyph;
110 
111 typedef struct xf_clipboard xfClipboard;
112 typedef struct s_xfDispContext xfDispContext;
113 typedef struct s_xfVideoContext xfVideoContext;
114 typedef struct xf_rail_icon_cache xfRailIconCache;
115 
116 /* Number of buttons that are mapped from X11 to RDP button events. */
117 #define NUM_BUTTONS_MAPPED 11
118 
119 typedef struct
120 {
121  UINT32 button;
122  UINT16 flags;
123 } button_map;
124 
125 #if defined(WITH_XI)
126 #define MAX_CONTACTS 20
127 
128 typedef struct touch_contact
129 {
130  int id;
131  int count;
132  double pos_x;
133  double pos_y;
134  double last_x;
135  double last_y;
136 
137 } touchContact;
138 
139 #endif
140 
142 {
143  rdpClientContext common;
144 
145  GC gc;
146  int xfds;
147  int depth;
148 
149  GC gc_mono;
150  BOOL invert;
151  Screen* screen;
152  XImage* image;
153  Pixmap primary;
154  Pixmap drawing;
155  Visual* visual;
156  Display* display;
157  Drawable drawable;
158  Pixmap bitmap_mono;
159  Colormap colormap;
160  int screen_number;
161  int scanline_pad;
162  BOOL big_endian;
163  BOOL fullscreen;
164  BOOL decorations;
165  BOOL grab_keyboard;
166  BOOL unobscured;
167  BOOL debug;
168  HANDLE x11event;
169  xfWindow* window;
170  xfAppWindow* appWindow;
171  xfPointer* pointer;
172  xfWorkArea workArea;
173  xfFullscreenMonitors fullscreenMonitors;
174  int current_desktop;
175  BOOL remote_app;
176  HANDLE mutex;
177  BOOL UseXThreads;
178  BOOL cursorHidden;
179 
180  UINT32 bitmap_size;
181  BYTE* bitmap_buffer;
182 
183  BOOL frame_begin;
184 
185  int XInputOpcode;
186 
187  int savedWidth;
188  int savedHeight;
189  int savedPosX;
190  int savedPosY;
191 
192 #ifdef WITH_XRENDER
193  int scaledWidth;
194  int scaledHeight;
195  int offset_x;
196  int offset_y;
197 #endif
198 
199  BOOL focused;
200  BOOL mouse_active;
201  BOOL fullscreen_toggle;
202  UINT32 KeyboardLayout;
203  BOOL KeyboardState[256];
204  XModifierKeymap* modifierMap;
205  wArrayList* keyCombinations;
206  wArrayList* xevents;
207  BOOL actionScriptExists;
208 
209  int attribs_mask;
210  XSetWindowAttributes attribs;
211  BOOL complex_regions;
212  VIRTUAL_SCREEN vscreen;
213 #if defined(CHANNEL_TSMF_CLIENT)
214  void* xv_context;
215 #endif
216 
217  Atom* supportedAtoms;
218  unsigned long supportedAtomCount;
219 
220  Atom UTF8_STRING;
221 
222  Atom _XWAYLAND_MAY_GRAB_KEYBOARD;
223 
224  Atom _NET_WM_ICON;
225  Atom _MOTIF_WM_HINTS;
226  Atom _NET_NUMBER_OF_DESKTOPS;
227  Atom _NET_CURRENT_DESKTOP;
228  Atom _NET_WORKAREA;
229 
230  Atom _NET_SUPPORTED;
231  Atom _NET_SUPPORTING_WM_CHECK;
232 
233  Atom _NET_WM_STATE;
234  Atom _NET_WM_STATE_MODAL;
235  Atom _NET_WM_STATE_STICKY;
236  Atom _NET_WM_STATE_MAXIMIZED_VERT;
237  Atom _NET_WM_STATE_MAXIMIZED_HORZ;
238  Atom _NET_WM_STATE_SHADED;
239  Atom _NET_WM_STATE_SKIP_TASKBAR;
240  Atom _NET_WM_STATE_SKIP_PAGER;
241  Atom _NET_WM_STATE_HIDDEN;
242  Atom _NET_WM_STATE_FULLSCREEN;
243  Atom _NET_WM_STATE_ABOVE;
244  Atom _NET_WM_STATE_BELOW;
245  Atom _NET_WM_STATE_DEMANDS_ATTENTION;
246 
247  Atom _NET_WM_FULLSCREEN_MONITORS;
248 
249  Atom _NET_WM_NAME;
250  Atom _NET_WM_PID;
251 
252  Atom _NET_WM_WINDOW_TYPE;
253  Atom _NET_WM_WINDOW_TYPE_NORMAL;
254  Atom _NET_WM_WINDOW_TYPE_DIALOG;
255  Atom _NET_WM_WINDOW_TYPE_UTILITY;
256  Atom _NET_WM_WINDOW_TYPE_POPUP;
257  Atom _NET_WM_WINDOW_TYPE_POPUP_MENU;
258  Atom _NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
259 
260  Atom _NET_WM_MOVERESIZE;
261  Atom _NET_MOVERESIZE_WINDOW;
262 
263  Atom WM_STATE;
264  Atom WM_PROTOCOLS;
265  Atom WM_DELETE_WINDOW;
266 
267  /* Allow actions */
268  Atom NET_WM_ALLOWED_ACTIONS;
269 
270  Atom NET_WM_ACTION_CLOSE;
271  Atom NET_WM_ACTION_MINIMIZE;
272  Atom NET_WM_ACTION_MOVE;
273  Atom NET_WM_ACTION_RESIZE;
274  Atom NET_WM_ACTION_MAXIMIZE_HORZ;
275  Atom NET_WM_ACTION_MAXIMIZE_VERT;
276  Atom NET_WM_ACTION_FULLSCREEN;
277  Atom NET_WM_ACTION_CHANGE_DESKTOP;
278 
279  /* Channels */
280 #if defined(CHANNEL_TSMF_CLIENT)
281  TsmfClientContext* tsmf;
282 #endif
283 
284  xfClipboard* clipboard;
285  CliprdrClientContext* cliprdr;
286  xfVideoContext* xfVideo;
287  xfDispContext* xfDisp;
288 
289  RailClientContext* rail;
290  wHashTable* railWindows;
291  xfRailIconCache* railIconCache;
292 
293  BOOL xkbAvailable;
294  BOOL xrenderAvailable;
295 
296  /* value to be sent over wire for each logical client mouse button */
297  button_map button_map[NUM_BUTTONS_MAPPED];
298  BYTE savedMaximizedState;
299  UINT32 locked;
300  BOOL wasRightCtrlAlreadyPressed;
301  BOOL ungrabKeyboardWithRightCtrl;
302 
303 #if defined(WITH_XI)
304  touchContact contacts[MAX_CONTACTS];
305  int active_contacts;
306  int lastEvType;
307  XIDeviceEvent lastEvent;
308  double firstDist;
309  double lastDist;
310  double z_vector;
311  double px_vector;
312  double py_vector;
313 #endif
314  BOOL xi_rawevent;
315  BOOL xi_event;
316  HANDLE pipethread;
317  wLog* log;
318 };
319 
320 BOOL xf_create_window(xfContext* xfc);
321 BOOL xf_create_image(xfContext* xfc);
322 void xf_toggle_fullscreen(xfContext* xfc);
323 void xf_minimize(xfContext* xfc);
324 
325 enum XF_EXIT_CODE
326 {
327  /* section 0-15: protocol-independent codes */
328  XF_EXIT_SUCCESS = 0,
329  XF_EXIT_DISCONNECT = 1,
330  XF_EXIT_LOGOFF = 2,
331  XF_EXIT_IDLE_TIMEOUT = 3,
332  XF_EXIT_LOGON_TIMEOUT = 4,
333  XF_EXIT_CONN_REPLACED = 5,
334  XF_EXIT_OUT_OF_MEMORY = 6,
335  XF_EXIT_CONN_DENIED = 7,
336  XF_EXIT_CONN_DENIED_FIPS = 8,
337  XF_EXIT_USER_PRIVILEGES = 9,
338  XF_EXIT_FRESH_CREDENTIALS_REQUIRED = 10,
339  XF_EXIT_DISCONNECT_BY_USER = 11,
340 
341  /* section 16-31: license error set */
342  XF_EXIT_LICENSE_INTERNAL = 16,
343  XF_EXIT_LICENSE_NO_LICENSE_SERVER = 17,
344  XF_EXIT_LICENSE_NO_LICENSE = 18,
345  XF_EXIT_LICENSE_BAD_CLIENT_MSG = 19,
346  XF_EXIT_LICENSE_HWID_DOESNT_MATCH = 20,
347  XF_EXIT_LICENSE_BAD_CLIENT = 21,
348  XF_EXIT_LICENSE_CANT_FINISH_PROTOCOL = 22,
349  XF_EXIT_LICENSE_CLIENT_ENDED_PROTOCOL = 23,
350  XF_EXIT_LICENSE_BAD_CLIENT_ENCRYPTION = 24,
351  XF_EXIT_LICENSE_CANT_UPGRADE = 25,
352  XF_EXIT_LICENSE_NO_REMOTE_CONNECTIONS = 26,
353 
354  /* section 32-127: RDP protocol error set */
355  XF_EXIT_RDP = 32,
356 
357  /* section 128-254: xfreerdp specific exit codes */
358  XF_EXIT_PARSE_ARGUMENTS = 128,
359  XF_EXIT_MEMORY = 129,
360  XF_EXIT_PROTOCOL = 130,
361  XF_EXIT_CONN_FAILED = 131,
362  XF_EXIT_AUTH_FAILURE = 132,
363  XF_EXIT_NEGO_FAILURE = 133,
364  XF_EXIT_LOGON_FAILURE = 134,
365  XF_EXIT_ACCOUNT_LOCKED_OUT = 135,
366  XF_EXIT_PRE_CONNECT_FAILED = 136,
367  XF_EXIT_CONNECT_UNDEFINED = 137,
368  XF_EXIT_POST_CONNECT_FAILED = 138,
369  XF_EXIT_DNS_ERROR = 139,
370  XF_EXIT_DNS_NAME_NOT_FOUND = 140,
371  XF_EXIT_CONNECT_FAILED = 141,
372  XF_EXIT_MCS_CONNECT_INITIAL_ERROR = 142,
373  XF_EXIT_TLS_CONNECT_FAILED = 143,
374  XF_EXIT_INSUFFICIENT_PRIVILEGES = 144,
375  XF_EXIT_CONNECT_CANCELLED = 145,
376 
377  XF_EXIT_CONNECT_TRANSPORT_FAILED = 147,
378  XF_EXIT_CONNECT_PASSWORD_EXPIRED = 148,
379  XF_EXIT_CONNECT_PASSWORD_MUST_CHANGE = 149,
380  XF_EXIT_CONNECT_KDC_UNREACHABLE = 150,
381  XF_EXIT_CONNECT_ACCOUNT_DISABLED = 151,
382  XF_EXIT_CONNECT_PASSWORD_CERTAINLY_EXPIRED = 152,
383  XF_EXIT_CONNECT_CLIENT_REVOKED = 153,
384  XF_EXIT_CONNECT_WRONG_PASSWORD = 154,
385  XF_EXIT_CONNECT_ACCESS_DENIED = 155,
386  XF_EXIT_CONNECT_ACCOUNT_RESTRICTION = 156,
387  XF_EXIT_CONNECT_ACCOUNT_EXPIRED = 157,
388  XF_EXIT_CONNECT_LOGON_TYPE_NOT_GRANTED = 158,
389  XF_EXIT_CONNECT_NO_OR_MISSING_CREDENTIALS = 159,
390 
391  XF_EXIT_UNKNOWN = 255,
392 };
393 
394 #define xf_lock_x11(xfc) xf_lock_x11_(xfc, __func__)
395 #define xf_unlock_x11(xfc) xf_unlock_x11_(xfc, __func__)
396 
397 void xf_lock_x11_(xfContext* xfc, const char* fkt);
398 void xf_unlock_x11_(xfContext* xfc, const char* fkt);
399 
400 BOOL xf_picture_transform_required(xfContext* xfc);
401 
402 #define xf_draw_screen(_xfc, _x, _y, _w, _h) \
403  xf_draw_screen_((_xfc), (_x), (_y), (_w), (_h), __func__, __FILE__, __LINE__)
404 void xf_draw_screen_(xfContext* xfc, int x, int y, int w, int h, const char* fkt, const char* file,
405  int line);
406 
407 BOOL xf_keyboard_update_modifier_map(xfContext* xfc);
408 
409 int xf_exit_code_from_disconnect_reason(DWORD reason);
410 
411 #endif /* FREERDP_CLIENT_X11_FREERDP_H */