1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
User interface services - X Window System |
User interface services - X Window System |
4 |
Copyright (C) Matthew Chapman 1999-2005 |
Copyright (C) Matthew Chapman 1999-2007 |
5 |
|
Copyright 2007 Pierre Ossman <ossman@cendio.se> for Cendio AB |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
8 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
21 |
|
|
22 |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
23 |
#include <X11/Xutil.h> |
#include <X11/Xutil.h> |
24 |
|
#include <X11/Xproto.h> |
25 |
#include <unistd.h> |
#include <unistd.h> |
26 |
#include <sys/time.h> |
#include <sys/time.h> |
27 |
#include <time.h> |
#include <time.h> |
35 |
extern int g_xpos; |
extern int g_xpos; |
36 |
extern int g_ypos; |
extern int g_ypos; |
37 |
extern int g_pos; |
extern int g_pos; |
38 |
extern BOOL g_sendmotion; |
extern RD_BOOL g_sendmotion; |
39 |
extern BOOL g_fullscreen; |
extern RD_BOOL g_fullscreen; |
40 |
extern BOOL g_grab_keyboard; |
extern RD_BOOL g_grab_keyboard; |
41 |
extern BOOL g_hide_decorations; |
extern RD_BOOL g_hide_decorations; |
42 |
extern char g_title[]; |
extern char g_title[]; |
43 |
/* Color depth of the RDP session. |
/* Color depth of the RDP session. |
44 |
As of RDP 5.1, it may be 8, 15, 16 or 24. */ |
As of RDP 5.1, it may be 8, 15, 16 or 24. */ |
50 |
static int g_x_socket; |
static int g_x_socket; |
51 |
static Screen *g_screen; |
static Screen *g_screen; |
52 |
Window g_wnd; |
Window g_wnd; |
53 |
|
|
54 |
|
/* SeamlessRDP support */ |
55 |
|
typedef struct _seamless_group |
56 |
|
{ |
57 |
|
Window wnd; |
58 |
|
unsigned long id; |
59 |
|
unsigned int refcnt; |
60 |
|
} seamless_group; |
61 |
|
typedef struct _seamless_window |
62 |
|
{ |
63 |
|
Window wnd; |
64 |
|
unsigned long id; |
65 |
|
unsigned long behind; |
66 |
|
seamless_group *group; |
67 |
|
int xoffset, yoffset; |
68 |
|
int width, height; |
69 |
|
int state; /* normal/minimized/maximized. */ |
70 |
|
unsigned int desktop; |
71 |
|
struct timeval *position_timer; |
72 |
|
|
73 |
|
RD_BOOL outstanding_position; |
74 |
|
unsigned int outpos_serial; |
75 |
|
int outpos_xoffset, outpos_yoffset; |
76 |
|
int outpos_width, outpos_height; |
77 |
|
|
78 |
|
unsigned int icon_size; |
79 |
|
unsigned int icon_offset; |
80 |
|
char icon_buffer[32 * 32 * 4]; |
81 |
|
|
82 |
|
struct _seamless_window *next; |
83 |
|
} seamless_window; |
84 |
|
static seamless_window *g_seamless_windows = NULL; |
85 |
|
static unsigned long g_seamless_focused = 0; |
86 |
|
static RD_BOOL g_seamless_started = False; /* Server end is up and running */ |
87 |
|
static RD_BOOL g_seamless_active = False; /* We are currently in seamless mode */ |
88 |
|
static RD_BOOL g_seamless_hidden = False; /* Desktop is hidden on server */ |
89 |
|
static RD_BOOL g_seamless_broken_restack = False; /* WM does not properly restack */ |
90 |
|
extern RD_BOOL g_seamless_rdp; |
91 |
|
|
92 |
extern uint32 g_embed_wnd; |
extern uint32 g_embed_wnd; |
93 |
BOOL g_enable_compose = False; |
RD_BOOL g_enable_compose = False; |
94 |
BOOL g_Unobscured; /* used for screenblt */ |
RD_BOOL g_Unobscured; /* used for screenblt */ |
95 |
static GC g_gc = NULL; |
static GC g_gc = NULL; |
96 |
static GC g_create_bitmap_gc = NULL; |
static GC g_create_bitmap_gc = NULL; |
97 |
static GC g_create_glyph_gc = NULL; |
static GC g_create_glyph_gc = NULL; |
98 |
|
static XRectangle g_clip_rectangle; |
99 |
static Visual *g_visual; |
static Visual *g_visual; |
100 |
/* Color depth of the X11 visual of our window (e.g. 24 for True Color R8G8B visual). |
/* Color depth of the X11 visual of our window (e.g. 24 for True Color R8G8B visual). |
101 |
This may be 32 for R8G8B8 visuals, and then the rest of the bits are undefined |
This may be 32 for R8G8B8 visuals, and then the rest of the bits are undefined |
108 |
static XIM g_IM; |
static XIM g_IM; |
109 |
static XIC g_IC; |
static XIC g_IC; |
110 |
static XModifierKeymap *g_mod_map; |
static XModifierKeymap *g_mod_map; |
111 |
|
/* Maps logical (xmodmap -pp) pointing device buttons (0-based) back |
112 |
|
to physical (1-based) indices. */ |
113 |
|
static unsigned char g_pointer_log_to_phys_map[16]; |
114 |
static Cursor g_current_cursor; |
static Cursor g_current_cursor; |
115 |
static HCURSOR g_null_cursor = NULL; |
static RD_HCURSOR g_null_cursor = NULL; |
116 |
static Atom g_protocol_atom, g_kill_atom; |
static Atom g_protocol_atom, g_kill_atom; |
117 |
static BOOL g_focused; |
extern Atom g_net_wm_state_atom; |
118 |
static BOOL g_mouse_in_wnd; |
extern Atom g_net_wm_desktop_atom; |
119 |
/* Indicates the visual is has 15, 16 or 24 depth |
static RD_BOOL g_focused; |
120 |
and the same color channel masks as its RDP equivalent. */ |
static RD_BOOL g_mouse_in_wnd; |
121 |
static BOOL g_compatible_depth; |
/* Indicates that: |
122 |
|
1) visual has 15, 16 or 24 depth and the same color channel masks |
123 |
|
as its RDP equivalent (implies X server is LE), |
124 |
|
2) host is LE |
125 |
|
This will trigger an optimization whose real value is questionable. |
126 |
|
*/ |
127 |
|
static RD_BOOL g_compatible_arch; |
128 |
/* Indicates whether RDP's bitmaps and our XImages have the same |
/* Indicates whether RDP's bitmaps and our XImages have the same |
129 |
binary format. If so, we can avoid an expensive translation. |
binary format. If so, we can avoid an expensive translation. |
130 |
If this is True, so is g_compatible_depth. */ |
Note that this can be true when g_compatible_arch is false, |
131 |
static BOOL g_no_translate_image = False; |
e.g.: |
132 |
|
|
133 |
|
RDP(LE) <-> host(BE) <-> X-Server(LE) |
134 |
|
|
135 |
|
('host' is the machine running rdesktop; the host simply memcpy's |
136 |
|
so its endianess doesn't matter) |
137 |
|
*/ |
138 |
|
static RD_BOOL g_no_translate_image = False; |
139 |
|
|
140 |
/* endianness */ |
/* endianness */ |
141 |
static BOOL g_host_be; |
static RD_BOOL g_host_be; |
142 |
static BOOL g_xserver_be; |
static RD_BOOL g_xserver_be; |
143 |
static int g_red_shift_r, g_blue_shift_r, g_green_shift_r; |
static int g_red_shift_r, g_blue_shift_r, g_green_shift_r; |
144 |
static int g_red_shift_l, g_blue_shift_l, g_green_shift_l; |
static int g_red_shift_l, g_blue_shift_l, g_green_shift_l; |
145 |
|
|
146 |
/* software backing store */ |
/* software backing store */ |
147 |
extern BOOL g_ownbackstore; |
extern RD_BOOL g_ownbackstore; |
148 |
static Pixmap g_backstore = 0; |
static Pixmap g_backstore = 0; |
149 |
|
|
150 |
/* Moving in single app mode */ |
/* Moving in single app mode */ |
151 |
static BOOL g_moving_wnd; |
static RD_BOOL g_moving_wnd; |
152 |
static int g_move_x_offset = 0; |
static int g_move_x_offset = 0; |
153 |
static int g_move_y_offset = 0; |
static int g_move_y_offset = 0; |
154 |
static BOOL g_using_full_workarea = False; |
static RD_BOOL g_using_full_workarea = False; |
155 |
|
|
156 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
157 |
extern int g_dsp_fd; |
extern RD_BOOL g_rdpsnd; |
|
extern BOOL g_dsp_busy; |
|
|
extern BOOL g_rdpsnd; |
|
158 |
#endif |
#endif |
159 |
|
|
160 |
/* MWM decorations */ |
/* MWM decorations */ |
178 |
} |
} |
179 |
PixelColour; |
PixelColour; |
180 |
|
|
181 |
|
#define ON_ALL_SEAMLESS_WINDOWS(func, args) \ |
182 |
|
do { \ |
183 |
|
seamless_window *sw; \ |
184 |
|
XRectangle rect; \ |
185 |
|
if (!g_seamless_windows) break; \ |
186 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) { \ |
187 |
|
rect.x = g_clip_rectangle.x - sw->xoffset; \ |
188 |
|
rect.y = g_clip_rectangle.y - sw->yoffset; \ |
189 |
|
rect.width = g_clip_rectangle.width; \ |
190 |
|
rect.height = g_clip_rectangle.height; \ |
191 |
|
XSetClipRectangles(g_display, g_gc, 0, 0, &rect, 1, YXBanded); \ |
192 |
|
func args; \ |
193 |
|
} \ |
194 |
|
XSetClipRectangles(g_display, g_gc, 0, 0, &g_clip_rectangle, 1, YXBanded); \ |
195 |
|
} while (0) |
196 |
|
|
197 |
|
static void |
198 |
|
seamless_XFillPolygon(Drawable d, XPoint * points, int npoints, int xoffset, int yoffset) |
199 |
|
{ |
200 |
|
points[0].x -= xoffset; |
201 |
|
points[0].y -= yoffset; |
202 |
|
XFillPolygon(g_display, d, g_gc, points, npoints, Complex, CoordModePrevious); |
203 |
|
points[0].x += xoffset; |
204 |
|
points[0].y += yoffset; |
205 |
|
} |
206 |
|
|
207 |
|
static void |
208 |
|
seamless_XDrawLines(Drawable d, XPoint * points, int npoints, int xoffset, int yoffset) |
209 |
|
{ |
210 |
|
points[0].x -= xoffset; |
211 |
|
points[0].y -= yoffset; |
212 |
|
XDrawLines(g_display, d, g_gc, points, npoints, CoordModePrevious); |
213 |
|
points[0].x += xoffset; |
214 |
|
points[0].y += yoffset; |
215 |
|
} |
216 |
|
|
217 |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
218 |
{ \ |
{ \ |
219 |
XFillRectangle(g_display, g_wnd, g_gc, x, y, cx, cy); \ |
XFillRectangle(g_display, g_wnd, g_gc, x, y, cx, cy); \ |
220 |
|
ON_ALL_SEAMLESS_WINDOWS(XFillRectangle, (g_display, sw->wnd, g_gc, x-sw->xoffset, y-sw->yoffset, cx, cy)); \ |
221 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
222 |
XFillRectangle(g_display, g_backstore, g_gc, x, y, cx, cy); \ |
XFillRectangle(g_display, g_backstore, g_gc, x, y, cx, cy); \ |
223 |
} |
} |
232 |
XFillPolygon(g_display, g_wnd, g_gc, p, np, Complex, CoordModePrevious); \ |
XFillPolygon(g_display, g_wnd, g_gc, p, np, Complex, CoordModePrevious); \ |
233 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
234 |
XFillPolygon(g_display, g_backstore, g_gc, p, np, Complex, CoordModePrevious); \ |
XFillPolygon(g_display, g_backstore, g_gc, p, np, Complex, CoordModePrevious); \ |
235 |
|
ON_ALL_SEAMLESS_WINDOWS(seamless_XFillPolygon, (sw->wnd, p, np, sw->xoffset, sw->yoffset)); \ |
236 |
} |
} |
237 |
|
|
238 |
#define DRAW_ELLIPSE(x,y,cx,cy,m)\ |
#define DRAW_ELLIPSE(x,y,cx,cy,m)\ |
241 |
{ \ |
{ \ |
242 |
case 0: /* Outline */ \ |
case 0: /* Outline */ \ |
243 |
XDrawArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \ |
XDrawArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \ |
244 |
|
ON_ALL_SEAMLESS_WINDOWS(XDrawArc, (g_display, sw->wnd, g_gc, x-sw->xoffset, y-sw->yoffset, cx, cy, 0, 360*64)); \ |
245 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
246 |
XDrawArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
XDrawArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
247 |
break; \ |
break; \ |
248 |
case 1: /* Filled */ \ |
case 1: /* Filled */ \ |
249 |
XFillArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \ |
XFillArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \ |
250 |
|
ON_ALL_SEAMLESS_WINDOWS(XFillArc, (g_display, sw->wnd, g_gc, x-sw->xoffset, y-sw->yoffset, cx, cy, 0, 360*64)); \ |
251 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
252 |
XFillArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
XFillArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
253 |
break; \ |
break; \ |
255 |
} |
} |
256 |
|
|
257 |
/* colour maps */ |
/* colour maps */ |
258 |
extern BOOL g_owncolmap; |
extern RD_BOOL g_owncolmap; |
259 |
static Colormap g_xcolmap; |
static Colormap g_xcolmap; |
260 |
static uint32 *g_colmap = NULL; |
static uint32 *g_colmap = NULL; |
261 |
|
|
285 |
#define SET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(g_display, g_gc, rop2_map[rop2]); } |
#define SET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(g_display, g_gc, rop2_map[rop2]); } |
286 |
#define RESET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(g_display, g_gc, GXcopy); } |
#define RESET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(g_display, g_gc, GXcopy); } |
287 |
|
|
288 |
|
static seamless_window * |
289 |
|
sw_get_window_by_id(unsigned long id) |
290 |
|
{ |
291 |
|
seamless_window *sw; |
292 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
293 |
|
{ |
294 |
|
if (sw->id == id) |
295 |
|
return sw; |
296 |
|
} |
297 |
|
return NULL; |
298 |
|
} |
299 |
|
|
300 |
|
|
301 |
|
static seamless_window * |
302 |
|
sw_get_window_by_wnd(Window wnd) |
303 |
|
{ |
304 |
|
seamless_window *sw; |
305 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
306 |
|
{ |
307 |
|
if (sw->wnd == wnd) |
308 |
|
return sw; |
309 |
|
} |
310 |
|
return NULL; |
311 |
|
} |
312 |
|
|
313 |
|
|
314 |
|
static void |
315 |
|
sw_remove_window(seamless_window * win) |
316 |
|
{ |
317 |
|
seamless_window *sw, **prevnext = &g_seamless_windows; |
318 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
319 |
|
{ |
320 |
|
if (sw == win) |
321 |
|
{ |
322 |
|
*prevnext = sw->next; |
323 |
|
sw->group->refcnt--; |
324 |
|
if (sw->group->refcnt == 0) |
325 |
|
{ |
326 |
|
XDestroyWindow(g_display, sw->group->wnd); |
327 |
|
xfree(sw->group); |
328 |
|
} |
329 |
|
xfree(sw->position_timer); |
330 |
|
xfree(sw); |
331 |
|
return; |
332 |
|
} |
333 |
|
prevnext = &sw->next; |
334 |
|
} |
335 |
|
return; |
336 |
|
} |
337 |
|
|
338 |
|
|
339 |
|
/* Move all windows except wnd to new desktop */ |
340 |
|
static void |
341 |
|
sw_all_to_desktop(Window wnd, unsigned int desktop) |
342 |
|
{ |
343 |
|
seamless_window *sw; |
344 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
345 |
|
{ |
346 |
|
if (sw->wnd == wnd) |
347 |
|
continue; |
348 |
|
if (sw->desktop != desktop) |
349 |
|
{ |
350 |
|
ewmh_move_to_desktop(sw->wnd, desktop); |
351 |
|
sw->desktop = desktop; |
352 |
|
} |
353 |
|
} |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
/* Send our position */ |
358 |
|
static void |
359 |
|
sw_update_position(seamless_window * sw) |
360 |
|
{ |
361 |
|
XWindowAttributes wa; |
362 |
|
int x, y; |
363 |
|
Window child_return; |
364 |
|
unsigned int serial; |
365 |
|
|
366 |
|
XGetWindowAttributes(g_display, sw->wnd, &wa); |
367 |
|
XTranslateCoordinates(g_display, sw->wnd, wa.root, |
368 |
|
-wa.border_width, -wa.border_width, &x, &y, &child_return); |
369 |
|
|
370 |
|
serial = seamless_send_position(sw->id, x, y, wa.width, wa.height, 0); |
371 |
|
|
372 |
|
sw->outstanding_position = True; |
373 |
|
sw->outpos_serial = serial; |
374 |
|
|
375 |
|
sw->outpos_xoffset = x; |
376 |
|
sw->outpos_yoffset = y; |
377 |
|
sw->outpos_width = wa.width; |
378 |
|
sw->outpos_height = wa.height; |
379 |
|
} |
380 |
|
|
381 |
|
|
382 |
|
/* Check if it's time to send our position */ |
383 |
|
static void |
384 |
|
sw_check_timers() |
385 |
|
{ |
386 |
|
seamless_window *sw; |
387 |
|
struct timeval now; |
388 |
|
|
389 |
|
gettimeofday(&now, NULL); |
390 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
391 |
|
{ |
392 |
|
if (timerisset(sw->position_timer) && timercmp(sw->position_timer, &now, <)) |
393 |
|
{ |
394 |
|
timerclear(sw->position_timer); |
395 |
|
sw_update_position(sw); |
396 |
|
} |
397 |
|
} |
398 |
|
} |
399 |
|
|
400 |
|
|
401 |
|
static void |
402 |
|
sw_restack_window(seamless_window * sw, unsigned long behind) |
403 |
|
{ |
404 |
|
seamless_window *sw_above; |
405 |
|
|
406 |
|
/* Remove window from stack */ |
407 |
|
for (sw_above = g_seamless_windows; sw_above; sw_above = sw_above->next) |
408 |
|
{ |
409 |
|
if (sw_above->behind == sw->id) |
410 |
|
break; |
411 |
|
} |
412 |
|
|
413 |
|
if (sw_above) |
414 |
|
sw_above->behind = sw->behind; |
415 |
|
|
416 |
|
/* And then add it at the new position */ |
417 |
|
for (sw_above = g_seamless_windows; sw_above; sw_above = sw_above->next) |
418 |
|
{ |
419 |
|
if (sw_above->behind == behind) |
420 |
|
break; |
421 |
|
} |
422 |
|
|
423 |
|
if (sw_above) |
424 |
|
sw_above->behind = sw->id; |
425 |
|
|
426 |
|
sw->behind = behind; |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
static void |
static void |
431 |
mwm_hide_decorations(void) |
sw_handle_restack(seamless_window * sw) |
432 |
|
{ |
433 |
|
Status status; |
434 |
|
Window root, parent, *children; |
435 |
|
unsigned int nchildren, i; |
436 |
|
seamless_window *sw_below; |
437 |
|
|
438 |
|
status = XQueryTree(g_display, RootWindowOfScreen(g_screen), |
439 |
|
&root, &parent, &children, &nchildren); |
440 |
|
if (!status || !nchildren) |
441 |
|
return; |
442 |
|
|
443 |
|
sw_below = NULL; |
444 |
|
|
445 |
|
i = 0; |
446 |
|
while (children[i] != sw->wnd) |
447 |
|
{ |
448 |
|
i++; |
449 |
|
if (i >= nchildren) |
450 |
|
goto end; |
451 |
|
} |
452 |
|
|
453 |
|
for (i++; i < nchildren; i++) |
454 |
|
{ |
455 |
|
sw_below = sw_get_window_by_wnd(children[i]); |
456 |
|
if (sw_below) |
457 |
|
break; |
458 |
|
} |
459 |
|
|
460 |
|
if (!sw_below && !sw->behind) |
461 |
|
goto end; |
462 |
|
if (sw_below && (sw_below->id == sw->behind)) |
463 |
|
goto end; |
464 |
|
|
465 |
|
if (sw_below) |
466 |
|
{ |
467 |
|
seamless_send_zchange(sw->id, sw_below->id, 0); |
468 |
|
sw_restack_window(sw, sw_below->id); |
469 |
|
} |
470 |
|
else |
471 |
|
{ |
472 |
|
seamless_send_zchange(sw->id, 0, 0); |
473 |
|
sw_restack_window(sw, 0); |
474 |
|
} |
475 |
|
|
476 |
|
end: |
477 |
|
XFree(children); |
478 |
|
} |
479 |
|
|
480 |
|
|
481 |
|
static seamless_group * |
482 |
|
sw_find_group(unsigned long id, RD_BOOL dont_create) |
483 |
|
{ |
484 |
|
seamless_window *sw; |
485 |
|
seamless_group *sg; |
486 |
|
XSetWindowAttributes attribs; |
487 |
|
|
488 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
489 |
|
{ |
490 |
|
if (sw->group->id == id) |
491 |
|
return sw->group; |
492 |
|
} |
493 |
|
|
494 |
|
if (dont_create) |
495 |
|
return NULL; |
496 |
|
|
497 |
|
sg = xmalloc(sizeof(seamless_group)); |
498 |
|
|
499 |
|
sg->wnd = |
500 |
|
XCreateWindow(g_display, RootWindowOfScreen(g_screen), -1, -1, 1, 1, 0, |
501 |
|
CopyFromParent, CopyFromParent, CopyFromParent, 0, &attribs); |
502 |
|
|
503 |
|
sg->id = id; |
504 |
|
sg->refcnt = 0; |
505 |
|
|
506 |
|
return sg; |
507 |
|
} |
508 |
|
|
509 |
|
|
510 |
|
static void |
511 |
|
mwm_hide_decorations(Window wnd) |
512 |
{ |
{ |
513 |
PropMotifWmHints motif_hints; |
PropMotifWmHints motif_hints; |
514 |
Atom hintsatom; |
Atom hintsatom; |
525 |
return; |
return; |
526 |
} |
} |
527 |
|
|
528 |
XChangeProperty(g_display, g_wnd, hintsatom, hintsatom, 32, PropModeReplace, |
XChangeProperty(g_display, wnd, hintsatom, hintsatom, 32, PropModeReplace, |
529 |
(unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS); |
(unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS); |
530 |
|
|
531 |
|
} |
532 |
|
|
533 |
|
typedef struct _sw_configurenotify_context |
534 |
|
{ |
535 |
|
Window window; |
536 |
|
unsigned long serial; |
537 |
|
} sw_configurenotify_context; |
538 |
|
|
539 |
|
/* Predicate procedure for sw_wait_configurenotify */ |
540 |
|
static Bool |
541 |
|
sw_configurenotify_p(Display * display, XEvent * xevent, XPointer arg) |
542 |
|
{ |
543 |
|
sw_configurenotify_context *context = (sw_configurenotify_context *) arg; |
544 |
|
if (xevent->xany.type == ConfigureNotify |
545 |
|
&& xevent->xconfigure.window == context->window |
546 |
|
&& xevent->xany.serial >= context->serial) |
547 |
|
return True; |
548 |
|
|
549 |
|
return False; |
550 |
|
} |
551 |
|
|
552 |
|
/* Wait for a ConfigureNotify, with a equal or larger serial, on the |
553 |
|
specified window. The event will be removed from the queue. We |
554 |
|
could use XMaskEvent(StructureNotifyMask), but we would then risk |
555 |
|
throwing away crucial events like DestroyNotify. |
556 |
|
|
557 |
|
After a ConfigureWindow, according to ICCCM section 4.1.5, we |
558 |
|
should recieve a ConfigureNotify, either a real or synthetic |
559 |
|
one. This indicates that the configure has been "completed". |
560 |
|
However, some WMs such as several versions of Metacity fails to |
561 |
|
send synthetic events. See bug |
562 |
|
http://bugzilla.gnome.org/show_bug.cgi?id=322840. We need to use a |
563 |
|
timeout to avoid a hang. Tk uses the same approach. */ |
564 |
|
static void |
565 |
|
sw_wait_configurenotify(Window wnd, unsigned long serial) |
566 |
|
{ |
567 |
|
XEvent xevent; |
568 |
|
sw_configurenotify_context context; |
569 |
|
time_t start; |
570 |
|
RD_BOOL got = False; |
571 |
|
|
572 |
|
context.window = wnd; |
573 |
|
context.serial = serial; |
574 |
|
start = time(NULL); |
575 |
|
|
576 |
|
do |
577 |
|
{ |
578 |
|
if (XCheckIfEvent(g_display, &xevent, sw_configurenotify_p, (XPointer) & context)) |
579 |
|
{ |
580 |
|
got = True; |
581 |
|
break; |
582 |
|
} |
583 |
|
usleep(100000); |
584 |
|
} |
585 |
|
while (time(NULL) - start < 2); |
586 |
|
|
587 |
|
if (!got) |
588 |
|
{ |
589 |
|
warning("Broken Window Manager: Timeout while waiting for ConfigureNotify\n"); |
590 |
|
} |
591 |
|
} |
592 |
|
|
593 |
|
/* Get the toplevel window, in case of reparenting */ |
594 |
|
static Window |
595 |
|
sw_get_toplevel(Window wnd) |
596 |
|
{ |
597 |
|
Window root, parent; |
598 |
|
Window *child_list; |
599 |
|
unsigned int num_children; |
600 |
|
|
601 |
|
while (1) |
602 |
|
{ |
603 |
|
XQueryTree(g_display, wnd, &root, &parent, &child_list, &num_children); |
604 |
|
if (root == parent) |
605 |
|
{ |
606 |
|
break; |
607 |
|
} |
608 |
|
else if (!parent) |
609 |
|
{ |
610 |
|
warning("Internal error: sw_get_toplevel called with root window\n"); |
611 |
|
} |
612 |
|
|
613 |
|
wnd = parent; |
614 |
|
} |
615 |
|
|
616 |
|
return wnd; |
617 |
|
} |
618 |
|
|
619 |
|
|
620 |
|
/* Check if wnd is already behind a window wrt stacking order */ |
621 |
|
static RD_BOOL |
622 |
|
sw_window_is_behind(Window wnd, Window behind) |
623 |
|
{ |
624 |
|
Window dummy1, dummy2; |
625 |
|
Window *child_list; |
626 |
|
unsigned int num_children; |
627 |
|
unsigned int i; |
628 |
|
RD_BOOL found_behind = False; |
629 |
|
RD_BOOL found_wnd = False; |
630 |
|
|
631 |
|
wnd = sw_get_toplevel(wnd); |
632 |
|
behind = sw_get_toplevel(behind); |
633 |
|
|
634 |
|
XQueryTree(g_display, RootWindowOfScreen(g_screen), &dummy1, &dummy2, &child_list, |
635 |
|
&num_children); |
636 |
|
|
637 |
|
for (i = num_children - 1; i >= 0; i--) |
638 |
|
{ |
639 |
|
if (child_list[i] == behind) |
640 |
|
{ |
641 |
|
found_behind = True; |
642 |
|
} |
643 |
|
else if (child_list[i] == wnd) |
644 |
|
{ |
645 |
|
found_wnd = True; |
646 |
|
break; |
647 |
|
} |
648 |
|
} |
649 |
|
|
650 |
|
if (child_list) |
651 |
|
XFree(child_list); |
652 |
|
|
653 |
|
if (!found_wnd) |
654 |
|
{ |
655 |
|
warning("sw_window_is_behind: Unable to find window 0x%lx\n", wnd); |
656 |
|
|
657 |
|
if (!found_behind) |
658 |
|
{ |
659 |
|
warning("sw_window_is_behind: Unable to find behind window 0x%lx\n", |
660 |
|
behind); |
661 |
|
} |
662 |
|
} |
663 |
|
|
664 |
|
return found_behind; |
665 |
|
} |
666 |
|
|
667 |
|
|
668 |
|
/* Test if the window manager correctly handles window restacking. In |
669 |
|
particular, we are testing if it's possible to place a window |
670 |
|
between two other windows. Many WMs such as Metacity can only stack |
671 |
|
windows on the top or bottom. The window creation should mostly |
672 |
|
match ui_seamless_create_window. */ |
673 |
|
static void |
674 |
|
seamless_restack_test() |
675 |
|
{ |
676 |
|
/* The goal is to have the middle window between top and |
677 |
|
bottom. The middle window is initially at the top, |
678 |
|
though. */ |
679 |
|
Window wnds[3]; /* top, middle and bottom */ |
680 |
|
int i; |
681 |
|
XEvent xevent; |
682 |
|
XWindowChanges values; |
683 |
|
unsigned long restack_serial; |
684 |
|
|
685 |
|
for (i = 0; i < 3; i++) |
686 |
|
{ |
687 |
|
char name[64]; |
688 |
|
wnds[i] = |
689 |
|
XCreateSimpleWindow(g_display, RootWindowOfScreen(g_screen), 0, 0, 20, 20, |
690 |
|
0, 0, 0); |
691 |
|
snprintf(name, sizeof(name), "SeamlessRDP restack test - window %d", i); |
692 |
|
XStoreName(g_display, wnds[i], name); |
693 |
|
ewmh_set_wm_name(wnds[i], name); |
694 |
|
|
695 |
|
/* Hide decorations. Often this means that no |
696 |
|
reparenting will be done, which makes the restack |
697 |
|
easier. Besides, we want to mimic our other |
698 |
|
seamless windows as much as possible. We must still |
699 |
|
handle the case with reparenting, though. */ |
700 |
|
mwm_hide_decorations(wnds[i]); |
701 |
|
|
702 |
|
/* Prevent windows from appearing in task bar */ |
703 |
|
XSetTransientForHint(g_display, wnds[i], RootWindowOfScreen(g_screen)); |
704 |
|
ewmh_set_window_popup(wnds[i]); |
705 |
|
|
706 |
|
/* We need to catch MapNotify/ConfigureNotify */ |
707 |
|
XSelectInput(g_display, wnds[i], StructureNotifyMask); |
708 |
|
} |
709 |
|
|
710 |
|
/* Map Windows. Currently, we assume that XMapRaised places |
711 |
|
the window on the top of the stack. Should be fairly safe; |
712 |
|
the window is configured before it's mapped. */ |
713 |
|
XMapRaised(g_display, wnds[2]); /* bottom */ |
714 |
|
do |
715 |
|
{ |
716 |
|
XWindowEvent(g_display, wnds[2], StructureNotifyMask, &xevent); |
717 |
|
} |
718 |
|
while (xevent.type != MapNotify); |
719 |
|
XMapRaised(g_display, wnds[0]); /* top */ |
720 |
|
do |
721 |
|
{ |
722 |
|
XWindowEvent(g_display, wnds[0], StructureNotifyMask, &xevent); |
723 |
|
} |
724 |
|
while (xevent.type != MapNotify); |
725 |
|
XMapRaised(g_display, wnds[1]); /* middle */ |
726 |
|
do |
727 |
|
{ |
728 |
|
XWindowEvent(g_display, wnds[1], StructureNotifyMask, &xevent); |
729 |
|
} |
730 |
|
while (xevent.type != MapNotify); |
731 |
|
|
732 |
|
/* The stacking order should now be 1 - 0 - 2 */ |
733 |
|
if (!sw_window_is_behind(wnds[0], wnds[1]) || !sw_window_is_behind(wnds[2], wnds[1])) |
734 |
|
{ |
735 |
|
/* Ok, technically a WM is allowed to stack windows arbitrarily, but... */ |
736 |
|
warning("Broken Window Manager: Unable to test window restacking\n"); |
737 |
|
g_seamless_broken_restack = True; |
738 |
|
for (i = 0; i < 3; i++) |
739 |
|
XDestroyWindow(g_display, wnds[i]); |
740 |
|
return; |
741 |
|
} |
742 |
|
|
743 |
|
/* Restack, using XReconfigureWMWindow, which should correctly |
744 |
|
handle reparented windows as well as nonreparenting WMs. */ |
745 |
|
values.stack_mode = Below; |
746 |
|
values.sibling = wnds[0]; |
747 |
|
restack_serial = XNextRequest(g_display); |
748 |
|
XReconfigureWMWindow(g_display, wnds[1], DefaultScreen(g_display), CWStackMode | CWSibling, |
749 |
|
&values); |
750 |
|
sw_wait_configurenotify(wnds[1], restack_serial); |
751 |
|
|
752 |
|
/* Now verify that middle is behind top but not behind |
753 |
|
bottom */ |
754 |
|
if (!sw_window_is_behind(wnds[1], wnds[0])) |
755 |
|
{ |
756 |
|
warning("Broken Window Manager: doesn't handle restack (restack request was ignored)\n"); |
757 |
|
g_seamless_broken_restack = True; |
758 |
|
} |
759 |
|
else if (sw_window_is_behind(wnds[1], wnds[2])) |
760 |
|
{ |
761 |
|
warning("Broken Window Manager: doesn't handle restack (window was moved to bottom)\n"); |
762 |
|
g_seamless_broken_restack = True; |
763 |
|
} |
764 |
|
|
765 |
|
/* Destroy windows */ |
766 |
|
for (i = 0; i < 3; i++) |
767 |
|
XDestroyWindow(g_display, wnds[i]); |
768 |
} |
} |
769 |
|
|
770 |
#define SPLITCOLOUR15(colour, rv) \ |
#define SPLITCOLOUR15(colour, rv) \ |
798 |
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ |
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ |
799 |
x = (x << 16) | (x >> 16); } |
x = (x << 16) | (x >> 16); } |
800 |
|
|
801 |
|
/* The following macros output the same octet sequences |
802 |
|
on both BE and LE hosts: */ |
803 |
|
|
804 |
#define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; } |
#define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; } |
805 |
#define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } |
#define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } |
806 |
#define BOUT32(o, x) { *(o++) = x >> 24; *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } |
#define BOUT32(o, x) { *(o++) = x >> 24; *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } |
821 |
SPLITCOLOUR16(colour, pc); |
SPLITCOLOUR16(colour, pc); |
822 |
break; |
break; |
823 |
case 24: |
case 24: |
824 |
|
case 32: |
825 |
SPLITCOLOUR24(colour, pc); |
SPLITCOLOUR24(colour, pc); |
826 |
break; |
break; |
827 |
default: |
default: |
881 |
{ |
{ |
882 |
uint16 value; |
uint16 value; |
883 |
|
|
884 |
if (g_compatible_depth) |
if (g_compatible_arch) |
885 |
{ |
{ |
886 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
887 |
REPEAT2 |
REPEAT2 |
915 |
{ |
{ |
916 |
uint32 value; |
uint32 value; |
917 |
|
|
918 |
if (g_compatible_depth) |
if (g_compatible_arch) |
919 |
{ |
{ |
920 |
while (out < end) |
while (out < end) |
921 |
{ |
{ |
938 |
{ |
{ |
939 |
uint32 value; |
uint32 value; |
940 |
|
|
941 |
if (g_compatible_depth) |
if (g_compatible_arch) |
942 |
{ |
{ |
943 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
944 |
REPEAT4 |
REPEAT4 |
1010 |
uint16 pixel; |
uint16 pixel; |
1011 |
PixelColour pc; |
PixelColour pc; |
1012 |
|
|
1013 |
if (g_compatible_depth) |
if (g_compatible_arch) |
1014 |
{ |
{ |
1015 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
1016 |
REPEAT3 |
REPEAT3 |
1060 |
uint32 value; |
uint32 value; |
1061 |
PixelColour pc; |
PixelColour pc; |
1062 |
|
|
1063 |
if (g_compatible_depth) |
if (g_compatible_arch) |
1064 |
{ |
{ |
1065 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
1066 |
REPEAT4 |
REPEAT4 |
1168 |
uint16 pixel; |
uint16 pixel; |
1169 |
PixelColour pc; |
PixelColour pc; |
1170 |
|
|
1171 |
if (g_compatible_depth) |
if (g_compatible_arch) |
1172 |
{ |
{ |
1173 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
1174 |
REPEAT3 |
REPEAT3 |
1238 |
uint32 value; |
uint32 value; |
1239 |
PixelColour pc; |
PixelColour pc; |
1240 |
|
|
1241 |
if (g_compatible_depth) |
if (g_compatible_arch) |
1242 |
{ |
{ |
1243 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
1244 |
REPEAT4 |
REPEAT4 |
1367 |
uint32 value; |
uint32 value; |
1368 |
PixelColour pc; |
PixelColour pc; |
1369 |
|
|
1370 |
if (g_compatible_depth) |
if (g_compatible_arch) |
1371 |
{ |
{ |
1372 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
1373 |
#ifdef NEED_ALIGN |
#ifdef NEED_ALIGN |
1430 |
is only set for compatible depths, but the RDP depth might've |
is only set for compatible depths, but the RDP depth might've |
1431 |
changed during connection negotiations. |
changed during connection negotiations. |
1432 |
*/ |
*/ |
1433 |
|
|
1434 |
|
/* todo */ |
1435 |
|
if (g_server_depth == 32 && g_depth == 24) |
1436 |
|
{ |
1437 |
|
return data; |
1438 |
|
} |
1439 |
|
|
1440 |
if (g_no_translate_image) |
if (g_no_translate_image) |
1441 |
{ |
{ |
1442 |
if ((g_depth == 15 && g_server_depth == 15) || |
if ((g_depth == 15 && g_server_depth == 15) || |
1514 |
return out; |
return out; |
1515 |
} |
} |
1516 |
|
|
1517 |
BOOL |
static void |
1518 |
|
xwin_refresh_pointer_map(void) |
1519 |
|
{ |
1520 |
|
unsigned char phys_to_log_map[sizeof(g_pointer_log_to_phys_map)]; |
1521 |
|
int i, pointer_buttons; |
1522 |
|
|
1523 |
|
pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map)); |
1524 |
|
for (i = 0; i < pointer_buttons; ++i) |
1525 |
|
{ |
1526 |
|
/* This might produce multiple logical buttons mapping |
1527 |
|
to a single physical one, but hey, that's |
1528 |
|
life... */ |
1529 |
|
g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1; |
1530 |
|
} |
1531 |
|
} |
1532 |
|
|
1533 |
|
RD_BOOL |
1534 |
get_key_state(unsigned int state, uint32 keysym) |
get_key_state(unsigned int state, uint32 keysym) |
1535 |
{ |
{ |
1536 |
int modifierpos, key, keysymMask = 0; |
int modifierpos, key, keysymMask = 0; |
1578 |
return weight; |
return weight; |
1579 |
} |
} |
1580 |
|
|
1581 |
static BOOL |
static RD_BOOL |
1582 |
select_visual() |
select_visual(int screen_num) |
1583 |
{ |
{ |
1584 |
XPixmapFormatValues *pfm; |
XPixmapFormatValues *pfm; |
1585 |
int pixmap_formats_count, visuals_count; |
int pixmap_formats_count, visuals_count; |
1590 |
|
|
1591 |
red_weight = blue_weight = green_weight = 0; |
red_weight = blue_weight = green_weight = 0; |
1592 |
|
|
1593 |
|
if (g_server_depth == -1) |
1594 |
|
{ |
1595 |
|
g_server_depth = DisplayPlanes(g_display, DefaultScreen(g_display)); |
1596 |
|
} |
1597 |
|
|
1598 |
pfm = XListPixmapFormats(g_display, &pixmap_formats_count); |
pfm = XListPixmapFormats(g_display, &pixmap_formats_count); |
1599 |
if (pfm == NULL) |
if (pfm == NULL) |
1600 |
{ |
{ |
1605 |
|
|
1606 |
/* Search for best TrueColor visual */ |
/* Search for best TrueColor visual */ |
1607 |
template.class = TrueColor; |
template.class = TrueColor; |
1608 |
vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &visuals_count); |
template.screen = screen_num; |
1609 |
|
vmatches = |
1610 |
|
XGetVisualInfo(g_display, VisualClassMask | VisualScreenMask, &template, |
1611 |
|
&visuals_count); |
1612 |
g_visual = NULL; |
g_visual = NULL; |
1613 |
g_no_translate_image = False; |
g_no_translate_image = False; |
1614 |
g_compatible_depth = False; |
g_compatible_arch = False; |
1615 |
if (vmatches != NULL) |
if (vmatches != NULL) |
1616 |
{ |
{ |
1617 |
for (i = 0; i < visuals_count; ++i) |
for (i = 0; i < visuals_count; ++i) |
1618 |
{ |
{ |
1619 |
XVisualInfo *visual_info = &vmatches[i]; |
XVisualInfo *visual_info = &vmatches[i]; |
1620 |
|
RD_BOOL can_translate_to_bpp = False; |
1621 |
|
int j; |
1622 |
|
|
1623 |
/* Try to find a no-translation visual that'll |
/* Try to find a no-translation visual that'll |
1624 |
allow us to use RDP bitmaps directly as ZPixmaps. */ |
allow us to use RDP bitmaps directly as ZPixmaps. */ |
1640 |
{ |
{ |
1641 |
g_visual = visual_info->visual; |
g_visual = visual_info->visual; |
1642 |
g_depth = visual_info->depth; |
g_depth = visual_info->depth; |
1643 |
g_compatible_depth = True; |
g_compatible_arch = !g_host_be; |
1644 |
g_no_translate_image = (visual_info->depth == g_server_depth); |
g_no_translate_image = (visual_info->depth == g_server_depth); |
1645 |
if (g_no_translate_image) |
if (g_no_translate_image) |
1646 |
/* We found the best visual */ |
/* We found the best visual */ |
1648 |
} |
} |
1649 |
else |
else |
1650 |
{ |
{ |
1651 |
g_compatible_depth = False; |
g_compatible_arch = False; |
1652 |
} |
} |
1653 |
|
|
1654 |
if (visual_info->depth > 24) |
if (visual_info->depth > 24) |
1662 |
|
|
1663 |
/* Only care for visuals, for whose BPPs (not depths!) |
/* Only care for visuals, for whose BPPs (not depths!) |
1664 |
we have a translateXtoY function. */ |
we have a translateXtoY function. */ |
|
BOOL can_translate_to_bpp = False; |
|
|
int j; |
|
1665 |
for (j = 0; j < pixmap_formats_count; ++j) |
for (j = 0; j < pixmap_formats_count; ++j) |
1666 |
{ |
{ |
1667 |
if (pfm[j].depth == visual_info->depth) |
if (pfm[j].depth == visual_info->depth) |
1773 |
return True; |
return True; |
1774 |
} |
} |
1775 |
|
|
1776 |
BOOL |
static XErrorHandler g_old_error_handler; |
1777 |
|
static RD_BOOL g_error_expected = False; |
1778 |
|
|
1779 |
|
/* Check if the X11 window corresponding to a seamless window with |
1780 |
|
specified id exists. */ |
1781 |
|
RD_BOOL |
1782 |
|
sw_window_exists(unsigned long id) |
1783 |
|
{ |
1784 |
|
seamless_window *sw; |
1785 |
|
char *name; |
1786 |
|
Status sts = 0; |
1787 |
|
|
1788 |
|
sw = sw_get_window_by_id(id); |
1789 |
|
if (!sw) |
1790 |
|
return False; |
1791 |
|
|
1792 |
|
g_error_expected = True; |
1793 |
|
sts = XFetchName(g_display, sw->wnd, &name); |
1794 |
|
g_error_expected = False; |
1795 |
|
if (sts) |
1796 |
|
{ |
1797 |
|
XFree(name); |
1798 |
|
} |
1799 |
|
|
1800 |
|
return sts; |
1801 |
|
} |
1802 |
|
|
1803 |
|
static int |
1804 |
|
error_handler(Display * dpy, XErrorEvent * eev) |
1805 |
|
{ |
1806 |
|
if (g_error_expected) |
1807 |
|
return 0; |
1808 |
|
|
1809 |
|
return g_old_error_handler(dpy, eev); |
1810 |
|
} |
1811 |
|
|
1812 |
|
RD_BOOL |
1813 |
ui_init(void) |
ui_init(void) |
1814 |
{ |
{ |
1815 |
int screen_num; |
int screen_num; |
1823 |
|
|
1824 |
{ |
{ |
1825 |
uint16 endianess_test = 1; |
uint16 endianess_test = 1; |
1826 |
g_host_be = !(BOOL) (*(uint8 *) (&endianess_test)); |
g_host_be = !(RD_BOOL) (*(uint8 *) (&endianess_test)); |
1827 |
} |
} |
1828 |
|
|
1829 |
|
g_old_error_handler = XSetErrorHandler(error_handler); |
1830 |
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
1831 |
screen_num = DefaultScreen(g_display); |
screen_num = DefaultScreen(g_display); |
1832 |
g_x_socket = ConnectionNumber(g_display); |
g_x_socket = ConnectionNumber(g_display); |
1833 |
g_screen = ScreenOfDisplay(g_display, screen_num); |
g_screen = ScreenOfDisplay(g_display, screen_num); |
1834 |
g_depth = DefaultDepthOfScreen(g_screen); |
g_depth = DefaultDepthOfScreen(g_screen); |
1835 |
|
|
1836 |
if (!select_visual()) |
if (!select_visual(screen_num)) |
1837 |
return False; |
return False; |
1838 |
|
|
1839 |
if (g_no_translate_image) |
if (g_no_translate_image) |
1872 |
{ |
{ |
1873 |
g_width = WidthOfScreen(g_screen); |
g_width = WidthOfScreen(g_screen); |
1874 |
g_height = HeightOfScreen(g_screen); |
g_height = HeightOfScreen(g_screen); |
1875 |
|
g_using_full_workarea = True; |
1876 |
} |
} |
1877 |
else if (g_width < 0) |
else if (g_width < 0) |
1878 |
{ |
{ |
1886 |
{ |
{ |
1887 |
/* Fetch geometry from _NET_WORKAREA */ |
/* Fetch geometry from _NET_WORKAREA */ |
1888 |
uint32 x, y, cx, cy; |
uint32 x, y, cx, cy; |
|
g_using_full_workarea = True; |
|
|
|
|
1889 |
if (get_current_workarea(&x, &y, &cx, &cy) == 0) |
if (get_current_workarea(&x, &y, &cx, &cy) == 0) |
1890 |
{ |
{ |
1891 |
g_width = cx; |
g_width = cx; |
1892 |
g_height = cy; |
g_height = cy; |
1893 |
|
g_using_full_workarea = True; |
1894 |
} |
} |
1895 |
else |
else |
1896 |
{ |
{ |
1897 |
warning("Failed to get workarea: probably your window manager does not support extended hints\n"); |
warning("Failed to get workarea: probably your window manager does not support extended hints\n"); |
1898 |
g_width = 800; |
g_width = WidthOfScreen(g_screen); |
1899 |
g_height = 600; |
g_height = HeightOfScreen(g_screen); |
1900 |
} |
} |
1901 |
} |
} |
1902 |
|
|
1904 |
g_width = (g_width + 3) & ~3; |
g_width = (g_width + 3) & ~3; |
1905 |
|
|
1906 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
1907 |
|
xwin_refresh_pointer_map(); |
1908 |
|
|
1909 |
xkeymap_init(); |
xkeymap_init(); |
1910 |
|
|
1912 |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
1913 |
|
|
1914 |
xclip_init(); |
xclip_init(); |
1915 |
|
ewmh_init(); |
1916 |
|
if (g_seamless_rdp) |
1917 |
|
{ |
1918 |
|
seamless_restack_test(); |
1919 |
|
seamless_init(); |
1920 |
|
} |
1921 |
|
|
1922 |
DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_depth, g_bpp, g_depth)); |
DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_depth, g_bpp, g_depth)); |
1923 |
|
|
1927 |
void |
void |
1928 |
ui_deinit(void) |
ui_deinit(void) |
1929 |
{ |
{ |
1930 |
|
while (g_seamless_windows) |
1931 |
|
{ |
1932 |
|
XDestroyWindow(g_display, g_seamless_windows->wnd); |
1933 |
|
sw_remove_window(g_seamless_windows); |
1934 |
|
} |
1935 |
|
|
1936 |
|
xclip_deinit(); |
1937 |
|
|
1938 |
if (g_IM != NULL) |
if (g_IM != NULL) |
1939 |
XCloseIM(g_IM); |
XCloseIM(g_IM); |
1940 |
|
|
1951 |
g_display = NULL; |
g_display = NULL; |
1952 |
} |
} |
1953 |
|
|
1954 |
BOOL |
|
1955 |
|
static void |
1956 |
|
get_window_attribs(XSetWindowAttributes * attribs) |
1957 |
|
{ |
1958 |
|
attribs->background_pixel = BlackPixelOfScreen(g_screen); |
1959 |
|
attribs->background_pixel = WhitePixelOfScreen(g_screen); |
1960 |
|
attribs->border_pixel = WhitePixelOfScreen(g_screen); |
1961 |
|
attribs->backing_store = g_ownbackstore ? NotUseful : Always; |
1962 |
|
attribs->override_redirect = g_fullscreen; |
1963 |
|
attribs->colormap = g_xcolmap; |
1964 |
|
} |
1965 |
|
|
1966 |
|
static void |
1967 |
|
get_input_mask(long *input_mask) |
1968 |
|
{ |
1969 |
|
*input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
1970 |
|
VisibilityChangeMask | FocusChangeMask | StructureNotifyMask; |
1971 |
|
|
1972 |
|
if (g_sendmotion) |
1973 |
|
*input_mask |= PointerMotionMask; |
1974 |
|
if (g_ownbackstore) |
1975 |
|
*input_mask |= ExposureMask; |
1976 |
|
if (g_fullscreen || g_grab_keyboard) |
1977 |
|
*input_mask |= EnterWindowMask; |
1978 |
|
if (g_grab_keyboard) |
1979 |
|
*input_mask |= LeaveWindowMask; |
1980 |
|
} |
1981 |
|
|
1982 |
|
RD_BOOL |
1983 |
ui_create_window(void) |
ui_create_window(void) |
1984 |
{ |
{ |
1985 |
uint8 null_pointer_mask[1] = { 0x80 }; |
uint8 null_pointer_mask[1] = { 0x80 }; |
2001 |
if (g_ypos < 0 || (g_ypos == 0 && (g_pos & 4))) |
if (g_ypos < 0 || (g_ypos == 0 && (g_pos & 4))) |
2002 |
g_ypos = HeightOfScreen(g_screen) + g_ypos - g_height; |
g_ypos = HeightOfScreen(g_screen) + g_ypos - g_height; |
2003 |
|
|
2004 |
attribs.background_pixel = BlackPixelOfScreen(g_screen); |
get_window_attribs(&attribs); |
|
attribs.border_pixel = WhitePixelOfScreen(g_screen); |
|
|
attribs.backing_store = g_ownbackstore ? NotUseful : Always; |
|
|
attribs.override_redirect = g_fullscreen; |
|
|
attribs.colormap = g_xcolmap; |
|
2005 |
|
|
2006 |
g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), g_xpos, g_ypos, wndwidth, |
g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), g_xpos, g_ypos, wndwidth, |
2007 |
wndheight, 0, g_depth, InputOutput, g_visual, |
wndheight, 0, g_depth, InputOutput, g_visual, |
2009 |
CWBorderPixel, &attribs); |
CWBorderPixel, &attribs); |
2010 |
|
|
2011 |
if (g_gc == NULL) |
if (g_gc == NULL) |
2012 |
|
{ |
2013 |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
2014 |
|
ui_reset_clip(); |
2015 |
|
} |
2016 |
|
|
2017 |
if (g_create_bitmap_gc == NULL) |
if (g_create_bitmap_gc == NULL) |
2018 |
g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
2027 |
} |
} |
2028 |
|
|
2029 |
XStoreName(g_display, g_wnd, g_title); |
XStoreName(g_display, g_wnd, g_title); |
2030 |
|
ewmh_set_wm_name(g_wnd, g_title); |
2031 |
|
|
2032 |
if (g_hide_decorations) |
if (g_hide_decorations) |
2033 |
mwm_hide_decorations(); |
mwm_hide_decorations(g_wnd); |
2034 |
|
|
2035 |
classhints = XAllocClassHint(); |
classhints = XAllocClassHint(); |
2036 |
if (classhints != NULL) |
if (classhints != NULL) |
2057 |
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); |
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); |
2058 |
} |
} |
2059 |
|
|
2060 |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
get_input_mask(&input_mask); |
|
VisibilityChangeMask | FocusChangeMask | StructureNotifyMask; |
|
|
|
|
|
if (g_sendmotion) |
|
|
input_mask |= PointerMotionMask; |
|
|
if (g_ownbackstore) |
|
|
input_mask |= ExposureMask; |
|
|
if (g_fullscreen || g_grab_keyboard) |
|
|
input_mask |= EnterWindowMask; |
|
|
if (g_grab_keyboard) |
|
|
input_mask |= LeaveWindowMask; |
|
2061 |
|
|
2062 |
if (g_IM != NULL) |
if (g_IM != NULL) |
2063 |
{ |
{ |
2142 |
{ |
{ |
2143 |
Pixmap contents = 0; |
Pixmap contents = 0; |
2144 |
|
|
2145 |
|
if (g_seamless_active) |
2146 |
|
/* Turn off SeamlessRDP mode */ |
2147 |
|
ui_seamless_toggle(); |
2148 |
|
|
2149 |
if (!g_ownbackstore) |
if (!g_ownbackstore) |
2150 |
{ |
{ |
2151 |
/* need to save contents of window */ |
/* need to save contents of window */ |
2167 |
} |
} |
2168 |
|
|
2169 |
static void |
static void |
2170 |
handle_button_event(XEvent xevent, BOOL down) |
handle_button_event(XEvent xevent, RD_BOOL down) |
2171 |
{ |
{ |
2172 |
uint16 button, flags = 0; |
uint16 button, flags = 0; |
2173 |
g_last_gesturetime = xevent.xbutton.time; |
g_last_gesturetime = xevent.xbutton.time; |
2174 |
|
/* Reverse the pointer button mapping, e.g. in the case of |
2175 |
|
"left-handed mouse mode"; the RDP session expects to |
2176 |
|
receive physical buttons (true in mstsc as well) and |
2177 |
|
logical button behavior depends on the remote desktop's own |
2178 |
|
mouse settings */ |
2179 |
|
xevent.xbutton.button = g_pointer_log_to_phys_map[xevent.xbutton.button - 1]; |
2180 |
button = xkeymap_translate_button(xevent.xbutton.button); |
button = xkeymap_translate_button(xevent.xbutton.button); |
2181 |
if (button == 0) |
if (button == 0) |
2182 |
return; |
return; |
2240 |
} |
} |
2241 |
} |
} |
2242 |
|
|
2243 |
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
if (xevent.xmotion.window == g_wnd) |
2244 |
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
{ |
2245 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
2246 |
|
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
2247 |
|
} |
2248 |
|
else |
2249 |
|
{ |
2250 |
|
/* SeamlessRDP */ |
2251 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
2252 |
|
flags | button, xevent.xbutton.x_root, xevent.xbutton.y_root); |
2253 |
|
} |
2254 |
} |
} |
2255 |
|
|
2256 |
|
|
2257 |
/* Process events in Xlib queue |
/* Process events in Xlib queue |
2258 |
Returns 0 after user quit, 1 otherwise */ |
Returns 0 after user quit, 1 otherwise */ |
2259 |
static int |
static int |
2265 |
char str[256]; |
char str[256]; |
2266 |
Status status; |
Status status; |
2267 |
int events = 0; |
int events = 0; |
2268 |
|
seamless_window *sw; |
2269 |
|
|
2270 |
while ((XPending(g_display) > 0) && events++ < 20) |
while ((XPending(g_display) > 0) && events++ < 20) |
2271 |
{ |
{ |
2280 |
switch (xevent.type) |
switch (xevent.type) |
2281 |
{ |
{ |
2282 |
case VisibilityNotify: |
case VisibilityNotify: |
2283 |
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
if (xevent.xvisibility.window == g_wnd) |
2284 |
|
g_Unobscured = |
2285 |
|
xevent.xvisibility.state == VisibilityUnobscured; |
2286 |
|
|
2287 |
break; |
break; |
2288 |
case ClientMessage: |
case ClientMessage: |
2289 |
/* the window manager told us to quit */ |
/* the window manager told us to quit */ |
2290 |
if ((xevent.xclient.message_type == g_protocol_atom) |
if ((xevent.xclient.message_type == g_protocol_atom) |
2291 |
&& ((Atom) xevent.xclient.data.l[0] == g_kill_atom)) |
&& ((Atom) xevent.xclient.data.l[0] == g_kill_atom)) |
2292 |
/* Quit */ |
{ |
2293 |
return 0; |
/* When killing a seamless window, close the window on the |
2294 |
|
serverside instead of terminating rdesktop */ |
2295 |
|
sw = sw_get_window_by_wnd(xevent.xclient.window); |
2296 |
|
if (!sw) |
2297 |
|
/* Otherwise, quit */ |
2298 |
|
return 0; |
2299 |
|
/* send seamless destroy process message */ |
2300 |
|
seamless_send_destroy(sw->id); |
2301 |
|
} |
2302 |
break; |
break; |
2303 |
|
|
2304 |
case KeyPress: |
case KeyPress: |
2371 |
if (g_fullscreen && !g_focused) |
if (g_fullscreen && !g_focused) |
2372 |
XSetInputFocus(g_display, g_wnd, RevertToPointerRoot, |
XSetInputFocus(g_display, g_wnd, RevertToPointerRoot, |
2373 |
CurrentTime); |
CurrentTime); |
2374 |
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
|
2375 |
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); |
if (xevent.xmotion.window == g_wnd) |
2376 |
|
{ |
2377 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, |
2378 |
|
xevent.xmotion.x, xevent.xmotion.y); |
2379 |
|
} |
2380 |
|
else |
2381 |
|
{ |
2382 |
|
/* SeamlessRDP */ |
2383 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, |
2384 |
|
xevent.xmotion.x_root, |
2385 |
|
xevent.xmotion.y_root); |
2386 |
|
} |
2387 |
break; |
break; |
2388 |
|
|
2389 |
case FocusIn: |
case FocusIn: |
2394 |
if (g_grab_keyboard && g_mouse_in_wnd) |
if (g_grab_keyboard && g_mouse_in_wnd) |
2395 |
XGrabKeyboard(g_display, g_wnd, True, |
XGrabKeyboard(g_display, g_wnd, True, |
2396 |
GrabModeAsync, GrabModeAsync, CurrentTime); |
GrabModeAsync, GrabModeAsync, CurrentTime); |
2397 |
|
|
2398 |
|
sw = sw_get_window_by_wnd(xevent.xfocus.window); |
2399 |
|
if (!sw) |
2400 |
|
break; |
2401 |
|
|
2402 |
|
/* Menu windows are real X11 windows, |
2403 |
|
with focus. When such a window is |
2404 |
|
destroyed, focus is reverted to the |
2405 |
|
main application window, which |
2406 |
|
would cause us to send FOCUS. This |
2407 |
|
breaks window switching in, say, |
2408 |
|
Seamonkey. We shouldn't need to |
2409 |
|
send FOCUS: Windows should also |
2410 |
|
revert focus to some other window |
2411 |
|
when the menu window is |
2412 |
|
destroyed. So, we only send FOCUS |
2413 |
|
if the previous focus window still |
2414 |
|
exists. */ |
2415 |
|
if (sw->id != g_seamless_focused) |
2416 |
|
{ |
2417 |
|
|
2418 |
|
if (sw_window_exists(g_seamless_focused)) |
2419 |
|
seamless_send_focus(sw->id, 0); |
2420 |
|
g_seamless_focused = sw->id; |
2421 |
|
} |
2422 |
break; |
break; |
2423 |
|
|
2424 |
case FocusOut: |
case FocusOut: |
2451 |
break; |
break; |
2452 |
|
|
2453 |
case Expose: |
case Expose: |
2454 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, |
if (xevent.xexpose.window == g_wnd) |
2455 |
xevent.xexpose.x, xevent.xexpose.y, |
{ |
2456 |
xevent.xexpose.width, |
XCopyArea(g_display, g_backstore, xevent.xexpose.window, |
2457 |
xevent.xexpose.height, |
g_gc, |
2458 |
xevent.xexpose.x, xevent.xexpose.y); |
xevent.xexpose.x, xevent.xexpose.y, |
2459 |
|
xevent.xexpose.width, xevent.xexpose.height, |
2460 |
|
xevent.xexpose.x, xevent.xexpose.y); |
2461 |
|
} |
2462 |
|
else |
2463 |
|
{ |
2464 |
|
sw = sw_get_window_by_wnd(xevent.xexpose.window); |
2465 |
|
if (!sw) |
2466 |
|
break; |
2467 |
|
XCopyArea(g_display, g_backstore, |
2468 |
|
xevent.xexpose.window, g_gc, |
2469 |
|
xevent.xexpose.x + sw->xoffset, |
2470 |
|
xevent.xexpose.y + sw->yoffset, |
2471 |
|
xevent.xexpose.width, |
2472 |
|
xevent.xexpose.height, xevent.xexpose.x, |
2473 |
|
xevent.xexpose.y); |
2474 |
|
} |
2475 |
|
|
2476 |
break; |
break; |
2477 |
|
|
2478 |
case MappingNotify: |
case MappingNotify: |
2487 |
XFreeModifiermap(g_mod_map); |
XFreeModifiermap(g_mod_map); |
2488 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
2489 |
} |
} |
2490 |
|
|
2491 |
|
if (xevent.xmapping.request == MappingPointer) |
2492 |
|
{ |
2493 |
|
xwin_refresh_pointer_map(); |
2494 |
|
} |
2495 |
|
|
2496 |
break; |
break; |
2497 |
|
|
2498 |
/* clipboard stuff */ |
/* clipboard stuff */ |
2507 |
break; |
break; |
2508 |
case PropertyNotify: |
case PropertyNotify: |
2509 |
xclip_handle_PropertyNotify(&xevent.xproperty); |
xclip_handle_PropertyNotify(&xevent.xproperty); |
2510 |
|
if (xevent.xproperty.window == g_wnd) |
2511 |
|
break; |
2512 |
|
if (xevent.xproperty.window == DefaultRootWindow(g_display)) |
2513 |
|
break; |
2514 |
|
|
2515 |
|
/* seamless */ |
2516 |
|
sw = sw_get_window_by_wnd(xevent.xproperty.window); |
2517 |
|
if (!sw) |
2518 |
|
break; |
2519 |
|
|
2520 |
|
if ((xevent.xproperty.atom == g_net_wm_state_atom) |
2521 |
|
&& (xevent.xproperty.state == PropertyNewValue)) |
2522 |
|
{ |
2523 |
|
sw->state = ewmh_get_window_state(sw->wnd); |
2524 |
|
seamless_send_state(sw->id, sw->state, 0); |
2525 |
|
} |
2526 |
|
|
2527 |
|
if ((xevent.xproperty.atom == g_net_wm_desktop_atom) |
2528 |
|
&& (xevent.xproperty.state == PropertyNewValue)) |
2529 |
|
{ |
2530 |
|
sw->desktop = ewmh_get_window_desktop(sw->wnd); |
2531 |
|
sw_all_to_desktop(sw->wnd, sw->desktop); |
2532 |
|
} |
2533 |
|
|
2534 |
break; |
break; |
2535 |
case MapNotify: |
case MapNotify: |
2536 |
rdp_send_client_window_status(1); |
if (!g_seamless_active) |
2537 |
|
rdp_send_client_window_status(1); |
2538 |
break; |
break; |
2539 |
case UnmapNotify: |
case UnmapNotify: |
2540 |
rdp_send_client_window_status(0); |
if (!g_seamless_active) |
2541 |
|
rdp_send_client_window_status(0); |
2542 |
|
break; |
2543 |
|
case ConfigureNotify: |
2544 |
|
if (!g_seamless_active) |
2545 |
|
break; |
2546 |
|
|
2547 |
|
sw = sw_get_window_by_wnd(xevent.xconfigure.window); |
2548 |
|
if (!sw) |
2549 |
|
break; |
2550 |
|
|
2551 |
|
gettimeofday(sw->position_timer, NULL); |
2552 |
|
if (sw->position_timer->tv_usec + SEAMLESSRDP_POSITION_TIMER >= |
2553 |
|
1000000) |
2554 |
|
{ |
2555 |
|
sw->position_timer->tv_usec += |
2556 |
|
SEAMLESSRDP_POSITION_TIMER - 1000000; |
2557 |
|
sw->position_timer->tv_sec += 1; |
2558 |
|
} |
2559 |
|
else |
2560 |
|
{ |
2561 |
|
sw->position_timer->tv_usec += SEAMLESSRDP_POSITION_TIMER; |
2562 |
|
} |
2563 |
|
|
2564 |
|
sw_handle_restack(sw); |
2565 |
break; |
break; |
2566 |
} |
} |
2567 |
} |
} |
2576 |
int n; |
int n; |
2577 |
fd_set rfds, wfds; |
fd_set rfds, wfds; |
2578 |
struct timeval tv; |
struct timeval tv; |
2579 |
BOOL s_timeout = False; |
RD_BOOL s_timeout = False; |
2580 |
|
|
2581 |
while (True) |
while (True) |
2582 |
{ |
{ |
2586 |
/* User quit */ |
/* User quit */ |
2587 |
return 0; |
return 0; |
2588 |
|
|
2589 |
|
if (g_seamless_active) |
2590 |
|
sw_check_timers(); |
2591 |
|
|
2592 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |
2593 |
FD_ZERO(&wfds); |
FD_ZERO(&wfds); |
2594 |
FD_SET(rdp_socket, &rfds); |
FD_SET(rdp_socket, &rfds); |
2595 |
FD_SET(g_x_socket, &rfds); |
FD_SET(g_x_socket, &rfds); |
2596 |
|
|
|
#ifdef WITH_RDPSND |
|
|
/* FIXME: there should be an API for registering fds */ |
|
|
if (g_dsp_busy) |
|
|
{ |
|
|
FD_SET(g_dsp_fd, &wfds); |
|
|
n = (g_dsp_fd > n) ? g_dsp_fd : n; |
|
|
} |
|
|
#endif |
|
2597 |
/* default timeout */ |
/* default timeout */ |
2598 |
tv.tv_sec = 60; |
tv.tv_sec = 60; |
2599 |
tv.tv_usec = 0; |
tv.tv_usec = 0; |
2600 |
|
|
2601 |
|
#ifdef WITH_RDPSND |
2602 |
|
rdpsnd_add_fds(&n, &rfds, &wfds, &tv); |
2603 |
|
#endif |
2604 |
|
|
2605 |
/* add redirection handles */ |
/* add redirection handles */ |
2606 |
rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout); |
rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout); |
2607 |
|
seamless_select_timeout(&tv); |
2608 |
|
|
2609 |
n++; |
n++; |
2610 |
|
|
2614 |
error("select: %s\n", strerror(errno)); |
error("select: %s\n", strerror(errno)); |
2615 |
|
|
2616 |
case 0: |
case 0: |
2617 |
|
#ifdef WITH_RDPSND |
2618 |
|
rdpsnd_check_fds(&rfds, &wfds); |
2619 |
|
#endif |
2620 |
|
|
2621 |
/* Abort serial read calls */ |
/* Abort serial read calls */ |
2622 |
if (s_timeout) |
if (s_timeout) |
2623 |
rdpdr_check_fds(&rfds, &wfds, (BOOL) True); |
rdpdr_check_fds(&rfds, &wfds, (RD_BOOL) True); |
2624 |
continue; |
continue; |
2625 |
} |
} |
2626 |
|
|
2627 |
rdpdr_check_fds(&rfds, &wfds, (BOOL) False); |
#ifdef WITH_RDPSND |
2628 |
|
rdpsnd_check_fds(&rfds, &wfds); |
2629 |
|
#endif |
2630 |
|
|
2631 |
|
rdpdr_check_fds(&rfds, &wfds, (RD_BOOL) False); |
2632 |
|
|
2633 |
if (FD_ISSET(rdp_socket, &rfds)) |
if (FD_ISSET(rdp_socket, &rfds)) |
2634 |
return 1; |
return 1; |
2635 |
|
|
|
#ifdef WITH_RDPSND |
|
|
if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds)) |
|
|
wave_out_play(); |
|
|
#endif |
|
2636 |
} |
} |
2637 |
} |
} |
2638 |
|
|
2642 |
XWarpPointer(g_display, g_wnd, g_wnd, 0, 0, 0, 0, x, y); |
XWarpPointer(g_display, g_wnd, g_wnd, 0, 0, 0, 0, x, y); |
2643 |
} |
} |
2644 |
|
|
2645 |
HBITMAP |
RD_HBITMAP |
2646 |
ui_create_bitmap(int width, int height, uint8 * data) |
ui_create_bitmap(int width, int height, uint8 * data) |
2647 |
{ |
{ |
2648 |
XImage *image; |
XImage *image; |
2672 |
XFree(image); |
XFree(image); |
2673 |
if (tdata != data) |
if (tdata != data) |
2674 |
xfree(tdata); |
xfree(tdata); |
2675 |
return (HBITMAP) bitmap; |
return (RD_HBITMAP) bitmap; |
2676 |
} |
} |
2677 |
|
|
2678 |
void |
void |
2702 |
{ |
{ |
2703 |
XPutImage(g_display, g_backstore, g_gc, image, 0, 0, x, y, cx, cy); |
XPutImage(g_display, g_backstore, g_gc, image, 0, 0, x, y, cx, cy); |
2704 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
2705 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2706 |
|
(g_display, g_backstore, sw->wnd, g_gc, x, y, cx, cy, |
2707 |
|
x - sw->xoffset, y - sw->yoffset)); |
2708 |
} |
} |
2709 |
else |
else |
2710 |
{ |
{ |
2711 |
XPutImage(g_display, g_wnd, g_gc, image, 0, 0, x, y, cx, cy); |
XPutImage(g_display, g_wnd, g_gc, image, 0, 0, x, y, cx, cy); |
2712 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2713 |
|
(g_display, g_wnd, sw->wnd, g_gc, x, y, cx, cy, |
2714 |
|
x - sw->xoffset, y - sw->yoffset)); |
2715 |
} |
} |
2716 |
|
|
2717 |
XFree(image); |
XFree(image); |
2720 |
} |
} |
2721 |
|
|
2722 |
void |
void |
2723 |
ui_destroy_bitmap(HBITMAP bmp) |
ui_destroy_bitmap(RD_HBITMAP bmp) |
2724 |
{ |
{ |
2725 |
XFreePixmap(g_display, (Pixmap) bmp); |
XFreePixmap(g_display, (Pixmap) bmp); |
2726 |
} |
} |
2727 |
|
|
2728 |
HGLYPH |
RD_HGLYPH |
2729 |
ui_create_glyph(int width, int height, uint8 * data) |
ui_create_glyph(int width, int height, uint8 * data) |
2730 |
{ |
{ |
2731 |
XImage *image; |
XImage *image; |
2747 |
XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height); |
XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height); |
2748 |
|
|
2749 |
XFree(image); |
XFree(image); |
2750 |
return (HGLYPH) bitmap; |
return (RD_HGLYPH) bitmap; |
2751 |
} |
} |
2752 |
|
|
2753 |
void |
void |
2754 |
ui_destroy_glyph(HGLYPH glyph) |
ui_destroy_glyph(RD_HGLYPH glyph) |
2755 |
{ |
{ |
2756 |
XFreePixmap(g_display, (Pixmap) glyph); |
XFreePixmap(g_display, (Pixmap) glyph); |
2757 |
} |
} |
2758 |
|
|
2759 |
HCURSOR |
RD_HCURSOR |
2760 |
ui_create_cursor(unsigned int x, unsigned int y, int width, int height, |
ui_create_cursor(unsigned int x, unsigned int y, int width, int height, |
2761 |
uint8 * andmask, uint8 * xormask) |
uint8 * andmask, uint8 * xormask) |
2762 |
{ |
{ |
2763 |
HGLYPH maskglyph, cursorglyph; |
RD_HGLYPH maskglyph, cursorglyph; |
2764 |
XColor bg, fg; |
XColor bg, fg; |
2765 |
Cursor xcursor; |
Cursor xcursor; |
2766 |
uint8 *cursor, *pcursor; |
uint8 *cursor, *pcursor; |
2824 |
ui_destroy_glyph(cursorglyph); |
ui_destroy_glyph(cursorglyph); |
2825 |
xfree(mask); |
xfree(mask); |
2826 |
xfree(cursor); |
xfree(cursor); |
2827 |
return (HCURSOR) xcursor; |
return (RD_HCURSOR) xcursor; |
2828 |
} |
} |
2829 |
|
|
2830 |
void |
void |
2831 |
ui_set_cursor(HCURSOR cursor) |
ui_set_cursor(RD_HCURSOR cursor) |
2832 |
{ |
{ |
2833 |
g_current_cursor = (Cursor) cursor; |
g_current_cursor = (Cursor) cursor; |
2834 |
XDefineCursor(g_display, g_wnd, g_current_cursor); |
XDefineCursor(g_display, g_wnd, g_current_cursor); |
2835 |
|
ON_ALL_SEAMLESS_WINDOWS(XDefineCursor, (g_display, sw->wnd, g_current_cursor)); |
2836 |
} |
} |
2837 |
|
|
2838 |
void |
void |
2839 |
ui_destroy_cursor(HCURSOR cursor) |
ui_destroy_cursor(RD_HCURSOR cursor) |
2840 |
{ |
{ |
2841 |
XFreeCursor(g_display, (Cursor) cursor); |
XFreeCursor(g_display, (Cursor) cursor); |
2842 |
} |
} |
2854 |
(xc)->flags = DoRed | DoGreen | DoBlue; |
(xc)->flags = DoRed | DoGreen | DoBlue; |
2855 |
|
|
2856 |
|
|
2857 |
HCOLOURMAP |
RD_HCOLOURMAP |
2858 |
ui_create_colourmap(COLOURMAP * colours) |
ui_create_colourmap(COLOURMAP * colours) |
2859 |
{ |
{ |
2860 |
COLOURENTRY *entry; |
COLOURENTRY *entry; |
2950 |
XStoreColors(g_display, map, xcolours, ncolours); |
XStoreColors(g_display, map, xcolours, ncolours); |
2951 |
|
|
2952 |
xfree(xcolours); |
xfree(xcolours); |
2953 |
return (HCOLOURMAP) map; |
return (RD_HCOLOURMAP) map; |
2954 |
} |
} |
2955 |
} |
} |
2956 |
|
|
2957 |
void |
void |
2958 |
ui_destroy_colourmap(HCOLOURMAP map) |
ui_destroy_colourmap(RD_HCOLOURMAP map) |
2959 |
{ |
{ |
2960 |
if (!g_owncolmap) |
if (!g_owncolmap) |
2961 |
xfree(map); |
xfree(map); |
2964 |
} |
} |
2965 |
|
|
2966 |
void |
void |
2967 |
ui_set_colourmap(HCOLOURMAP map) |
ui_set_colourmap(RD_HCOLOURMAP map) |
2968 |
{ |
{ |
2969 |
if (!g_owncolmap) |
if (!g_owncolmap) |
2970 |
{ |
{ |
2974 |
g_colmap = (uint32 *) map; |
g_colmap = (uint32 *) map; |
2975 |
} |
} |
2976 |
else |
else |
2977 |
|
{ |
2978 |
XSetWindowColormap(g_display, g_wnd, (Colormap) map); |
XSetWindowColormap(g_display, g_wnd, (Colormap) map); |
2979 |
|
ON_ALL_SEAMLESS_WINDOWS(XSetWindowColormap, (g_display, sw->wnd, (Colormap) map)); |
2980 |
|
} |
2981 |
} |
} |
2982 |
|
|
2983 |
void |
void |
2984 |
ui_set_clip(int x, int y, int cx, int cy) |
ui_set_clip(int x, int y, int cx, int cy) |
2985 |
{ |
{ |
2986 |
XRectangle rect; |
g_clip_rectangle.x = x; |
2987 |
|
g_clip_rectangle.y = y; |
2988 |
rect.x = x; |
g_clip_rectangle.width = cx; |
2989 |
rect.y = y; |
g_clip_rectangle.height = cy; |
2990 |
rect.width = cx; |
XSetClipRectangles(g_display, g_gc, 0, 0, &g_clip_rectangle, 1, YXBanded); |
|
rect.height = cy; |
|
|
XSetClipRectangles(g_display, g_gc, 0, 0, &rect, 1, YXBanded); |
|
2991 |
} |
} |
2992 |
|
|
2993 |
void |
void |
2994 |
ui_reset_clip(void) |
ui_reset_clip(void) |
2995 |
{ |
{ |
2996 |
XRectangle rect; |
g_clip_rectangle.x = 0; |
2997 |
|
g_clip_rectangle.y = 0; |
2998 |
rect.x = 0; |
g_clip_rectangle.width = g_width; |
2999 |
rect.y = 0; |
g_clip_rectangle.height = g_height; |
3000 |
rect.width = g_width; |
XSetClipRectangles(g_display, g_gc, 0, 0, &g_clip_rectangle, 1, YXBanded); |
|
rect.height = g_height; |
|
|
XSetClipRectangles(g_display, g_gc, 0, 0, &rect, 1, YXBanded); |
|
3001 |
} |
} |
3002 |
|
|
3003 |
void |
void |
3052 |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
3053 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
3054 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
3055 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((RD_HGLYPH) fill); |
3056 |
break; |
break; |
3057 |
|
|
3058 |
case 3: /* Pattern */ |
case 3: /* Pattern */ |
3067 |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
3068 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
3069 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
3070 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((RD_HGLYPH) fill); |
3071 |
break; |
break; |
3072 |
|
|
3073 |
default: |
default: |
3078 |
|
|
3079 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3080 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
3081 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
3082 |
|
(g_display, g_ownbackstore ? g_backstore : g_wnd, sw->wnd, g_gc, |
3083 |
|
x, y, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
3084 |
} |
} |
3085 |
|
|
3086 |
void |
void |
3091 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
3092 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3093 |
{ |
{ |
3094 |
if (g_Unobscured) |
XCopyArea(g_display, g_Unobscured ? g_wnd : g_backstore, |
3095 |
{ |
g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
3096 |
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
|
|
y); |
|
|
} |
|
|
else |
|
|
{ |
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
|
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
|
|
y); |
|
|
} |
|
3097 |
} |
} |
3098 |
else |
else |
3099 |
{ |
{ |
3100 |
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
3101 |
} |
} |
3102 |
|
|
3103 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
3104 |
|
(g_display, g_ownbackstore ? g_backstore : g_wnd, |
3105 |
|
sw->wnd, g_gc, x, y, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
3106 |
|
|
3107 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
3108 |
} |
} |
3109 |
|
|
3110 |
void |
void |
3111 |
ui_memblt(uint8 opcode, |
ui_memblt(uint8 opcode, |
3112 |
/* dest */ int x, int y, int cx, int cy, |
/* dest */ int x, int y, int cx, int cy, |
3113 |
/* src */ HBITMAP src, int srcx, int srcy) |
/* src */ RD_HBITMAP src, int srcx, int srcy) |
3114 |
{ |
{ |
3115 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
3116 |
XCopyArea(g_display, (Pixmap) src, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(g_display, (Pixmap) src, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
3117 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
3118 |
|
(g_display, (Pixmap) src, sw->wnd, g_gc, |
3119 |
|
srcx, srcy, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
3120 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3121 |
XCopyArea(g_display, (Pixmap) src, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(g_display, (Pixmap) src, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
3122 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
3125 |
void |
void |
3126 |
ui_triblt(uint8 opcode, |
ui_triblt(uint8 opcode, |
3127 |
/* dest */ int x, int y, int cx, int cy, |
/* dest */ int x, int y, int cx, int cy, |
3128 |
/* src */ HBITMAP src, int srcx, int srcy, |
/* src */ RD_HBITMAP src, int srcx, int srcy, |
3129 |
/* brush */ BRUSH * brush, int bgcolour, int fgcolour) |
/* brush */ BRUSH * brush, int bgcolour, int fgcolour) |
3130 |
{ |
{ |
3131 |
/* This is potentially difficult to do in general. Until someone |
/* This is potentially difficult to do in general. Until someone |
3163 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
3164 |
SET_FOREGROUND(pen->colour); |
SET_FOREGROUND(pen->colour); |
3165 |
XDrawLine(g_display, g_wnd, g_gc, startx, starty, endx, endy); |
XDrawLine(g_display, g_wnd, g_gc, startx, starty, endx, endy); |
3166 |
|
ON_ALL_SEAMLESS_WINDOWS(XDrawLine, (g_display, sw->wnd, g_gc, |
3167 |
|
startx - sw->xoffset, starty - sw->yoffset, |
3168 |
|
endx - sw->xoffset, endy - sw->yoffset)); |
3169 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3170 |
XDrawLine(g_display, g_backstore, g_gc, startx, starty, endx, endy); |
XDrawLine(g_display, g_backstore, g_gc, startx, starty, endx, endy); |
3171 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
3183 |
void |
void |
3184 |
ui_polygon(uint8 opcode, |
ui_polygon(uint8 opcode, |
3185 |
/* mode */ uint8 fillmode, |
/* mode */ uint8 fillmode, |
3186 |
/* dest */ POINT * point, int npoints, |
/* dest */ RD_POINT * point, int npoints, |
3187 |
/* brush */ BRUSH * brush, int bgcolour, int fgcolour) |
/* brush */ BRUSH * brush, int bgcolour, int fgcolour) |
3188 |
{ |
{ |
3189 |
uint8 style, i, ipattern[8]; |
uint8 style, i, ipattern[8]; |
3226 |
FILL_POLYGON((XPoint *) point, npoints); |
FILL_POLYGON((XPoint *) point, npoints); |
3227 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
3228 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
3229 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((RD_HGLYPH) fill); |
3230 |
break; |
break; |
3231 |
|
|
3232 |
case 3: /* Pattern */ |
case 3: /* Pattern */ |
3241 |
FILL_POLYGON((XPoint *) point, npoints); |
FILL_POLYGON((XPoint *) point, npoints); |
3242 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
3243 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
3244 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((RD_HGLYPH) fill); |
3245 |
break; |
break; |
3246 |
|
|
3247 |
default: |
default: |
3253 |
|
|
3254 |
void |
void |
3255 |
ui_polyline(uint8 opcode, |
ui_polyline(uint8 opcode, |
3256 |
/* dest */ POINT * points, int npoints, |
/* dest */ RD_POINT * points, int npoints, |
3257 |
/* pen */ PEN * pen) |
/* pen */ PEN * pen) |
3258 |
{ |
{ |
3259 |
/* TODO: set join style */ |
/* TODO: set join style */ |
3263 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3264 |
XDrawLines(g_display, g_backstore, g_gc, (XPoint *) points, npoints, |
XDrawLines(g_display, g_backstore, g_gc, (XPoint *) points, npoints, |
3265 |
CoordModePrevious); |
CoordModePrevious); |
3266 |
|
|
3267 |
|
ON_ALL_SEAMLESS_WINDOWS(seamless_XDrawLines, |
3268 |
|
(sw->wnd, (XPoint *) points, npoints, sw->xoffset, sw->yoffset)); |
3269 |
|
|
3270 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
3271 |
} |
} |
3272 |
|
|
3304 |
DRAW_ELLIPSE(x, y, cx, cy, fillmode); |
DRAW_ELLIPSE(x, y, cx, cy, fillmode); |
3305 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
3306 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
3307 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((RD_HGLYPH) fill); |
3308 |
break; |
break; |
3309 |
|
|
3310 |
case 3: /* Pattern */ |
case 3: /* Pattern */ |
3319 |
DRAW_ELLIPSE(x, y, cx, cy, fillmode); |
DRAW_ELLIPSE(x, y, cx, cy, fillmode); |
3320 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
3321 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
3322 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((RD_HGLYPH) fill); |
3323 |
break; |
break; |
3324 |
|
|
3325 |
default: |
default: |
3333 |
void |
void |
3334 |
ui_draw_glyph(int mixmode, |
ui_draw_glyph(int mixmode, |
3335 |
/* dest */ int x, int y, int cx, int cy, |
/* dest */ int x, int y, int cx, int cy, |
3336 |
/* src */ HGLYPH glyph, int srcx, int srcy, |
/* src */ RD_HGLYPH glyph, int srcx, int srcy, |
3337 |
int bgcolour, int fgcolour) |
int bgcolour, int fgcolour) |
3338 |
{ |
{ |
3339 |
SET_FOREGROUND(fgcolour); |
SET_FOREGROUND(fgcolour); |
3487 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3488 |
{ |
{ |
3489 |
if (boxcx > 1) |
if (boxcx > 1) |
3490 |
|
{ |
3491 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, boxx, |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, boxx, |
3492 |
boxy, boxcx, boxcy, boxx, boxy); |
boxy, boxcx, boxcy, boxx, boxy); |
3493 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
3494 |
|
(g_display, g_backstore, sw->wnd, g_gc, |
3495 |
|
boxx, boxy, |
3496 |
|
boxcx, boxcy, |
3497 |
|
boxx - sw->xoffset, boxy - sw->yoffset)); |
3498 |
|
} |
3499 |
else |
else |
3500 |
|
{ |
3501 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, clipx, |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, clipx, |
3502 |
clipy, clipcx, clipcy, clipx, clipy); |
clipy, clipcx, clipcy, clipx, clipy); |
3503 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
3504 |
|
(g_display, g_backstore, sw->wnd, g_gc, |
3505 |
|
clipx, clipy, |
3506 |
|
clipcx, clipcy, clipx - sw->xoffset, |
3507 |
|
clipy - sw->yoffset)); |
3508 |
|
} |
3509 |
} |
} |
3510 |
} |
} |
3511 |
|
|
3518 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3519 |
{ |
{ |
3520 |
image = XGetImage(g_display, g_backstore, x, y, cx, cy, AllPlanes, ZPixmap); |
image = XGetImage(g_display, g_backstore, x, y, cx, cy, AllPlanes, ZPixmap); |
3521 |
|
exit_if_null(image); |
3522 |
} |
} |
3523 |
else |
else |
3524 |
{ |
{ |
3525 |
pix = XCreatePixmap(g_display, g_wnd, cx, cy, g_depth); |
pix = XCreatePixmap(g_display, g_wnd, cx, cy, g_depth); |
3526 |
XCopyArea(g_display, g_wnd, pix, g_gc, x, y, cx, cy, 0, 0); |
XCopyArea(g_display, g_wnd, pix, g_gc, x, y, cx, cy, 0, 0); |
3527 |
image = XGetImage(g_display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap); |
image = XGetImage(g_display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap); |
3528 |
|
exit_if_null(image); |
3529 |
XFreePixmap(g_display, pix); |
XFreePixmap(g_display, pix); |
3530 |
} |
} |
3531 |
|
|
3547 |
return; |
return; |
3548 |
|
|
3549 |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
3550 |
(char *) data, cx, cy, BitmapPad(g_display), cx * g_bpp / 8); |
(char *) data, cx, cy, g_bpp, 0); |
3551 |
|
|
3552 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3553 |
{ |
{ |
3554 |
XPutImage(g_display, g_backstore, g_gc, image, 0, 0, x, y, cx, cy); |
XPutImage(g_display, g_backstore, g_gc, image, 0, 0, x, y, cx, cy); |
3555 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
3556 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
3557 |
|
(g_display, g_backstore, sw->wnd, g_gc, |
3558 |
|
x, y, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
3559 |
} |
} |
3560 |
else |
else |
3561 |
{ |
{ |
3562 |
XPutImage(g_display, g_wnd, g_gc, image, 0, 0, x, y, cx, cy); |
XPutImage(g_display, g_wnd, g_gc, image, 0, 0, x, y, cx, cy); |
3563 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
3564 |
|
(g_display, g_wnd, sw->wnd, g_gc, x, y, cx, cy, |
3565 |
|
x - sw->xoffset, y - sw->yoffset)); |
3566 |
} |
} |
3567 |
|
|
3568 |
XFree(image); |
XFree(image); |
3578 |
ui_end_update(void) |
ui_end_update(void) |
3579 |
{ |
{ |
3580 |
} |
} |
3581 |
|
|
3582 |
|
|
3583 |
|
void |
3584 |
|
ui_seamless_begin(RD_BOOL hidden) |
3585 |
|
{ |
3586 |
|
if (!g_seamless_rdp) |
3587 |
|
return; |
3588 |
|
|
3589 |
|
if (g_seamless_started) |
3590 |
|
return; |
3591 |
|
|
3592 |
|
g_seamless_started = True; |
3593 |
|
g_seamless_hidden = hidden; |
3594 |
|
|
3595 |
|
if (!hidden) |
3596 |
|
ui_seamless_toggle(); |
3597 |
|
} |
3598 |
|
|
3599 |
|
|
3600 |
|
void |
3601 |
|
ui_seamless_hide_desktop() |
3602 |
|
{ |
3603 |
|
if (!g_seamless_rdp) |
3604 |
|
return; |
3605 |
|
|
3606 |
|
if (!g_seamless_started) |
3607 |
|
return; |
3608 |
|
|
3609 |
|
if (g_seamless_active) |
3610 |
|
ui_seamless_toggle(); |
3611 |
|
|
3612 |
|
g_seamless_hidden = True; |
3613 |
|
} |
3614 |
|
|
3615 |
|
|
3616 |
|
void |
3617 |
|
ui_seamless_unhide_desktop() |
3618 |
|
{ |
3619 |
|
if (!g_seamless_rdp) |
3620 |
|
return; |
3621 |
|
|
3622 |
|
if (!g_seamless_started) |
3623 |
|
return; |
3624 |
|
|
3625 |
|
g_seamless_hidden = False; |
3626 |
|
|
3627 |
|
ui_seamless_toggle(); |
3628 |
|
} |
3629 |
|
|
3630 |
|
|
3631 |
|
void |
3632 |
|
ui_seamless_toggle() |
3633 |
|
{ |
3634 |
|
if (!g_seamless_rdp) |
3635 |
|
return; |
3636 |
|
|
3637 |
|
if (!g_seamless_started) |
3638 |
|
return; |
3639 |
|
|
3640 |
|
if (g_seamless_hidden) |
3641 |
|
return; |
3642 |
|
|
3643 |
|
if (g_seamless_active) |
3644 |
|
{ |
3645 |
|
/* Deactivate */ |
3646 |
|
while (g_seamless_windows) |
3647 |
|
{ |
3648 |
|
XDestroyWindow(g_display, g_seamless_windows->wnd); |
3649 |
|
sw_remove_window(g_seamless_windows); |
3650 |
|
} |
3651 |
|
XMapWindow(g_display, g_wnd); |
3652 |
|
} |
3653 |
|
else |
3654 |
|
{ |
3655 |
|
/* Activate */ |
3656 |
|
XUnmapWindow(g_display, g_wnd); |
3657 |
|
seamless_send_sync(); |
3658 |
|
} |
3659 |
|
|
3660 |
|
g_seamless_active = !g_seamless_active; |
3661 |
|
} |
3662 |
|
|
3663 |
|
|
3664 |
|
void |
3665 |
|
ui_seamless_create_window(unsigned long id, unsigned long group, unsigned long parent, |
3666 |
|
unsigned long flags) |
3667 |
|
{ |
3668 |
|
Window wnd; |
3669 |
|
XSetWindowAttributes attribs; |
3670 |
|
XClassHint *classhints; |
3671 |
|
XSizeHints *sizehints; |
3672 |
|
XWMHints *wmhints; |
3673 |
|
long input_mask; |
3674 |
|
seamless_window *sw, *sw_parent; |
3675 |
|
|
3676 |
|
if (!g_seamless_active) |
3677 |
|
return; |
3678 |
|
|
3679 |
|
/* Ignore CREATEs for existing windows */ |
3680 |
|
sw = sw_get_window_by_id(id); |
3681 |
|
if (sw) |
3682 |
|
return; |
3683 |
|
|
3684 |
|
get_window_attribs(&attribs); |
3685 |
|
wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), -1, -1, 1, 1, 0, g_depth, |
3686 |
|
InputOutput, g_visual, |
3687 |
|
CWBackPixel | CWBackingStore | CWColormap | CWBorderPixel, &attribs); |
3688 |
|
|
3689 |
|
XStoreName(g_display, wnd, "SeamlessRDP"); |
3690 |
|
ewmh_set_wm_name(wnd, "SeamlessRDP"); |
3691 |
|
|
3692 |
|
mwm_hide_decorations(wnd); |
3693 |
|
|
3694 |
|
classhints = XAllocClassHint(); |
3695 |
|
if (classhints != NULL) |
3696 |
|
{ |
3697 |
|
classhints->res_name = "rdesktop"; |
3698 |
|
classhints->res_class = "SeamlessRDP"; |
3699 |
|
XSetClassHint(g_display, wnd, classhints); |
3700 |
|
XFree(classhints); |
3701 |
|
} |
3702 |
|
|
3703 |
|
/* WM_NORMAL_HINTS */ |
3704 |
|
sizehints = XAllocSizeHints(); |
3705 |
|
if (sizehints != NULL) |
3706 |
|
{ |
3707 |
|
sizehints->flags = USPosition; |
3708 |
|
XSetWMNormalHints(g_display, wnd, sizehints); |
3709 |
|
XFree(sizehints); |
3710 |
|
} |
3711 |
|
|
3712 |
|
/* Parent-less transient windows */ |
3713 |
|
if (parent == 0xFFFFFFFF) |
3714 |
|
{ |
3715 |
|
XSetTransientForHint(g_display, wnd, RootWindowOfScreen(g_screen)); |
3716 |
|
/* Some buggy wm:s (kwin) do not handle the above, so fake it |
3717 |
|
using some other hints. */ |
3718 |
|
ewmh_set_window_popup(wnd); |
3719 |
|
} |
3720 |
|
/* Normal transient windows */ |
3721 |
|
else if (parent != 0x00000000) |
3722 |
|
{ |
3723 |
|
sw_parent = sw_get_window_by_id(parent); |
3724 |
|
if (sw_parent) |
3725 |
|
XSetTransientForHint(g_display, wnd, sw_parent->wnd); |
3726 |
|
else |
3727 |
|
warning("ui_seamless_create_window: No parent window 0x%lx\n", parent); |
3728 |
|
} |
3729 |
|
|
3730 |
|
if (flags & SEAMLESSRDP_CREATE_MODAL) |
3731 |
|
{ |
3732 |
|
/* We do this to support buggy wm:s (*cough* metacity *cough*) |
3733 |
|
somewhat at least */ |
3734 |
|
if (parent == 0x00000000) |
3735 |
|
XSetTransientForHint(g_display, wnd, RootWindowOfScreen(g_screen)); |
3736 |
|
ewmh_set_window_modal(wnd); |
3737 |
|
} |
3738 |
|
|
3739 |
|
if (flags & SEAMLESSRDP_CREATE_TOPMOST) |
3740 |
|
{ |
3741 |
|
/* Make window always-on-top */ |
3742 |
|
ewmh_set_window_above(wnd); |
3743 |
|
} |
3744 |
|
|
3745 |
|
/* FIXME: Support for Input Context:s */ |
3746 |
|
|
3747 |
|
get_input_mask(&input_mask); |
3748 |
|
input_mask |= PropertyChangeMask; |
3749 |
|
|
3750 |
|
XSelectInput(g_display, wnd, input_mask); |
3751 |
|
|
3752 |
|
/* handle the WM_DELETE_WINDOW protocol. */ |
3753 |
|
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
3754 |
|
|
3755 |
|
sw = xmalloc(sizeof(seamless_window)); |
3756 |
|
|
3757 |
|
memset(sw, 0, sizeof(seamless_window)); |
3758 |
|
|
3759 |
|
sw->wnd = wnd; |
3760 |
|
sw->id = id; |
3761 |
|
sw->group = sw_find_group(group, False); |
3762 |
|
sw->group->refcnt++; |
3763 |
|
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
3764 |
|
sw->desktop = 0; |
3765 |
|
sw->position_timer = xmalloc(sizeof(struct timeval)); |
3766 |
|
timerclear(sw->position_timer); |
3767 |
|
|
3768 |
|
sw->outstanding_position = False; |
3769 |
|
sw->outpos_serial = 0; |
3770 |
|
sw->outpos_xoffset = sw->outpos_yoffset = 0; |
3771 |
|
sw->outpos_width = sw->outpos_height = 0; |
3772 |
|
|
3773 |
|
sw->next = g_seamless_windows; |
3774 |
|
g_seamless_windows = sw; |
3775 |
|
|
3776 |
|
/* WM_HINTS */ |
3777 |
|
wmhints = XAllocWMHints(); |
3778 |
|
if (wmhints) |
3779 |
|
{ |
3780 |
|
wmhints->flags = WindowGroupHint; |
3781 |
|
wmhints->window_group = sw->group->wnd; |
3782 |
|
XSetWMHints(g_display, sw->wnd, wmhints); |
3783 |
|
XFree(wmhints); |
3784 |
|
} |
3785 |
|
} |
3786 |
|
|
3787 |
|
|
3788 |
|
void |
3789 |
|
ui_seamless_destroy_window(unsigned long id, unsigned long flags) |
3790 |
|
{ |
3791 |
|
seamless_window *sw; |
3792 |
|
|
3793 |
|
if (!g_seamless_active) |
3794 |
|
return; |
3795 |
|
|
3796 |
|
sw = sw_get_window_by_id(id); |
3797 |
|
if (!sw) |
3798 |
|
{ |
3799 |
|
warning("ui_seamless_destroy_window: No information for window 0x%lx\n", id); |
3800 |
|
return; |
3801 |
|
} |
3802 |
|
|
3803 |
|
XDestroyWindow(g_display, sw->wnd); |
3804 |
|
sw_remove_window(sw); |
3805 |
|
} |
3806 |
|
|
3807 |
|
|
3808 |
|
void |
3809 |
|
ui_seamless_destroy_group(unsigned long id, unsigned long flags) |
3810 |
|
{ |
3811 |
|
seamless_window *sw, *sw_next; |
3812 |
|
|
3813 |
|
if (!g_seamless_active) |
3814 |
|
return; |
3815 |
|
|
3816 |
|
for (sw = g_seamless_windows; sw; sw = sw_next) |
3817 |
|
{ |
3818 |
|
sw_next = sw->next; |
3819 |
|
|
3820 |
|
if (sw->group->id == id) |
3821 |
|
{ |
3822 |
|
XDestroyWindow(g_display, sw->wnd); |
3823 |
|
sw_remove_window(sw); |
3824 |
|
} |
3825 |
|
} |
3826 |
|
} |
3827 |
|
|
3828 |
|
|
3829 |
|
void |
3830 |
|
ui_seamless_seticon(unsigned long id, const char *format, int width, int height, int chunk, |
3831 |
|
const char *data, int chunk_len) |
3832 |
|
{ |
3833 |
|
seamless_window *sw; |
3834 |
|
|
3835 |
|
if (!g_seamless_active) |
3836 |
|
return; |
3837 |
|
|
3838 |
|
sw = sw_get_window_by_id(id); |
3839 |
|
if (!sw) |
3840 |
|
{ |
3841 |
|
warning("ui_seamless_seticon: No information for window 0x%lx\n", id); |
3842 |
|
return; |
3843 |
|
} |
3844 |
|
|
3845 |
|
if (chunk == 0) |
3846 |
|
{ |
3847 |
|
if (sw->icon_size) |
3848 |
|
warning("ui_seamless_seticon: New icon started before previous completed\n"); |
3849 |
|
|
3850 |
|
if (strcmp(format, "RGBA") != 0) |
3851 |
|
{ |
3852 |
|
warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format); |
3853 |
|
return; |
3854 |
|
} |
3855 |
|
|
3856 |
|
sw->icon_size = width * height * 4; |
3857 |
|
if (sw->icon_size > 32 * 32 * 4) |
3858 |
|
{ |
3859 |
|
warning("ui_seamless_seticon: Icon too large (%d bytes)\n", sw->icon_size); |
3860 |
|
sw->icon_size = 0; |
3861 |
|
return; |
3862 |
|
} |
3863 |
|
|
3864 |
|
sw->icon_offset = 0; |
3865 |
|
} |
3866 |
|
else |
3867 |
|
{ |
3868 |
|
if (!sw->icon_size) |
3869 |
|
return; |
3870 |
|
} |
3871 |
|
|
3872 |
|
if (chunk_len > (sw->icon_size - sw->icon_offset)) |
3873 |
|
{ |
3874 |
|
warning("ui_seamless_seticon: Too large chunk received (%d bytes > %d bytes)\n", |
3875 |
|
chunk_len, sw->icon_size - sw->icon_offset); |
3876 |
|
sw->icon_size = 0; |
3877 |
|
return; |
3878 |
|
} |
3879 |
|
|
3880 |
|
memcpy(sw->icon_buffer + sw->icon_offset, data, chunk_len); |
3881 |
|
sw->icon_offset += chunk_len; |
3882 |
|
|
3883 |
|
if (sw->icon_offset == sw->icon_size) |
3884 |
|
{ |
3885 |
|
ewmh_set_icon(sw->wnd, width, height, sw->icon_buffer); |
3886 |
|
sw->icon_size = 0; |
3887 |
|
} |
3888 |
|
} |
3889 |
|
|
3890 |
|
|
3891 |
|
void |
3892 |
|
ui_seamless_delicon(unsigned long id, const char *format, int width, int height) |
3893 |
|
{ |
3894 |
|
seamless_window *sw; |
3895 |
|
|
3896 |
|
if (!g_seamless_active) |
3897 |
|
return; |
3898 |
|
|
3899 |
|
sw = sw_get_window_by_id(id); |
3900 |
|
if (!sw) |
3901 |
|
{ |
3902 |
|
warning("ui_seamless_seticon: No information for window 0x%lx\n", id); |
3903 |
|
return; |
3904 |
|
} |
3905 |
|
|
3906 |
|
if (strcmp(format, "RGBA") != 0) |
3907 |
|
{ |
3908 |
|
warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format); |
3909 |
|
return; |
3910 |
|
} |
3911 |
|
|
3912 |
|
ewmh_del_icon(sw->wnd, width, height); |
3913 |
|
} |
3914 |
|
|
3915 |
|
|
3916 |
|
void |
3917 |
|
ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags) |
3918 |
|
{ |
3919 |
|
seamless_window *sw; |
3920 |
|
|
3921 |
|
if (!g_seamless_active) |
3922 |
|
return; |
3923 |
|
|
3924 |
|
sw = sw_get_window_by_id(id); |
3925 |
|
if (!sw) |
3926 |
|
{ |
3927 |
|
warning("ui_seamless_move_window: No information for window 0x%lx\n", id); |
3928 |
|
return; |
3929 |
|
} |
3930 |
|
|
3931 |
|
/* We ignore server updates until it has handled our request. */ |
3932 |
|
if (sw->outstanding_position) |
3933 |
|
return; |
3934 |
|
|
3935 |
|
if (!width || !height) |
3936 |
|
/* X11 windows must be at least 1x1 */ |
3937 |
|
return; |
3938 |
|
|
3939 |
|
sw->xoffset = x; |
3940 |
|
sw->yoffset = y; |
3941 |
|
sw->width = width; |
3942 |
|
sw->height = height; |
3943 |
|
|
3944 |
|
/* If we move the window in a maximized state, then KDE won't |
3945 |
|
accept restoration */ |
3946 |
|
switch (sw->state) |
3947 |
|
{ |
3948 |
|
case SEAMLESSRDP_MINIMIZED: |
3949 |
|
case SEAMLESSRDP_MAXIMIZED: |
3950 |
|
return; |
3951 |
|
} |
3952 |
|
|
3953 |
|
/* FIXME: Perhaps use ewmh_net_moveresize_window instead */ |
3954 |
|
XMoveResizeWindow(g_display, sw->wnd, sw->xoffset, sw->yoffset, sw->width, sw->height); |
3955 |
|
} |
3956 |
|
|
3957 |
|
|
3958 |
|
void |
3959 |
|
ui_seamless_restack_window(unsigned long id, unsigned long behind, unsigned long flags) |
3960 |
|
{ |
3961 |
|
seamless_window *sw; |
3962 |
|
XWindowChanges values; |
3963 |
|
unsigned long restack_serial; |
3964 |
|
|
3965 |
|
if (!g_seamless_active) |
3966 |
|
return; |
3967 |
|
|
3968 |
|
sw = sw_get_window_by_id(id); |
3969 |
|
if (!sw) |
3970 |
|
{ |
3971 |
|
warning("ui_seamless_restack_window: No information for window 0x%lx\n", id); |
3972 |
|
return; |
3973 |
|
} |
3974 |
|
|
3975 |
|
if (behind) |
3976 |
|
{ |
3977 |
|
seamless_window *sw_behind; |
3978 |
|
|
3979 |
|
sw_behind = sw_get_window_by_id(behind); |
3980 |
|
if (!sw_behind) |
3981 |
|
{ |
3982 |
|
warning("ui_seamless_restack_window: No information for behind window 0x%lx\n", behind); |
3983 |
|
return; |
3984 |
|
} |
3985 |
|
|
3986 |
|
if (!g_seamless_broken_restack) |
3987 |
|
{ |
3988 |
|
values.stack_mode = Below; |
3989 |
|
values.sibling = sw_behind->wnd; |
3990 |
|
restack_serial = XNextRequest(g_display); |
3991 |
|
XReconfigureWMWindow(g_display, sw->wnd, DefaultScreen(g_display), |
3992 |
|
CWStackMode | CWSibling, &values); |
3993 |
|
sw_wait_configurenotify(sw->wnd, restack_serial); |
3994 |
|
} |
3995 |
|
} |
3996 |
|
else |
3997 |
|
{ |
3998 |
|
values.stack_mode = Above; |
3999 |
|
restack_serial = XNextRequest(g_display); |
4000 |
|
XReconfigureWMWindow(g_display, sw->wnd, DefaultScreen(g_display), CWStackMode, |
4001 |
|
&values); |
4002 |
|
sw_wait_configurenotify(sw->wnd, restack_serial); |
4003 |
|
} |
4004 |
|
|
4005 |
|
sw_restack_window(sw, behind); |
4006 |
|
|
4007 |
|
if (flags & SEAMLESSRDP_CREATE_TOPMOST) |
4008 |
|
{ |
4009 |
|
/* Make window always-on-top */ |
4010 |
|
ewmh_set_window_above(sw->wnd); |
4011 |
|
} |
4012 |
|
} |
4013 |
|
|
4014 |
|
|
4015 |
|
void |
4016 |
|
ui_seamless_settitle(unsigned long id, const char *title, unsigned long flags) |
4017 |
|
{ |
4018 |
|
seamless_window *sw; |
4019 |
|
|
4020 |
|
if (!g_seamless_active) |
4021 |
|
return; |
4022 |
|
|
4023 |
|
sw = sw_get_window_by_id(id); |
4024 |
|
if (!sw) |
4025 |
|
{ |
4026 |
|
warning("ui_seamless_settitle: No information for window 0x%lx\n", id); |
4027 |
|
return; |
4028 |
|
} |
4029 |
|
|
4030 |
|
/* FIXME: Might want to convert the name for non-EWMH WMs */ |
4031 |
|
XStoreName(g_display, sw->wnd, title); |
4032 |
|
ewmh_set_wm_name(sw->wnd, title); |
4033 |
|
} |
4034 |
|
|
4035 |
|
|
4036 |
|
void |
4037 |
|
ui_seamless_setstate(unsigned long id, unsigned int state, unsigned long flags) |
4038 |
|
{ |
4039 |
|
seamless_window *sw; |
4040 |
|
|
4041 |
|
if (!g_seamless_active) |
4042 |
|
return; |
4043 |
|
|
4044 |
|
sw = sw_get_window_by_id(id); |
4045 |
|
if (!sw) |
4046 |
|
{ |
4047 |
|
warning("ui_seamless_setstate: No information for window 0x%lx\n", id); |
4048 |
|
return; |
4049 |
|
} |
4050 |
|
|
4051 |
|
switch (state) |
4052 |
|
{ |
4053 |
|
case SEAMLESSRDP_NORMAL: |
4054 |
|
case SEAMLESSRDP_MAXIMIZED: |
4055 |
|
ewmh_change_state(sw->wnd, state); |
4056 |
|
XMapWindow(g_display, sw->wnd); |
4057 |
|
break; |
4058 |
|
case SEAMLESSRDP_MINIMIZED: |
4059 |
|
/* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN |
4060 |
|
the Window Manager should probably just ignore the request, since |
4061 |
|
_NET_WM_STATE_HIDDEN is a function of some other aspect of the window |
4062 |
|
such as minimization, rather than an independent state." Besides, |
4063 |
|
XIconifyWindow is easier. */ |
4064 |
|
if (sw->state == SEAMLESSRDP_NOTYETMAPPED) |
4065 |
|
{ |
4066 |
|
XWMHints *hints; |
4067 |
|
hints = XGetWMHints(g_display, sw->wnd); |
4068 |
|
if (hints) |
4069 |
|
{ |
4070 |
|
hints->flags |= StateHint; |
4071 |
|
hints->initial_state = IconicState; |
4072 |
|
XSetWMHints(g_display, sw->wnd, hints); |
4073 |
|
XFree(hints); |
4074 |
|
} |
4075 |
|
XMapWindow(g_display, sw->wnd); |
4076 |
|
} |
4077 |
|
else |
4078 |
|
XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display)); |
4079 |
|
break; |
4080 |
|
default: |
4081 |
|
warning("SeamlessRDP: Invalid state %d\n", state); |
4082 |
|
break; |
4083 |
|
} |
4084 |
|
|
4085 |
|
sw->state = state; |
4086 |
|
} |
4087 |
|
|
4088 |
|
|
4089 |
|
void |
4090 |
|
ui_seamless_syncbegin(unsigned long flags) |
4091 |
|
{ |
4092 |
|
if (!g_seamless_active) |
4093 |
|
return; |
4094 |
|
|
4095 |
|
/* Destroy all seamless windows */ |
4096 |
|
while (g_seamless_windows) |
4097 |
|
{ |
4098 |
|
XDestroyWindow(g_display, g_seamless_windows->wnd); |
4099 |
|
sw_remove_window(g_seamless_windows); |
4100 |
|
} |
4101 |
|
} |
4102 |
|
|
4103 |
|
|
4104 |
|
void |
4105 |
|
ui_seamless_ack(unsigned int serial) |
4106 |
|
{ |
4107 |
|
seamless_window *sw; |
4108 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
4109 |
|
{ |
4110 |
|
if (sw->outstanding_position && (sw->outpos_serial == serial)) |
4111 |
|
{ |
4112 |
|
sw->xoffset = sw->outpos_xoffset; |
4113 |
|
sw->yoffset = sw->outpos_yoffset; |
4114 |
|
sw->width = sw->outpos_width; |
4115 |
|
sw->height = sw->outpos_height; |
4116 |
|
sw->outstanding_position = False; |
4117 |
|
|
4118 |
|
/* Do a complete redraw of the window as part of the |
4119 |
|
completion of the move. This is to remove any |
4120 |
|
artifacts caused by our lack of synchronization. */ |
4121 |
|
XCopyArea(g_display, g_backstore, |
4122 |
|
sw->wnd, g_gc, |
4123 |
|
sw->xoffset, sw->yoffset, sw->width, sw->height, 0, 0); |
4124 |
|
|
4125 |
|
break; |
4126 |
|
} |
4127 |
|
} |
4128 |
|
} |