Rename of global variable for clarity

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
This commit is contained in:
Cendio 2018-01-10 15:41:12 +01:00
parent bcd676dacc
commit 7f76e2218a
7 changed files with 72 additions and 72 deletions

View File

@ -69,11 +69,11 @@ int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */
int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */
int g_dpi = 0; /* device DPI: default not set */
/* Following variables holds the initial width and height for a
/* Following variables holds the requested width and height for a
rdesktop window, this is sent upon connect and tells the server
what size of session we want to have. Set to decent defaults. */
uint32 g_initial_width = 1024;
uint32 g_initial_height = 768;
uint32 g_requested_session_width = 1024;
uint32 g_requested_session_height = 768;
window_size_type_t g_window_size_type = Fixed;
@ -614,7 +614,7 @@ int parse_geometry_string(const char *optarg)
return -1;
}
g_initial_width = value;
g_requested_session_width = value;
ps = pe;
/* expect % or x */
@ -641,7 +641,7 @@ int parse_geometry_string(const char *optarg)
return -1;
}
g_initial_height = value;
g_requested_session_height = value;
ps = pe;
if (*ps == '%' && g_window_size_type == Fixed)
@ -666,7 +666,7 @@ int parse_geometry_string(const char *optarg)
if (g_window_size_type == PercentageOfScreen)
{
/* percentage of screen used for both width and height */
g_initial_height = g_initial_width;
g_requested_session_height = g_requested_session_width;
}
else
{
@ -1322,7 +1322,7 @@ main(int argc, char *argv[])
g_network_error = False;
}
utils_apply_session_size_limitations(&g_initial_width, &g_initial_height);
utils_apply_session_size_limitations(&g_requested_session_width, &g_requested_session_height);
if (!rdp_connect
(server, flags, domain, g_password, shell, directory, g_reconnect_loop))
@ -1392,7 +1392,7 @@ main(int argc, char *argv[])
if (g_pending_resize)
{
logger(Core, Verbose, "Resize reconnect loop triggered, new size %dx%d",
g_initial_width, g_initial_height);
g_requested_session_width, g_requested_session_height);
g_pending_resize = False;
g_reconnect_loop = True;
continue;
@ -1925,7 +1925,7 @@ rd_create_ui()
if (!ui_have_window())
{
/* create a window if we don't have one initialized */
if (!ui_create_window(g_initial_width, g_initial_height))
if (!ui_create_window(g_requested_session_width, g_requested_session_height))
exit(EX_OSERR);
}
else

4
rdp.c
View File

@ -43,8 +43,8 @@ extern RDP_VERSION g_rdp_version;
extern uint16 g_server_rdp_version;
extern uint32 g_rdp5_performanceflags;
extern int g_server_depth;
extern uint32 g_initial_width;
extern uint32 g_initial_height;
extern uint32 g_requested_session_width;
extern uint32 g_requested_session_height;
extern RD_BOOL g_bitmap_cache;
extern RD_BOOL g_bitmap_cache_persist_enable;
extern RD_BOOL g_numlock_sync;

View File

