MultitaskingView/Gestures: Use pan backend

This commit is contained in:
Leonhard Kargl 2024-10-18 17:44:05 +02:00
parent 14a1be52cd
commit d5ffdff512
2 changed files with 22 additions and 4 deletions

View File

@ -53,6 +53,8 @@ namespace Gala {
} }
} }
private float workspaces_travel_distance;
public MultitaskingView (WindowManager wm) { public MultitaskingView (WindowManager wm) {
Object (wm: wm); Object (wm: wm);
} }
@ -70,11 +72,13 @@ namespace Gala {
multitasking_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION); multitasking_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);
multitasking_gesture_tracker.enable_touchpad (); 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_detected.connect (on_multitasking_gesture_detected);
multitasking_gesture_tracker.on_gesture_handled.connect (() => toggle (true, false)); 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 = new GestureTracker (AnimationDuration.WORKSPACE_SWITCH_MIN, AnimationDuration.WORKSPACE_SWITCH);
workspace_gesture_tracker.enable_touchpad (); 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.enable_scroll (this, Clutter.Orientation.HORIZONTAL);
workspace_gesture_tracker.on_gesture_detected.connect (on_workspace_gesture_detected); workspace_gesture_tracker.on_gesture_detected.connect (on_workspace_gesture_detected);
workspace_gesture_tracker.on_gesture_handled.connect ((gesture, timestamp) => { workspace_gesture_tracker.on_gesture_handled.connect ((gesture, timestamp) => {
@ -312,7 +316,8 @@ namespace Gala {
return false; 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; 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) { if (!is_nudge_animation && active_icon_group.get_transition ("backdrop-opacity") != null) {
active_icon_group.remove_transition ("backdrop-opacity"); active_icon_group.remove_transition ("backdrop-opacity");
} }
@ -689,9 +696,6 @@ namespace Gala {
} }
if (opening) { if (opening) {
modal_proxy = wm.push_modal (this);
modal_proxy.set_keybinding_filter (keybinding_filter);
wm.background_group.hide (); wm.background_group.hide ();
wm.window_group.hide (); wm.window_group.hide ();
wm.top_window_group.hide (); wm.top_window_group.hide ();
@ -761,6 +765,13 @@ namespace Gala {
dock_clones.destroy_all_children (); dock_clones.destroy_all_children ();
wm.pop_modal (modal_proxy); 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; animating = false;

View File

@ -180,6 +180,13 @@ namespace Gala {
}); });
background = new FramedBackground (wm); background = new FramedBackground (wm);
background.add_action (background_click_action); 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) { window_container = new WindowCloneContainer (wm, gesture_tracker, scale_factor) {
width = monitor_geometry.width, width = monitor_geometry.width,