Unverified Commit ee046a02 authored by System64's avatar System64 Committed by GitHub

Fix brightness slider choppiness (#372)

* Fix brightness slider choppiness Make setting the brightness function async to prevent stutter on some devices. * Fix implicit .begin deprecation warning --------- Co-authored-by: 's avatarAmir Dahan <amirdahan24@gmail.com> Co-authored-by: 's avatarErik Reider <35975961+ErikReider@users.noreply.github.com>
parent 7e4a8a1c
......@@ -52,7 +52,7 @@ namespace SwayNotificationCenter.Widgets {
slider.set_draw_value (false);
slider.set_round_digits (0);
slider.value_changed.connect (() => {
this.client.set_brightness ((float) slider.get_value ());
this.client.set_brightness.begin ((float) slider.get_value ());
slider.tooltip_text = ((int) slider.get_value ()).to_string ();
});
......
......@@ -3,7 +3,7 @@ namespace SwayNotificationCenter.Widgets {
[DBus (name = "org.freedesktop.login1.Session")]
interface Login1 : Object {
public abstract void set_brightness (string subsystem,
public abstract async void set_brightness (string subsystem,
string name, uint32 brightness) throws GLib.Error;
}
......@@ -77,14 +77,14 @@ namespace SwayNotificationCenter.Widgets {
if (monitor != null) monitor.cancel ();
}
public void set_brightness (float percent) {
public async void set_brightness (float percent) {
this.close ();
try {
if (subsystem == "backlight") {
int actual = calc_actual (percent);
login1.set_brightness (subsystem, device, actual);
login1.set_brightness.begin (subsystem, device, actual);
} else {
login1.set_brightness (subsystem, device, (uint32) percent);
login1.set_brightness.begin (subsystem, device, (uint32) percent);
}
} catch (Error e) {
error ("Error %s\n", e.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment