Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/CloseButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 };
}
Expand Down
10 changes: 8 additions & 2 deletions lib/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<int, Gdk.Pixbuf?> ();
Expand Down Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion plugins/pip/PopupWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions src/Widgets/MultitaskingView/WindowCloneContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -325,7 +325,7 @@ public class Gala.WindowCloneContainer : ActorTarget {
/**
* Careful: List<TilableWindow?> windows will be modified in place and shouldn't be used afterwards.
*/
private static GLib.List<TilableWindow?> calculate_grid_placement (Mtk.Rectangle area, GLib.List<TilableWindow?> windows) {
private GLib.List<TilableWindow?> calculate_grid_placement (Mtk.Rectangle area, GLib.List<TilableWindow?> windows) {
uint window_count = windows.length ();
int columns = (int) Math.ceil (Math.sqrt (window_count));
int rows = (int) Math.ceil (window_count / (double) columns);
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down