aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2023-10-06 15:01:34 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-10-10 22:33:00 +0200
commitf3a3bc4ce6a5a88b4514a9f14b18aec087e16d53 (patch)
tree575069048897f7ff55520e2d8641da76d4deb464
parent9e1b5ad15bbb8e62bf2127e825ad1d0e13ee821f (diff)
downloadarctica-greeter-f3a3bc4ce6a5a88b4514a9f14b18aec087e16d53.tar.gz
arctica-greeter-f3a3bc4ce6a5a88b4514a9f14b18aec087e16d53.tar.bz2
arctica-greeter-f3a3bc4ce6a5a88b4514a9f14b18aec087e16d53.zip
src/arctica-greeter.vala: add error handling to check_hidpi ().
Make sure that the value falls in the range 0 < x <= 5. Values higher than 5 are most probably errors (at the time of writing this code), negative values don't make sense at all and a value of 0 would mean not showing anything, which likewise is totally useless.
-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)