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

Fix brightness slider choppiness #372

Merged
merged 5 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/controlCenter/widgets/backlight/backlight.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
});

Expand Down
8 changes: 4 additions & 4 deletions src/controlCenter/widgets/backlight/backlightUtil.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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) {
System64fumo marked this conversation as resolved.
Show resolved Hide resolved
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);
Expand Down
Loading