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-2007 |
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 |
75 |
int outpos_xoffset, outpos_yoffset; |
int outpos_xoffset, outpos_yoffset; |
76 |
int outpos_width, outpos_height; |
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; |
struct _seamless_window *next; |
83 |
} seamless_window; |
} seamless_window; |
84 |
static seamless_window *g_seamless_windows = NULL; |
static seamless_window *g_seamless_windows = NULL; |
107 |
static XIM g_IM; |
static XIM g_IM; |
108 |
static XIC g_IC; |
static XIC g_IC; |
109 |
static XModifierKeymap *g_mod_map; |
static XModifierKeymap *g_mod_map; |
110 |
|
/* Maps logical (xmodmap -pp) pointing device buttons (0-based) back |
111 |
|
to physical (1-based) indices. */ |
112 |
|
static unsigned char g_pointer_log_to_phys_map[16]; |
113 |
static Cursor g_current_cursor; |
static Cursor g_current_cursor; |
114 |
static RD_HCURSOR g_null_cursor = NULL; |
static RD_HCURSOR g_null_cursor = NULL; |
115 |
static Atom g_protocol_atom, g_kill_atom; |
static Atom g_protocol_atom, g_kill_atom; |
583 |
SPLITCOLOUR16(colour, pc); |
SPLITCOLOUR16(colour, pc); |
584 |
break; |
break; |
585 |
case 24: |
case 24: |
586 |
|
case 32: |
587 |
SPLITCOLOUR24(colour, pc); |
SPLITCOLOUR24(colour, pc); |
588 |
break; |
break; |
589 |
default: |
default: |
1192 |
is only set for compatible depths, but the RDP depth might've |
is only set for compatible depths, but the RDP depth might've |
1193 |
changed during connection negotiations. |
changed during connection negotiations. |
1194 |
*/ |
*/ |
1195 |
|
|
1196 |
|
/* todo */ |
1197 |
|
if (g_server_depth == 32 && g_depth == 24) |
1198 |
|
{ |
1199 |
|
return data; |
1200 |
|
} |
1201 |
|
|
1202 |
if (g_no_translate_image) |
if (g_no_translate_image) |
1203 |
{ |
{ |
1204 |
if ((g_depth == 15 && g_server_depth == 15) || |
if ((g_depth == 15 && g_server_depth == 15) || |
1276 |
return out; |
return out; |
1277 |
} |
} |
1278 |
|
|
1279 |
|
static void |
1280 |
|
xwin_refresh_pointer_map(void) |
1281 |
|
{ |
1282 |
|
unsigned char phys_to_log_map[sizeof(g_pointer_log_to_phys_map)]; |
1283 |
|
int i, pointer_buttons; |
1284 |
|
|
1285 |
|
pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map)); |
1286 |
|
for (i = 0; i < pointer_buttons; ++i) |
1287 |
|
{ |
1288 |
|
/* This might produce multiple logical buttons mapping |
1289 |
|
to a single physical one, but hey, that's |
1290 |
|
life... */ |
1291 |
|
g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1; |
1292 |
|
} |
1293 |
|
} |
1294 |
|
|
1295 |
RD_BOOL |
RD_BOOL |
1296 |
get_key_state(unsigned int state, uint32 keysym) |
get_key_state(unsigned int state, uint32 keysym) |
1297 |
{ |
{ |
1646 |
g_width = (g_width + 3) & ~3; |
g_width = (g_width + 3) & ~3; |
1647 |
|
|
1648 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
1649 |
|
xwin_refresh_pointer_map(); |
1650 |
|
|
1651 |
xkeymap_init(); |
xkeymap_init(); |
1652 |
|
|
1910 |
{ |
{ |
1911 |
uint16 button, flags = 0; |
uint16 button, flags = 0; |
1912 |
g_last_gesturetime = xevent.xbutton.time; |
g_last_gesturetime = xevent.xbutton.time; |
1913 |
|
/* Reverse the pointer button mapping, e.g. in the case of |
1914 |
|
"left-handed mouse mode"; the RDP session expects to |
1915 |
|
receive physical buttons (true in mstsc as well) and |
1916 |
|
logical button behavior depends on the remote desktop's own |
1917 |
|
mouse settings */ |
1918 |
|
xevent.xbutton.button = g_pointer_log_to_phys_map[xevent.xbutton.button - 1]; |
1919 |
button = xkeymap_translate_button(xevent.xbutton.button); |
button = xkeymap_translate_button(xevent.xbutton.button); |
1920 |
if (button == 0) |
if (button == 0) |
1921 |
return; |
return; |
2203 |
XFreeModifiermap(g_mod_map); |
XFreeModifiermap(g_mod_map); |
2204 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
2205 |
} |
} |
2206 |
|
|
2207 |
|
if (xevent.xmapping.request == MappingPointer) |
2208 |
|
{ |
2209 |
|
xwin_refresh_pointer_map(); |
2210 |
|
} |
2211 |
|
|
2212 |
break; |
break; |
2213 |
|
|
2214 |
/* clipboard stuff */ |
/* clipboard stuff */ |
3263 |
return; |
return; |
3264 |
|
|
3265 |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
3266 |
(char *) data, cx, cy, BitmapPad(g_display), cx * g_bpp / 8); |
(char *) data, cx, cy, g_bpp, 0); |
3267 |
|
|
3268 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3269 |
{ |
{ |
3465 |
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
3466 |
|
|
3467 |
sw = xmalloc(sizeof(seamless_window)); |
sw = xmalloc(sizeof(seamless_window)); |
3468 |
|
|
3469 |
|
memset(sw, 0, sizeof(seamless_window)); |
3470 |
|
|
3471 |
sw->wnd = wnd; |
sw->wnd = wnd; |
3472 |
sw->id = id; |
sw->id = id; |
|
sw->behind = 0; |
|
3473 |
sw->group = sw_find_group(group, False); |
sw->group = sw_find_group(group, False); |
3474 |
sw->group->refcnt++; |
sw->group->refcnt++; |
|
sw->xoffset = 0; |
|
|
sw->yoffset = 0; |
|
|
sw->width = 0; |
|
|
sw->height = 0; |
|
3475 |
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
3476 |
sw->desktop = 0; |
sw->desktop = 0; |
3477 |
sw->position_timer = xmalloc(sizeof(struct timeval)); |
sw->position_timer = xmalloc(sizeof(struct timeval)); |
3538 |
} |
} |
3539 |
|
|
3540 |
|
|
3541 |
|
void |
3542 |
|
ui_seamless_seticon(unsigned long id, const char *format, int width, int height, int chunk, |
3543 |
|
const char *data, int chunk_len) |
3544 |
|
{ |
3545 |
|
seamless_window *sw; |
3546 |
|
|
3547 |
|
if (!g_seamless_active) |
3548 |
|
return; |
3549 |
|
|
3550 |
|
sw = sw_get_window_by_id(id); |
3551 |
|
if (!sw) |
3552 |
|
{ |
3553 |
|
warning("ui_seamless_seticon: No information for window 0x%lx\n", id); |
3554 |
|
return; |
3555 |
|
} |
3556 |
|
|
3557 |
|
if (chunk == 0) |
3558 |
|
{ |
3559 |
|
if (sw->icon_size) |
3560 |
|
warning("ui_seamless_seticon: New icon started before previous completed\n"); |
3561 |
|
|
3562 |
|
if (strcmp(format, "RGBA") != 0) |
3563 |
|
{ |
3564 |
|
warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format); |
3565 |
|
return; |
3566 |
|
} |
3567 |
|
|
3568 |
|
sw->icon_size = width * height * 4; |
3569 |
|
if (sw->icon_size > 32 * 32 * 4) |
3570 |
|
{ |
3571 |
|
warning("ui_seamless_seticon: Icon too large (%d bytes)\n", sw->icon_size); |
3572 |
|
sw->icon_size = 0; |
3573 |
|
return; |
3574 |
|
} |
3575 |
|
|
3576 |
|
sw->icon_offset = 0; |
3577 |
|
} |
3578 |
|
else |
3579 |
|
{ |
3580 |
|
if (!sw->icon_size) |
3581 |
|
return; |
3582 |
|
} |
3583 |
|
|
3584 |
|
if (chunk_len > (sw->icon_size - sw->icon_offset)) |
3585 |
|
{ |
3586 |
|
warning("ui_seamless_seticon: Too large chunk received (%d bytes > %d bytes)\n", |
3587 |
|
chunk_len, sw->icon_size - sw->icon_offset); |
3588 |
|
sw->icon_size = 0; |
3589 |
|
return; |
3590 |
|
} |
3591 |
|
|
3592 |
|
memcpy(sw->icon_buffer + sw->icon_offset, data, chunk_len); |
3593 |
|
sw->icon_offset += chunk_len; |
3594 |
|
|
3595 |
|
if (sw->icon_offset == sw->icon_size) |
3596 |
|
{ |
3597 |
|
ewmh_set_icon(sw->wnd, width, height, sw->icon_buffer); |
3598 |
|
sw->icon_size = 0; |
3599 |
|
} |
3600 |
|
} |
3601 |
|
|
3602 |
|
|
3603 |
|
void |
3604 |
|
ui_seamless_delicon(unsigned long id, const char *format, int width, int height) |
3605 |
|
{ |
3606 |
|
seamless_window *sw; |
3607 |
|
|
3608 |
|
if (!g_seamless_active) |
3609 |
|
return; |
3610 |
|
|
3611 |
|
sw = sw_get_window_by_id(id); |
3612 |
|
if (!sw) |
3613 |
|
{ |
3614 |
|
warning("ui_seamless_seticon: No information for window 0x%lx\n", id); |
3615 |
|
return; |
3616 |
|
} |
3617 |
|
|
3618 |
|
if (strcmp(format, "RGBA") != 0) |
3619 |
|
{ |
3620 |
|
warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format); |
3621 |
|
return; |
3622 |
|
} |
3623 |
|
|
3624 |
|
ewmh_del_icon(sw->wnd, width, height); |
3625 |
|
} |
3626 |
|
|
3627 |
|
|
3628 |
void |
void |
3629 |
ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags) |
ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags) |
3630 |
{ |
{ |