From 7ddfa06d6248ca18e33781ec8ba20163fc4c2ad5 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 16 Mar 2018 12:37:45 +0100 Subject: Port HiDPI support from slick-greeter. Inspired by these slick-greeter commits: commit ffd43c4d425e70bc003b490dcddb8fbae1fffea7 Author: Clement Lefebvre Date: Sat Apr 8 14:13:23 2017 +0100 HiDPI: Allow to force HiDPI support ON or OFF commit 809f1b30a321ae12fdd3ba154791f9ead291acc7 Author: Clement Lefebvre Date: Fri Apr 7 23:04:50 2017 +0100 HiDPI: Take the screen size in consideration HiDPI shouldn't be activated on large screens where the dpi is OK. commit 851fca4e5508471d6f388edcd0327c3fc5b2b12f Author: Clement Lefebvre Date: Fri Apr 7 18:43:42 2017 +0100 Add HiDPI support Only support 1x and 2x scale ratios for now. Also add a setting so the user can disable HiDPI support. --- src/arctica-greeter.vala | 31 ++++++++++++++++++++++++++++--- src/settings.vala | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index adeb480..74be36a 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -606,6 +606,22 @@ public class ArcticaGreeter } } + private static void check_hidpi () + { + try { + string output; + Process.spawn_command_line_sync(Path.build_filename (Config.PKGLIBEXECDIR, "arctica-greeter-check-hidpi"), out output, null, null); + output = output.strip(); + if (output == "2") { + debug ("Activating HiDPI (2x scale ratio)"); + GLib.Environment.set_variable ("GDK_SCALE", "2", true); + } + } + catch (Error e){ + warning ("Error while setting HiDPI support: %s", e.message); + } + } + public static int main (string[] args) { /* Protect memory from being paged to disk, as we deal with passwords */ @@ -629,6 +645,18 @@ public class ArcticaGreeter */ GLib.Environment.set_variable ("GDK_CORE_DEVICE_EVENTS", "1", true); + log_timer = new Timer (); + Log.set_default_handler (log_cb); + + var hidpi = AGSettings.get_string (AGSettings.KEY_ENABLE_HIDPI); + debug ("HiDPI support: %s", hidpi); + if (hidpi == "auto") { + check_hidpi (); + } + else if (hidpi == "on") { + GLib.Environment.set_variable ("GDK_SCALE", "2", true); + } + bool do_show_version = false; bool do_test_mode = false; OptionEntry versionOption = { "version", 'v', 0, OptionArg.NONE, ref do_show_version, @@ -710,9 +738,6 @@ public class ArcticaGreeter Gtk.init (ref args); Ido.init (); - log_timer = new Timer (); - Log.set_default_handler (log_cb); - debug ("Starting arctica-greeter %s UID=%d LANG=%s", Config.VERSION, (int) Posix.getuid (), Environment.get_variable ("LANG")); /* Set the cursor to not be the crap default */ diff --git a/src/settings.vala b/src/settings.vala index e55b0c2..441035b 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -47,6 +47,7 @@ public class AGSettings public const string KEY_REMOTE_SERVICE_FQDN = "remote-service-fqdn"; public const string KEY_TOGGLEBOX_FONT_FGCOLOR = "togglebox-font-fgcolor"; public const string KEY_TOGGLEBOX_BUTTON_BGCOLOR = "togglebox-button-bgcolor"; + public const string KEY_ENABLE_HIDPI = "enable-hidpi"; public static bool get_boolean (string key) { -- cgit v1.2.3