diff options
author | Cendio <cendio@pairstation.lkpg.cendio.se> | 2018-02-13 16:04:20 +0100 |
---|---|---|
committer | Cendio <cendio@pairstation.lkpg.cendio.se> | 2018-02-14 10:49:30 +0100 |
commit | 8bc2cea80f7604dbbbeb63a43ca08805666b55c3 (patch) | |
tree | 9a8551a3307cbb5459440a0b0ca721c312050fba | |
parent | 9d163423eb4ac4dc6245662cb56eb7b3066b3c07 (diff) | |
download | rdesktop-8bc2cea80f7604dbbbeb63a43ca08805666b55c3.zip |
Add check if we can use dynamic session resize
When the server does not comply with our initial session size
request, we disable the dynamic session resize feature.
Co-authored-by: Henrik Andersson <hean01@cendio.com>
Co-authored-by: Karl Mikaelsson <derfian@cendio.se>
-rw-r--r-- | proto.h | 1 | ||||
-rw-r--r-- | rdp.c | 23 | ||||
-rw-r--r-- | xwin.c | 19 |
3 files changed, 41 insertions, 2 deletions
@@ -264,6 +264,7 @@ void ui_deinit(void); RD_BOOL ui_create_window(uint32 width, uint32 height); void ui_resize_window(uint32 width, uint32 height); void ui_destroy_window(void); +void ui_update_window_sizehints(uint32 width, uint32 height); RD_BOOL ui_have_window(void); void xwin_toggle_fullscreen(void); void ui_select(int rdp_socket); @@ -54,6 +54,8 @@ extern struct timeval g_pending_resize_defer_timer; extern RD_BOOL g_network_error; extern time_t g_wait_for_deactivate_ts; +extern RD_BOOL g_dynamic_session_resize; + RD_BOOL g_exit_mainloop = False; uint8 *g_next_packet; @@ -1102,10 +1104,13 @@ rdp_process_general_caps(STREAM s) g_rdp_version = RDP_V4; } +static RD_BOOL g_first_bitmap_caps = True; + /* Process a bitmap capability set */ static void rdp_process_bitmap_caps(STREAM s) { + uint16 depth; logger(Protocol, Debug, "%s()", __func__); @@ -1120,6 +1125,15 @@ rdp_process_bitmap_caps(STREAM s) "rdp_process_bitmap_caps(), setting desktop size and depth to: %dx%dx%d", g_session_width, g_session_height, depth); + /* Detect if we can have dynamic session resize enabled, only once. */ + if (g_first_bitmap_caps == True && !(g_session_width == g_requested_session_width + && g_session_height == g_requested_session_height)) + { + logger(Core, Notice, "Disabling dynamic session resize"); + g_dynamic_session_resize = False; + } + g_first_bitmap_caps = False; + /* * The server may limit depth and change the size of the desktop (for * example when shadowing another session). @@ -1139,6 +1153,14 @@ rdp_process_bitmap_caps(STREAM s) if (g_fullscreen == True) return; + /* If dynamic session resize is disabled, set window size hints to + fixed session size */ + if (g_dynamic_session_resize == False) + { + ui_update_window_sizehints(g_session_width, g_session_height); + return; + } + ui_resize_window(g_session_width, g_session_height); } @@ -1974,6 +1996,7 @@ rdp_reset_state(void) g_next_packet = NULL; /* reset the packet information */ g_rdp_shareid = 0; g_exit_mainloop = False; + g_first_bitmap_caps = True; sec_reset_state(); } @@ -77,6 +77,8 @@ static int g_x_socket; static Screen *g_screen; Window g_wnd; +RD_BOOL g_dynamic_session_resize = True; + /* These are the last known window sizes. They are updated whenever the window size is changed. */ static uint32 g_window_width; static uint32 g_window_height; @@ -2076,7 +2078,7 @@ get_sizehints(XSizeHints *sizehints, uint32 width, uint32 height) sizehints->width_inc = 2; /* session width must be divisible by two */ sizehints->height_inc = 1; - if (g_seamless_rdp) + if (g_seamless_rdp || !g_dynamic_session_resize) { /* disable dynamic session resize based on window size for rdesktop main window when seamless is enabled */ @@ -2086,6 +2088,19 @@ get_sizehints(XSizeHints *sizehints, uint32 width, uint32 height) } } +void +ui_update_window_sizehints(uint32 width, uint32 height) +{ + XSizeHints *sizehints; + sizehints = XAllocSizeHints(); + if (sizehints) + { + get_sizehints(sizehints, width, height); + XSetWMNormalHints(g_display, g_wnd, sizehints); + XFree(sizehints); + } +} + RD_BOOL ui_create_window(uint32 width, uint32 height) { @@ -3124,7 +3139,7 @@ ui_select(int rdp_socket) continue; } - if (g_pending_resize == True) + if (g_pending_resize == True && g_dynamic_session_resize) { /* returns True on disconnect-reconnect resize */ if (process_pending_resize() == True) |