48 |
static int g_x_socket; |
static int g_x_socket; |
49 |
static Screen *g_screen; |
static Screen *g_screen; |
50 |
Window g_wnd; |
Window g_wnd; |
51 |
|
|
52 |
|
/* SeamlessRDP support */ |
53 |
|
typedef struct _seamless_window |
54 |
|
{ |
55 |
|
Window wnd; |
56 |
|
unsigned long id; |
57 |
|
unsigned long parent; |
58 |
|
XWMHints *hints; |
59 |
|
int xoffset, yoffset; |
60 |
|
int width, height; |
61 |
|
int state; /* normal/minimized/maximized. */ |
62 |
|
unsigned int desktop; |
63 |
|
struct _seamless_window *next; |
64 |
|
} seamless_window; |
65 |
|
static seamless_window *g_seamless_windows = NULL; |
66 |
|
extern BOOL g_seamless_rdp; |
67 |
|
|
68 |
extern uint32 g_embed_wnd; |
extern uint32 g_embed_wnd; |
69 |
BOOL g_enable_compose = False; |
BOOL g_enable_compose = False; |
70 |
BOOL g_Unobscured; /* used for screenblt */ |
BOOL g_Unobscured; /* used for screenblt */ |
71 |
static GC g_gc = NULL; |
static GC g_gc = NULL; |
72 |
static GC g_create_bitmap_gc = NULL; |
static GC g_create_bitmap_gc = NULL; |
73 |
static GC g_create_glyph_gc = NULL; |
static GC g_create_glyph_gc = NULL; |
74 |
|
static XRectangle g_clip_rectangle; |
75 |
static Visual *g_visual; |
static Visual *g_visual; |
76 |
/* 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). |
77 |
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 |
87 |
static Cursor g_current_cursor; |
static Cursor g_current_cursor; |
88 |
static HCURSOR g_null_cursor = NULL; |
static HCURSOR g_null_cursor = NULL; |
89 |
static Atom g_protocol_atom, g_kill_atom; |
static Atom g_protocol_atom, g_kill_atom; |
90 |
|
extern Atom g_net_wm_state_atom; |
91 |
|
extern Atom g_net_wm_desktop_atom; |
92 |
static BOOL g_focused; |
static BOOL g_focused; |
93 |
static BOOL g_mouse_in_wnd; |
static BOOL g_mouse_in_wnd; |
94 |
/* Indicates the visual is has 15, 16 or 24 depth |
/* Indicates that: |
95 |
and the same color channel masks as its RDP equivalent. */ |
1) visual has 15, 16 or 24 depth and the same color channel masks |
96 |
static BOOL g_compatible_depth; |
as its RDP equivalent (implies X server is LE), |
97 |
|
2) host is LE |
98 |
|
This will trigger an optimization whose real value is questionable. |
99 |
|
*/ |
100 |
|
static BOOL g_compatible_arch; |
101 |
/* Indicates whether RDP's bitmaps and our XImages have the same |
/* Indicates whether RDP's bitmaps and our XImages have the same |
102 |
binary format. If so, we can avoid an expensive translation. |
binary format. If so, we can avoid an expensive translation. |
103 |
If this is True, so is g_compatible_depth. */ |
Note that this can be true when g_compatible_arch is false, |
104 |
|
e.g.: |
105 |
|
|
106 |
|
RDP(LE) <-> host(BE) <-> X-Server(LE) |
107 |
|
|
108 |
|
('host' is the machine running rdesktop; the host simply memcpy's |
109 |
|
so its endianess doesn't matter) |
110 |
|
*/ |
111 |
static BOOL g_no_translate_image = False; |
static BOOL g_no_translate_image = False; |
112 |
|
|
113 |
/* endianness */ |
/* endianness */ |
153 |
} |
} |
154 |
PixelColour; |
PixelColour; |
155 |
|
|
156 |
|
#define ON_ALL_SEAMLESS_WINDOWS(func, args) \ |
157 |
|
do { \ |
158 |
|
seamless_window *sw; \ |
159 |
|
XRectangle rect; \ |
160 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) { \ |
161 |
|
rect.x = g_clip_rectangle.x - sw->xoffset; \ |
162 |
|
rect.y = g_clip_rectangle.y - sw->yoffset; \ |
163 |
|
rect.width = g_clip_rectangle.width; \ |
164 |
|
rect.height = g_clip_rectangle.height; \ |
165 |
|
XSetClipRectangles(g_display, g_gc, 0, 0, &rect, 1, YXBanded); \ |
166 |
|
func args; \ |
167 |
|
} \ |
168 |
|
XSetClipRectangles(g_display, g_gc, 0, 0, &g_clip_rectangle, 1, YXBanded); \ |
169 |
|
} while (0) |
170 |
|
|
171 |
|
static void |
172 |
|
seamless_XFillPolygon(Drawable d, XPoint * points, int npoints, int xoffset, int yoffset) |
173 |
|
{ |
174 |
|
points[0].x -= xoffset; |
175 |
|
points[0].y -= yoffset; |
176 |
|
XFillPolygon(g_display, d, g_gc, points, npoints, Complex, CoordModePrevious); |
177 |
|
points[0].x += xoffset; |
178 |
|
points[0].y += yoffset; |
179 |
|
} |
180 |
|
|
181 |
|
static void |
182 |
|
seamless_XDrawLines(Drawable d, XPoint * points, int npoints, int xoffset, int yoffset) |
183 |
|
{ |
184 |
|
points[0].x -= xoffset; |
185 |
|
points[0].y -= yoffset; |
186 |
|
XDrawLines(g_display, d, g_gc, points, npoints, CoordModePrevious); |
187 |
|
points[0].x += xoffset; |
188 |
|
points[0].y += yoffset; |
189 |
|
} |
190 |
|
|
191 |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
192 |
{ \ |
{ \ |
193 |
XFillRectangle(g_display, g_wnd, g_gc, x, y, cx, cy); \ |
XFillRectangle(g_display, g_wnd, g_gc, x, y, cx, cy); \ |
194 |
|
ON_ALL_SEAMLESS_WINDOWS(XFillRectangle, (g_display, sw->wnd, g_gc, x-sw->xoffset, y-sw->yoffset, cx, cy)); \ |
195 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
196 |
XFillRectangle(g_display, g_backstore, g_gc, x, y, cx, cy); \ |
XFillRectangle(g_display, g_backstore, g_gc, x, y, cx, cy); \ |
197 |
} |
} |
206 |
XFillPolygon(g_display, g_wnd, g_gc, p, np, Complex, CoordModePrevious); \ |
XFillPolygon(g_display, g_wnd, g_gc, p, np, Complex, CoordModePrevious); \ |
207 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
208 |
XFillPolygon(g_display, g_backstore, g_gc, p, np, Complex, CoordModePrevious); \ |
XFillPolygon(g_display, g_backstore, g_gc, p, np, Complex, CoordModePrevious); \ |
209 |
|
ON_ALL_SEAMLESS_WINDOWS(seamless_XFillPolygon, (sw->wnd, p, np, sw->xoffset, sw->yoffset)); \ |
210 |
} |
} |
211 |
|
|
212 |
#define DRAW_ELLIPSE(x,y,cx,cy,m)\ |
#define DRAW_ELLIPSE(x,y,cx,cy,m)\ |
215 |
{ \ |
{ \ |
216 |
case 0: /* Outline */ \ |
case 0: /* Outline */ \ |
217 |
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); \ |
218 |
|
ON_ALL_SEAMLESS_WINDOWS(XDrawArc, (g_display, sw->wnd, g_gc, x-sw->xoffset, y-sw->yoffset, cx, cy, 0, 360*64)); \ |
219 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
220 |
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); \ |
221 |
break; \ |
break; \ |
222 |
case 1: /* Filled */ \ |
case 1: /* Filled */ \ |
223 |
XFillArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \ |
XFillArc(g_display, g_wnd, g_gc, x, y, \ |
224 |
|
cx, cy, 0, 360*64); \ |
225 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, (g_display, g_ownbackstore ? g_backstore : g_wnd, sw->wnd, g_gc, x, y, cx, cy, x-sw->xoffset, y-sw->yoffset)); \ |
226 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
227 |
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); \ |
228 |
break; \ |
break; \ |
260 |
#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]); } |
261 |
#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); } |
262 |
|
|
263 |
|
static seamless_window * |
264 |
|
seamless_get_window_by_id(unsigned long id) |
265 |
|
{ |
266 |
|
seamless_window *sw; |
267 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
268 |
|
{ |
269 |
|
if (sw->id == id) |
270 |
|
return sw; |
271 |
|
} |
272 |
|
return NULL; |
273 |
|
} |
274 |
|
|
275 |
|
|
276 |
|
static seamless_window * |
277 |
|
seamless_get_window_by_wnd(Window wnd) |
278 |
|
{ |
279 |
|
seamless_window *sw; |
280 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
281 |
|
{ |
282 |
|
if (sw->wnd == wnd) |
283 |
|
return sw; |
284 |
|
} |
285 |
|
return NULL; |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
static void |
290 |
|
seamless_remove_window(seamless_window * win) |
291 |
|
{ |
292 |
|
seamless_window *sw, **prevnext = &g_seamless_windows; |
293 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
294 |
|
{ |
295 |
|
if (sw == win) |
296 |
|
{ |
297 |
|
*prevnext = sw->next; |
298 |
|
XFree(sw->hints); |
299 |
|
xfree(sw); |
300 |
|
return; |
301 |
|
} |
302 |
|
prevnext = &sw->next; |
303 |
|
} |
304 |
|
return; |
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
|
/* Move all windows except wnd to new desktop */ |
309 |
static void |
static void |
310 |
mwm_hide_decorations(void) |
seamless_all_to_desktop(Window wnd, unsigned int desktop) |
311 |
|
{ |
312 |
|
seamless_window *sw; |
313 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
314 |
|
{ |
315 |
|
if (sw->wnd == wnd) |
316 |
|
continue; |
317 |
|
if (sw->desktop != desktop) |
318 |
|
{ |
319 |
|
ewmh_move_to_desktop(sw->wnd, desktop); |
320 |
|
sw->desktop = desktop; |
321 |
|
} |
322 |
|
} |
323 |
|
} |
324 |
|
|
325 |
|
|
326 |
|
static void |
327 |
|
mwm_hide_decorations(Window wnd) |
328 |
{ |
{ |
329 |
PropMotifWmHints motif_hints; |
PropMotifWmHints motif_hints; |
330 |
Atom hintsatom; |
Atom hintsatom; |
341 |
return; |
return; |
342 |
} |
} |
343 |
|
|
344 |
XChangeProperty(g_display, g_wnd, hintsatom, hintsatom, 32, PropModeReplace, |
XChangeProperty(g_display, wnd, hintsatom, hintsatom, 32, PropModeReplace, |
345 |
(unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS); |
(unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS); |
346 |
|
|
347 |
} |
} |
348 |
|
|
349 |
#define SPLITCOLOUR15(colour, rv) \ |
#define SPLITCOLOUR15(colour, rv) \ |
377 |
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ |
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ |
378 |
x = (x << 16) | (x >> 16); } |
x = (x << 16) | (x >> 16); } |
379 |
|
|
380 |
|
/* The following macros output the same octet sequences |
381 |
|
on both BE and LE hosts: */ |
382 |
|
|
383 |
#define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; } |
#define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; } |
384 |
#define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } |
#define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } |
385 |
#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; } |
459 |
{ |
{ |
460 |
uint16 value; |
uint16 value; |
461 |
|
|
462 |
if (g_compatible_depth) |
if (g_compatible_arch) |
463 |
{ |
{ |
464 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
465 |
REPEAT2 |
REPEAT2 |
493 |
{ |
{ |
494 |
uint32 value; |
uint32 value; |
495 |
|
|
496 |
if (g_compatible_depth) |
if (g_compatible_arch) |
497 |
{ |
{ |
498 |
while (out < end) |
while (out < end) |
499 |
{ |
{ |
516 |
{ |
{ |
517 |
uint32 value; |
uint32 value; |
518 |
|
|
519 |
if (g_compatible_depth) |
if (g_compatible_arch) |
520 |
{ |
{ |
521 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
522 |
REPEAT4 |
REPEAT4 |
588 |
uint16 pixel; |
uint16 pixel; |
589 |
PixelColour pc; |
PixelColour pc; |
590 |
|
|
591 |
if (g_compatible_depth) |
if (g_compatible_arch) |
592 |
{ |
{ |
593 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
594 |
REPEAT3 |
REPEAT3 |
638 |
uint32 value; |
uint32 value; |
639 |
PixelColour pc; |
PixelColour pc; |
640 |
|
|
641 |
if (g_compatible_depth) |
if (g_compatible_arch) |
642 |
{ |
{ |
643 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
644 |
REPEAT4 |
REPEAT4 |
746 |
uint16 pixel; |
uint16 pixel; |
747 |
PixelColour pc; |
PixelColour pc; |
748 |
|
|
749 |
if (g_compatible_depth) |
if (g_compatible_arch) |
750 |
{ |
{ |
751 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
752 |
REPEAT3 |
REPEAT3 |
816 |
uint32 value; |
uint32 value; |
817 |
PixelColour pc; |
PixelColour pc; |
818 |
|
|
819 |
if (g_compatible_depth) |
if (g_compatible_arch) |
820 |
{ |
{ |
821 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
822 |
REPEAT4 |
REPEAT4 |
945 |
uint32 value; |
uint32 value; |
946 |
PixelColour pc; |
PixelColour pc; |
947 |
|
|
948 |
if (g_compatible_depth) |
if (g_compatible_arch) |
949 |
{ |
{ |
950 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
951 |
#ifdef NEED_ALIGN |
#ifdef NEED_ALIGN |
1158 |
vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &visuals_count); |
vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &visuals_count); |
1159 |
g_visual = NULL; |
g_visual = NULL; |
1160 |
g_no_translate_image = False; |
g_no_translate_image = False; |
1161 |
g_compatible_depth = False; |
g_compatible_arch = False; |
1162 |
if (vmatches != NULL) |
if (vmatches != NULL) |
1163 |
{ |
{ |
1164 |
for (i = 0; i < visuals_count; ++i) |
for (i = 0; i < visuals_count; ++i) |
1185 |
{ |
{ |
1186 |
g_visual = visual_info->visual; |
g_visual = visual_info->visual; |
1187 |
g_depth = visual_info->depth; |
g_depth = visual_info->depth; |
1188 |
g_compatible_depth = True; |
g_compatible_arch = !g_host_be; |
1189 |
g_no_translate_image = (visual_info->depth == g_server_depth); |
g_no_translate_image = (visual_info->depth == g_server_depth); |
1190 |
if (g_no_translate_image) |
if (g_no_translate_image) |
1191 |
/* We found the best visual */ |
/* We found the best visual */ |
1193 |
} |
} |
1194 |
else |
else |
1195 |
{ |
{ |
1196 |
g_compatible_depth = False; |
g_compatible_arch = False; |
1197 |
} |
} |
1198 |
|
|
1199 |
if (visual_info->depth > 24) |
if (visual_info->depth > 24) |
1382 |
{ |
{ |
1383 |
g_width = WidthOfScreen(g_screen); |
g_width = WidthOfScreen(g_screen); |
1384 |
g_height = HeightOfScreen(g_screen); |
g_height = HeightOfScreen(g_screen); |
1385 |
|
g_using_full_workarea = True; |
1386 |
} |
} |
1387 |
else if (g_width < 0) |
else if (g_width < 0) |
1388 |
{ |
{ |
1396 |
{ |
{ |
1397 |
/* Fetch geometry from _NET_WORKAREA */ |
/* Fetch geometry from _NET_WORKAREA */ |
1398 |
uint32 x, y, cx, cy; |
uint32 x, y, cx, cy; |
|
g_using_full_workarea = True; |
|
|
|
|
1399 |
if (get_current_workarea(&x, &y, &cx, &cy) == 0) |
if (get_current_workarea(&x, &y, &cx, &cy) == 0) |
1400 |
{ |
{ |
1401 |
g_width = cx; |
g_width = cx; |
1402 |
g_height = cy; |
g_height = cy; |
1403 |
|
g_using_full_workarea = True; |
1404 |
} |
} |
1405 |
else |
else |
1406 |
{ |
{ |
1407 |
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"); |
1408 |
g_width = 800; |
g_width = WidthOfScreen(g_screen); |
1409 |
g_height = 600; |
g_height = HeightOfScreen(g_screen); |
1410 |
} |
} |
1411 |
} |
} |
1412 |
|
|
1421 |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
1422 |
|
|
1423 |
xclip_init(); |
xclip_init(); |
1424 |
|
ewmh_init(); |
1425 |
|
if (g_seamless_rdp) |
1426 |
|
seamless_init(); |
1427 |
|
|
1428 |
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)); |
1429 |
|
|
1449 |
g_display = NULL; |
g_display = NULL; |
1450 |
} |
} |
1451 |
|
|
1452 |
|
|
1453 |
|
static void |
1454 |
|
get_window_attribs(XSetWindowAttributes * attribs) |
1455 |
|
{ |
1456 |
|
attribs->background_pixel = BlackPixelOfScreen(g_screen); |
1457 |
|
attribs->background_pixel = WhitePixelOfScreen(g_screen); |
1458 |
|
attribs->border_pixel = WhitePixelOfScreen(g_screen); |
1459 |
|
attribs->backing_store = g_ownbackstore ? NotUseful : Always; |
1460 |
|
attribs->override_redirect = g_fullscreen; |
1461 |
|
attribs->colormap = g_xcolmap; |
1462 |
|
} |
1463 |
|
|
1464 |
|
static void |
1465 |
|
get_input_mask(long *input_mask) |
1466 |
|
{ |
1467 |
|
*input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
1468 |
|
VisibilityChangeMask | FocusChangeMask | StructureNotifyMask; |
1469 |
|
|
1470 |
|
if (g_sendmotion) |
1471 |
|
*input_mask |= PointerMotionMask; |
1472 |
|
if (g_ownbackstore) |
1473 |
|
*input_mask |= ExposureMask; |
1474 |
|
if (g_fullscreen || g_grab_keyboard) |
1475 |
|
*input_mask |= EnterWindowMask; |
1476 |
|
if (g_grab_keyboard) |
1477 |
|
*input_mask |= LeaveWindowMask; |
1478 |
|
} |
1479 |
|
|
1480 |
BOOL |
BOOL |
1481 |
ui_create_window(void) |
ui_create_window(void) |
1482 |
{ |
{ |
1499 |
if (g_ypos < 0 || (g_ypos == 0 && (g_pos & 4))) |
if (g_ypos < 0 || (g_ypos == 0 && (g_pos & 4))) |
1500 |
g_ypos = HeightOfScreen(g_screen) + g_ypos - g_height; |
g_ypos = HeightOfScreen(g_screen) + g_ypos - g_height; |
1501 |
|
|
1502 |
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; |
|
1503 |
|
|
1504 |
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, |
1505 |
wndheight, 0, g_depth, InputOutput, g_visual, |
wndheight, 0, g_depth, InputOutput, g_visual, |
1507 |
CWBorderPixel, &attribs); |
CWBorderPixel, &attribs); |
1508 |
|
|
1509 |
if (g_gc == NULL) |
if (g_gc == NULL) |
1510 |
|
{ |
1511 |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
1512 |
|
ui_reset_clip(); |
1513 |
|
} |
1514 |
|
|
1515 |
if (g_create_bitmap_gc == NULL) |
if (g_create_bitmap_gc == NULL) |
1516 |
g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
1527 |
XStoreName(g_display, g_wnd, g_title); |
XStoreName(g_display, g_wnd, g_title); |
1528 |
|
|
1529 |
if (g_hide_decorations) |
if (g_hide_decorations) |
1530 |
mwm_hide_decorations(); |
mwm_hide_decorations(g_wnd); |
1531 |
|
|
1532 |
classhints = XAllocClassHint(); |
classhints = XAllocClassHint(); |
1533 |
if (classhints != NULL) |
if (classhints != NULL) |
1554 |
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); |
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); |
1555 |
} |
} |
1556 |
|
|
1557 |
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; |
|
1558 |
|
|
1559 |
if (g_IM != NULL) |
if (g_IM != NULL) |
1560 |
{ |
{ |
1567 |
} |
} |
1568 |
|
|
1569 |
XSelectInput(g_display, g_wnd, input_mask); |
XSelectInput(g_display, g_wnd, input_mask); |
1570 |
XMapWindow(g_display, g_wnd); |
if (!g_seamless_rdp) |
|
|
|
|
/* wait for VisibilityNotify */ |
|
|
do |
|
1571 |
{ |
{ |
1572 |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
XMapWindow(g_display, g_wnd); |
1573 |
|
/* wait for VisibilityNotify */ |
1574 |
|
do |
1575 |
|
{ |
1576 |
|
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
1577 |
|
} |
1578 |
|
while (xevent.type != VisibilityNotify); |
1579 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1580 |
} |
} |
|
while (xevent.type != VisibilityNotify); |
|
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
|
1581 |
|
|
1582 |
g_focused = False; |
g_focused = False; |
1583 |
g_mouse_in_wnd = False; |
g_mouse_in_wnd = False; |
1641 |
{ |
{ |
1642 |
Pixmap contents = 0; |
Pixmap contents = 0; |
1643 |
|
|
1644 |
|
if (g_seamless_rdp) |
1645 |
|
/* Turn off SeamlessRDP mode */ |
1646 |
|
ui_seamless_toggle(); |
1647 |
|
|
1648 |
if (!g_ownbackstore) |
if (!g_ownbackstore) |
1649 |
{ |
{ |
1650 |
/* need to save contents of window */ |
/* need to save contents of window */ |
1733 |
} |
} |
1734 |
} |
} |
1735 |
|
|
1736 |
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
if (xevent.xmotion.window == g_wnd) |
1737 |
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
{ |
1738 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
1739 |
|
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
1740 |
|
} |
1741 |
|
else |
1742 |
|
{ |
1743 |
|
/* SeamlessRDP */ |
1744 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
1745 |
|
flags | button, xevent.xbutton.x_root, xevent.xbutton.y_root); |
1746 |
|
} |
1747 |
} |
} |
1748 |
|
|
1749 |
/* Process events in Xlib queue |
/* Process events in Xlib queue |
1757 |
char str[256]; |
char str[256]; |
1758 |
Status status; |
Status status; |
1759 |
int events = 0; |
int events = 0; |
1760 |
|
seamless_window *sw; |
1761 |
|
|
1762 |
while ((XPending(g_display) > 0) && events++ < 20) |
while ((XPending(g_display) > 0) && events++ < 20) |
1763 |
{ |
{ |
1772 |
switch (xevent.type) |
switch (xevent.type) |
1773 |
{ |
{ |
1774 |
case VisibilityNotify: |
case VisibilityNotify: |
1775 |
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
if (xevent.xvisibility.window == g_wnd) |
1776 |
|
g_Unobscured = |
1777 |
|
xevent.xvisibility.state == VisibilityUnobscured; |
1778 |
|
|
1779 |
break; |
break; |
1780 |
case ClientMessage: |
case ClientMessage: |
1781 |
/* the window manager told us to quit */ |
/* the window manager told us to quit */ |
1855 |
if (g_fullscreen && !g_focused) |
if (g_fullscreen && !g_focused) |
1856 |
XSetInputFocus(g_display, g_wnd, RevertToPointerRoot, |
XSetInputFocus(g_display, g_wnd, RevertToPointerRoot, |
1857 |
CurrentTime); |
CurrentTime); |
1858 |
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
|
1859 |
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); |
if (xevent.xmotion.window == g_wnd) |
1860 |
|
{ |
1861 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, |
1862 |
|
xevent.xmotion.x, xevent.xmotion.y); |
1863 |
|
} |
1864 |
|
else |
1865 |
|
{ |
1866 |
|
/* SeamlessRDP */ |
1867 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, |
1868 |
|
xevent.xmotion.x_root, |
1869 |
|
xevent.xmotion.y_root); |
1870 |
|
} |
1871 |
break; |
break; |
1872 |
|
|
1873 |
case FocusIn: |
case FocusIn: |
1910 |
break; |
break; |
1911 |
|
|
1912 |
case Expose: |
case Expose: |
1913 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, |
if (xevent.xexpose.window == g_wnd) |
1914 |
xevent.xexpose.x, xevent.xexpose.y, |
{ |
1915 |
xevent.xexpose.width, |
XCopyArea(g_display, g_backstore, xevent.xexpose.window, |
1916 |
xevent.xexpose.height, |
g_gc, |
1917 |
xevent.xexpose.x, xevent.xexpose.y); |
xevent.xexpose.x, xevent.xexpose.y, |
1918 |
|
xevent.xexpose.width, xevent.xexpose.height, |
1919 |
|
xevent.xexpose.x, xevent.xexpose.y); |
1920 |
|
} |
1921 |
|
else |
1922 |
|
{ |
1923 |
|
sw = seamless_get_window_by_wnd(xevent.xexpose.window); |
1924 |
|
if (sw) |
1925 |
|
XCopyArea(g_display, g_backstore, |
1926 |
|
xevent.xexpose.window, g_gc, |
1927 |
|
xevent.xexpose.x + sw->xoffset, |
1928 |
|
xevent.xexpose.y + sw->yoffset, |
1929 |
|
xevent.xexpose.width, |
1930 |
|
xevent.xexpose.height, xevent.xexpose.x, |
1931 |
|
xevent.xexpose.y); |
1932 |
|
else |
1933 |
|
{ |
1934 |
|
error("Expose for unknown window 0x%lx\n", |
1935 |
|
xevent.xexpose.window); |
1936 |
|
} |
1937 |
|
} |
1938 |
|
|
1939 |
break; |
break; |
1940 |
|
|
1941 |
case MappingNotify: |
case MappingNotify: |
1964 |
break; |
break; |
1965 |
case PropertyNotify: |
case PropertyNotify: |
1966 |
xclip_handle_PropertyNotify(&xevent.xproperty); |
xclip_handle_PropertyNotify(&xevent.xproperty); |
1967 |
|
if (xevent.xproperty.window == g_wnd) |
1968 |
|
break; |
1969 |
|
if (xevent.xproperty.window == DefaultRootWindow(g_display)) |
1970 |
|
break; |
1971 |
|
|
1972 |
|
/* seamless */ |
1973 |
|
sw = seamless_get_window_by_wnd(xevent.xproperty.window); |
1974 |
|
if (!sw) |
1975 |
|
break; |
1976 |
|
|
1977 |
|
if ((xevent.xproperty.atom == g_net_wm_state_atom) |
1978 |
|
&& (xevent.xproperty.state == PropertyNewValue)) |
1979 |
|
{ |
1980 |
|
sw->state = ewmh_get_window_state(sw->wnd); |
1981 |
|
seamless_send_state(sw->id, sw->state, 0); |
1982 |
|
} |
1983 |
|
|
1984 |
|
if ((xevent.xproperty.atom == g_net_wm_desktop_atom) |
1985 |
|
&& (xevent.xproperty.state == PropertyNewValue)) |
1986 |
|
{ |
1987 |
|
sw->desktop = ewmh_get_window_desktop(sw->wnd); |
1988 |
|
seamless_all_to_desktop(sw->wnd, sw->desktop); |
1989 |
|
} |
1990 |
|
|
1991 |
break; |
break; |
1992 |
case MapNotify: |
case MapNotify: |
1993 |
rdp_send_client_window_status(1); |
if (!g_seamless_rdp) |
1994 |
|
rdp_send_client_window_status(1); |
1995 |
break; |
break; |
1996 |
case UnmapNotify: |
case UnmapNotify: |
1997 |
rdp_send_client_window_status(0); |
if (!g_seamless_rdp) |
1998 |
|
rdp_send_client_window_status(0); |
1999 |
break; |
break; |
2000 |
} |
} |
2001 |
} |
} |
2132 |
{ |
{ |
2133 |
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); |
2134 |
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); |
2135 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2136 |
|
(g_display, g_backstore, sw->wnd, g_gc, x, y, cx, cy, |
2137 |
|
x - sw->xoffset, y - sw->yoffset)); |
2138 |
} |
} |
2139 |
else |
else |
2140 |
{ |
{ |
2141 |
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); |
2142 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2143 |
|
(g_display, g_wnd, sw->wnd, g_gc, x, y, cx, cy, |
2144 |
|
x - sw->xoffset, y - sw->yoffset)); |
2145 |
} |
} |
2146 |
|
|
2147 |
XFree(image); |
XFree(image); |
2262 |
{ |
{ |
2263 |
g_current_cursor = (Cursor) cursor; |
g_current_cursor = (Cursor) cursor; |
2264 |
XDefineCursor(g_display, g_wnd, g_current_cursor); |
XDefineCursor(g_display, g_wnd, g_current_cursor); |
2265 |
|
ON_ALL_SEAMLESS_WINDOWS(XDefineCursor, (g_display, sw->wnd, g_current_cursor)); |
2266 |
} |
} |
2267 |
|
|
2268 |
void |
void |
2404 |
g_colmap = (uint32 *) map; |
g_colmap = (uint32 *) map; |
2405 |
} |
} |
2406 |
else |
else |
2407 |
|
{ |
2408 |
XSetWindowColormap(g_display, g_wnd, (Colormap) map); |
XSetWindowColormap(g_display, g_wnd, (Colormap) map); |
2409 |
|
ON_ALL_SEAMLESS_WINDOWS(XSetWindowColormap, (g_display, sw->wnd, (Colormap) map)); |
2410 |
|
} |
2411 |
} |
} |
2412 |
|
|
2413 |
void |
void |
2414 |
ui_set_clip(int x, int y, int cx, int cy) |
ui_set_clip(int x, int y, int cx, int cy) |
2415 |
{ |
{ |
2416 |
XRectangle rect; |
g_clip_rectangle.x = x; |
2417 |
|
g_clip_rectangle.y = y; |
2418 |
rect.x = x; |
g_clip_rectangle.width = cx; |
2419 |
rect.y = y; |
g_clip_rectangle.height = cy; |
2420 |
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); |
|
2421 |
} |
} |
2422 |
|
|
2423 |
void |
void |
2424 |
ui_reset_clip(void) |
ui_reset_clip(void) |
2425 |
{ |
{ |
2426 |
XRectangle rect; |
g_clip_rectangle.x = 0; |
2427 |
|
g_clip_rectangle.y = 0; |
2428 |
rect.x = 0; |
g_clip_rectangle.width = g_width; |
2429 |
rect.y = 0; |
g_clip_rectangle.height = g_height; |
2430 |
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); |
|
2431 |
} |
} |
2432 |
|
|
2433 |
void |
void |
2508 |
|
|
2509 |
if (g_ownbackstore) |
if (g_ownbackstore) |
2510 |
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); |
2511 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2512 |
|
(g_display, g_ownbackstore ? g_backstore : g_wnd, sw->wnd, g_gc, |
2513 |
|
x, y, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
2514 |
} |
} |
2515 |
|
|
2516 |
void |
void |
2521 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
2522 |
if (g_ownbackstore) |
if (g_ownbackstore) |
2523 |
{ |
{ |
2524 |
if (g_Unobscured) |
XCopyArea(g_display, g_Unobscured ? g_wnd : g_backstore, |
2525 |
{ |
g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
2526 |
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); |
|
|
} |
|
2527 |
} |
} |
2528 |
else |
else |
2529 |
{ |
{ |
2530 |
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); |
2531 |
} |
} |
2532 |
|
|
2533 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2534 |
|
(g_display, g_ownbackstore ? g_backstore : g_wnd, |
2535 |
|
sw->wnd, g_gc, x, y, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
2536 |
|
|
2537 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
2538 |
} |
} |
2539 |
|
|
2544 |
{ |
{ |
2545 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
2546 |
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); |
2547 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2548 |
|
(g_display, (Pixmap) src, sw->wnd, g_gc, |
2549 |
|
srcx, srcy, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
2550 |
if (g_ownbackstore) |
if (g_ownbackstore) |
2551 |
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); |
2552 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
2593 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
2594 |
SET_FOREGROUND(pen->colour); |
SET_FOREGROUND(pen->colour); |
2595 |
XDrawLine(g_display, g_wnd, g_gc, startx, starty, endx, endy); |
XDrawLine(g_display, g_wnd, g_gc, startx, starty, endx, endy); |
2596 |
|
ON_ALL_SEAMLESS_WINDOWS(XDrawLine, (g_display, sw->wnd, g_gc, |
2597 |
|
startx - sw->xoffset, starty - sw->yoffset, |
2598 |
|
endx - sw->xoffset, endy - sw->yoffset)); |
2599 |
if (g_ownbackstore) |
if (g_ownbackstore) |
2600 |
XDrawLine(g_display, g_backstore, g_gc, startx, starty, endx, endy); |
XDrawLine(g_display, g_backstore, g_gc, startx, starty, endx, endy); |
2601 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
2693 |
if (g_ownbackstore) |
if (g_ownbackstore) |
2694 |
XDrawLines(g_display, g_backstore, g_gc, (XPoint *) points, npoints, |
XDrawLines(g_display, g_backstore, g_gc, (XPoint *) points, npoints, |
2695 |
CoordModePrevious); |
CoordModePrevious); |
2696 |
|
|
2697 |
|
ON_ALL_SEAMLESS_WINDOWS(seamless_XDrawLines, |
2698 |
|
(sw->wnd, (XPoint *) points, npoints, sw->xoffset, sw->yoffset)); |
2699 |
|
|
2700 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
2701 |
} |
} |
2702 |
|
|
2917 |
if (g_ownbackstore) |
if (g_ownbackstore) |
2918 |
{ |
{ |
2919 |
if (boxcx > 1) |
if (boxcx > 1) |
2920 |
|
{ |
2921 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, boxx, |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, boxx, |
2922 |
boxy, boxcx, boxcy, boxx, boxy); |
boxy, boxcx, boxcy, boxx, boxy); |
2923 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2924 |
|
(g_display, g_backstore, sw->wnd, g_gc, |
2925 |
|
boxx, boxy, |
2926 |
|
boxcx, boxcy, |
2927 |
|
boxx - sw->xoffset, boxy - sw->yoffset)); |
2928 |
|
} |
2929 |
else |
else |
2930 |
|
{ |
2931 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, clipx, |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, clipx, |
2932 |
clipy, clipcx, clipcy, clipx, clipy); |
clipy, clipcx, clipcy, clipx, clipy); |
2933 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2934 |
|
(g_display, g_backstore, sw->wnd, g_gc, |
2935 |
|
clipx, clipy, |
2936 |
|
clipcx, clipcy, clipx - sw->xoffset, |
2937 |
|
clipy - sw->yoffset)); |
2938 |
|
} |
2939 |
} |
} |
2940 |
} |
} |
2941 |
|
|
2981 |
{ |
{ |
2982 |
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); |
2983 |
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); |
2984 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2985 |
|
(g_display, g_backstore, sw->wnd, g_gc, |
2986 |
|
x, y, cx, cy, x - sw->xoffset, y - sw->yoffset)); |
2987 |
} |
} |
2988 |
else |
else |
2989 |
{ |
{ |
2990 |
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); |
2991 |
|
ON_ALL_SEAMLESS_WINDOWS(XCopyArea, |
2992 |
|
(g_display, g_wnd, sw->wnd, g_gc, x, y, cx, cy, |
2993 |
|
x - sw->xoffset, y - sw->yoffset)); |
2994 |
} |
} |
2995 |
|
|
2996 |
XFree(image); |
XFree(image); |
3006 |
ui_end_update(void) |
ui_end_update(void) |
3007 |
{ |
{ |
3008 |
} |
} |
3009 |
|
|
3010 |
|
void |
3011 |
|
ui_seamless_toggle() |
3012 |
|
{ |
3013 |
|
if (g_seamless_rdp) |
3014 |
|
{ |
3015 |
|
/* Deactivate */ |
3016 |
|
while (g_seamless_windows) |
3017 |
|
{ |
3018 |
|
XDestroyWindow(g_display, g_seamless_windows->wnd); |
3019 |
|
seamless_remove_window(g_seamless_windows); |
3020 |
|
} |
3021 |
|
XMapWindow(g_display, g_wnd); |
3022 |
|
} |
3023 |
|
else |
3024 |
|
{ |
3025 |
|
/* Activate */ |
3026 |
|
if (g_win_button_size) |
3027 |
|
{ |
3028 |
|
error("SeamlessRDP mode cannot be activated when using single application mode\n"); |
3029 |
|
return; |
3030 |
|
} |
3031 |
|
if (!g_using_full_workarea) |
3032 |
|
{ |
3033 |
|
error("SeamlessRDP mode requires a session that covers the whole screen"); |
3034 |
|
return; |
3035 |
|
} |
3036 |
|
|
3037 |
|
XUnmapWindow(g_display, g_wnd); |
3038 |
|
seamless_send_sync(); |
3039 |
|
} |
3040 |
|
|
3041 |
|
g_seamless_rdp = !g_seamless_rdp; |
3042 |
|
} |
3043 |
|
|
3044 |
|
void |
3045 |
|
ui_seamless_create_window(unsigned long id, unsigned long parent, unsigned long flags) |
3046 |
|
{ |
3047 |
|
Window wnd; |
3048 |
|
XSetWindowAttributes attribs; |
3049 |
|
XClassHint *classhints; |
3050 |
|
XSizeHints *sizehints; |
3051 |
|
long input_mask; |
3052 |
|
seamless_window *sw, *sw_parent; |
3053 |
|
|
3054 |
|
/* Ignore CREATEs for existing windows */ |
3055 |
|
sw = seamless_get_window_by_id(id); |
3056 |
|
if (sw) |
3057 |
|
return; |
3058 |
|
|
3059 |
|
get_window_attribs(&attribs); |
3060 |
|
attribs.override_redirect = False; |
3061 |
|
|
3062 |
|
wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), -1, -1, 1, 1, 0, g_depth, |
3063 |
|
InputOutput, g_visual, |
3064 |
|
CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | |
3065 |
|
CWBorderPixel, &attribs); |
3066 |
|
|
3067 |
|
XStoreName(g_display, wnd, "SeamlessRDP"); |
3068 |
|
ewmh_set_wm_name(wnd, "SeamlessRDP"); |
3069 |
|
|
3070 |
|
mwm_hide_decorations(wnd); |
3071 |
|
|
3072 |
|
classhints = XAllocClassHint(); |
3073 |
|
if (classhints != NULL) |
3074 |
|
{ |
3075 |
|
classhints->res_name = "rdesktop"; |
3076 |
|
classhints->res_class = "SeamlessRDP"; |
3077 |
|
XSetClassHint(g_display, wnd, classhints); |
3078 |
|
XFree(classhints); |
3079 |
|
} |
3080 |
|
|
3081 |
|
/* WM_NORMAL_HINTS */ |
3082 |
|
sizehints = XAllocSizeHints(); |
3083 |
|
if (sizehints != NULL) |
3084 |
|
{ |
3085 |
|
sizehints->flags = USPosition; |
3086 |
|
XSetWMNormalHints(g_display, wnd, sizehints); |
3087 |
|
XFree(sizehints); |
3088 |
|
} |
3089 |
|
|
3090 |
|
/* Set WM_TRANSIENT_FOR, if necessary */ |
3091 |
|
if ((parent != 0x00000000) && (parent != 0xFFFFFFFF)) |
3092 |
|
{ |
3093 |
|
sw_parent = seamless_get_window_by_id(parent); |
3094 |
|
if (sw_parent) |
3095 |
|
XSetTransientForHint(g_display, wnd, sw_parent->wnd); |
3096 |
|
else |
3097 |
|
warning("ui_seamless_create_window: No parent window 0x%lx\n", parent); |
3098 |
|
} |
3099 |
|
|
3100 |
|
|
3101 |
|
/* FIXME: Support for Input Context:s */ |
3102 |
|
|
3103 |
|
get_input_mask(&input_mask); |
3104 |
|
input_mask |= PropertyChangeMask; |
3105 |
|
|
3106 |
|
XSelectInput(g_display, wnd, input_mask); |
3107 |
|
|
3108 |
|
/* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a |
3109 |
|
seamless window, we could try to close the window on the |
3110 |
|
serverside, instead of terminating rdesktop */ |
3111 |
|
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
3112 |
|
|
3113 |
|
sw = malloc(sizeof(seamless_window)); |
3114 |
|
sw->wnd = wnd; |
3115 |
|
sw->id = id; |
3116 |
|
sw->parent = parent; |
3117 |
|
sw->hints = XAllocWMHints(); |
3118 |
|
sw->hints->flags = 0; |
3119 |
|
sw->xoffset = 0; |
3120 |
|
sw->yoffset = 0; |
3121 |
|
sw->width = 0; |
3122 |
|
sw->height = 0; |
3123 |
|
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
3124 |
|
sw->desktop = 0; |
3125 |
|
sw->next = g_seamless_windows; |
3126 |
|
g_seamless_windows = sw; |
3127 |
|
} |
3128 |
|
|
3129 |
|
|
3130 |
|
void |
3131 |
|
ui_seamless_destroy_window(unsigned long id, unsigned long flags) |
3132 |
|
{ |
3133 |
|
seamless_window *sw; |
3134 |
|
|
3135 |
|
sw = seamless_get_window_by_id(id); |
3136 |
|
if (!sw) |
3137 |
|
{ |
3138 |
|
warning("ui_seamless_destroy_window: No information for window 0x%lx\n", id); |
3139 |
|
return; |
3140 |
|
} |
3141 |
|
|
3142 |
|
XDestroyWindow(g_display, sw->wnd); |
3143 |
|
seamless_remove_window(sw); |
3144 |
|
} |
3145 |
|
|
3146 |
|
|
3147 |
|
void |
3148 |
|
ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags) |
3149 |
|
{ |
3150 |
|
seamless_window *sw; |
3151 |
|
|
3152 |
|
sw = seamless_get_window_by_id(id); |
3153 |
|
if (!sw) |
3154 |
|
{ |
3155 |
|
warning("ui_seamless_move_window: No information for window 0x%lx\n", id); |
3156 |
|
return; |
3157 |
|
} |
3158 |
|
|
3159 |
|
if (!width || !height) |
3160 |
|
/* X11 windows must be at least 1x1 */ |
3161 |
|
return; |
3162 |
|
|
3163 |
|
/* About MAX and MIN: Windows allows moving a window outside |
3164 |
|
the desktop. This happens, for example, when maximizing an |
3165 |
|
application. In this case, the position is set to something |
3166 |
|
like -4,-4,1288,1032. Many WMs does not allow windows |
3167 |
|
outside the desktop, however. Therefore, clip the window |
3168 |
|
ourselves. */ |
3169 |
|
sw->xoffset = MAX(0, x); |
3170 |
|
sw->yoffset = MAX(0, y); |
3171 |
|
sw->width = MIN(MIN(width, width + x), g_width - sw->xoffset); |
3172 |
|
sw->height = MIN(MIN(height, height + y), g_height - sw->yoffset); |
3173 |
|
|
3174 |
|
/* If we move the window in a maximized state, then KDE won't |
3175 |
|
accept restoration */ |
3176 |
|
switch (sw->state) |
3177 |
|
{ |
3178 |
|
case SEAMLESSRDP_MINIMIZED: |
3179 |
|
case SEAMLESSRDP_MAXIMIZED: |
3180 |
|
return; |
3181 |
|
} |
3182 |
|
|
3183 |
|
/* FIXME: Perhaps use ewmh_net_moveresize_window instead */ |
3184 |
|
XMoveResizeWindow(g_display, sw->wnd, sw->xoffset, sw->yoffset, sw->width, sw->height); |
3185 |
|
} |
3186 |
|
|
3187 |
|
|
3188 |
|
void |
3189 |
|
ui_seamless_settitle(unsigned long id, const char *title, unsigned long flags) |
3190 |
|
{ |
3191 |
|
seamless_window *sw; |
3192 |
|
|
3193 |
|
sw = seamless_get_window_by_id(id); |
3194 |
|
if (!sw) |
3195 |
|
{ |
3196 |
|
warning("ui_seamless_settitle: No information for window 0x%lx\n", id); |
3197 |
|
return; |
3198 |
|
} |
3199 |
|
|
3200 |
|
/* FIXME: Might want to convert the name for non-EWMH WMs */ |
3201 |
|
XStoreName(g_display, sw->wnd, title); |
3202 |
|
ewmh_set_wm_name(sw->wnd, title); |
3203 |
|
} |
3204 |
|
|
3205 |
|
|
3206 |
|
void |
3207 |
|
ui_seamless_setstate(unsigned long id, unsigned int state, unsigned long flags) |
3208 |
|
{ |
3209 |
|
seamless_window *sw; |
3210 |
|
|
3211 |
|
sw = seamless_get_window_by_id(id); |
3212 |
|
if (!sw) |
3213 |
|
{ |
3214 |
|
warning("ui_seamless_setstate: No information for window 0x%lx\n", id); |
3215 |
|
return; |
3216 |
|
} |
3217 |
|
|
3218 |
|
switch (state) |
3219 |
|
{ |
3220 |
|
case SEAMLESSRDP_NORMAL: |
3221 |
|
case SEAMLESSRDP_MAXIMIZED: |
3222 |
|
ewmh_change_state(sw->wnd, state); |
3223 |
|
XMapWindow(g_display, sw->wnd); |
3224 |
|
break; |
3225 |
|
case SEAMLESSRDP_MINIMIZED: |
3226 |
|
/* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN |
3227 |
|
the Window Manager should probably just ignore the request, since |
3228 |
|
_NET_WM_STATE_HIDDEN is a function of some other aspect of the window |
3229 |
|
such as minimization, rather than an independent state." Besides, |
3230 |
|
XIconifyWindow is easier. */ |
3231 |
|
if (sw->state == SEAMLESSRDP_NOTYETMAPPED) |
3232 |
|
{ |
3233 |
|
sw->hints->flags |= StateHint; |
3234 |
|
sw->hints->initial_state = IconicState; |
3235 |
|
XSetWMHints(g_display, sw->wnd, sw->hints); |
3236 |
|
XMapWindow(g_display, sw->wnd); |
3237 |
|
} |
3238 |
|
else |
3239 |
|
XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display)); |
3240 |
|
break; |
3241 |
|
default: |
3242 |
|
warning("SeamlessRDP: Invalid state %d\n", state); |
3243 |
|
break; |
3244 |
|
} |
3245 |
|
|
3246 |
|
/* Handle popups without parents through some ewm hints */ |
3247 |
|
if ((sw->state == SEAMLESSRDP_NOTYETMAPPED) && (sw->parent == 0xFFFFFFFF)) |
3248 |
|
ewmh_set_window_popup(sw->wnd); |
3249 |
|
|
3250 |
|
sw->state = state; |
3251 |
|
} |
3252 |
|
|
3253 |
|
|
3254 |
|
void |
3255 |
|
ui_seamless_syncbegin(unsigned long flags) |
3256 |
|
{ |
3257 |
|
/* Destroy all seamless windows */ |
3258 |
|
while (g_seamless_windows) |
3259 |
|
{ |
3260 |
|
XDestroyWindow(g_display, g_seamless_windows->wnd); |
3261 |
|
seamless_remove_window(g_seamless_windows); |
3262 |
|
} |
3263 |
|
} |