diff --git a/src/Gestures/GesturePropertyTransition.vala b/src/Gestures/GesturePropertyTransition.vala index 0281a3964..f90124e31 100644 --- a/src/Gestures/GesturePropertyTransition.vala +++ b/src/Gestures/GesturePropertyTransition.vala @@ -79,9 +79,9 @@ public class Gala.GesturePropertyTransition : Object { } /** - * Starts animating the property from {@link from_value} to {@link to_value}. If with_gesture is true + * Starts animating the property from {@link from_value} to {@link to_value}. If the GestureTracker is recognizing * it will connect to the gesture trackers signals and animate according to the input finishing with an easing - * to the final position. If with_gesture is false it will just ease to the {@link to_value}. + * to the final position. If it's not it will just ease to the {@link to_value}. * #this will keep itself alive until the animation finishes so it is safe to immediatly unref it after creation and calling start. * * @param done_callback a callback for when the transition finishes. This shouldn't be used for setting state, instead state should @@ -89,7 +89,7 @@ public class Gala.GesturePropertyTransition : Object { * done_callback will only be called if the animation finishes, not if it is interrupted e.g. by starting a new animation for the same property, * destroying the actor or removing the transition. */ - public void start (bool with_gesture, owned DoneCallback? done_callback = null) { + public void start (owned DoneCallback? done_callback = null) { ref (); this.done_callback = (owned) done_callback; @@ -159,7 +159,7 @@ public class Gala.GesturePropertyTransition : Object { } }; - if (with_gesture && AnimationsSettings.get_enable_animations ()) { + if (gesture_tracker.recognizing && AnimationsSettings.get_enable_animations ()) { gesture_tracker.connect_handlers (on_animation_begin, on_animation_update, on_animation_end); } else { on_animation_begin (0); diff --git a/src/Gestures/GestureTracker.vala b/src/Gestures/GestureTracker.vala index 89b684d0d..42db19a1a 100644 --- a/src/Gestures/GestureTracker.vala +++ b/src/Gestures/GestureTracker.vala @@ -197,10 +197,10 @@ public class Gala.GestureTracker : Object { /** * Connects a callback that will only be called if != 0 completions were made. - * If with_gesture is false it will be called immediately, otherwise once {@link on_end} is emitted. + * If #this is not recognizing it will be called immediately, otherwise once {@link on_end} is emitted. */ - public void add_success_callback (bool with_gesture, owned OnEnd callback) { - if (!with_gesture) { + public void add_success_callback (owned OnEnd callback) { + if (!recognizing || !AnimationsSettings.get_enable_animations ()) { callback (1, 1, min_animation_duration); } else { ulong handler_id = on_end.connect ((percentage, completions, duration) => { @@ -249,6 +249,7 @@ public class Gala.GestureTracker : Object { private bool gesture_detected (GestureBackend backend, Gesture gesture, uint32 timestamp) { if (enabled && on_gesture_detected (gesture)) { backend.prepare_gesture_handling (); + recognizing = true; on_gesture_handled (gesture, timestamp); return true; } @@ -261,7 +262,6 @@ public class Gala.GestureTracker : Object { on_begin (percentage); } - recognizing = true; previous_percentage = percentage; previous_time = elapsed_time; } @@ -298,12 +298,13 @@ public class Gala.GestureTracker : Object { completions += end_percentage < 0 ? -1 : 1; } + recognizing = false; + if (enabled) { on_end (end_percentage, completions, calculated_duration); } disconnect_all_handlers (); - recognizing = false; previous_percentage = 0; previous_time = 0; percentage_delta = 0; diff --git a/src/ShellClients/PanelClone.vala b/src/ShellClients/PanelClone.vala index 27d7d7099..66da80304 100644 --- a/src/ShellClients/PanelClone.vala +++ b/src/ShellClients/PanelClone.vala @@ -89,9 +89,9 @@ public class Gala.PanelClone : Object { return; } - new GesturePropertyTransition (actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (true)).start (false); + new GesturePropertyTransition (actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (true)).start (); - default_gesture_tracker.add_success_callback (false, () => panel_hidden = true); + default_gesture_tracker.add_success_callback (() => panel_hidden = true); } private void show () { @@ -103,8 +103,8 @@ public class Gala.PanelClone : Object { Utils.x11_unset_window_pass_through (panel.window); } - new GesturePropertyTransition (actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (false)).start (false); + new GesturePropertyTransition (actor, default_gesture_tracker, "translation-y", null, calculate_translation_y (false)).start (); - default_gesture_tracker.add_success_callback (false, () => panel_hidden = false); + default_gesture_tracker.add_success_callback (() => panel_hidden = false); } } diff --git a/src/Widgets/MonitorClone.vala b/src/Widgets/MonitorClone.vala index 5f6f66e7f..78e91a59e 100644 --- a/src/Widgets/MonitorClone.vala +++ b/src/Widgets/MonitorClone.vala @@ -92,17 +92,17 @@ namespace Gala { /** * Animate the windows from their old location to a tiled layout */ - public void open (bool with_gesture = false, bool is_cancel_animation = false) { + public void open (bool is_cancel_animation = false) { window_container.restack_windows (); - window_container.open (null, with_gesture, is_cancel_animation); + window_container.open (null, is_cancel_animation); } /** * Animate the windows back to their old location */ - public void close (bool with_gesture = false, bool is_cancel_animation = false) { + public void close (bool is_cancel_animation = false) { window_container.restack_windows (); - window_container.close (with_gesture); + window_container.close (); } private void window_left (int window_monitor, Meta.Window window) { diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 6c00b783f..44b6875c0 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -71,7 +71,7 @@ namespace Gala { multitasking_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION); multitasking_gesture_tracker.enable_touchpad (); multitasking_gesture_tracker.on_gesture_detected.connect (on_multitasking_gesture_detected); - multitasking_gesture_tracker.on_gesture_handled.connect (() => toggle (true, false)); + multitasking_gesture_tracker.on_gesture_handled.connect (() => toggle (false)); workspace_gesture_tracker = new GestureTracker (AnimationDuration.WORKSPACE_SWITCH_MIN, AnimationDuration.WORKSPACE_SWITCH); workspace_gesture_tracker.enable_touchpad (); @@ -367,7 +367,7 @@ namespace Gala { new GesturePropertyTransition (workspaces, workspace_gesture_tracker, "x", null, target_x) { overshoot_lower_clamp = lower_clamp, overshoot_upper_clamp = upper_clamp - }.start (true); + }.start (); GestureTracker.OnEnd on_animation_end = (percentage, completions, calculated_duration) => { switching_workspace_with_gesture = false; @@ -595,7 +595,7 @@ namespace Gala { * starting the modal mode and hiding the WindowGroup. Finally tells all components * to animate to their positions. */ - private void toggle (bool with_gesture = false, bool is_cancel_animation = false) { + private void toggle (bool is_cancel_animation = false) { if (animating) { return; } @@ -618,9 +618,9 @@ namespace Gala { foreach (var container in window_containers_monitors) { if (opening) { container.visible = true; - container.open (with_gesture, is_cancel_animation); + container.open (is_cancel_animation); } else { - container.close (with_gesture, is_cancel_animation); + container.close (is_cancel_animation); } } @@ -668,16 +668,16 @@ namespace Gala { foreach (unowned var child in workspaces.get_children ()) { unowned WorkspaceClone workspace = (WorkspaceClone) child; if (opening) { - workspace.open (with_gesture, is_cancel_animation); + workspace.open (is_cancel_animation); } else { - workspace.close (with_gesture, is_cancel_animation); + workspace.close (is_cancel_animation); } } if (opening) { - show_docks (with_gesture, is_cancel_animation); + show_docks (is_cancel_animation); } else { - hide_docks (with_gesture, is_cancel_animation); + hide_docks (is_cancel_animation); } GestureTracker.OnEnd on_animation_end = (percentage, completions) => { @@ -702,21 +702,21 @@ namespace Gala { animating = false; if (completions == 0) { - toggle (false, true); + toggle (true); } return Source.REMOVE; }); }; - if (!with_gesture) { + if (!multitasking_gesture_tracker.recognizing) { on_animation_end (1, 1, 0); } else { multitasking_gesture_tracker.connect_handlers (null, null, (owned) on_animation_end); } } - private void show_docks (bool with_gesture, bool is_cancel_animation) { + private void show_docks (bool is_cancel_animation) { unowned GLib.List window_actors = display.get_window_actors (); foreach (unowned Meta.WindowActor actor in window_actors) { const int MAX_OFFSET = 200; @@ -778,7 +778,7 @@ namespace Gala { clone.restore_easing_state (); }; - if (!with_gesture || !AnimationsSettings.get_enable_animations ()) { + if (!multitasking_gesture_tracker.recognizing || !AnimationsSettings.get_enable_animations ()) { on_animation_end (1, 1, 0); } else { multitasking_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end); @@ -786,7 +786,7 @@ namespace Gala { } } - private void hide_docks (bool with_gesture, bool is_cancel_animation) { + private void hide_docks (bool is_cancel_animation) { foreach (unowned var child in dock_clones.get_children ()) { var dock = (Clutter.Clone) child; var initial_y = dock.y; @@ -809,7 +809,7 @@ namespace Gala { dock.restore_easing_state (); }; - if (!with_gesture || !AnimationsSettings.get_enable_animations ()) { + if (!multitasking_gesture_tracker.recognizing || !AnimationsSettings.get_enable_animations ()) { on_animation_end (1, 1, 0); } else { multitasking_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end); diff --git a/src/Widgets/WindowClone.vala b/src/Widgets/WindowClone.vala index d7beb7f67..e1c9148d3 100644 --- a/src/Widgets/WindowClone.vala +++ b/src/Widgets/WindowClone.vala @@ -245,7 +245,7 @@ public class Gala.WindowClone : Clutter.Actor { * * @param animate Animate the transformation of the placement */ - public void transition_to_original_state (bool with_gesture = false) { + public void transition_to_original_state () { var outer_rect = window.get_frame_rect (); unowned var display = window.get_display (); @@ -257,18 +257,18 @@ public class Gala.WindowClone : Clutter.Actor { active = false; update_hover_widgets (true); - new GesturePropertyTransition (this, gesture_tracker, "x", null, (float) target_x).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "y", null, (float) target_y).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "width", null, (float) outer_rect.width).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "height", null, (float) outer_rect.height).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "shadow-opacity", (uint8) 255, (uint8) 0).start (with_gesture); - new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 255u, 0u).start (with_gesture, () => { + new GesturePropertyTransition (this, gesture_tracker, "x", null, (float) target_x).start (); + new GesturePropertyTransition (this, gesture_tracker, "y", null, (float) target_y).start (); + new GesturePropertyTransition (this, gesture_tracker, "width", null, (float) outer_rect.width).start (); + new GesturePropertyTransition (this, gesture_tracker, "height", null, (float) outer_rect.height).start (); + new GesturePropertyTransition (this, gesture_tracker, "shadow-opacity", (uint8) 255, (uint8) 0).start (); + new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 255u, 0u).start (() => { update_hover_widgets (false); toggle_shadow (false); }); if (should_fade ()) { - new GesturePropertyTransition (this, gesture_tracker, "opacity", null, 0u).start (with_gesture); + new GesturePropertyTransition (this, gesture_tracker, "opacity", null, 0u).start (); } } @@ -276,9 +276,9 @@ public class Gala.WindowClone : Clutter.Actor { * Animate the window to the given slot */ #if HAS_MUTTER45 - public void take_slot (Mtk.Rectangle rect, bool from_window_position, bool with_gesture = false) { + public void take_slot (Mtk.Rectangle rect, bool from_window_position) { #else - public void take_slot (Meta.Rectangle rect, bool from_window_position, bool with_gesture = false) { + public void take_slot (Meta.Rectangle rect, bool from_window_position) { #endif slot = rect; active = false; @@ -294,13 +294,13 @@ public class Gala.WindowClone : Clutter.Actor { update_hover_widgets (true); - new GesturePropertyTransition (this, gesture_tracker, "x", intial_x, (float) rect.x).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "y", intial_y, (float) rect.y).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "width", (float) initial_width, (float) rect.width).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "height", (float) initial_height, (float) rect.height).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "opacity", null, 255u).start (with_gesture); - new GesturePropertyTransition (this, gesture_tracker, "shadow-opacity", (uint8) 0, (uint8) 255).start (with_gesture); - new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 0u, 255u).start (with_gesture, () => { + new GesturePropertyTransition (this, gesture_tracker, "x", intial_x, (float) rect.x).start (); + new GesturePropertyTransition (this, gesture_tracker, "y", intial_y, (float) rect.y).start (); + new GesturePropertyTransition (this, gesture_tracker, "width", (float) initial_width, (float) rect.width).start (); + new GesturePropertyTransition (this, gesture_tracker, "height", (float) initial_height, (float) rect.height).start (); + new GesturePropertyTransition (this, gesture_tracker, "opacity", null, 255u).start (); + new GesturePropertyTransition (this, gesture_tracker, "shadow-opacity", (uint8) 0, (uint8) 255).start (); + new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 0u, 255u).start (() => { update_hover_widgets (false); toggle_shadow (true); }); diff --git a/src/Widgets/WindowCloneContainer.vala b/src/Widgets/WindowCloneContainer.vala index 4776e492d..d8fde7e62 100644 --- a/src/Widgets/WindowCloneContainer.vala +++ b/src/Widgets/WindowCloneContainer.vala @@ -167,7 +167,7 @@ namespace Gala { * Recalculate the tiling positions of the windows and animate them to * the resulting spots. */ - public void reflow (bool with_gesture = false, bool is_cancel_animation = false, bool opening = false) { + private void reflow (bool is_cancel_animation = false, bool opening = false) { if (!opened) { return; } @@ -206,7 +206,7 @@ namespace Gala { foreach (var tilable in window_positions) { unowned var clone = (WindowClone) tilable.id; - clone.take_slot (tilable.rect, opening && !is_cancel_animation, with_gesture); + clone.take_slot (tilable.rect, opening && !is_cancel_animation); } } @@ -369,7 +369,7 @@ namespace Gala { /** * When opened the WindowClones are animated to a tiled layout */ - public void open (Meta.Window? selected_window, bool with_gesture, bool is_cancel_animation) { + public void open (Meta.Window? selected_window, bool is_cancel_animation) { if (opened) { return; } @@ -393,14 +393,14 @@ namespace Gala { current_window = null; } - reflow (with_gesture, is_cancel_animation, true); + reflow (is_cancel_animation, true); } /** * Calls the transition_to_original_state() function on each child * to make them take their original locations again. */ - public void close (bool with_gesture = false) { + public void close () { if (!opened) { return; } @@ -408,7 +408,7 @@ namespace Gala { opened = false; foreach (var window in get_children ()) { - ((WindowClone) window).transition_to_original_state (with_gesture); + ((WindowClone) window).transition_to_original_state (); } } } diff --git a/src/Widgets/WindowOverview.vala b/src/Widgets/WindowOverview.vala index dda2272e9..30cdde90d 100644 --- a/src/Widgets/WindowOverview.vala +++ b/src/Widgets/WindowOverview.vala @@ -152,7 +152,7 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { } container.add_window (window); - container.open (display.get_focus_window (), false, false); + container.open (display.get_focus_window (), false); } } diff --git a/src/Widgets/WorkspaceClone.vala b/src/Widgets/WorkspaceClone.vala index 0b624c87d..5b3422488 100644 --- a/src/Widgets/WorkspaceClone.vala +++ b/src/Widgets/WorkspaceClone.vala @@ -368,7 +368,7 @@ namespace Gala { * Also sets the current_window of the WindowCloneContainer to the active window * if it belongs to this workspace. */ - public void open (bool with_gesture = false, bool is_cancel_animation = false) { + public void open (bool is_cancel_animation = false) { if (opened) { return; } @@ -389,9 +389,9 @@ namespace Gala { update_size (monitor); - new GesturePropertyTransition (this, gesture_tracker, "x", initial_x, target_x).start (with_gesture); - new GesturePropertyTransition (background, gesture_tracker, "scale-x", null, (double) scale).start (with_gesture); - new GesturePropertyTransition (background, gesture_tracker, "scale-y", null, (double) scale).start (with_gesture); + new GesturePropertyTransition (this, gesture_tracker, "x", initial_x, target_x).start (); + new GesturePropertyTransition (background, gesture_tracker, "scale-x", null, (double) scale).start (); + new GesturePropertyTransition (background, gesture_tracker, "scale-y", null, (double) scale).start (); #if HAS_MUTTER45 Mtk.Rectangle area = { @@ -413,14 +413,14 @@ namespace Gala { icon_group.redraw (); Meta.Window? selected_window = display.get_workspace_manager ().get_active_workspace () == workspace ? display.get_focus_window () : null; - window_container.open (selected_window, with_gesture, is_cancel_animation); + window_container.open (selected_window, is_cancel_animation); } /** * Close the view again by animating the background back to its scale and * the windows back to their old locations. */ - public void close (bool with_gesture = false, bool is_cancel_animation = false) { + public void close (bool is_cancel_animation = false) { if (!opened) { return; } @@ -432,11 +432,11 @@ namespace Gala { var initial_x = is_cancel_animation ? x : multitasking_view_x (); var target_x = multitasking_view_x () + current_x_overlap (); - new GesturePropertyTransition (this, gesture_tracker, "x", initial_x, target_x).start (with_gesture); - new GesturePropertyTransition (background, gesture_tracker, "scale-x", null, 1.0d).start (with_gesture); - new GesturePropertyTransition (background, gesture_tracker, "scale-y", null, 1.0d).start (with_gesture); + new GesturePropertyTransition (this, gesture_tracker, "x", initial_x, target_x).start (); + new GesturePropertyTransition (background, gesture_tracker, "scale-x", null, 1.0d).start (); + new GesturePropertyTransition (background, gesture_tracker, "scale-y", null, 1.0d).start (); - window_container.close (with_gesture); + window_container.close (); } } } diff --git a/src/WindowManager.vala b/src/WindowManager.vala index c3e7335a1..06873e990 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -657,11 +657,11 @@ namespace Gala { new GesturePropertyTransition (out_group, gesture_tracker, "x", 0f, to_value) { overshoot_upper_clamp = 0.1 - }.start (switch_workspace_with_gesture); + }.start (); new GesturePropertyTransition (wallpaper, gesture_tracker, "x", 0f, to_value) { overshoot_upper_clamp = 0.1 - }.start (switch_workspace_with_gesture, () => { + }.start (() => { switch_workspace_animation_finished (direction, false, true); animating_switch_workspace = false; });