diff --git a/lib/Gestures/ActorTarget.vala b/lib/Gestures/ActorTarget.vala index 97a287a85..cba526a44 100644 --- a/lib/Gestures/ActorTarget.vala +++ b/lib/Gestures/ActorTarget.vala @@ -11,12 +11,6 @@ * If a new child (or target via {@link add_target}) is added, its progress will be synced. */ public class Gala.ActorTarget : Clutter.Actor, GestureTarget { - public Clutter.Actor? actor { - get { - return this; - } - } - public bool animating { get { return ongoing_animations > 0; } } private double[] current_progress; diff --git a/lib/Gestures/GestureTarget.vala b/lib/Gestures/GestureTarget.vala index ad39067de..638797ece 100644 --- a/lib/Gestures/GestureTarget.vala +++ b/lib/Gestures/GestureTarget.vala @@ -13,11 +13,5 @@ public interface Gala.GestureTarget : Object { END } - /** - * The actor manipulated by the gesture. The associated frame clock - * will be used for animation timelines. - */ - public abstract Clutter.Actor? actor { get; } - public virtual void propagate (UpdateType update_type, GestureAction action, double progress) { } } diff --git a/lib/Gestures/PropertyTarget.vala b/lib/Gestures/PropertyTarget.vala index 13a606035..d2a971624 100644 --- a/lib/Gestures/PropertyTarget.vala +++ b/lib/Gestures/PropertyTarget.vala @@ -7,27 +7,34 @@ public class Gala.PropertyTarget : Object, GestureTarget { public GestureAction action { get; construct; } - - //we don't want to hold a strong reference to the actor because we might've been added to it which would form a reference cycle - private weak Clutter.Actor? _actor; - public Clutter.Actor? actor { get { return _actor; } } - + // Don't take a reference since we are most of the time owned by the target + public weak Object? target { get; private set; } public string property { get; construct; } public Clutter.Interval interval { get; construct; } - public PropertyTarget (GestureAction action, Clutter.Actor actor, string property, Type value_type, Value from_value, Value to_value) { + public PropertyTarget (GestureAction action, Object target, string property, Type value_type, Value from_value, Value to_value) { Object (action: action, property: property, interval: new Clutter.Interval.with_values (value_type, from_value, to_value)); - _actor = actor; - _actor.destroy.connect (() => _actor = null); + this.target = target; + this.target.weak_ref (on_target_disposed); + } + + ~PropertyTarget () { + if (target != null) { + target.weak_unref (on_target_disposed); + } + } + + private void on_target_disposed () { + target = null; } public override void propagate (UpdateType update_type, GestureAction action, double progress) { - if (update_type != UPDATE || action != this.action) { + if (target == null || update_type != UPDATE || action != this.action) { return; } - actor.set_property (property, interval.compute (progress)); + target.set_property (property, interval.compute (progress)); } } diff --git a/lib/Gestures/RootTarget.vala b/lib/Gestures/RootTarget.vala index 214347b45..fac6afcaa 100644 --- a/lib/Gestures/RootTarget.vala +++ b/lib/Gestures/RootTarget.vala @@ -6,6 +6,12 @@ */ public interface Gala.RootTarget : Object, GestureTarget { + /** + * The actor manipulated by the gesture. The associated frame clock + * will be used for animation timelines. + */ + public abstract Clutter.Actor? actor { get; } + public void add_gesture_controller (GestureController controller) requires (controller.target == null) { controller.attached (this); weak_ref (controller.detached); diff --git a/src/ShellClients/PanelWindow.vala b/src/ShellClients/PanelWindow.vala index 8ad3619a8..4235ea05b 100644 --- a/src/ShellClients/PanelWindow.vala +++ b/src/ShellClients/PanelWindow.vala @@ -8,6 +8,7 @@ public class Gala.PanelWindow : ShellWindow, RootTarget { private static HashTable window_struts = new HashTable (null, null); + public Clutter.Actor? actor { get { return (Clutter.Actor) window.get_compositor_private (); } } public WindowManager wm { get; construct; } public Pantheon.Desktop.Anchor anchor { get; construct set; } diff --git a/src/ShellClients/ShellClientsManager.vala b/src/ShellClients/ShellClientsManager.vala index b18691cf0..c56ee07b7 100644 --- a/src/ShellClients/ShellClientsManager.vala +++ b/src/ShellClients/ShellClientsManager.vala @@ -20,8 +20,6 @@ public class Gala.ShellClientsManager : Object, GestureTarget { return instance; } - public Clutter.Actor? actor { get { return wm.stage; } } - public WindowManager wm { get; construct; } private NotificationsClient notifications_client; diff --git a/src/ShellClients/ShellWindow.vala b/src/ShellClients/ShellWindow.vala index 778deefa1..5d5d7d2b1 100644 --- a/src/ShellClients/ShellWindow.vala +++ b/src/ShellClients/ShellWindow.vala @@ -6,7 +6,6 @@ */ public class Gala.ShellWindow : PositionedWindow, GestureTarget { - public Clutter.Actor? actor { get { return window_actor; } } public bool restore_previous_x11_region { private get; set; default = false; } private Meta.WindowActor window_actor; diff --git a/src/Widgets/MultitaskingView/MultitaskingView.vala b/src/Widgets/MultitaskingView/MultitaskingView.vala index fefb94ea3..4ee643cc9 100644 --- a/src/Widgets/MultitaskingView/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView/MultitaskingView.vala @@ -26,6 +26,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone private GestureController workspaces_gesture_controller; private GestureController multitasking_gesture_controller; + public Clutter.Actor? actor { get { return this; } } public WindowManagerGala wm { get; construct; } private Meta.Display display; diff --git a/src/Widgets/MultitaskingView/WindowClone.vala b/src/Widgets/MultitaskingView/WindowClone.vala index 44830a23a..dba31632c 100644 --- a/src/Widgets/MultitaskingView/WindowClone.vala +++ b/src/Widgets/MultitaskingView/WindowClone.vala @@ -27,6 +27,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget { */ public signal void request_reposition (); + public Clutter.Actor? actor { get { return this; } } public WindowManager wm { get; construct; } public Meta.Window window { get; construct; } diff --git a/src/Widgets/WindowOverview.vala b/src/Widgets/WindowOverview.vala index 78ead9884..dc78017d7 100644 --- a/src/Widgets/WindowOverview.vala +++ b/src/Widgets/WindowOverview.vala @@ -10,6 +10,7 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent private const int TOP_GAP = 30; private const int BOTTOM_GAP = 100; + public Clutter.Actor? actor { get { return this; } } public WindowManager wm { get; construct; } private GestureController gesture_controller; // Currently not used for actual touchpad gestures but only as controller