Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions plugins/pip/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
38 changes: 28 additions & 10 deletions plugins/pip/PopupWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 () {
Expand All @@ -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))) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down