diff --git a/lib/Gestures/GestureController.vala b/lib/Gestures/GestureController.vala index 89ee3e2f1..3b093dcf3 100644 --- a/lib/Gestures/GestureController.vala +++ b/lib/Gestures/GestureController.vala @@ -61,8 +61,8 @@ public class Gala.GestureController : Object { public double progress { get { return _progress; } set { - _progress = value; - target?.propagate (UPDATE, action, value); + _progress = value.clamp (overshoot_lower_clamp, overshoot_upper_clamp); + target?.propagate (UPDATE, action, _progress); } } diff --git a/lib/Gestures/Targets/PropertyTarget.vala b/lib/Gestures/Targets/PropertyTarget.vala index fca2add53..6f723463f 100644 --- a/lib/Gestures/Targets/PropertyTarget.vala +++ b/lib/Gestures/Targets/PropertyTarget.vala @@ -6,6 +6,26 @@ */ public class Gala.PropertyTarget : Object, GestureTarget { + static construct { + /* The default progress func starts from the beginning when it overflows but we want + to clamp. E.g. when the multitasking view overshoots we want the opacity + to stay at max and not switch to 0 again. */ + Clutter.Interval.register_progress_func (typeof (uint8), uint8_progress_func); + } + + private static bool uint8_progress_func (Value a, Value b, double progress, Value result) { + if (a.type () != typeof (uint8) || b.type () != typeof (uint8)) { + return false; + } + + var a_val = a.get_uchar (); + var b_val = b.get_uchar (); + + var res = (uint8) (a_val + progress * b_val).clamp (0, 255); + result.set_uchar (res); + return true; + } + public GestureAction action { get; construct; } // Don't take a reference since we are most of the time owned by the target public weak Object? target { get; private set; } diff --git a/src/ShellClients/ExtendedBehaviorWindow.vala b/src/ShellClients/ExtendedBehaviorWindow.vala index 0e83b7fac..f729bb6b4 100644 --- a/src/ShellClients/ExtendedBehaviorWindow.vala +++ b/src/ShellClients/ExtendedBehaviorWindow.vala @@ -10,7 +10,7 @@ public class Gala.ExtendedBehaviorWindow : ShellWindow { public bool dim { get; private set; default = false; } public ExtendedBehaviorWindow (Meta.Window window) { - var target = new PropertyTarget (CUSTOM, window.get_compositor_private (), "opacity", typeof (uint), 255u, 0u); + var target = new PropertyTarget (CUSTOM, window.get_compositor_private (), "opacity", typeof (uint8), (uint8) 255u, (uint8) 0u); Object (window: window, hide_target: target); } diff --git a/src/Widgets/MultitaskingView/MultitaskingView.vala b/src/Widgets/MultitaskingView/MultitaskingView.vala index ac0a76642..a94064a84 100644 --- a/src/Widgets/MultitaskingView/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView/MultitaskingView.vala @@ -59,7 +59,10 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone opened = false; display = wm.get_display (); - multitasking_gesture_controller = new GestureController (MULTITASKING_VIEW); + multitasking_gesture_controller = new GestureController (MULTITASKING_VIEW) { + overshoot_upper_clamp = 1.1, + overshoot_lower_clamp = -0.1, + }; multitasking_gesture_controller.add_trigger (new GlobalTrigger (MULTITASKING_VIEW, wm)); add_gesture_controller (multitasking_gesture_controller); diff --git a/src/Widgets/MultitaskingView/StaticWindowClone.vala b/src/Widgets/MultitaskingView/StaticWindowClone.vala index 56b0c744d..1ef2440ef 100644 --- a/src/Widgets/MultitaskingView/StaticWindowClone.vala +++ b/src/Widgets/MultitaskingView/StaticWindowClone.vala @@ -22,7 +22,7 @@ public class Gala.StaticWindowClone : ActorTarget { var clone = new Clutter.Clone (window_actor); add_child (clone); - add_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint), 255u, 0u)); + add_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint8), (uint8) 255u, (uint8) 0u)); window_actor.bind_property ("x", this, "x", SYNC_CREATE); window_actor.bind_property ("y", this, "y", SYNC_CREATE); diff --git a/src/Widgets/MultitaskingView/WindowClone.vala b/src/Widgets/MultitaskingView/WindowClone.vala index ff3255af4..5a185c08d 100644 --- a/src/Widgets/MultitaskingView/WindowClone.vala +++ b/src/Widgets/MultitaskingView/WindowClone.vala @@ -274,11 +274,11 @@ public class Gala.WindowClone : ActorTarget, RootTarget { opacity = 255u; } - add_target (new PropertyTarget (MULTITASKING_VIEW, window_icon, "opacity", typeof (uint), 0u, 255u)); + add_target (new PropertyTarget (MULTITASKING_VIEW, window_icon, "opacity", typeof (uint8), (uint8) 0u, (uint8) 255u)); - add_target (new PropertyTarget (MULTITASKING_VIEW, window_title, "opacity", typeof (uint), 0u, 255u)); + add_target (new PropertyTarget (MULTITASKING_VIEW, window_title, "opacity", typeof (uint8), (uint8) 0u, (uint8) 255u)); - add_target (new PropertyTarget (MULTITASKING_VIEW, close_button, "opacity", typeof (uint), 0u, 255u)); + add_target (new PropertyTarget (MULTITASKING_VIEW, close_button, "opacity", typeof (uint8), (uint8) 0u, (uint8) 255u)); } public override void update_progress (Gala.GestureAction action, double progress) {