Skip to content

Commit db16bca

Browse files
committed
Clamp to pixel
1 parent 3190129 commit db16bca

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/InternalUtils.vala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,16 @@ namespace Gala {
336336
return { 0, 0, (int) screen_width, (int) screen_height };
337337
}
338338
}
339+
340+
public static Clutter.ActorBox actor_box_from_rect (float x, float y, float width, float height, bool clamp_to_pixel = true) {
341+
var actor_box = Clutter.ActorBox ();
342+
actor_box.init_rect (x, y, width, height);
343+
344+
if (clamp_to_pixel) {
345+
Clutter.ActorBox.clamp_to_pixel (ref actor_box);
346+
}
347+
348+
return actor_box;
349+
}
339350
}
340351
}

src/Widgets/WindowClone.vala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ public class Gala.WindowClone : Clutter.Actor {
456456
float clone_x = (input_rect.x - outer_rect.x) * clone_scale_factor;
457457
float clone_y = (input_rect.y - outer_rect.y) * clone_scale_factor;
458458

459-
var clone_alloc = Clutter.ActorBox ();
460-
clone_alloc.init_rect (clone_x, clone_y, clone_width, clone_height);
459+
var clone_alloc = InternalUtils.actor_box_from_rect (clone_x, clone_y, clone_width, clone_height);
461460
clone.allocate (clone_alloc);
462461

463462
Clutter.ActorBox shape_alloc = {
@@ -466,6 +465,7 @@ public class Gala.WindowClone : Clutter.Actor {
466465
box.get_width () + ACTIVE_SHAPE_SIZE,
467466
box.get_height () + ACTIVE_SHAPE_SIZE
468467
};
468+
Clutter.ActorBox.clamp_to_pixel (ref shape_alloc);
469469
active_shape.allocate (shape_alloc);
470470

471471
float close_button_width, close_button_height;
@@ -474,8 +474,7 @@ public class Gala.WindowClone : Clutter.Actor {
474474
var close_button_x = is_close_button_on_left () ?
475475
-close_button_width * 0.5f : box.get_width () - close_button_width * 0.5f;
476476

477-
var close_button_alloc = Clutter.ActorBox ();
478-
close_button_alloc.init_rect (close_button_x, -close_button_height * 0.33f, close_button_width, close_button_height);
477+
var close_button_alloc = InternalUtils.actor_box_from_rect (close_button_x, -close_button_height * 0.33f, close_button_width, close_button_height);
479478
close_button.allocate (close_button_alloc);
480479

481480
var monitor_index = wm.get_display ().get_monitor_index_for_rect ({ (int) box.get_x (), (int) box.get_y (), (int) box.get_width (), (int) box.get_height ()});
@@ -490,8 +489,7 @@ public class Gala.WindowClone : Clutter.Actor {
490489
float window_title_x = (box.get_width () - window_title_width) / 2;
491490
float window_title_y = box.get_height () - InternalUtils.scale_to_int (WINDOW_ICON_SIZE, monitor_scale) * 0.75f - (window_title_height / 2) - InternalUtils.scale_to_int (18, monitor_scale);
492491

493-
var window_title_alloc = Clutter.ActorBox ();
494-
window_title_alloc.init_rect (window_title_x, window_title_y, window_title_width, window_title_height);
492+
var window_title_alloc = InternalUtils.actor_box_from_rect (window_title_x, window_title_y, window_title_width, window_title_height);
495493
window_title.allocate (window_title_alloc);
496494
}
497495

0 commit comments

Comments
 (0)