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; |
1268 |
return out; |
return out; |
1269 |
} |
} |
1270 |
|
|
1271 |
|
static void |
1272 |
|
xwin_refresh_pointer_map(void) |
1273 |
|
{ |
1274 |
|
unsigned char phys_to_log_map[sizeof(g_pointer_log_to_phys_map)]; |
1275 |
|
int i, pointer_buttons; |
1276 |
|
|
1277 |
|
pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map)); |
1278 |
|
for (i = 0; i < pointer_buttons; ++i) |
1279 |
|
{ |
1280 |
|
/* This might produce multiple logical buttons mapping |
1281 |
|
to a single physical one, but hey, that's |
1282 |
|
life... */ |
1283 |
|
g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1; |
1284 |
|
} |
1285 |
|
} |
1286 |
|
|
1287 |
RD_BOOL |
RD_BOOL |
1288 |
get_key_state(unsigned int state, uint32 keysym) |
get_key_state(unsigned int state, uint32 keysym) |
1289 |
{ |
{ |
1638 |
g_width = (g_width + 3) & ~3; |
g_width = (g_width + 3) & ~3; |
1639 |
|
|
1640 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
1641 |
|
xwin_refresh_pointer_map(); |
1642 |
|
|
1643 |
xkeymap_init(); |
xkeymap_init(); |
1644 |
|
|
1902 |
{ |
{ |
1903 |
uint16 button, flags = 0; |
uint16 button, flags = 0; |
1904 |
g_last_gesturetime = xevent.xbutton.time; |
g_last_gesturetime = xevent.xbutton.time; |
1905 |
|
/* Reverse the pointer button mapping, e.g. in the case of |
1906 |
|
"left-handed mouse mode"; the RDP session expects to |
1907 |
|
receive physical buttons (true in mstsc as well) and |
1908 |
|
logical button behavior depends on the remote desktop's own |
1909 |
|
mouse settings */ |
1910 |
|
xevent.xbutton.button = g_pointer_log_to_phys_map[xevent.xbutton.button - 1]; |
1911 |
button = xkeymap_translate_button(xevent.xbutton.button); |
button = xkeymap_translate_button(xevent.xbutton.button); |
1912 |
if (button == 0) |
if (button == 0) |
1913 |
return; |
return; |
2195 |
XFreeModifiermap(g_mod_map); |
XFreeModifiermap(g_mod_map); |
2196 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
2197 |
} |
} |
2198 |
|
|
2199 |
|
if (xevent.xmapping.request == MappingPointer) |
2200 |
|
{ |
2201 |
|
xwin_refresh_pointer_map(); |
2202 |
|
} |
2203 |
|
|
2204 |
break; |
break; |
2205 |
|
|
2206 |
/* clipboard stuff */ |
/* clipboard stuff */ |
3255 |
return; |
return; |
3256 |
|
|
3257 |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
3258 |
(char *) data, cx, cy, BitmapPad(g_display), cx * g_bpp / 8); |
(char *) data, cx, cy, g_bpp, 0); |
3259 |
|
|
3260 |
if (g_ownbackstore) |
if (g_ownbackstore) |
3261 |
{ |
{ |
3457 |
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
3458 |
|
|
3459 |
sw = xmalloc(sizeof(seamless_window)); |
sw = xmalloc(sizeof(seamless_window)); |
3460 |
|
|
3461 |
|
memset(sw, 0, sizeof(seamless_window)); |
3462 |
|
|
3463 |
sw->wnd = wnd; |
sw->wnd = wnd; |
3464 |
sw->id = id; |
sw->id = id; |
|
sw->behind = 0; |
|
3465 |
sw->group = sw_find_group(group, False); |
sw->group = sw_find_group(group, False); |
3466 |
sw->group->refcnt++; |
sw->group->refcnt++; |
|
sw->xoffset = 0; |
|
|
sw->yoffset = 0; |
|
|
sw->width = 0; |
|
|
sw->height = 0; |
|
3467 |
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
3468 |
sw->desktop = 0; |
sw->desktop = 0; |
3469 |
sw->position_timer = xmalloc(sizeof(struct timeval)); |
sw->position_timer = xmalloc(sizeof(struct timeval)); |
3530 |
} |
} |
3531 |
|
|
3532 |
|
|
3533 |
|
void |
3534 |
|
ui_seamless_seticon(unsigned long id, const char *format, int width, int height, int chunk, |
3535 |
|
const char *data, int chunk_len) |
3536 |
|
{ |
3537 |
|
seamless_window *sw; |
3538 |
|
|
3539 |
|
if (!g_seamless_active) |
3540 |
|
return; |
3541 |
|
|
3542 |
|
sw = sw_get_window_by_id(id); |
3543 |
|
if (!sw) |
3544 |
|
{ |
3545 |
|
warning("ui_seamless_seticon: No information for window 0x%lx\n", id); |
3546 |
|
return; |
3547 |
|
} |
3548 |
|
|
3549 |
|
if (chunk == 0) |
3550 |
|
{ |
3551 |
|
if (sw->icon_size) |
3552 |
|
warning("ui_seamless_seticon: New icon started before previous completed\n"); |
3553 |
|
|
3554 |
|
if (strcmp(format, "RGBA") != 0) |
3555 |
|
{ |
3556 |
|
warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format); |
3557 |
|
return; |
3558 |
|
} |
3559 |
|
|
3560 |
|
sw->icon_size = width * height * 4; |
3561 |
|
if (sw->icon_size > 32 * 32 * 4) |
3562 |
|
{ |
3563 |
|
warning("ui_seamless_seticon: Icon too large (%d bytes)\n", sw->icon_size); |
3564 |
|
sw->icon_size = 0; |
3565 |
|
return; |
3566 |
|
} |
3567 |
|
|
3568 |
|
sw->icon_offset = 0; |
3569 |
|
} |
3570 |
|
else |
3571 |
|
{ |
3572 |
|
if (!sw->icon_size) |
3573 |
|
return; |
3574 |
|
} |
3575 |
|
|
3576 |
|
if (chunk_len > (sw->icon_size - sw->icon_offset)) |
3577 |
|
{ |
3578 |
|
warning("ui_seamless_seticon: Too large chunk received (%d bytes > %d bytes)\n", |
3579 |
|
chunk_len, sw->icon_size - sw->icon_offset); |
3580 |
|
sw->icon_size = 0; |
3581 |
|
return; |
3582 |
|
} |
3583 |
|
|
3584 |
|
memcpy(sw->icon_buffer + sw->icon_offset, data, chunk_len); |
3585 |
|
sw->icon_offset += chunk_len; |
3586 |
|
|
3587 |
|
if (sw->icon_offset == sw->icon_size) |
3588 |
|
{ |
3589 |
|
ewmh_set_icon(sw->wnd, width, height, sw->icon_buffer); |
3590 |
|
sw->icon_size = 0; |
3591 |
|
} |
3592 |
|
} |
3593 |
|
|
3594 |
|
|
3595 |
|
void |
3596 |
|
ui_seamless_delicon(unsigned long id, const char *format, int width, int height) |
3597 |
|
{ |
3598 |
|
seamless_window *sw; |
3599 |
|
|
3600 |
|
if (!g_seamless_active) |
3601 |
|
return; |
3602 |
|
|
3603 |
|
sw = sw_get_window_by_id(id); |
3604 |
|
if (!sw) |
3605 |
|
{ |
3606 |
|
warning("ui_seamless_seticon: No information for window 0x%lx\n", id); |
3607 |
|
return; |
3608 |
|
} |
3609 |
|
|
3610 |
|
if (strcmp(format, "RGBA") != 0) |
3611 |
|
{ |
3612 |
|
warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format); |
3613 |
|
return; |
3614 |
|
} |
3615 |
|
|
3616 |
|
ewmh_del_icon(sw->wnd, width, height); |
3617 |
|
} |
3618 |
|
|
3619 |
|
|
3620 |
void |
void |
3621 |
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) |
3622 |
{ |
{ |