diff --git a/lib/CloseButton.vala b/lib/CloseButton.vala index fc69bea68..6bb31e509 100644 --- a/lib/CloseButton.vala +++ b/lib/CloseButton.vala @@ -46,7 +46,7 @@ public class Gala.CloseButton : Clutter.Actor { } private static Gdk.Pixbuf? get_close_button_pixbuf (float scale) { - var height = Utils.scale_to_int (36, scale); + var height = Utils.calculate_button_size (scale); if (close_pixbufs[height] == null) { try { @@ -71,7 +71,7 @@ public class Gala.CloseButton : Clutter.Actor { // works as good as some weird fallback-image-failed-to-load pixbuf critical ("Could not create close button"); - var size = Utils.scale_to_int (36, scale); + var size = Utils.calculate_button_size (scale); pixbuf_actor.set_size (size, size); pixbuf_actor.background_color = { 255, 0, 0, 255 }; } diff --git a/lib/Utils.vala b/lib/Utils.vala index 692c9351b..753f05a51 100644 --- a/lib/Utils.vala +++ b/lib/Utils.vala @@ -17,6 +17,8 @@ namespace Gala { public class Utils { + private const int BUTTON_SIZE = 36; + private struct CachedIcon { public Gdk.Pixbuf icon; public int icon_size; @@ -365,7 +367,7 @@ namespace Gala { * @return the resize button pixbuf or null if it failed to load */ public static Gdk.Pixbuf? get_resize_button_pixbuf (float scale) { - var height = scale_to_int (36, scale); + var height = calculate_button_size (scale); if (resize_pixbufs == null) { resize_pixbufs = new Gee.HashMap (); @@ -407,7 +409,7 @@ namespace Gala { // we'll just make this red so there's at least something as an // indicator that loading failed. Should never happen and this // works as good as some weird fallback-image-failed-to-load pixbuf - var size = scale_to_int (36, scale); + var size = calculate_button_size (scale); texture.set_size (size, size); texture.background_color = { 255, 0, 0, 255 }; } @@ -480,5 +482,9 @@ namespace Gala { return false; } } + + public static int calculate_button_size (float monitor_scale) { + return Utils.scale_to_int (BUTTON_SIZE, monitor_scale); + } } } diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index 78857a057..11f02777f 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -52,7 +52,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { construct { var scale = display.get_monitor_scale (display.get_current_monitor ()); - button_size = Gala.Utils.scale_to_int (36, scale); + button_size = Gala.Utils.calculate_button_size (scale); container_margin = button_size / 2; reactive = true; diff --git a/src/Widgets/MultitaskingView/WindowCloneContainer.vala b/src/Widgets/MultitaskingView/WindowCloneContainer.vala index 708534a41..9b1e76a20 100644 --- a/src/Widgets/MultitaskingView/WindowCloneContainer.vala +++ b/src/Widgets/MultitaskingView/WindowCloneContainer.vala @@ -309,8 +309,8 @@ public class Gala.WindowCloneContainer : ActorTarget { return k1 * k1 + k2 * k2; } - private static Mtk.Rectangle rect_adjusted (Mtk.Rectangle rect, int dx1, int dy1, int dx2, int dy2) { - return {rect.x + dx1, rect.y + dy1, rect.width + (-dx1 + dx2), rect.height + (-dy1 + dy2)}; + private static Mtk.Rectangle rect_adjusted (Mtk.Rectangle rect, int dw, int dh) { + return { rect.x + dw / 2, rect.y + dh / 2, rect.width - dw, rect.height - dh }; } private static Graphene.Point rect_center (Mtk.Rectangle rect) { @@ -325,7 +325,7 @@ public class Gala.WindowCloneContainer : ActorTarget { /** * Careful: List windows will be modified in place and shouldn't be used afterwards. */ - private static GLib.List calculate_grid_placement (Mtk.Rectangle area, GLib.List windows) { + private GLib.List calculate_grid_placement (Mtk.Rectangle area, GLib.List windows) { uint window_count = windows.length (); int columns = (int) Math.ceil (Math.sqrt (window_count)); int rows = (int) Math.ceil (window_count / (double) columns); @@ -395,6 +395,8 @@ public class Gala.WindowCloneContainer : ActorTarget { // see how many windows we have on the last row int left_over = (int) window_count - columns * (rows - 1); + var button_size = Utils.calculate_button_size (monitor_scale); + for (int slot = 0; slot < columns * rows; slot++) { var window = taken_slots[slot]; // some slots might be empty @@ -410,7 +412,7 @@ public class Gala.WindowCloneContainer : ActorTarget { slot_width, slot_height }; - target = rect_adjusted (target, 10, 10, -10, -10); + target = rect_adjusted (target, button_size, button_size); float scale; if (target.width / (double) rect.width < target.height / (double) rect.height) {