60 |
int width, height; |
int width, height; |
61 |
int state; /* normal/minimized/maximized. */ |
int state; /* normal/minimized/maximized. */ |
62 |
unsigned int desktop; |
unsigned int desktop; |
63 |
|
struct timeval *position_timer; |
64 |
struct _seamless_window *next; |
struct _seamless_window *next; |
65 |
} seamless_window; |
} seamless_window; |
66 |
static seamless_window *g_seamless_windows = NULL; |
static seamless_window *g_seamless_windows = NULL; |
326 |
} |
} |
327 |
|
|
328 |
|
|
329 |
|
/* Send our position */ |
330 |
|
static void |
331 |
|
seamless_update_position(seamless_window * sw) |
332 |
|
{ |
333 |
|
XWindowAttributes wa; |
334 |
|
int x, y; |
335 |
|
Window child_return; |
336 |
|
|
337 |
|
XGetWindowAttributes(g_display, sw->wnd, &wa); |
338 |
|
XTranslateCoordinates(g_display, sw->wnd, wa.root, |
339 |
|
-wa.border_width, -wa.border_width, &x, &y, &child_return); |
340 |
|
|
341 |
|
seamless_send_position(sw->id, x, y, wa.width, wa.height, 0); |
342 |
|
sw->xoffset = x; |
343 |
|
sw->yoffset = y; |
344 |
|
sw->width = wa.width; |
345 |
|
sw->height = wa.height; |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
|
/* Check if it's time to send our position */ |
350 |
|
static void |
351 |
|
seamless_check_timers() |
352 |
|
{ |
353 |
|
seamless_window *sw; |
354 |
|
struct timeval now; |
355 |
|
|
356 |
|
gettimeofday(&now, NULL); |
357 |
|
for (sw = g_seamless_windows; sw; sw = sw->next) |
358 |
|
{ |
359 |
|
if (timerisset(sw->position_timer) && timercmp(sw->position_timer, &now, <)) |
360 |
|
{ |
361 |
|
timerclear(sw->position_timer); |
362 |
|
seamless_update_position(sw); |
363 |
|
} |
364 |
|
} |
365 |
|
} |
366 |
|
|
367 |
|
|
368 |
static void |
static void |
369 |
seamless_restack_window(seamless_window * sw, unsigned long behind) |
seamless_restack_window(seamless_window * sw, unsigned long behind) |
370 |
{ |
{ |
2125 |
rdp_send_client_window_status(0); |
rdp_send_client_window_status(0); |
2126 |
break; |
break; |
2127 |
case ConfigureNotify: |
case ConfigureNotify: |
2128 |
/* seamless */ |
if (!g_seamless_active) |
2129 |
|
break; |
2130 |
|
|
2131 |
sw = seamless_get_window_by_wnd(xevent.xconfigure.window); |
sw = seamless_get_window_by_wnd(xevent.xconfigure.window); |
2132 |
if (!sw) |
if (!sw) |
2133 |
break; |
{ |
2134 |
|
error("ConfigureNotify for unknown window 0x%lx\n", |
2135 |
|
xevent.xconfigure.window); |
2136 |
|
} |
2137 |
|
|
2138 |
|
gettimeofday(sw->position_timer, NULL); |
2139 |
|
if (sw->position_timer->tv_usec + SEAMLESSRDP_POSITION_TIMER >= |
2140 |
|
1000000) |
2141 |
|
{ |
2142 |
|
sw->position_timer->tv_usec += |
2143 |
|
SEAMLESSRDP_POSITION_TIMER - 1000000; |
2144 |
|
sw->position_timer->tv_sec += 1; |
2145 |
|
} |
2146 |
|
else |
2147 |
|
{ |
2148 |
|
sw->position_timer->tv_usec += SEAMLESSRDP_POSITION_TIMER; |
2149 |
|
} |
2150 |
|
|
2151 |
ui_seamless_handle_restack(sw); |
ui_seamless_handle_restack(sw); |
2152 |
|
break; |
2153 |
} |
} |
2154 |
} |
} |
2155 |
/* Keep going */ |
/* Keep going */ |
2173 |
/* User quit */ |
/* User quit */ |
2174 |
return 0; |
return 0; |
2175 |
|
|
2176 |
|
if (g_seamless_active) |
2177 |
|
seamless_check_timers(); |
2178 |
|
|
2179 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |
2180 |
FD_ZERO(&wfds); |
FD_ZERO(&wfds); |
2181 |
FD_SET(rdp_socket, &rfds); |
FD_SET(rdp_socket, &rfds); |
2195 |
|
|
2196 |
/* add redirection handles */ |
/* add redirection handles */ |
2197 |
rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout); |
rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout); |
2198 |
|
seamless_select_timeout(&tv); |
2199 |
|
|
2200 |
n++; |
n++; |
2201 |
|
|
3279 |
serverside, instead of terminating rdesktop */ |
serverside, instead of terminating rdesktop */ |
3280 |
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
XSetWMProtocols(g_display, wnd, &g_kill_atom, 1); |
3281 |
|
|
3282 |
sw = malloc(sizeof(seamless_window)); |
sw = xmalloc(sizeof(seamless_window)); |
3283 |
sw->wnd = wnd; |
sw->wnd = wnd; |
3284 |
sw->id = id; |
sw->id = id; |
3285 |
sw->parent = parent; |
sw->parent = parent; |
3290 |
sw->height = 0; |
sw->height = 0; |
3291 |
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
3292 |
sw->desktop = 0; |
sw->desktop = 0; |
3293 |
|
sw->position_timer = xmalloc(sizeof(struct timeval)); |
3294 |
|
timerclear(sw->position_timer); |
3295 |
sw->next = g_seamless_windows; |
sw->next = g_seamless_windows; |
3296 |
g_seamless_windows = sw; |
g_seamless_windows = sw; |
3297 |
} |
} |
3336 |
/* X11 windows must be at least 1x1 */ |
/* X11 windows must be at least 1x1 */ |
3337 |
return; |
return; |
3338 |
|
|
3339 |
/* About MAX and MIN: Windows allows moving a window outside |
sw->xoffset = x; |
3340 |
the desktop. This happens, for example, when maximizing an |
sw->yoffset = y; |
3341 |
application. In this case, the position is set to something |
sw->width = width; |
3342 |
like -4,-4,1288,1032. Many WMs does not allow windows |
sw->height = height; |
|
outside the desktop, however. Therefore, clip the window |
|
|
ourselves. */ |
|
|
sw->xoffset = MAX(0, x); |
|
|
sw->yoffset = MAX(0, y); |
|
|
sw->width = MIN(MIN(width, width + x), g_width - sw->xoffset); |
|
|
sw->height = MIN(MIN(height, height + y), g_height - sw->yoffset); |
|
3343 |
|
|
3344 |
/* If we move the window in a maximized state, then KDE won't |
/* If we move the window in a maximized state, then KDE won't |
3345 |
accept restoration */ |
accept restoration */ |