Skip to content

Commit f1c9964

Browse files
committed
WindowClone: Fix some warnings on allocate
1 parent 47035e4 commit f1c9964

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/Widgets/MultitaskingView/WindowClone.vala

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
308308

309309
var input_rect = window.get_buffer_rect ();
310310
var outer_rect = window.get_frame_rect ();
311-
var clone_scale_factor = width / outer_rect.width;
311+
var clone_scale_factor = outer_rect.width != 0 ? width / outer_rect.width : 1f;
312312

313313
// Compensate for invisible borders of the texture
314314
float clone_x = (input_rect.x - outer_rect.x) * clone_scale_factor;
@@ -325,12 +325,6 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
325325

326326
clone.set_scale (clone_scale_factor, clone_scale_factor);
327327

328-
float clone_width, clone_height;
329-
clone.get_preferred_size (null, null, out clone_width, out clone_height);
330-
331-
var clone_alloc = InternalUtils.actor_box_from_rect (0, 0, clone_width, clone_height);
332-
clone.allocate (clone_alloc);
333-
334328
Clutter.ActorBox shape_alloc = {
335329
-ACTIVE_SHAPE_SIZE,
336330
-ACTIVE_SHAPE_SIZE,
@@ -362,11 +356,12 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
362356
var monitor_index = display.get_monitor_index_for_rect (Mtk.Rectangle.from_graphene_rect (rect, ROUND));
363357
var monitor_scale = display.get_monitor_scale (monitor_index);
364358

365-
float window_title_max_width = box.get_width () - Utils.scale_to_int (TITLE_MAX_WIDTH_MARGIN, monitor_scale);
366-
float window_title_height, window_title_nat_width;
367-
window_title.get_preferred_size (null, null, out window_title_nat_width, out window_title_height);
359+
float window_title_min_width, window_title_nat_width, window_title_height;
360+
window_title.get_preferred_size (out window_title_min_width, null, out window_title_nat_width, out window_title_height);
361+
362+
float window_title_max_width = float.max (window_title_min_width, box.get_width () - Utils.scale_to_int (TITLE_MAX_WIDTH_MARGIN, monitor_scale));
368363

369-
var window_title_width = window_title_nat_width.clamp (0, window_title_max_width);
364+
var window_title_width = float.min (window_title_nat_width, window_title_max_width);
370365

371366
float window_title_x = (box.get_width () - window_title_width) / 2;
372367
float window_title_y = (window_icon.visible ? window_icon_y : box.get_height ()) - (window_title_height / 2) - Utils.scale_to_int (18, monitor_scale);

0 commit comments

Comments
 (0)