Moved code that determines desktop size from ui_init to

ui_create_window. ui_init is only called once during the execution,
but the size of the screen can change, for example, when resizing
using Xrandr. 

Note however that this also means that ui_create_window must be called
before rdp_connect. rdesktop.c has been modified accordingly. One
additional advantage is that you will get a window during the
connection phase, which gives the user better feedback in case the
connection takes time. 



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1538 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Peter Åstrand 2010-01-12 10:19:35 +00:00
parent adbb524e13
commit d0327a9989
2 changed files with 42 additions and 42 deletions

View File

@ -960,6 +960,10 @@ main(int argc, char *argv[])
while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */ while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */
{ {
if (run_count == 0)
if (!ui_create_window())
return EX_OSERR;
if (run_count == 0) if (run_count == 0)
{ {
if (!rdp_connect(server, flags, domain, password, shell, directory, False)) if (!rdp_connect(server, flags, domain, password, shell, directory, False))
@ -977,10 +981,6 @@ main(int argc, char *argv[])
DEBUG(("Connection successful.\n")); DEBUG(("Connection successful.\n"));
memset(password, 0, sizeof(password)); memset(password, 0, sizeof(password));
if (run_count == 0)
if (!ui_create_window())
continue_connect = False;
if (continue_connect) if (continue_connect)
rdp_main_loop(&deactivated, &ext_disc_reason); rdp_main_loop(&deactivated, &ext_disc_reason);

76
xwin.c
View File

@ -1874,44 +1874,6 @@ ui_init(void)
g_ownbackstore = True; g_ownbackstore = True;
} }
/*
* Determine desktop size
*/
if (g_fullscreen)
{
g_width = WidthOfScreen(g_screen);
g_height = HeightOfScreen(g_screen);
g_using_full_workarea = True;
}
else if (g_width < 0)
{
/* Percent of screen */
if (-g_width >= 100)
g_using_full_workarea = True;
g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
}
else if (g_width == 0)
{
/* Fetch geometry from _NET_WORKAREA */
uint32 x, y, cx, cy;
if (get_current_workarea(&x, &y, &cx, &cy) == 0)
{
g_width = cx;
g_height = cy;
g_using_full_workarea = True;
}
else
{
warning("Failed to get workarea: probably your window manager does not support extended hints\n");
g_width = WidthOfScreen(g_screen);
g_height = HeightOfScreen(g_screen);
}
}
/* make sure width is a multiple of 4 */
g_width = (g_width + 3) & ~3;
g_mod_map = XGetModifierMapping(g_display); g_mod_map = XGetModifierMapping(g_display);
xwin_refresh_pointer_map(); xwin_refresh_pointer_map();
@ -1999,6 +1961,44 @@ ui_create_window(void)
long input_mask, ic_input_mask; long input_mask, ic_input_mask;
XEvent xevent; XEvent xevent;
/*
* Determine desktop size
*/
if (g_fullscreen)
{
g_width = WidthOfScreen(g_screen);
g_height = HeightOfScreen(g_screen);
g_using_full_workarea = True;
}
else if (g_width < 0)
{
/* Percent of screen */
if (-g_width >= 100)
g_using_full_workarea = True;
g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
}
else if (g_width == 0)
{
/* Fetch geometry from _NET_WORKAREA */
uint32 x, y, cx, cy;
if (get_current_workarea(&x, &y, &cx, &cy) == 0)
{
g_width = cx;
g_height = cy;
g_using_full_workarea = True;
}
else
{
warning("Failed to get workarea: probably your window manager does not support extended hints\n");
g_width = WidthOfScreen(g_screen);
g_height = HeightOfScreen(g_screen);
}
}
/* make sure width is a multiple of 4 */
g_width = (g_width + 3) & ~3;
wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width; wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width;
wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height; wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height;