@@ -19,10 +19,9 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
1919 public Gala . WindowManager wm { get ; construct; }
2020 public Meta . WindowActor window_actor { get ; construct; }
2121
22- private bool dynamic_container = false ;
23-
24- private Clutter . Actor clone;
25- private Clutter . Actor container;
22+ private Clutter . Clone clone; // clone itself
23+ private Clutter . Actor clone_container; // clips the clone
24+ private Clutter . Actor container; // draws the shadow
2625 private Gala . CloseButton close_button;
2726 private Clutter . Actor resize_button;
2827 private DragDropAction move_action;
@@ -65,33 +64,30 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
6564 container_margin = button_size / 2 ;
6665
6766 reactive = true ;
68-
6967 set_pivot_point (0.5f , 0.5f );
7068 set_easing_mode (Clutter . AnimationMode . EASE_IN_QUAD );
7169
72- unowned var window = window_actor. get_meta_window ();
73- window. unmanaged. connect (on_close_click_clicked);
74- window. notify[" appears-focused" ]. connect (update_window_focus);
75-
76- unowned var workspace_manager = wm. get_display (). get_workspace_manager ();
77- workspace_manager. active_workspace_changed. connect (update_window_focus);
78-
7970 clone = new Clutter .Clone (window_actor);
8071
8172 move_action = new DragDropAction (DragDropActionType . SOURCE , " pip" );
8273 move_action. drag_begin. connect (on_move_begin);
8374 move_action. drag_canceled. connect (on_move_end);
8475 move_action. actor_clicked. connect (activate);
8576
86- container = new Clutter .Actor ();
87- container. reactive = true ;
88- container. set_scale (0.35f , 0.35f );
89- container. add_effect (new ShadowEffect (" window" ) { border_radius = 6 });
90- container. add_child (clone);
77+ clone_container = new Clutter .Actor () {
78+ scale_x = 0.35f ,
79+ scale_y = 0.35f
80+ };
81+ clone_container. add_child (clone);
82+
83+ container = new Clutter .Actor () {
84+ reactive = true
85+ };
86+ container. add_child (clone_container);
87+ container. add_effect (new ShadowEffect (" window" ));
9188 container. add_action (move_action);
9289
9390 update_size ();
94- update_container_position ();
9591
9692#if HAS_MUTTER45
9793 Mtk . Rectangle monitor_rect;
@@ -132,6 +128,13 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
132128 window_actor. notify[" allocation" ]. connect (on_allocation_changed);
133129 container. set_position (container_margin, container_margin);
134130 update_clone_clip ();
131+
132+ unowned var window = window_actor. get_meta_window ();
133+ window. unmanaged. connect (on_close_click_clicked);
134+ window. notify[" appears-focused" ]. connect (update_window_focus);
135+
136+ unowned var workspace_manager = wm. get_display (). get_workspace_manager ();
137+ workspace_manager. active_workspace_changed. connect (update_window_focus);
135138 }
136139
137140 public override void show () {
@@ -206,9 +209,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
206209 }
207210
208211 public void set_container_clip (Graphene . Rect ? container_clip) {
209- container. clip_rect = container_clip;
210- dynamic_container = true ;
211- update_container_scale ();
212+ clone_container. clip_rect = container_clip;
213+ update_clone_container_scale ();
212214 on_allocation_changed ();
213215 }
214216
@@ -269,7 +271,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
269271 width = begin_resize_width + diff_x;
270272 height = begin_resize_height + diff_y;
271273
272- update_container_scale ();
274+ update_clone_container_scale ();
273275 update_size ();
274276
275277 break ;
@@ -348,17 +350,28 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
348350 }
349351
350352 private void update_size () {
351- if (dynamic_container) {
353+ int clone_container_width, clone_container_height;
354+
355+ if (clone_container. has_clip) {
352356 float src_width = 0.0f , src_height = 0.0f ;
353- container . get_clip (null , null , out src_width, out src_height);
354- width = (int )(src_width * container . scale_x + button_size );
355- height = (int )(src_height * container . scale_y + button_size );
357+ clone_container . get_clip (null , null , out src_width, out src_height);
358+ clone_container_width = (int ) (src_width * clone_container . scale_x);
359+ clone_container_height = (int ) (src_height * clone_container . scale_y);
356360 } else {
357- width = (int )(container . width * container . scale_x + button_size );
358- height = (int )(container . height * container . scale_y + button_size );
361+ clone_container_width = (int ) (clone_container . width * clone_container . scale_x);
362+ clone_container_height = (int ) (clone_container . height * clone_container . scale_y);
359363 }
364+
365+ container. width = clone_container_width;
366+ container. height = clone_container_height;
367+
368+ width = clone_container_width + button_size;
369+ height = clone_container_height + button_size;
360370 }
361371
372+ /*
373+ * Offsets clone by csd shadow size.
374+ */
362375 private void update_clone_clip () {
363376 var rect = window_actor. get_meta_window (). get_frame_rect ();
364377
@@ -367,16 +380,16 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
367380 clone. set_clip (x_offset, y_offset, rect. width, rect. height);
368381 clone. set_position (- x_offset, - y_offset);
369382
370- container . set_size (rect. width, rect. height);
383+ clone_container . set_size (rect. width, rect. height);
371384 }
372385
373- private void update_container_scale () {
386+ private void update_clone_container_scale () {
374387 float src_width = 1.0f , src_height = 1.0f ;
375- if (dynamic_container ) {
376- container . get_clip (null , null , out src_width, out src_height);
388+ if (clone_container . has_clip ) {
389+ clone_container . get_clip (null , null , out src_width, out src_height);
377390 } else {
378- src_width = container . width;
379- src_height = container . height;
391+ src_width = clone_container . width;
392+ src_height = clone_container . height;
380393 }
381394
382395 float max_width = width - button_size;
@@ -395,18 +408,18 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
395408 float new_scale_x = new_width / window_width;
396409 float new_scale_y = new_height / window_height;
397410
398- container . scale_x = new_scale_x. clamp (MINIMUM_SCALE , MAXIMUM_SCALE );
399- container . scale_y = new_scale_y. clamp (MINIMUM_SCALE , MAXIMUM_SCALE );
411+ clone_container . scale_x = new_scale_x. clamp (MINIMUM_SCALE , MAXIMUM_SCALE );
412+ clone_container . scale_y = new_scale_y. clamp (MINIMUM_SCALE , MAXIMUM_SCALE );
400413
401- update_container_position ();
414+ update_clone_container_position ();
402415 }
403416
404- private void update_container_position () {
405- if (dynamic_container ) {
417+ private void update_clone_container_position () {
418+ if (clone_container . has_clip ) {
406419 float clip_x = 0.0f , clip_y = 0.0f ;
407- container . get_clip (out clip_x, out clip_y, null , null );
408- container . x = (float )(- clip_x * container . scale_x + container_margin );
409- container . y = (float )(- clip_y * container . scale_y + container_margin );
420+ clone_container . get_clip (out clip_x, out clip_y, null , null );
421+ clone_container . x = (float ) (- clip_x * clone_container . scale_x);
422+ clone_container . y = (float ) (- clip_y * clone_container . scale_y);
410423 }
411424 }
412425
@@ -545,8 +558,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
545558 }
546559
547560 private void get_target_window_size (out float width, out float height) {
548- if (dynamic_container ) {
549- container . get_clip (null , null , out width, out height);
561+ if (clone_container . has_clip ) {
562+ clone_container . get_clip (null , null , out width, out height);
550563 } else if (clone. has_clip) {
551564 clone. get_clip (null , null , out width, out height);
552565 } else {
0 commit comments