Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cursor scaling for HiDPI displays #235

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/slick-greeter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public class SlickGreeter
stderr.printf ("[%+.2fs] %s %s\n", log_timer.elapsed (), prefix, message);
}

private static void check_hidpi ()
private static bool check_hidpi ()
{
try {
string output;
Expand All @@ -620,11 +620,13 @@ public class SlickGreeter
if (output == "2") {
debug ("Activating HiDPI (2x scale ratio)");
GLib.Environment.set_variable ("GDK_SCALE", "2", true);
return true;
}
}
catch (Error e){
warning ("Error while setting HiDPI support: %s", e.message);
}
return false;
}

private static void set_keyboard_layout ()
Expand Down Expand Up @@ -714,12 +716,15 @@ public class SlickGreeter
UGSettings.apply_conf_settings ();

var hidpi = UGSettings.get_string (UGSettings.KEY_ENABLE_HIDPI);
var cursor_scale = 1;
debug ("HiDPI support: %s", hidpi);
if (hidpi == "auto") {
check_hidpi ();
if (check_hidpi ())
cursor_scale = 2;
}
else if (hidpi == "on") {
GLib.Environment.set_variable ("GDK_SCALE", "2", true);
cursor_scale = 2;
}

/* Set the keyboard layout */
Expand Down Expand Up @@ -799,8 +804,8 @@ public class SlickGreeter
}
var int_value = UGSettings.get_integer (UGSettings.KEY_CURSOR_THEME_SIZE);
if (int_value != 0) {
debug ("Settings cursor theme size: %d", int_value);
settings.set ("gtk-cursor-theme-size", int_value, null);
debug ("Settings cursor theme size: %d", int_value * cursor_scale);
settings.set ("gtk-cursor-theme-size", int_value * cursor_scale, null);
}
value = UGSettings.get_string (UGSettings.KEY_FONT_NAME);
if (value != ""){
Expand Down