@@ -67,23 +67,23 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
6767 }
6868
6969 private DragDropAction ? drag_action = null ;
70- private Clutter . Clone ? clone = null ;
7170 private ShadowEffect ? shadow_effect = null ;
7271
7372 private Clutter . Actor prev_parent = null ;
7473 private int prev_index = - 1 ;
7574 private ulong check_confirm_dialog_cb = 0 ;
7675 private bool in_slot_animation = false ;
7776
78- private Clutter . Actor clone_container ;
77+ private Clutter . Clone clone ;
7978 private Gala . CloseButton close_button;
8079 private ActiveShape active_shape;
8180 private Clutter . Actor window_icon;
8281 private Tooltip window_title;
8382
8483 private GestureController gesture_controller;
8584
86- public WindowClone (WindowManager wm, Meta . Window window, float monitor_scale, bool overview_mode = false ) {
85+ public WindowClone (WindowManager wm, Meta . Window window, float monitor_scale, bool overview_mode = false )
86+ requires (window. get_compositor_private () != null ) {
8787 Object (
8888 wm: wm,
8989 window: window,
@@ -126,23 +126,22 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
126126 add_action (drag_action);
127127 }
128128
129- active_shape = new ActiveShape ();
130- active_shape. opacity = 0 ;
131-
132- clone_container = new Clutter .Actor () {
133- pivot_point = { 0.5f , 0.5f }
129+ active_shape = new ActiveShape () {
130+ opacity = 0
134131 };
135132
133+ clone = new Clutter .Clone ((Meta . WindowActor ) window. get_compositor_private ());
134+
136135 window_title = new Tooltip ();
137136
138137 add_child (active_shape);
139- add_child (clone_container );
138+ add_child (clone );
140139 add_child (window_title);
141140
142141 notify[" monitor-scale" ]. connect (reallocate);
143142 reallocate ();
144143
145- InternalUtils . wait_for_window_actor (window, load_clone );
144+ check_shadow_requirements ( );
146145
147146 window. notify[" title" ]. connect (() = > window_title. set_text (window. get_title () ?? " " ));
148147 window_title. set_text (window. get_title () ?? " " );
@@ -178,29 +177,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
178177 set_child_below_sibling (window_icon, window_title);
179178 }
180179
181- /**
182- * Waits for the texture of a new Meta.WindowActor to be available
183- * and makes a close of it. If it was already was assigned a slot
184- * at this point it will animate to it. Otherwise it will just place
185- * itself at the location of the original window. Also adds the shadow
186- * effect and makes sure the shadow is updated on size changes.
187- */
188- private void load_clone (Meta . WindowActor actor) {
189- if (overview_mode) {
190- actor. hide ();
191- }
192-
193- clone = new Clutter .Clone (actor);
194- clone_container. add_child (clone);
195-
196- check_shadow_requirements ();
197- }
198-
199180 private void check_shadow_requirements () {
200- if (clone == null ) {
201- return ;
202- }
203-
204181 if (window. fullscreen || window. maximized_horizontally && window. maximized_vertically) {
205182 if (shadow_effect == null ) {
206183 shadow_effect = new ShadowEffect (" window" , monitor_scale);
@@ -279,8 +256,8 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
279256 var target_translation_y = (float ) (- CLOSE_TRANSLATION * monitor_scale * progress);
280257 var target_opacity = (uint ) (255 * (1 - progress));
281258
282- clone_container . translation_y = target_translation_y;
283- clone_container . opacity = target_opacity;
259+ clone . translation_y = target_translation_y;
260+ clone . opacity = target_opacity;
284261
285262 window_icon. translation_y = target_translation_y;
286263 window_icon. opacity = target_opacity;
@@ -303,29 +280,24 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
303280 public override void allocate (Clutter . ActorBox box) {
304281 base . allocate (box);
305282
306- var input_rect = window. get_buffer_rect ();
307- var outer_rect = window. get_frame_rect ();
308- var clone_scale_factor = width / outer_rect. width;
309-
310- // Compensate for invisible borders of the texture
311- float clone_x = (input_rect. x - outer_rect. x) * clone_scale_factor;
312- float clone_y = (input_rect. y - outer_rect. y) * clone_scale_factor;
313-
314- var clone_container_alloc = InternalUtils . actor_box_from_rect (clone_x, clone_y, input_rect. width * clone_scale_factor, input_rect. height * clone_scale_factor);
315- clone_container. allocate (clone_container_alloc);
316-
317- if (clone == null || (drag_action != null && drag_action. dragging)) {
283+ if (drag_action != null && drag_action. dragging) {
318284 return ;
319285 }
320286
321- unowned var display = wm. get_display ();
287+ var input_rect = window. get_buffer_rect ();
288+ var outer_rect = window. get_frame_rect ();
289+ var clone_scale_factor = width / outer_rect. width;
322290
323291 clone. set_scale (clone_scale_factor, clone_scale_factor);
324292
325293 float clone_width, clone_height;
326294 clone. get_preferred_size (null , null , out clone_width, out clone_height);
327295
328- var clone_alloc = InternalUtils . actor_box_from_rect (0 , 0 , clone_width, clone_height);
296+ // Compensate for invisible borders of the texture
297+ float clone_x = (input_rect. x - outer_rect. x) * clone_scale_factor;
298+ float clone_y = (input_rect. y - outer_rect. y) * clone_scale_factor;
299+
300+ var clone_alloc = InternalUtils . actor_box_from_rect (clone_x, clone_y, clone_width, clone_height);
329301 clone. allocate (clone_alloc);
330302
331303 Clutter . ActorBox shape_alloc = {
@@ -355,6 +327,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
355327 var window_icon_alloc = InternalUtils . actor_box_from_rect (window_icon_x, window_icon_y, window_icon_width, window_icon_height);
356328 window_icon. allocate (window_icon_alloc);
357329
330+ unowned var display = wm. get_display ();
358331 var rect = get_transformed_extents ();
359332 var monitor_index = display. get_monitor_index_for_rect (Mtk . Rectangle . from_graphene_rect (rect, ROUND ));
360333 var monitor_scale = display. get_monitor_scale (monitor_index);
@@ -429,9 +402,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
429402 drag_action. cancel ();
430403 }
431404
432- if (clone != null ) {
433- clone. destroy ();
434- }
405+ clone. destroy ();
435406
436407 if (check_confirm_dialog_cb != 0 ) {
437408 SignalHandler . disconnect (window. get_display (), check_confirm_dialog_cb);
0 commit comments