]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
libply, main: Add device scale setting
authorMichael Kuhn <suraia@ikkoku.de>
Mon, 22 Aug 2016 19:54:18 +0000 (21:54 +0200)
committerRay Strode <rstrode@redhat.com>
Tue, 23 Aug 2016 14:01:29 +0000 (10:01 -0400)
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

src/libply/ply-utils.c
src/libply/ply-utils.h
src/main.c

index 239c365dc624676abc9092385839be44141a5555..89e37e932b19ef4a3e14fcf2b2966f23b8dd9227 100644 (file)
@@ -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;
 
index 2f4ce81864107c1f36f3e58f65aab0475c6c0d5b..c46603eec6da9c644fba107052c50ce949f77e1a 100644 (file)
@@ -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,
index a5b6d7a3fed9dd6ee38de73a7c4f176398d3c35d..3b7b17911299e51a5d8089cfb37173bcd533cb58 100644 (file)
@@ -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);