Skip to content
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
4 changes: 2 additions & 2 deletions lib/Gestures/GestureController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
20 changes: 20 additions & 0 deletions lib/Gestures/Targets/PropertyTarget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion src/ShellClients/ExtendedBehaviorWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Widgets/MultitaskingView/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/MultitaskingView/StaticWindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/MultitaskingView/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down