From 20eaad110f2cb05c28064b1654c69ff6f53fbbef Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Mon, 22 Aug 2016 18:31:48 +0200 Subject: [PATCH 2/3] 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. --- src/libply/ply-utils.c | 12 ++++++++++++ src/libply/ply-utils.h | 2 ++ src/main.c | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index 7f4521a..e666a43 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 device_scale_setting = 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) +{ + device_scale_setting = 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 @@ -981,6 +990,9 @@ ply_get_device_scale (uint32_t width, if ((force_device_scale = getenv ("PLYMOUTH_FORCE_SCALE"))) return strtoul (force_device_scale, NULL, 0); + if (device_scale_setting != 0) + return device_scale_setting; + if (width < SMALLEST_4K_WIDTH) return 1; diff --git a/src/libply/ply-utils.h b/src/libply/ply-utils.h index 2f4ce81..c46603e 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 a5b6d7a..3b7b179 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); -- 2.7.4