From d5ffdff51212e585f3b0ea73a2401245a1c10997 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Fri, 18 Oct 2024 17:44:05 +0200 Subject: [PATCH] MultitaskingView/Gestures: Use pan backend --- src/Widgets/MultitaskingView.vala | 19 +++++++++++++++---- src/Widgets/WorkspaceClone.vala | 7 +++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 3d882e52..8d6fc928 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -53,6 +53,8 @@ namespace Gala { } } + private float workspaces_travel_distance; + public MultitaskingView (WindowManager wm) { Object (wm: wm); } @@ -70,11 +72,13 @@ namespace Gala { multitasking_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION); multitasking_gesture_tracker.enable_touchpad (); + multitasking_gesture_tracker.enable_pan (wm, display.get_stage (), () => InternalUtils.travel_distance_from_primary (wm.get_display (), VERTICAL)); multitasking_gesture_tracker.on_gesture_detected.connect (on_multitasking_gesture_detected); multitasking_gesture_tracker.on_gesture_handled.connect (() => toggle (true, false)); workspace_gesture_tracker = new GestureTracker (AnimationDuration.WORKSPACE_SWITCH_MIN, AnimationDuration.WORKSPACE_SWITCH); workspace_gesture_tracker.enable_touchpad (); + workspace_gesture_tracker.enable_pan (wm, this, () => workspaces_travel_distance); workspace_gesture_tracker.enable_scroll (this, Clutter.Orientation.HORIZONTAL); workspace_gesture_tracker.on_gesture_detected.connect (on_workspace_gesture_detected); workspace_gesture_tracker.on_gesture_handled.connect ((gesture, timestamp) => { @@ -312,7 +316,8 @@ namespace Gala { return false; } - if (gesture.type == SCROLL || GestureSettings.get_action (gesture) == SWITCH_WORKSPACE) { + if (gesture.type == SCROLL || GestureSettings.get_action (gesture) == SWITCH_WORKSPACE || + gesture.type == TOUCHPAD_SWIPE && gesture.fingers == 1 && (gesture.direction == RIGHT || gesture.direction == LEFT)) { return true; } @@ -360,6 +365,8 @@ namespace Gala { } } + workspaces_travel_distance = (initial_x - target_x).abs (); + if (!is_nudge_animation && active_icon_group.get_transition ("backdrop-opacity") != null) { active_icon_group.remove_transition ("backdrop-opacity"); } @@ -689,9 +696,6 @@ namespace Gala { } if (opening) { - modal_proxy = wm.push_modal (this); - modal_proxy.set_keybinding_filter (keybinding_filter); - wm.background_group.hide (); wm.window_group.hide (); wm.top_window_group.hide (); @@ -761,6 +765,13 @@ namespace Gala { dock_clones.destroy_all_children (); wm.pop_modal (modal_proxy); + + multitasking_gesture_tracker.enable_pan (wm, wm.get_display ().get_stage (), () => InternalUtils.travel_distance_from_primary (wm.get_display (), VERTICAL)); + } else { + modal_proxy = wm.push_modal (this); + modal_proxy.set_keybinding_filter (keybinding_filter); + // We now have to listen to events on this because it's now modal i.e. the stage doesn't get the events anymore + multitasking_gesture_tracker.enable_pan (wm, this, () => InternalUtils.travel_distance_from_primary (wm.get_display (), VERTICAL)); } animating = false; diff --git a/src/Widgets/WorkspaceClone.vala b/src/Widgets/WorkspaceClone.vala index 2dfe0c99..aeac825e 100644 --- a/src/Widgets/WorkspaceClone.vala +++ b/src/Widgets/WorkspaceClone.vala @@ -180,6 +180,13 @@ namespace Gala { }); background = new FramedBackground (wm); background.add_action (background_click_action); + // For some reason the click action doesn't respond to button releases anymore + // once the background was touched. This should hopefully be fixed with the + // new Clutter.Gestures that are being introduced upstream + background.button_release_event.connect (() => { + selected (true); + return Clutter.EVENT_STOP; + }); window_container = new WindowCloneContainer (wm, gesture_tracker, scale_factor) { width = monitor_geometry.width,