From: Michael Kuhn Date: Mon, 22 Aug 2016 19:54:18 +0000 (+0200) Subject: libply, main: Add device scale setting X-Git-Tag: 0.9.3~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91b983277c626864e8650d99671d10a84dbe20a7;p=thirdparty%2Fplymouth.git libply, main: Add device scale setting This adds a DeviceScale setting to plymouthd.conf. It can be used to override the device scale detection when setting the PLYMOUTH_FORCE_SCALE environment variable is too complicated. https://bugs.freedesktop.org/show_bug.cgi?id=97424 --- diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index 239c365d..89e37e93 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -78,6 +78,8 @@ static int errno_stack[PLY_ERRNO_STACK_SIZE]; static int errno_stack_position = 0; +static int overridden_device_scale = 0; + bool ply_open_unidirectional_pipe (int *sender_fd, int *receiver_fd) @@ -960,6 +962,13 @@ out: return (pid_t) ppid; } +void +ply_set_device_scale (int device_scale) +{ + overridden_device_scale = device_scale; + ply_trace ("Device scale is set to %d", device_scale); +} + /* The minimum resolution at which we turn on a device-scale of 2 */ #define HIDPI_LIMIT 192 #define HIDPI_MIN_HEIGHT 1200 @@ -979,6 +988,9 @@ ply_get_device_scale (uint32_t width, if ((force_device_scale = getenv ("PLYMOUTH_FORCE_SCALE"))) return strtoul (force_device_scale, NULL, 0); + if (overridden_device_scale != 0) + return overridden_device_scale; + if (height < HIDPI_MIN_HEIGHT) return 1; diff --git a/src/libply/ply-utils.h b/src/libply/ply-utils.h index 2f4ce818..c46603ee 100644 --- a/src/libply/ply-utils.h +++ b/src/libply/ply-utils.h @@ -121,6 +121,8 @@ int ply_utf8_string_get_length (const char *string, char *ply_get_process_command_line (pid_t pid); pid_t ply_get_process_parent_pid (pid_t pid); +void ply_set_device_scale (int device_scale); + int ply_get_device_scale (uint32_t width, uint32_t height, uint32_t width_mm, diff --git a/src/main.c b/src/main.c index a5b6d7a3..3b7b1791 100644 --- a/src/main.c +++ b/src/main.c @@ -295,6 +295,7 @@ load_settings (state_t *state, { ply_key_file_t *key_file = NULL; bool settings_loaded = false; + const char *scale_string; const char *splash_string; ply_trace ("Trying to load %s", path); @@ -334,6 +335,12 @@ load_settings (state_t *state, } } + scale_string = ply_key_file_get_value (key_file, "Daemon", "DeviceScale"); + + if (scale_string != NULL) { + ply_set_device_scale (strtoul (scale_string, NULL, 0)); + } + settings_loaded = true; out: ply_key_file_free (key_file);