@ -23,8 +23,8 @@
#include "ssl.h"
extern char g_hostname[16];
extern uint32 g_initial_width;
extern uint32 g_initial_height;
extern uint32 g_requested_session_width;
extern uint32 g_requested_session_height;
extern int g_dpi;
extern unsigned int g_keylayout;
extern int g_keyboard_type;
@ -426,8 +426,8 @@ sec_out_mcs_connect_initial_pdu(STREAM s, uint32 selected_protocol)
out_uint16_le(s, CS_CORE); /* type */
out_uint16_le(s, 216 + (g_dpi > 0 ? 18 : 0)); /* length */
out_uint32_le(s, rdpversion); /* version */
out_uint16_le(s, g_initial_width); /* desktopWidth */
out_uint16_le(s, g_initial_height); /* desktopHeight */
out_uint16_le(s, g_requested_session_width); /* desktopWidth */
out_uint16_le(s, g_requested_session_height); /* desktopHeight */
out_uint16_le(s, RNS_UD_COLOR_8BPP); /* colorDepth */
out_uint16_le(s, RNS_UD_SAS_DEL); /* SASSequence */
out_uint32_le(s, g_keylayout); /* keyboardLayout */
@ -459,7 +459,7 @@ sec_out_mcs_connect_initial_pdu(STREAM s, uint32 selected_protocol)
if (g_dpi > 0)
{
/* Extended client info describing monitor geometry */
utils_calculate_dpi_scale_factors(g_initial_width, g_initial_height, g_dpi,
utils_calculate_dpi_scale_factors(g_requested_session_width, g_requested_session_height, g_dpi,
&physwidth, &physheight,
&desktopscale, &devicescale);
out_uint32_le(s, physwidth); /* physicalwidth */

View File

@ -26,12 +26,12 @@ RD_BOOL g_using_full_workarea;
Ensure(ParseGeometry, HandlesWxH)
{
g_initial_width = g_initial_height = 0;
g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x2345"), is_equal_to(0));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(2345));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(2345));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
@ -40,11 +40,11 @@ Ensure(ParseGeometry, FailsOnMissingHeight)
always_expect_error_log();
g_initial_width = g_initial_height = 0;
g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234"), is_equal_to(-1));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(0));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(0));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
@ -52,116 +52,116 @@ Ensure(ParseGeometry, FailsOnMissingHeightVariant2)
{
always_expect_error_log();
g_initial_width = g_initial_height = 0;
g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x"), is_equal_to(-1));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(0));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(0));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
Ensure(ParseGeometry, HandlesPercentageOfScreen)
{
g_initial_width = g_initial_height = 0;
g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("80%"), is_equal_to(0));
assert_that(g_initial_width, is_equal_to(80));
assert_that(g_initial_height, is_equal_to(80));
assert_that(g_requested_session_width, is_equal_to(80));
assert_that(g_requested_session_height, is_equal_to(80));
assert_that(g_window_size_type, is_equal_to(PercentageOfScreen));
}
Ensure(ParseGeometry, HandlesSpecificWidthAndHeightPercentageOfScreen)
{
g_initial_width = g_initial_height = 0;
g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("100%x60%"), is_equal_to(0));
assert_that(g_initial_width, is_equal_to(100));
assert_that(g_initial_height, is_equal_to(60));
assert_that(g_requested_session_width, is_equal_to(100));
assert_that(g_requested_session_height, is_equal_to(60));
assert_that(g_window_size_type, is_equal_to(PercentageOfScreen));
}
Ensure(ParseGeometry, HandlesSpecifiedDPI)
{
g_dpi = g_initial_width = g_initial_height = 0;
g_dpi = g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x2345@234"), is_equal_to(0));
assert_that(g_dpi, is_equal_to(234));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(2345));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(2345));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
Ensure(ParseGeometry, HandlesSpecifiedXPosition)
{
g_xpos = g_ypos = g_initial_width = g_initial_height = 0;
g_xpos = g_ypos = g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x2345+123"), is_equal_to(0));
assert_that(g_xpos, is_equal_to(123));
assert_that(g_ypos, is_equal_to(0));
assert_that(g_pos, is_equal_to(1));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(2345));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(2345));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
Ensure(ParseGeometry, HandlesSpecifiedNegativeXPosition)
{
g_ypos = g_xpos = g_initial_width = g_initial_height = 0;
g_ypos = g_xpos = g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x2345-500"), is_equal_to(0));
assert_that(g_xpos, is_equal_to(-500));
assert_that(g_ypos, is_equal_to(0));
assert_that(g_pos, is_equal_to(2));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(2345));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(2345));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
Ensure(ParseGeometry, HandlesSpecifiedNegativeXAndYPosition)
{
g_ypos = g_xpos = g_initial_width = g_initial_height = 0;
g_ypos = g_xpos = g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x2345-500-501"), is_equal_to(0));
assert_that(g_xpos, is_equal_to(-500));
assert_that(g_ypos, is_equal_to(-501));
assert_that(g_pos, is_equal_to(2 | 4));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(2345));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(2345));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
Ensure(ParseGeometry, HandlesSpecifiedXandYPosition)
{
g_xpos = g_ypos = g_initial_width = g_initial_height = 0;
g_xpos = g_ypos = g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x2345+123+234"), is_equal_to(0));
assert_that(g_xpos, is_equal_to(123));
assert_that(g_ypos, is_equal_to(234));
assert_that(g_pos, is_equal_to(1));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(2345));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(2345));
assert_that(g_window_size_type, is_equal_to(Fixed));
}
Ensure(ParseGeometry, HandlesSpecifiedXandYPositionWithDPI)
{
g_dpi = g_xpos = g_ypos = g_initial_width = g_initial_height = 0;
g_dpi = g_xpos = g_ypos = g_requested_session_width = g_requested_session_height = 0;
assert_that(parse_geometry_string("1234x2345@678+123+234"), is_equal_to(0));
assert_that(g_dpi, is_equal_to(678));
assert_that(g_xpos, is_equal_to(123));
assert_that(g_ypos, is_equal_to(234));
assert_that(g_initial_width, is_equal_to(1234));
assert_that(g_initial_height, is_equal_to(2345));
assert_that(g_requested_session_width, is_equal_to(1234));
assert_that(g_requested_session_height, is_equal_to(2345));
assert_that(g_window_size_type, is_equal_to(Fixed));
}

