From 8ecdb4cb2ae125898d92d9db82724d0b3da3e6a8 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 4 Mar 2026 15:11:47 +0100 Subject: [PATCH 1/4] PropertyTargets: Actually specify the type as uint8 if it's uint8 --- src/ShellClients/ExtendedBehaviorWindow.vala | 2 +- src/Widgets/MultitaskingView/StaticWindowClone.vala | 2 +- src/Widgets/MultitaskingView/WindowClone.vala | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) 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/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) { From e3c47e9e76a5eb41a2ca14e1a2328b45b668c7f9 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 4 Mar 2026 15:14:46 +0100 Subject: [PATCH 2/4] Specify custom progress func for uint8 --- lib/Gestures/Targets/PropertyTarget.vala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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; } From 4ef353d19259837502b370b4429e8f0eb465c2fc Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 4 Mar 2026 15:15:09 +0100 Subject: [PATCH 3/4] GestureController: Clamp progress to the given clamps --- lib/Gestures/GestureController.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } } From 5815f8a74d91242cc020638c6fc9c2cb4278f028 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Wed, 4 Mar 2026 15:15:23 +0100 Subject: [PATCH 4/4] MultitaskingView: Allow overshoot --- src/Widgets/MultitaskingView/MultitaskingView.vala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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);