Add additional background and logo parameters to xrdp.ini

This commit is contained in:
matt335672
2021-08-04 18:41:42 +01:00
parent 971f911290
commit d998ce7b5b
3 changed files with 113 additions and 13 deletions
+17 -2
View File
@@ -123,12 +123,27 @@ ls_height=430
; login screen background color in RGB format
ls_bg_color=dedede
; optional background image filename (bmp format).
; optional background image filename. BMP format is always supported,
; but other formats will be supported if xrdp is build with imlib2
; The transform can be one of the following:-
; none : No transformation. Image is placed in bottom-right corner
; of the screen.
; scale : Image is scaled to the screen size. The image aspect
; ratio is not preserved.
; zoom : Image is scaled to the screen size. The image aspect
; ratio is preserved by clipping the image.
#ls_background_image=
#ls_background_transform=none
; logo
; full path to bmp-file or file in shared folder
; full path to file or file in shared folder. BMP format is always supported,
; but other formats will be supported if xrdp is build with imlib2
; For transform values, see 'ls_background_transform'. The logo width and
; logo height are ignored for a transform of 'none'.
ls_logo_filename=
#ls_logo_transform=none
#ls_logo_width=240
#ls_logo_height=140
ls_logo_x_pos=55
ls_logo_y_pos=50
+89 -10
View File
@@ -740,12 +740,27 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
XRDP_SHARE_PATH, globals->ls_background_image);
}
LOG(LOG_LEVEL_DEBUG, "We try to load the following background file: %s", fileName);
xrdp_bitmap_load(but, fileName, self->palette,
globals->ls_top_window_bg_color, XBLT_NONE, 0, 0);
if (globals->ls_background_transform == XBLT_NONE)
{
xrdp_bitmap_load(but, fileName, self->palette,
globals->ls_top_window_bg_color,
globals->ls_background_transform,
0, 0);
/* Place the background in the bottom right corner */
but->left = self->screen->width - but->width;
but->top = self->screen->height - but->height;
}
else
{
xrdp_bitmap_load(but, fileName, self->palette,
globals->ls_top_window_bg_color,
globals->ls_background_transform,
self->screen->width, self->screen->height);
but->left = 0;
but->top = 0;
}
but->parent = self->screen;
but->owner = self->screen;
but->left = self->screen->width - but->width;
but->top = self->screen->height - but->height;
list_add_item(self->screen->child_list, (long)but);
}
@@ -764,7 +779,10 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
}
xrdp_bitmap_load(but, globals->ls_logo_filename, self->palette,
globals->ls_bg_color, XBLT_NONE, 0, 0);
globals->ls_bg_color,
globals->ls_logo_transform,
globals->ls_logo_width,
globals->ls_logo_height);
but->parent = self->login_window;
but->owner = self->login_window;
but->left = globals->ls_logo_x_pos;
@@ -833,6 +851,42 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
return 0;
}
/**
* Map a bitmap transform string to a value
*
* @param param Param we're trying to read
* @param str String we're trying to map
*
* @return enum xrdp_bitmap_load_transform value
*
* A warning is logged if the string is not recognised
*****************************************************************************/
static enum xrdp_bitmap_load_transform
bitmap_transform_str_to_val(const char *param, const char *str)
{
enum xrdp_bitmap_load_transform rv;
if (g_strcmp(str, "none") == 0)
{
rv = XBLT_NONE;
}
else if (g_strcmp(str, "scale") == 0)
{
rv = XBLT_SCALE;
}
else if (g_strcmp(str, "zoom") == 0)
{
rv = XBLT_ZOOM;
}
else
{
LOG(LOG_LEVEL_WARNING, "Param '%s' has unrecognised value '%s'"
" - assuming 'none'", param, str);
rv = XBLT_NONE;
}
return rv;
}
/**
* Load configuration from xrdp.ini file
*
@@ -868,6 +922,8 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
globals->ls_bg_color = HCOLOR(bpp, xrdp_wm_htoi("dedede"));
globals->ls_width = 350;
globals->ls_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;
@@ -1105,16 +1161,39 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
globals->ls_title[255] = 0;
}
else if (g_strncmp(n, "ls_logo_filename", 255) == 0)
{
g_strncpy(globals->ls_logo_filename, v, 255);
globals->ls_logo_filename[255] = 0;
}
else if (g_strncmp(n, "ls_background_image", 255) == 0)
{
g_strncpy(globals->ls_background_image, v, 255);
globals->ls_background_image[255] = 0;
}
else if (g_strncmp(n, "ls_background_transform", 255) == 0)
{
globals->ls_background_transform =
bitmap_transform_str_to_val(n, v);
}
else if (g_strncmp(n, "ls_logo_filename", 255) == 0)
{
g_strncpy(globals->ls_logo_filename, v, 255);
globals->ls_logo_filename[255] = 0;
}
else if (g_strncmp(n, "ls_logo_transform", 255) == 0)
{
globals->ls_logo_transform = bitmap_transform_str_to_val(n, v);
}
else if (g_strncmp(n, "ls_logo_width", 64) == 0)
{
globals->ls_logo_width = g_atoi(v);
}
else if (g_strncmp(n, "ls_logo_height", 64) == 0)
{
globals->ls_logo_height = g_atoi(v);
}
else if (g_strncmp(n, "ls_logo_x_pos", 64) == 0)
{
globals->ls_logo_x_pos = g_atoi(v);
+7 -1
View File
@@ -644,8 +644,14 @@ struct xrdp_cfg_globals
int ls_width; /* window width */
int ls_height; /* window height */
int ls_bg_color; /* background color */
char ls_logo_filename[256]; /* logo filename */
char ls_background_image[256]; /* background image file name */
enum xrdp_bitmap_load_transform ls_background_transform;
/* transform to apply to background image */
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 co-ordinate */
int ls_logo_y_pos; /* logo y co-ordinate */
int ls_label_x_pos; /* x pos of labels */