View File

@ -11,8 +11,8 @@ AfterEach(Resize) {};
/* globals driven by xwin.c */
RD_BOOL g_user_quit;
RD_BOOL g_exit_mainloop;
uint32 g_initial_width;
uint32 g_initial_height;
uint32 g_requested_session_width;
uint32 g_requested_session_height;
window_size_type_t g_window_size_type;
uint16 g_session_width;
uint16 g_session_height;
@ -56,8 +56,8 @@ RDP_VERSION g_rdp_version;
uint16 g_server_rdp_version;
uint32 g_rdp5_performanceflags;
int g_server_depth;
uint32 g_initial_width;
uint32 g_initial_height;
uint32 g_requested_session_width;
uint32 g_requested_session_height;
RD_BOOL g_bitmap_cache;
RD_BOOL g_bitmap_cache_persist_enable;
RD_BOOL g_numlock_sync;
@ -87,8 +87,8 @@ RD_BOOL g_local_cursor;
/* globals from secure.c */
char g_hostname[16];
uint32 g_initial_width;
uint32 g_initial_height;
uint32 g_requested_session_width;
uint32 g_requested_session_height;
int g_dpi;
unsigned int g_keylayout;
int g_keyboard_type;

View File

@ -17,8 +17,8 @@ AfterEach(XWIN) {};
RD_BOOL g_user_quit;
RD_BOOL g_exit_mainloop;
uint32 g_initial_width;
uint32 g_initial_height;
uint32 g_requested_session_width;
uint32 g_requested_session_height;
window_size_type_t g_window_size_type;
uint16 g_session_width;
uint16 g_session_height;

30
xwin.c
View File

@ -46,8 +46,8 @@ extern RD_BOOL g_user_quit;
extern RD_BOOL g_exit_mainloop;
extern window_size_type_t g_window_size_type;
extern uint32 g_initial_width;
extern uint32 g_initial_height;
extern uint32 g_requested_session_width;
extern uint32 g_requested_session_height;
extern uint16 g_session_width;
extern uint16 g_session_height;
extern int g_xpos;
@ -1973,31 +1973,31 @@ ui_init_connection(void)
*/
if (g_window_size_type == Fullscreen)
{
g_initial_width = WidthOfScreen(g_screen);
g_initial_height = HeightOfScreen(g_screen);
g_requested_session_width = WidthOfScreen(g_screen);
g_requested_session_height = HeightOfScreen(g_screen);
g_using_full_workarea = True;
}
else if (g_window_size_type == PercentageOfScreen)
{
/* g_initial_width/height holds percentage of screen in each axis */
g_initial_height = HeightOfScreen(g_screen) * g_initial_height / 100;
g_initial_width = WidthOfScreen(g_screen) * g_initial_width / 100;
/* g_requested_session_width/height holds percentage of screen in each axis */
g_requested_session_height = HeightOfScreen(g_screen) * g_requested_session_height / 100;
g_requested_session_width = WidthOfScreen(g_screen) * g_requested_session_width / 100;
}
else if (g_window_size_type == Workarea)
{
uint32 x, y, cx, cy;
if (get_current_workarea(&x, &y, &cx, &cy) == 0)
{
g_initial_width = cx;
g_initial_height = cy;
g_requested_session_width = cx;
g_requested_session_height = cy;
g_using_full_workarea = True;
}
else
{
logger(GUI, Warning,
"Failed to get workarea: probably your window manager does not support extended hints, using full screensize as fallback\n");
g_initial_width = WidthOfScreen(g_screen);
g_initial_height = HeightOfScreen(g_screen);
g_requested_session_width = WidthOfScreen(g_screen);
g_requested_session_height = HeightOfScreen(g_screen);
}
}
}
@ -3026,12 +3026,12 @@ process_pending_resize ()
* server.
*/
g_initial_width = g_window_width;
g_initial_height = g_window_height;
g_requested_session_width = g_window_width;
g_requested_session_height = g_window_height;
logger(GUI, Verbose, "Window resize detected, reconnecting to new size %dx%d",
g_initial_width,
g_initial_height);
g_requested_session_width,
g_requested_session_height);
return True;
}