diff --git a/lib/WindowManager.vala b/lib/WindowManager.vala index 908b9d6ec..6d26e91aa 100644 --- a/lib/WindowManager.vala +++ b/lib/WindowManager.vala @@ -204,5 +204,13 @@ namespace Gala { * @return true if the action should be prohibited, false otherwise */ public abstract bool filter_action (GestureAction action); + + /** + * Adds target to the multitasking view and window overview so the target responds to the multitasking view + * close/open gesture and shortcuts. + * + * @param target Target to add to multitasking view and window overview + */ + public abstract void add_multitasking_view_target (GestureTarget target); } } diff --git a/plugins/pip/Main.vala b/plugins/pip/Main.vala index c5976e7e2..9e81aecef 100644 --- a/plugins/pip/Main.vala +++ b/plugins/pip/Main.vala @@ -97,7 +97,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin { return; } - var popup_window = new PopupWindow (wm.get_display (), active); + var popup_window = new PopupWindow (wm, active); popup_window.set_container_clip (rect); popup_window.show.connect (on_popup_window_show); popup_window.hide.connect (on_popup_window_hide); @@ -117,7 +117,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin { private void select_window_at (int x, int y) { var selected = get_window_actor_at (x, y); if (selected != null) { - var popup_window = new PopupWindow (wm.get_display (), selected); + var popup_window = new PopupWindow (wm, selected); popup_window.show.connect (on_popup_window_show); popup_window.hide.connect (on_popup_window_hide); add_window (popup_window); diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index ebb7f8549..ec9c08f08 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { +public class Gala.Plugins.PIP.PopupWindow : ActorTarget, RootTarget { private int button_size; private int container_margin; private const uint FADE_OUT_TIMEOUT = 200; @@ -16,7 +16,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { public signal void closed (); - public Meta.Display display { get; construct; } + public WindowManager wm { get; construct; } public Meta.WindowActor window_actor { get; construct; } private Clutter.Clone clone; // clone itself @@ -46,11 +46,13 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { height = src_height * ratio; } - public PopupWindow (Meta.Display display, Meta.WindowActor window_actor) { - Object (display: display, window_actor: window_actor); + public PopupWindow (WindowManager wm, Meta.WindowActor window_actor) { + Object (wm: wm, window_actor: window_actor); } construct { + unowned var display = wm.get_display (); + var scale = display.get_monitor_scale (display.get_current_monitor ()); button_size = Gala.Utils.scale_to_int (36, scale); @@ -127,6 +129,18 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { unowned var workspace_manager = display.get_workspace_manager (); workspace_manager.active_workspace_changed.connect (update_window_focus); + + wm.add_multitasking_view_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint), 255u, 0u)); + } + + public override void start_progress (GestureAction action) { + reactive = false; + } + + public override void end_progress (GestureAction action) { + if (get_current_commit (MULTITASKING_VIEW) < 0.5) { + reactive = true; + } } public override void show () { @@ -200,9 +214,9 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private Clutter.Actor on_move_begin () { #if HAS_MUTTER48 - display.set_cursor (Meta.Cursor.MOVE); + wm.get_display ().set_cursor (Meta.Cursor.MOVE); #else - display.set_cursor (Meta.Cursor.DND_IN_DRAG); + wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG); #endif return this; @@ -211,7 +225,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private void on_move_end () { reactive = true; update_screen_position (); - display.set_cursor (Meta.Cursor.DEFAULT); + wm.get_display ().set_cursor (Meta.Cursor.DEFAULT); } private bool on_resize_button_press (Clutter.Event event) { @@ -229,7 +243,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { grab = resize_button.get_stage ().grab (resize_button); resize_button.event.connect (on_resize_event); - display.set_cursor (Meta.Cursor.SE_RESIZE); + wm.get_display ().set_cursor (Meta.Cursor.SE_RESIZE); return Clutter.EVENT_PROPAGATE; } @@ -290,7 +304,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { update_screen_position (); - display.set_cursor (Meta.Cursor.DEFAULT); + wm.get_display ().set_cursor (Meta.Cursor.DEFAULT); } private void on_allocation_changed () { @@ -317,6 +331,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { } private void update_window_focus () { + unowned var display = wm.get_display (); unowned Meta.Window focus_window = display.get_focus_window (); if ((focus_window != null && !Utils.get_window_is_normal (focus_window)) || (previous_focus != null && !Utils.get_window_is_normal (previous_focus))) { @@ -423,7 +438,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private void place_window_in_screen () { off_screen = false; - var workarea_rect = display.get_workspace_manager ().get_active_workspace ().get_work_area_all_monitors (); + var workarea_rect = wm.get_display ().get_workspace_manager ().get_active_workspace ().get_work_area_all_monitors (); var screen_limit_start_x = workarea_rect.x + SCREEN_MARGIN; var screen_limit_end_x = workarea_rect.x + workarea_rect.width - SCREEN_MARGIN - width; @@ -449,6 +464,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK); set_easing_duration (duration); + unowned var display = wm.get_display (); var monitor_rect = display.get_monitor_geometry (display.get_current_monitor ()); int monitor_x = monitor_rect.x; @@ -496,6 +512,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { } private bool coord_is_in_other_monitor (float coord, Clutter.Orientation axis) { + unowned var display = wm.get_display (); + int n_monitors = display.get_n_monitors (); if (n_monitors == 1) { diff --git a/src/WindowManager.vala b/src/WindowManager.vala index b22b019f7..e6a1d26d1 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -1688,6 +1688,14 @@ namespace Gala { return modal_stack.peek_head ().filter_action (action); } + public void add_multitasking_view_target (GestureTarget target) { + multitasking_view.add_target (target); + + if (window_overview is WindowOverview) { + ((WindowOverview) window_overview).add_target (target); + } + } + public override void confirm_display_change () { unowned var monitor_manager = get_display ().get_context ().get_backend ().get_monitor_manager (); var timeout = monitor_manager.get_display_configuration_timeout ();