Skip to content

Commit 2913596

Browse files
committed
Hide PiP in multitasking view
1 parent 4b53f12 commit 2913596

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

plugins/pip/Main.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {
9797
return;
9898
}
9999

100-
var popup_window = new PopupWindow (wm.get_display (), active);
100+
var popup_window = new PopupWindow (wm, active);
101101
popup_window.set_container_clip (rect);
102102
popup_window.show.connect (on_popup_window_show);
103103
popup_window.hide.connect (on_popup_window_hide);
@@ -117,7 +117,7 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {
117117
private void select_window_at (int x, int y) {
118118
var selected = get_window_actor_at (x, y);
119119
if (selected != null) {
120-
var popup_window = new PopupWindow (wm.get_display (), selected);
120+
var popup_window = new PopupWindow (wm, selected);
121121
popup_window.show.connect (on_popup_window_show);
122122
popup_window.hide.connect (on_popup_window_hide);
123123
add_window (popup_window);

plugins/pip/PopupWindow.vala

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: GPL-3.0-or-later
55
*/
66

7-
public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
7+
public class Gala.Plugins.PIP.PopupWindow : ActorTarget, RootTarget {
88
private int button_size;
99
private int container_margin;
1010
private const uint FADE_OUT_TIMEOUT = 200;
@@ -16,7 +16,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
1616

1717
public signal void closed ();
1818

19-
public Meta.Display display { get; construct; }
19+
public WindowManager wm { get; construct; }
2020
public Meta.WindowActor window_actor { get; construct; }
2121

2222
private Clutter.Clone clone; // clone itself
@@ -46,11 +46,13 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
4646
height = src_height * ratio;
4747
}
4848

49-
public PopupWindow (Meta.Display display, Meta.WindowActor window_actor) {
50-
Object (display: display, window_actor: window_actor);
49+
public PopupWindow (WindowManager wm, Meta.WindowActor window_actor) {
50+
Object (wm: wm, window_actor: window_actor);
5151
}
5252

5353
construct {
54+
unowned var display = wm.get_display ();
55+
5456
var scale = display.get_monitor_scale (display.get_current_monitor ());
5557

5658
button_size = Gala.Utils.scale_to_int (36, scale);
@@ -127,6 +129,21 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
127129

128130
unowned var workspace_manager = display.get_workspace_manager ();
129131
workspace_manager.active_workspace_changed.connect (update_window_focus);
132+
133+
var gesture_controller = new GestureController (MULTITASKING_VIEW, wm);
134+
gesture_controller.enable_touchpad ();
135+
add_gesture_controller (gesture_controller);
136+
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "opacity", typeof (uint), 255u, 0u));
137+
}
138+
139+
public override void start_progress (GestureAction action) {
140+
reactive = false;
141+
}
142+
143+
public override void end_progress (GestureAction action) {
144+
if (get_current_commit (MULTITASKING_VIEW) < 0.5) {
145+
reactive = true;
146+
}
130147
}
131148

132149
public override void show () {
@@ -200,9 +217,9 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
200217

201218
private Clutter.Actor on_move_begin () {
202219
#if HAS_MUTTER48
203-
display.set_cursor (Meta.Cursor.MOVE);
220+
wm.get_display ().set_cursor (Meta.Cursor.MOVE);
204221
#else
205-
display.set_cursor (Meta.Cursor.DND_IN_DRAG);
222+
wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG);
206223
#endif
207224

208225
return this;
@@ -211,7 +228,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
211228
private void on_move_end () {
212229
reactive = true;
213230
update_screen_position ();
214-
display.set_cursor (Meta.Cursor.DEFAULT);
231+
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
215232
}
216233

217234
private bool on_resize_button_press (Clutter.Event event) {
@@ -229,7 +246,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
229246
grab = resize_button.get_stage ().grab (resize_button);
230247
resize_button.event.connect (on_resize_event);
231248

232-
display.set_cursor (Meta.Cursor.SE_RESIZE);
249+
wm.get_display ().set_cursor (Meta.Cursor.SE_RESIZE);
233250

234251
return Clutter.EVENT_PROPAGATE;
235252
}
@@ -290,7 +307,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
290307

291308
update_screen_position ();
292309

293-
display.set_cursor (Meta.Cursor.DEFAULT);
310+
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
294311
}
295312

296313
private void on_allocation_changed () {
@@ -317,6 +334,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
317334
}
318335

319336
private void update_window_focus () {
337+
unowned var display = wm.get_display ();
320338
unowned Meta.Window focus_window = display.get_focus_window ();
321339
if ((focus_window != null && !Utils.get_window_is_normal (focus_window))
322340
|| (previous_focus != null && !Utils.get_window_is_normal (previous_focus))) {
@@ -423,7 +441,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
423441
private void place_window_in_screen () {
424442
off_screen = false;
425443

426-
var workarea_rect = display.get_workspace_manager ().get_active_workspace ().get_work_area_all_monitors ();
444+
var workarea_rect = wm.get_display ().get_workspace_manager ().get_active_workspace ().get_work_area_all_monitors ();
427445

428446
var screen_limit_start_x = workarea_rect.x + SCREEN_MARGIN;
429447
var screen_limit_end_x = workarea_rect.x + workarea_rect.width - SCREEN_MARGIN - width;
@@ -449,6 +467,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
449467
set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK);
450468
set_easing_duration (duration);
451469

470+
unowned var display = wm.get_display ();
452471
var monitor_rect = display.get_monitor_geometry (display.get_current_monitor ());
453472

454473
int monitor_x = monitor_rect.x;
@@ -496,6 +515,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
496515
}
497516

498517
private bool coord_is_in_other_monitor (float coord, Clutter.Orientation axis) {
518+
unowned var display = wm.get_display ();
519+
499520
int n_monitors = display.get_n_monitors ();
500521

501522
if (n_monitors == 1) {

0 commit comments

Comments
 (0)