diff options
author | Mihai Moldovan <ionic@ionic.de> | 2023-10-06 14:55:20 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2023-10-06 14:55:20 +0200 |
commit | 23a2bd20924f785e4f0af6e43de1ceb4d460f330 (patch) | |
tree | cebafac665047360b45b9d0ceaca7d6b7a6549f9 | |
parent | 57838b0b9a9bd91114c0473e963dac6199cc5888 (diff) | |
parent | 27993e437661f590cbd5551c09776df514f66aa2 (diff) | |
download | arctica-greeter-23a2bd20924f785e4f0af6e43de1ceb4d460f330.tar.gz arctica-greeter-23a2bd20924f785e4f0af6e43de1ceb4d460f330.tar.bz2 arctica-greeter-23a2bd20924f785e4f0af6e43de1ceb4d460f330.zip |
Merge branch 'sunweaver-mr/earlier-hidpi-setup'
Attributes GH PR #84: https://github.com/ArcticaProject/arctica-greeter/pull/84
-rw-r--r-- | src/arctica-greeter.vala | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index dabf64e..b0161c9 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -873,20 +873,19 @@ public class ArcticaGreeter : Object } } - private static void check_hidpi () + private static int 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); - } + debug ("Auto-detected scaling factor in check_hidpi(): %d", int.parse(output)); + return int.parse (output); } catch (Error e){ warning ("Error while setting HiDPI support: %s", e.message); } + /* Fallback value for GDK scaling */ + return 1; } public static int main (string[] args) @@ -937,6 +936,25 @@ public class ArcticaGreeter : Object log_timer = new Timer (); Log.set_default_handler (log_cb); + int scaling_factor_hidpi = 1; + + /* HiDPI settings */ + var hidpi = AGSettings.get_string (AGSettings.KEY_ENABLE_HIDPI); + debug ("HiDPI support: %s", hidpi); + if (hidpi == "auto") + { + /* This detects if the display size "recommends" hidpi and sets scaling_factor to 2. */ + scaling_factor_hidpi = check_hidpi (); + } + else if (hidpi == "on") + { + /* User configured an exlicit scaling factor via KEY_ENBALE_HIDPI. */ + scaling_factor_hidpi = 2; + } + /* Adjust GDK_SCALE to our configured scaling factor (via HiDPI settings). */ + debug ("Setting GDK_SCALE to: %d (scaling all UI elements by this factor)", scaling_factor_hidpi); + GLib.Environment.set_variable ("GDK_SCALE", "%d".printf (scaling_factor_hidpi), true); + /* Make nm-applet hide items the user does not have permissions to interact with */ Environment.set_variable ("NM_APPLET_HIDE_POLICY_ITEMS", "1", true); @@ -986,17 +1004,6 @@ public class ArcticaGreeter : Object return Posix.EXIT_FAILURE; } - if (!do_test_mode) - { - 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); - } - } if (do_show_version) { |