Skip to content

Commit 34ca9b3

Browse files
authored
Add cursor scaling for HiDPI displays (#235)
1 parent 5bd9be1 commit 34ca9b3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/slick-greeter.vala

+9-4
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public class SlickGreeter
611611
stderr.printf ("[%+.2fs] %s %s\n", log_timer.elapsed (), prefix, message);
612612
}
613613

614-
private static void check_hidpi ()
614+
private static bool check_hidpi ()
615615
{
616616
try {
617617
string output;
@@ -620,11 +620,13 @@ public class SlickGreeter
620620
if (output == "2") {
621621
debug ("Activating HiDPI (2x scale ratio)");
622622
GLib.Environment.set_variable ("GDK_SCALE", "2", true);
623+
return true;
623624
}
624625
}
625626
catch (Error e){
626627
warning ("Error while setting HiDPI support: %s", e.message);
627628
}
629+
return false;
628630
}
629631

630632
private static void set_keyboard_layout ()
@@ -714,12 +716,15 @@ public class SlickGreeter
714716
UGSettings.apply_conf_settings ();
715717

716718
var hidpi = UGSettings.get_string (UGSettings.KEY_ENABLE_HIDPI);
719+
var cursor_scale = 1;
717720
debug ("HiDPI support: %s", hidpi);
718721
if (hidpi == "auto") {
719-
check_hidpi ();
722+
if (check_hidpi ())
723+
cursor_scale = 2;
720724
}
721725
else if (hidpi == "on") {
722726
GLib.Environment.set_variable ("GDK_SCALE", "2", true);
727+
cursor_scale = 2;
723728
}
724729

725730
/* Set the keyboard layout */
@@ -799,8 +804,8 @@ public class SlickGreeter
799804
}
800805
var int_value = UGSettings.get_integer (UGSettings.KEY_CURSOR_THEME_SIZE);
801806
if (int_value != 0) {
802-
debug ("Settings cursor theme size: %d", int_value);
803-
settings.set ("gtk-cursor-theme-size", int_value, null);
807+
debug ("Settings cursor theme size: %d", int_value * cursor_scale);
808+
settings.set ("gtk-cursor-theme-size", int_value * cursor_scale, null);
804809
}
805810
value = UGSettings.get_string (UGSettings.KEY_FONT_NAME);
806811
if (value != ""){

0 commit comments

Comments
 (0)