Skip to content

Commit 1290c94

Browse files
authored
Fix OSD level animation lag when using gesture volume control (#13338)
* Fix jerky level animation for small value changes Fix jerky level animation for small value changes, if level value changes by less than 0.4 do it using new fast constant, set it to zero for now. the 0.4 is kind of hardcoded as the I wanted the brightness (that jumps by 0.4 on my system) to have the 100ms level animation and all below it 0ms. * Fix throttling OSD updates for gesture volume change throttling OSD manager show function calls to prevent event flooding when using gestures for volume control, which too was contributing to some choppiness. * Update Clutter animation to linear Updates Clutter animation to linear to make is smooth and lower burstiness of animation. * passed time arg to _set_volume which I forgot * add separate level func for gesture * update clean and minimal code * gesture: add polling const and UI touchups add polling const, reset last_time to 0 in begin() and show final volume state after gesture end. * update: fix indentation code had auto indented because of editor.
1 parent 8e6ab58 commit 1290c94

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

js/ui/gestures/actions.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const Magnifier = imports.ui.magnifier;
88

99
const touchpad_settings = new Gio.Settings({ schema_id: "org.cinnamon.desktop.peripherals.touchpad" });
1010

11+
const CONTINUOUS_ACTION_POLL_INTERVAL = 50 * 1000;
12+
1113
var make_action = (settings, definition, device) => {
1214
var threshold = 100;
1315

@@ -320,9 +322,12 @@ var VolumeAction = class extends BaseAction {
320322
this.max_volume = mixer.get_vol_max_norm();
321323

322324
this.pct_step = Math.ceil(this.max_volume / 100);
325+
326+
this.last_time = 0;
327+
this.poll_interval = CONTINUOUS_ACTION_POLL_INTERVAL;
323328
}
324329

325-
_set_volume(up, percentage) {
330+
_set_volume(up, percentage, time) {
326331
const sink = mixer.get_default_sink();
327332

328333
if (sink == null) {
@@ -356,7 +361,12 @@ var VolumeAction = class extends BaseAction {
356361
sink.change_is_muted(false);
357362
}
358363

364+
if (time < (this.last_time + this.poll_interval)) {
365+
return;
366+
}
367+
359368
Main.osdWindowManager.show(-1, this._get_volume_icon(int_pct, false), null, int_pct, false);
369+
this.last_time = time;
360370
}
361371

362372
_toggle_muted() {
@@ -395,16 +405,17 @@ var VolumeAction = class extends BaseAction {
395405
return;
396406
};
397407

408+
this.last_time = 0;
398409
this.update(direction, percentage, time);
399410
}
400411

401412
update(direction, percentage, time) {
402413
if (this.definition.action === "VOLUME_UP") {
403-
this._set_volume(true, percentage);
414+
this._set_volume(true, percentage, time);
404415
}
405416
else
406417
if (this.definition.action === "VOLUME_DOWN") {
407-
this._set_volume(false, 100 - percentage);
418+
this._set_volume(false, 100 - percentage, time);
408419
}
409420
}
410421

@@ -417,6 +428,13 @@ var VolumeAction = class extends BaseAction {
417428
if (percentage < this.threshold) {
418429
return;
419430
}
431+
432+
var int_pct = Math.ceil(percentage);
433+
if (this.definition.action === "VOLUME_DOWN") {
434+
int_pct = 100 - int_pct;
435+
}
436+
437+
Main.osdWindowManager.show(-1, this._get_volume_icon(int_pct), null, int_pct, false);
420438
}
421439
}
422440

@@ -462,7 +480,7 @@ var ZoomAction = class extends BaseAction {
462480
super(definition, device, threshold);
463481
this.last_percentage = 0;
464482
this.last_time = 0;
465-
this.poll_interval = 50 * 1000;
483+
this.poll_interval = CONTINUOUS_ACTION_POLL_INTERVAL;
466484

467485
if (definition.custom_value !== "") {
468486
try {

0 commit comments

Comments
 (0)