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: Amir Dahan <amirdahan24@gmail.com> Co-authored-by: Erik Reider <35975961+ErikReider@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user