a11y: Delay dwell click timer animation (#1156)

This commit is contained in:
José Expósito 2021-06-04 18:00:42 +02:00 committed by GitHub
parent 29cd5ad361
commit 11643da1e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,13 @@ namespace Gala {
private const double START_ANGLE = 3 * Math.PI / 2;
/**
* Delay, in milliseconds, before showing the animation.
* libinput uses a timeout of 180ms when tapping is enabled. Use that value plus a safety
* margin so the animation is never displayed when tapping.
*/
private const double DELAY_TIMEOUT = 185;
private int scaling_factor = 1;
private int cursor_size = 24;
@ -94,6 +101,10 @@ namespace Gala {
}
public override void paint (Clutter.PaintContext context) {
if (angle == 0) {
return;
}
var rgba = InternalUtils.get_theme_accent_color ();
/* Don't use alpha from the stylesheet to ensure contrast */
@ -145,7 +156,14 @@ namespace Gala {
public bool interpolate_value (string property_name, Clutter.Interval interval, double progress, out Value @value) {
if (property_name == "angle") {
@value = progress * 2 * Math.PI;
@value = 0;
var elapsed_time = transition.get_elapsed_time ();
if (elapsed_time > DELAY_TIMEOUT) {
double delayed_progress = (elapsed_time - DELAY_TIMEOUT) / (transition.duration - DELAY_TIMEOUT);
@value = (delayed_progress * 2 * Math.PI);
}
return true;
}