Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/neutrinolabs/xrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt335672 <30179339+matt335672@users.noreply.github.com>2022-08-11 16:31:50 +0300
committermatt335672 <30179339+matt335672@users.noreply.github.com>2022-09-06 11:42:14 +0300
commitd0c8e28d273c9fb849ba27ac68ca84deabe4a32a (patch)
tree8d4aab40aaa9bc24d9a09ea9c657d41d209de476
parent36959e593acab22ce6f33eee312d7412097e6270 (diff)
Add a scaling capability to the login screen
The dimensions from xrdp.ini are replaced with scaled and unscaled versions. The unscaled versions are read from the config file, and then scaled to match the loaded font. Currently this has no significant effect, as the same font is still loaded, so the scaling factor is 1.00. However, when a different font is loaded, the login window can be made larger for use on higher DPI monitors.
-rw-r--r--xrdp/xrdp.h3
-rw-r--r--xrdp/xrdp_login_wnd.c272
-rw-r--r--xrdp/xrdp_types.h69
-rw-r--r--xrdp/xrdp_wm.c29
4 files changed, 256 insertions, 117 deletions
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index d6d66b78..a769f987 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -391,6 +391,9 @@ int
xrdp_login_wnd_create(struct xrdp_wm *self);
int
load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp);
+void
+xrdp_login_wnd_scale_config_values(struct xrdp_wm *self);
+
/* xrdp_bitmap_compress.c */
int
diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c
index 8bc04d15..d11287c5 100644
--- a/xrdp/xrdp_login_wnd.c
+++ b/xrdp/xrdp_login_wnd.c
@@ -159,9 +159,23 @@ xrdp_wm_help_clicked(struct xrdp_bitmap *wnd)
{
struct xrdp_bitmap *help;
struct xrdp_bitmap *but;
+ const int width =
+ wnd->wm->xrdp_config->cfg_globals.ls_scaled.help_wnd_width;
+ const int height =
+ wnd->wm->xrdp_config->cfg_globals.ls_scaled.help_wnd_height;
+ const int ok_height =
+ wnd->wm->xrdp_config->cfg_globals.ls_scaled.default_btn_height;
+ const char *ok_string = "OK";
+
+ /* Get a width for the OK button */
+ struct xrdp_painter *p = xrdp_painter_create(wnd->wm, wnd->wm->session);
+ xrdp_painter_font_needed(p);
+ const int ok_width = xrdp_painter_text_width(p, ok_string) +
+ DEFAULT_BUTTON_MARGIN_W;
+ xrdp_painter_delete(p);
/* create help screen */
- help = xrdp_bitmap_create(DEFAULT_WND_HELP_W, DEFAULT_WND_HELP_H, wnd->wm->screen->bpp,
+ help = xrdp_bitmap_create(width, height, wnd->wm->screen->bpp,
WND_TYPE_WND, wnd->wm);
list_insert_item(wnd->wm->screen->child_list, 0, (long)help);
help->parent = wnd->wm->screen;
@@ -173,16 +187,16 @@ xrdp_wm_help_clicked(struct xrdp_bitmap *wnd)
help->notify = xrdp_wm_login_help_notify;
set_string(&help->caption1, "Login help");
/* ok button */
- but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, wnd->wm->screen->bpp,
+ but = xrdp_bitmap_create(ok_width, ok_height, wnd->wm->screen->bpp,
WND_TYPE_BUTTON, wnd->wm);
list_insert_item(help->child_list, 0, (long)but);
but->parent = help;
but->owner = help;
- but->left = ((DEFAULT_WND_HELP_W / 2) - (DEFAULT_BUTTON_W / 2)); /* center */
- but->top = DEFAULT_WND_HELP_H - DEFAULT_BUTTON_H - 15;
+ but->left = ((help->width / 2) - (ok_width / 2)); /* center */
+ but->top = help->height - ok_height - 15;
but->id = 1;
but->tab_stop = 1;
- set_string(&but->caption1, "OK");
+ set_string(&but->caption1, ok_string);
/* draw it */
help->focused_control = but;
help->default_button = but;
@@ -399,32 +413,40 @@ xrdp_wm_show_edits(struct xrdp_wm *self, struct xrdp_bitmap *combo)
}
else if (g_strncmp(ASK, value, ASK_LEN) == 0)
{
+ const int combo_height =
+ self->xrdp_config->cfg_globals.ls_scaled.combo_height;
+ const int edit_height =
+ self->xrdp_config->cfg_globals.ls_scaled.edit_height;
/* label */
- b = xrdp_bitmap_create(globals->ls_label_width, DEFAULT_EDIT_H, self->screen->bpp,
+ b = xrdp_bitmap_create(globals->ls_scaled.label_width,
+ edit_height, self->screen->bpp,
WND_TYPE_LABEL, self);
list_insert_item(self->login_window->child_list, insert_index,
(long)b);
insert_index++;
b->parent = self->login_window;
b->owner = self->login_window;
- b->left = globals->ls_label_x_pos;
+ b->left = globals->ls_scaled.label_x_pos;
- b->top = globals->ls_input_y_pos + DEFAULT_COMBO_H + 5 + (DEFAULT_EDIT_H + 5) * count;
+ b->top = globals->ls_scaled.input_y_pos + combo_height + 5 +
+ (edit_height + 5) * count;
b->id = 100 + 2 * count;
name = (char *)list_get_item(mod->names, index);
set_string(&b->caption1, name);
/* edit */
- b = xrdp_bitmap_create(globals->ls_input_width, DEFAULT_EDIT_H, self->screen->bpp,
+ b = xrdp_bitmap_create(globals->ls_scaled.input_width,
+ edit_height, self->screen->bpp,
WND_TYPE_EDIT, self);
list_insert_item(self->login_window->child_list, insert_index,
(long)b);
insert_index++;
b->parent = self->login_window;
b->owner = self->login_window;
- b->left = globals->ls_input_x_pos;
+ b->left = globals->ls_scaled.input_x_pos;
- b->top = globals->ls_input_y_pos + DEFAULT_COMBO_H + 5 + (DEFAULT_EDIT_H + 5) * count;
+ b->top = globals->ls_scaled.input_y_pos + combo_height + 5 +
+ (edit_height + 5) * count;
b->id = 100 + 2 * count + 1;
b->pointer = 1;
@@ -669,6 +691,10 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
int y;
int cx;
int cy;
+ const int combo_height =
+ self->xrdp_config->cfg_globals.ls_scaled.combo_height;
+ const int edit_height =
+ self->xrdp_config->cfg_globals.ls_scaled.edit_height;
globals = &self->xrdp_config->cfg_globals;
@@ -677,8 +703,8 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
primary_x_offset = primary_width / 2;
primary_y_offset = primary_height / 2;
- log_width = globals->ls_width;
- log_height = globals->ls_height;
+ log_width = globals->ls_scaled.width;
+ log_height = globals->ls_scaled.height;
regular = 1;
if (self->screen->width < log_width)
@@ -823,58 +849,61 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
xrdp_bitmap_load(but, globals->ls_logo_filename, self->palette,
globals->ls_bg_color,
globals->ls_logo_transform,
- globals->ls_logo_width,
- globals->ls_logo_height);
+ globals->ls_scaled.logo_width,
+ globals->ls_scaled.logo_height);
but->parent = self->login_window;
but->owner = self->login_window;
- but->left = globals->ls_logo_x_pos;
- but->top = globals->ls_logo_y_pos;
+ but->left = globals->ls_scaled.logo_x_pos;
+ but->top = globals->ls_scaled.logo_y_pos;
list_add_item(self->login_window->child_list, (long)but);
}
/* label */
- but = xrdp_bitmap_create(globals->ls_label_width, DEFAULT_EDIT_H, self->screen->bpp, WND_TYPE_LABEL, self);
+ but = xrdp_bitmap_create(globals->ls_scaled.label_width, edit_height,
+ self->screen->bpp, WND_TYPE_LABEL, self);
list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
- but->left = globals->ls_label_x_pos;
- but->top = globals->ls_input_y_pos;
+ but->left = globals->ls_scaled.label_x_pos;
+ but->top = globals->ls_scaled.input_y_pos;
set_string(&but->caption1, "Session");
/* combo */
- combo = xrdp_bitmap_create(globals->ls_input_width, DEFAULT_COMBO_H,
+ combo = xrdp_bitmap_create(globals->ls_scaled.input_width, combo_height,
self->screen->bpp, WND_TYPE_COMBO, self);
list_add_item(self->login_window->child_list, (long)combo);
combo->parent = self->login_window;
combo->owner = self->login_window;
- combo->left = globals->ls_input_x_pos;
- combo->top = globals->ls_input_y_pos;
+ combo->left = globals->ls_scaled.input_x_pos;
+ combo->top = globals->ls_scaled.input_y_pos;
combo->id = 6;
combo->tab_stop = 1;
xrdp_wm_login_fill_in_combo(self, combo);
/* OK button */
- but = xrdp_bitmap_create(globals->ls_btn_ok_width, globals->ls_btn_ok_height,
+ but = xrdp_bitmap_create(globals->ls_scaled.btn_ok_width,
+ globals->ls_scaled.btn_ok_height,
self->screen->bpp, WND_TYPE_BUTTON, self);
list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
- but->left = globals->ls_btn_ok_x_pos;
- but->top = globals->ls_btn_ok_y_pos;
+ but->left = globals->ls_scaled.btn_ok_x_pos;
+ but->top = globals->ls_scaled.btn_ok_y_pos;
but->id = 3;
set_string(&but->caption1, "OK");
but->tab_stop = 1;
self->login_window->default_button = but;
/* Cancel button */
- but = xrdp_bitmap_create(globals->ls_btn_cancel_width,
- globals->ls_btn_cancel_height, self->screen->bpp,
+ but = xrdp_bitmap_create(globals->ls_scaled.btn_cancel_width,
+ globals->ls_scaled.btn_cancel_height,
+ self->screen->bpp,
WND_TYPE_BUTTON, self);
list_add_item(self->login_window->child_list, (long)but);
but->parent = self->login_window;
but->owner = self->login_window;
- but->left = globals->ls_btn_cancel_x_pos;
- but->top = globals->ls_btn_cancel_y_pos;
+ but->left = globals->ls_scaled.btn_cancel_x_pos;
+ but->top = globals->ls_scaled.btn_cancel_y_pos;
but->id = 2;
set_string(&but->caption1, "Cancel");
but->tab_stop = 1;
@@ -960,27 +989,38 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
/* set default values in case we can't get them from xrdp.ini file */
globals->ini_version = 1;
+
globals->ls_top_window_bg_color = HCOLOR(bpp, xrdp_wm_htoi("009cb5"));
globals->ls_bg_color = HCOLOR(bpp, xrdp_wm_htoi("dedede"));
- globals->ls_width = 350;
- globals->ls_height = 350;
+ globals->ls_unscaled.width = 350;
+ globals->ls_unscaled.height = 350;
globals->ls_background_transform = XBLT_NONE;
globals->ls_logo_transform = XBLT_NONE;
- globals->ls_logo_x_pos = 63;
- globals->ls_logo_y_pos = 50;
- globals->ls_label_x_pos = 30;
- globals->ls_label_width = 65;
- globals->ls_input_x_pos = 110;
- globals->ls_input_width = 210;
- globals->ls_input_y_pos = 150;
- globals->ls_btn_ok_x_pos = 150;
- globals->ls_btn_ok_y_pos = 300;
- globals->ls_btn_ok_width = 85;
- globals->ls_btn_ok_height = 30;
- globals->ls_btn_cancel_x_pos = 245;
- globals->ls_btn_cancel_y_pos = 300;
- globals->ls_btn_cancel_width = 85;
- globals->ls_btn_cancel_height = 30;
+ globals->ls_unscaled.logo_x_pos = 63;
+ globals->ls_unscaled.logo_y_pos = 50;
+ globals->ls_unscaled.label_x_pos = 30;
+ globals->ls_unscaled.label_width = 65;
+ globals->ls_unscaled.input_x_pos = 110;
+ globals->ls_unscaled.input_width = 210;
+ globals->ls_unscaled.input_y_pos = 150;
+ globals->ls_unscaled.btn_ok_x_pos = 150;
+ globals->ls_unscaled.btn_ok_y_pos = 300;
+ globals->ls_unscaled.btn_ok_width = 85;
+ globals->ls_unscaled.btn_ok_height = 30;
+ globals->ls_unscaled.btn_cancel_x_pos = 245;
+ globals->ls_unscaled.btn_cancel_y_pos = 300;
+ globals->ls_unscaled.btn_cancel_width = 85;
+ globals->ls_unscaled.btn_cancel_height = 30;
+ globals->ls_unscaled.default_btn_height =
+ DEFAULT_FONT_PIXEL_SIZE + DEFAULT_BUTTON_MARGIN_H;
+ globals->ls_unscaled.log_wnd_width = DEFAULT_WND_LOG_W;
+ globals->ls_unscaled.log_wnd_height = DEFAULT_WND_LOG_H;
+ globals->ls_unscaled.edit_height =
+ DEFAULT_FONT_PIXEL_SIZE + DEFAULT_EDIT_MARGIN_H;
+ globals->ls_unscaled.combo_height =
+ DEFAULT_FONT_PIXEL_SIZE + DEFAULT_COMBO_MARGIN_H;
+ globals->ls_unscaled.help_wnd_width = DEFAULT_WND_HELP_W;
+ globals->ls_unscaled.help_wnd_height = DEFAULT_WND_HELP_H;
/* open xrdp.ini file */
if ((fd = g_file_open(xrdp_ini)) < 0)
@@ -1184,12 +1224,12 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
else if (g_strncmp(n, "ls_width", 64) == 0)
{
- globals->ls_width = g_atoi(v);
+ globals->ls_unscaled.width = g_atoi(v);
}
else if (g_strncmp(n, "ls_height", 64) == 0)
{
- globals->ls_height = g_atoi(v);
+ globals->ls_unscaled.height = g_atoi(v);
}
else if (g_strncmp(n, "ls_bg_color", 64) == 0)
@@ -1228,87 +1268,87 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
else if (g_strncmp(n, "ls_logo_width", 64) == 0)
{
- globals->ls_logo_width = g_atoi(v);
+ globals->ls_unscaled.logo_width = g_atoi(v);
}
else if (g_strncmp(n, "ls_logo_height", 64) == 0)
{
- globals->ls_logo_height = g_atoi(v);
+ globals->ls_unscaled.logo_height = g_atoi(v);
}
else if (g_strncmp(n, "ls_logo_x_pos", 64) == 0)
{
- globals->ls_logo_x_pos = g_atoi(v);
+ globals->ls_unscaled.logo_x_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_logo_y_pos", 64) == 0)
{
- globals->ls_logo_y_pos = g_atoi(v);
+ globals->ls_unscaled.logo_y_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_label_x_pos", 64) == 0)
{
- globals->ls_label_x_pos = g_atoi(v);
+ globals->ls_unscaled.label_x_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_label_width", 64) == 0)
{
- globals->ls_label_width = g_atoi(v);
+ globals->ls_unscaled.label_width = g_atoi(v);
}
else if (g_strncmp(n, "ls_input_x_pos", 64) == 0)
{
- globals->ls_input_x_pos = g_atoi(v);
+ globals->ls_unscaled.input_x_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_input_width", 64) == 0)
{
- globals->ls_input_width = g_atoi(v);
+ globals->ls_unscaled.input_width = g_atoi(v);
}
else if (g_strncmp(n, "ls_input_y_pos", 64) == 0)
{
- globals->ls_input_y_pos = g_atoi(v);
+ globals->ls_unscaled.input_y_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_ok_x_pos", 64) == 0)
{
- globals->ls_btn_ok_x_pos = g_atoi(v);
+ globals->ls_unscaled.btn_ok_x_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_ok_y_pos", 64) == 0)
{
- globals->ls_btn_ok_y_pos = g_atoi(v);
+ globals->ls_unscaled.btn_ok_y_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_ok_width", 64) == 0)
{
- globals->ls_btn_ok_width = g_atoi(v);
+ globals->ls_unscaled.btn_ok_width = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_ok_height", 64) == 0)
{
- globals->ls_btn_ok_height = g_atoi(v);
+ globals->ls_unscaled.btn_ok_height = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_cancel_x_pos", 64) == 0)
{
- globals->ls_btn_cancel_x_pos = g_atoi(v);
+ globals->ls_unscaled.btn_cancel_x_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_cancel_y_pos", 64) == 0)
{
- globals->ls_btn_cancel_y_pos = g_atoi(v);
+ globals->ls_unscaled.btn_cancel_y_pos = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_cancel_width", 64) == 0)
{
- globals->ls_btn_cancel_width = g_atoi(v);
+ globals->ls_unscaled.btn_cancel_width = g_atoi(v);
}
else if (g_strncmp(n, "ls_btn_cancel_height", 64) == 0)
{
- globals->ls_btn_cancel_height = g_atoi(v);
+ globals->ls_unscaled.btn_cancel_height = g_atoi(v);
}
}
@@ -1347,29 +1387,95 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
LOG(LOG_LEVEL_DEBUG, "enable_token_login: %d", globals->enable_token_login);
LOG(LOG_LEVEL_DEBUG, "ls_top_window_bg_color: %x", globals->ls_top_window_bg_color);
- LOG(LOG_LEVEL_DEBUG, "ls_width: %d", globals->ls_width);
- LOG(LOG_LEVEL_DEBUG, "ls_height: %d", globals->ls_height);
+ LOG(LOG_LEVEL_DEBUG, "ls_width (unscaled): %d", globals->ls_unscaled.width);
+ LOG(LOG_LEVEL_DEBUG, "ls_height (unscaled): %d", globals->ls_unscaled.height);
LOG(LOG_LEVEL_DEBUG, "ls_bg_color: %x", globals->ls_bg_color);
LOG(LOG_LEVEL_DEBUG, "ls_title: %s", globals->ls_title);
LOG(LOG_LEVEL_DEBUG, "ls_logo_filename: %s", globals->ls_logo_filename);
- LOG(LOG_LEVEL_DEBUG, "ls_logo_x_pos: %d", globals->ls_logo_x_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_logo_y_pos: %d", globals->ls_logo_y_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_label_x_pos: %d", globals->ls_label_x_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_label_width: %d", globals->ls_label_width);
- LOG(LOG_LEVEL_DEBUG, "ls_input_x_pos: %d", globals->ls_input_x_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_input_width: %d", globals->ls_input_width);
- LOG(LOG_LEVEL_DEBUG, "ls_input_y_pos: %d", globals->ls_input_y_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_x_pos: %d", globals->ls_btn_ok_x_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_y_pos: %d", globals->ls_btn_ok_y_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_width: %d", globals->ls_btn_ok_width);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_height: %d", globals->ls_btn_ok_height);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_x_pos: %d", globals->ls_btn_cancel_x_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_y_pos: %d", globals->ls_btn_cancel_y_pos);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_width: %d", globals->ls_btn_cancel_width);
- LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_height: %d", globals->ls_btn_cancel_height);
+ LOG(LOG_LEVEL_DEBUG, "ls_logo_x_pos : %d", globals->ls_unscaled.logo_x_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_logo_y_pos : %d", globals->ls_unscaled.logo_y_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_label_x_pos : %d", globals->ls_unscaled.label_x_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_label_width : %d", globals->ls_unscaled.label_width);
+ LOG(LOG_LEVEL_DEBUG, "ls_input_x_pos : %d", globals->ls_unscaled.input_x_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_input_width : %d", globals->ls_unscaled.input_width);
+ LOG(LOG_LEVEL_DEBUG, "ls_input_y_pos : %d", globals->ls_unscaled.input_y_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_x_pos : %d", globals->ls_unscaled.btn_ok_x_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_y_pos : %d", globals->ls_unscaled.btn_ok_y_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_width : %d", globals->ls_unscaled.btn_ok_width);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_ok_height : %d", globals->ls_unscaled.btn_ok_height);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_x_pos : %d", globals->ls_unscaled.btn_cancel_x_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_y_pos : %d", globals->ls_unscaled.btn_cancel_y_pos);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_width : %d", globals->ls_unscaled.btn_cancel_width);
+ LOG(LOG_LEVEL_DEBUG, "ls_btn_cancel_height : %d", globals->ls_unscaled.btn_cancel_height);
list_delete(names);
list_delete(values);
g_file_close(fd);
return 0;
}
+
+/**
+ * Scale the configuration values
+ *
+ * After a font has been loaded, we can produce scaled versions of the
+ * login screen layout parameters which will correspond to the size of the
+ * font
+ */
+void
+xrdp_login_wnd_scale_config_values(struct xrdp_wm *self)
+{
+ const struct xrdp_ls_dimensions *unscaled =
+ &self->xrdp_config->cfg_globals.ls_unscaled;
+ struct xrdp_ls_dimensions *scaled =
+ &self->xrdp_config->cfg_globals.ls_scaled;
+
+ /* Clear the scaled values, so if we add one and forget to scale it,
+ * it will be obvious */
+ g_memset(scaled, '\0', sizeof(*scaled));
+
+ /* If we don't have a font, use zeros for everything */
+ if (self->default_font == NULL)
+ {
+ LOG(LOG_LEVEL_ERROR, "Can't scale login values - no font available");
+ }
+ else
+ {
+ const int fheight = self->default_font->body_height;
+ /* Define a Macro to scale to the nearest pixel value,
+ * rounding up as appropriate */
+#define SCALE_AND_ROUND(x) \
+ (((x) * fheight + (DEFAULT_FONT_PIXEL_SIZE / 2)) / \
+ DEFAULT_FONT_PIXEL_SIZE)
+
+ LOG(LOG_LEVEL_DEBUG, "Login screen scale factor %f",
+ (float)fheight / DEFAULT_FONT_PIXEL_SIZE);
+
+ scaled->width = SCALE_AND_ROUND(unscaled->width);
+ scaled->height = SCALE_AND_ROUND(unscaled->height);
+ scaled->logo_width = SCALE_AND_ROUND(unscaled->logo_width);
+ scaled->logo_height = SCALE_AND_ROUND(unscaled->logo_height);
+ scaled->logo_x_pos = SCALE_AND_ROUND(unscaled->logo_x_pos);
+ scaled->logo_y_pos = SCALE_AND_ROUND(unscaled->logo_y_pos);
+ scaled->label_x_pos = SCALE_AND_ROUND(unscaled->label_x_pos);
+ scaled->label_width = SCALE_AND_ROUND(unscaled->label_width);
+ scaled->input_x_pos = SCALE_AND_ROUND(unscaled->input_x_pos);
+ scaled->input_width = SCALE_AND_ROUND(unscaled->input_width);
+ scaled->input_y_pos = SCALE_AND_ROUND(unscaled->input_y_pos);
+ scaled->btn_ok_x_pos = SCALE_AND_ROUND(unscaled->btn_ok_x_pos);
+ scaled->btn_ok_y_pos = SCALE_AND_ROUND(unscaled->btn_ok_y_pos);
+ scaled->btn_ok_width = SCALE_AND_ROUND(unscaled->btn_ok_width);
+ scaled->btn_ok_height = SCALE_AND_ROUND(unscaled->btn_ok_height);
+ scaled->btn_cancel_x_pos = SCALE_AND_ROUND(unscaled->btn_cancel_x_pos);
+ scaled->btn_cancel_y_pos = SCALE_AND_ROUND(unscaled->btn_cancel_y_pos);
+ scaled->btn_cancel_width = SCALE_AND_ROUND(unscaled->btn_cancel_width);
+ scaled->btn_cancel_height = SCALE_AND_ROUND(unscaled->btn_cancel_height);
+ scaled->default_btn_height = fheight + DEFAULT_BUTTON_MARGIN_H;
+ scaled->log_wnd_width = SCALE_AND_ROUND(unscaled->log_wnd_width);
+ scaled->log_wnd_height = SCALE_AND_ROUND(unscaled->log_wnd_height);
+ scaled->edit_height = fheight + DEFAULT_EDIT_MARGIN_H;
+ scaled->combo_height = fheight + DEFAULT_COMBO_MARGIN_H;
+ scaled->help_wnd_width = SCALE_AND_ROUND(unscaled->help_wnd_width);
+ scaled->help_wnd_height = SCALE_AND_ROUND(unscaled->help_wnd_height);
+#undef SCALE_AND_ROUND
+ }
+}
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index 2f907f03..12f75e0c 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -605,12 +605,12 @@ struct xrdp_bitmap
#define NUM_FONTS 0x4e00
#define DEFAULT_FONT_NAME "sans-10.fv1"
+#define DEFAULT_FONT_PIXEL_SIZE 16
-#define DEFAULT_ELEMENT_TOP 35
-#define DEFAULT_BUTTON_W 60
-#define DEFAULT_BUTTON_H 23
-#define DEFAULT_COMBO_H 21
-#define DEFAULT_EDIT_H 21
+#define DEFAULT_BUTTON_MARGIN_H 12
+#define DEFAULT_BUTTON_MARGIN_W 12
+#define DEFAULT_COMBO_MARGIN_H 6
+#define DEFAULT_EDIT_MARGIN_H 6
#define DEFAULT_WND_LOGIN_W 425
#define DEFAULT_WND_LOGIN_H 475
#define DEFAULT_WND_HELP_W 340
@@ -657,9 +657,39 @@ struct xrdp_startup_params
};
/*
- * For storing xrdp.ini configuration settings
+ * For storing xrdp.ini (and other) configuration settings
*/
+struct xrdp_ls_dimensions
+{
+ int width; /* window width */
+ int height; /* window height */
+ int logo_width; /* logo width (optional) */
+ int logo_height; /* logo height (optional) */
+ int logo_x_pos; /* logo x co-ordinate */
+ int logo_y_pos; /* logo y co-ordinate */
+ int label_x_pos; /* x pos of labels */
+ int label_width; /* width of labels */
+ int input_x_pos; /* x pos of text and combo boxes */
+ int input_width; /* width of input and combo boxes */
+ int input_y_pos; /* y pos for for first label and combo box */
+ int btn_ok_x_pos; /* x pos for OK button */
+ int btn_ok_y_pos; /* y pos for OK button */
+ int btn_ok_width; /* width of OK button */
+ int btn_ok_height; /* height of OK button */
+ int btn_cancel_x_pos; /* x pos for Cancel button */
+ int btn_cancel_y_pos; /* y pos for Cancel button */
+ int btn_cancel_width; /* width of Cancel button */
+ int btn_cancel_height; /* height of Cancel button */
+ int default_btn_height; /* Default button height (e.g. OK on login box) */
+ int log_wnd_width; /* Width of log window */
+ int log_wnd_height; /* Height of log window */
+ int edit_height; /* Height of an edit box */
+ int combo_height; /* Height of a combo box */
+ int help_wnd_width; /* Width of login help window */
+ int help_wnd_height; /* Height of login help window */
+};
+
struct xrdp_cfg_globals
{
int ini_version; /* xrdp.ini file version number */
@@ -697,33 +727,18 @@ struct xrdp_cfg_globals
/* login screen */
int ls_top_window_bg_color; /* top level window background color */
- int ls_width; /* window width */
- int ls_height; /* window height */
int ls_bg_color; /* background color */
char ls_background_image[256]; /* background image file name */
- enum xrdp_bitmap_load_transform ls_background_transform;
/* transform to apply to background image */
+ enum xrdp_bitmap_load_transform ls_background_transform;
char ls_logo_filename[256]; /* logo filename */
- enum xrdp_bitmap_load_transform ls_logo_transform;
/* transform to apply to logo */
- int ls_logo_width; /* logo width (optional) */
- int ls_logo_height; /* logo height (optional) */
- int ls_logo_x_pos; /* logo x coordinate */
- int ls_logo_y_pos; /* logo y coordinate */
- int ls_label_x_pos; /* x pos of labels */
- int ls_label_width; /* width of labels */
- int ls_input_x_pos; /* x pos of text and combo boxes */
- int ls_input_width; /* width of input and combo boxes */
- int ls_input_y_pos; /* y pos for for first label and combo box */
- int ls_btn_ok_x_pos; /* x pos for OK button */
- int ls_btn_ok_y_pos; /* y pos for OK button */
- int ls_btn_ok_width; /* width of OK button */
- int ls_btn_ok_height; /* height of OK button */
- int ls_btn_cancel_x_pos; /* x pos for Cancel button */
- int ls_btn_cancel_y_pos; /* y pos for Cancel button */
- int ls_btn_cancel_width; /* width of Cancel button */
- int ls_btn_cancel_height; /* height of Cancel button */
+ enum xrdp_bitmap_load_transform ls_logo_transform;
char ls_title[256]; /* loginscreen window title */
+ /* Login screen dimensions, unscaled (from config) */
+ struct xrdp_ls_dimensions ls_unscaled;
+ /* Login screen dimensions, scaled (after font is loaded) */
+ struct xrdp_ls_dimensions ls_scaled;
};
struct xrdp_cfg_logging
diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c
index ff37deb7..0076ef44 100644
--- a/xrdp/xrdp_wm.c
+++ b/xrdp/xrdp_wm.c
@@ -62,7 +62,6 @@ xrdp_wm_create(struct xrdp_process *owner,
self->log = list_create();
self->log->auto_free = 1;
self->mm = xrdp_mm_create(self);
- self->default_font = xrdp_font_create(self);
/* this will use built in keymap or load from file */
get_keymaps(self->session->client_info->keylayout, &(self->keymap));
xrdp_wm_set_login_state(self, WMLS_RESET);
@@ -576,6 +575,12 @@ xrdp_wm_init(struct xrdp_wm *self)
load_xrdp_config(self->xrdp_config, self->session->xrdp_ini,
self->screen->bpp);
+ /* Load the font */
+ self->default_font = xrdp_font_create(self);
+
+ /* Scale the login screen values */
+ xrdp_login_wnd_scale_config_values(self);
+
/* global channels allow */
names = list_create();
names->auto_free = 1;
@@ -2047,12 +2052,14 @@ xrdp_wm_log_wnd_notify(struct xrdp_bitmap *wnd,
if (painter != 0)
{
+ unsigned int row_height = xrdp_painter_font_body_height(painter);
painter->fg_color = wnd->wm->black;
for (index = 0; index < wnd->wm->log->count; index++)
{
text = (char *)list_get_item(wnd->wm->log, index);
- xrdp_painter_draw_text(painter, wnd, 10, 30 + index * 15, text);
+ xrdp_painter_draw_text(painter, wnd, 10,
+ (index + 2) * row_height, text);
}
}
}
@@ -2102,8 +2109,9 @@ xrdp_wm_show_log(struct xrdp_wm *self)
if (self->log_wnd == 0)
{
- w = DEFAULT_WND_LOG_W;
- h = DEFAULT_WND_LOG_H;
+ w = self->xrdp_config->cfg_globals.ls_scaled.log_wnd_width;
+ h = self->xrdp_config->cfg_globals.ls_scaled.log_wnd_height;
+
xoffset = 10;
yoffset = 10;
@@ -2147,12 +2155,19 @@ xrdp_wm_show_log(struct xrdp_wm *self)
self->log_wnd->top = primary_y_offset + yoffset;
set_string(&(self->log_wnd->caption1), "Connection Log");
/* ok button */
- but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, self->screen->bpp, WND_TYPE_BUTTON, self);
+ const char *ok_string = "OK";
+ const int ok_height =
+ self->xrdp_config->cfg_globals.ls_scaled.default_btn_height;
+ const int ok_width = xrdp_painter_text_width(self->painter, ok_string) +
+ DEFAULT_BUTTON_MARGIN_W;
+
+ but = xrdp_bitmap_create(ok_width, ok_height, self->screen->bpp,
+ WND_TYPE_BUTTON, self);
list_insert_item(self->log_wnd->child_list, 0, (long)but);
but->parent = self->log_wnd;
but->owner = self->log_wnd;
- but->left = (w - DEFAULT_BUTTON_W) - xoffset;
- but->top = (h - DEFAULT_BUTTON_H) - yoffset;
+ but->left = (w - ok_width) - xoffset;
+ but->top = (h - ok_height) - yoffset;
but->id = 1;
but->tab_stop = 1;
set_string(&but->caption1, "OK");