aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-10-10 22:33:16 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-10-10 22:33:16 +0200
commit008705c0833a974a8ebd9efdf7cc40b3fdfcc97b (patch)
tree575069048897f7ff55520e2d8641da76d4deb464 /src
parent9e1b5ad15bbb8e62bf2127e825ad1d0e13ee821f (diff)
parentf3a3bc4ce6a5a88b4514a9f14b18aec087e16d53 (diff)
downloadarctica-greeter-008705c0833a974a8ebd9efdf7cc40b3fdfcc97b.tar.gz
arctica-greeter-008705c0833a974a8ebd9efdf7cc40b3fdfcc97b.tar.bz2
arctica-greeter-008705c0833a974a8ebd9efdf7cc40b3fdfcc97b.zip
Merge branch 'Ionic-feature/hidpi-error-handling'
Attributes GH PR #89: https://github.com/ArcticaProject/arctica-greeter/pull/89
Diffstat (limited to 'src')
-rw-r--r--src/arctica-greeter.vala27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala
index 4a574d3..3ff9a24 100644
--- a/src/arctica-greeter.vala
+++ b/src/arctica-greeter.vala
@@ -875,17 +875,36 @@ public class ArcticaGreeter : Object
private static int check_hidpi ()
{
+ int ret = 1;
+
try {
string output;
Process.spawn_command_line_sync(Path.build_filename (Config.PKGLIBEXECDIR, "arctica-greeter-check-hidpi"), out output, null, null);
- debug ("Auto-detected scaling factor in check_hidpi(): %d", int.parse(output));
- return int.parse (output);
+ ret = int.parse (output);
+ debug ("Auto-detected scaling factor in check_hidpi(): %d", ret);
}
catch (Error e){
warning ("Error while setting HiDPI support: %s", e.message);
}
- /* Fallback value for GDK scaling */
- return 1;
+
+ /*
+ * Make sure that the value lies in the range of 0 < x <= 5.
+ *
+ * GDK only knows integer-based scaling factors and anything above 2
+ * is highly unusual. Anything above 5 is most likely an error (at the
+ * time of writing this code; we might want to respect this in the
+ * future).
+ * A scaling factor of 0 doesn't make sense, as is the case with
+ * negative values.
+ */
+ if ((1 > ret) || (5 < ret))
+ {
+ /* Fallback value for GDK scaling */
+ debug ("Scaling factor out of range, defaulting to 1");
+ ret = 1;
+ }
+
+ return ret;
}
public static int main (string[] args)