Skip to content

Commit 50df688

Browse files
authored
Remove InternalUtils.scale_to_int (#2422)
1 parent 847ca2e commit 50df688

18 files changed

+64
-72
lines changed

lib/Utils.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ namespace Gala {
260260
* Multiplies an integer by a floating scaling factor, and then
261261
* returns the result rounded to the nearest integer
262262
*/
263-
public static int scale_to_int (int value, float scale_factor) {
263+
public static int scale_to_int (int value, float scale_factor) {
264264
return (int) (Math.round ((float)value * scale_factor));
265265
}
266266

src/DesktopIntegration.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public class Gala.DesktopIntegration : GLib.Object {
210210
transition.set_to_value (0);
211211
transition.set_key_frames ( { 0.5, -0.5 } );
212212

213-
var offset = InternalUtils.scale_to_int (15, wm.get_display ().get_monitor_scale (window.get_monitor ()));
213+
var offset = Utils.scale_to_int (15, wm.get_display ().get_monitor_scale (window.get_monitor ()));
214214
transition.set_values ( { -offset, offset });
215215

216216
transition.stopped.connect (() => {

src/HotCorners/HotCorner.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class Gala.HotCorner : Object {
101101
}
102102

103103
private static Mtk.Rectangle get_barrier_rect (float x, float y, float scale, string hot_corner_position, Clutter.Orientation orientation) {
104-
var barrier_size = InternalUtils.scale_to_int (BARRIER_SIZE, scale);
104+
var barrier_size = Utils.scale_to_int (BARRIER_SIZE, scale);
105105

106106
int x1 = (int) x;
107107
int y1 = (int) y;

src/InternalUtils.vala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,6 @@ namespace Gala {
271271
}
272272
}
273273

274-
/**
275-
* Multiplies an integer by a floating scaling factor, and then
276-
* returns the result rounded to the nearest integer
277-
*/
278-
public static int scale_to_int (int value, float scale_factor) {
279-
return (int) (Math.round ((float)value * scale_factor));
280-
}
281-
282274
/**
283275
* Returns the workspaces geometry following the only_on_primary settings.
284276
*/

src/NotificationStack.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public class Gala.NotificationStack : Object {
103103
notification_x_pos = 0;
104104
}
105105

106-
move_window (notification, notification_x_pos, stack_y + TOP_OFFSET + InternalUtils.scale_to_int (ADDITIONAL_MARGIN, scale));
106+
move_window (notification, notification_x_pos, stack_y + TOP_OFFSET + Utils.scale_to_int (ADDITIONAL_MARGIN, scale));
107107
notifications.insert (0, notification);
108108
}
109109

@@ -112,13 +112,13 @@ public class Gala.NotificationStack : Object {
112112
var area = display.get_workspace_manager ().get_active_workspace ().get_work_area_for_monitor (primary);
113113

114114
var scale = display.get_monitor_scale (primary);
115-
stack_width = InternalUtils.scale_to_int (WIDTH + MARGIN, scale);
115+
stack_width = Utils.scale_to_int (WIDTH + MARGIN, scale);
116116

117117
stack_y = area.y;
118118
}
119119

120120
private void update_positions (float scale, float add_y = 0.0f) {
121-
var y = stack_y + TOP_OFFSET + add_y + InternalUtils.scale_to_int (ADDITIONAL_MARGIN, scale);
121+
var y = stack_y + TOP_OFFSET + add_y + Utils.scale_to_int (ADDITIONAL_MARGIN, scale);
122122
var i = notifications.size;
123123
var delay_step = i > 0 ? 150 / i : 0;
124124
var iterator = 0;

src/ShellClients/HideTracker.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public class Gala.HideTracker : Object {
271271
private void setup_barrier () {
272272
var monitor_geom = display.get_monitor_geometry (display.get_primary_monitor ());
273273
var scale = display.get_monitor_scale (display.get_primary_monitor ());
274-
var offset = InternalUtils.scale_to_int (BARRIER_OFFSET, scale);
274+
var offset = Utils.scale_to_int (BARRIER_OFFSET, scale);
275275

276276
switch (panel.anchor) {
277277
case TOP:

src/Widgets/DwellClickTimer.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public class Gala.DwellClickTimer : Clutter.Actor, Clutter.Animatable {
108108

109109
var radius = int.min (cursor_size / 2, cursor_size / 2);
110110
var end_angle = START_ANGLE + angle;
111-
var border_width = InternalUtils.scale_to_int (BORDER_WIDTH_PX, scaling_factor);
111+
var border_width = Utils.scale_to_int (BORDER_WIDTH_PX, scaling_factor);
112112

113113
var cr = new Cairo.Context (surface);
114114

src/Widgets/MultitaskingView/IconGroup.vala

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class Gala.IconGroup : CanvasActor {
9292
}
9393

9494
private void resize () {
95-
var size = InternalUtils.scale_to_int (SIZE, scale_factor);
95+
var size = Utils.scale_to_int (SIZE, scale_factor);
9696

9797
width = size;
9898
height = size;
@@ -107,10 +107,10 @@ public class Gala.IconGroup : CanvasActor {
107107
return;
108108
}
109109

110-
var width = InternalUtils.scale_to_int (100, scale_factor);
111-
var x = (InternalUtils.scale_to_int (SIZE, scale_factor) - width) / 2;
110+
var width = Utils.scale_to_int (100, scale_factor);
111+
var x = (Utils.scale_to_int (SIZE, scale_factor) - width) / 2;
112112
var y = -10;
113-
var height = InternalUtils.scale_to_int (WorkspaceClone.BOTTOM_OFFSET, scale_factor);
113+
var height = Utils.scale_to_int (WorkspaceClone.BOTTOM_OFFSET, scale_factor);
114114
var backdrop_opacity_int = (uint8) (BACKDROP_ABSOLUTE_OPACITY * backdrop_opacity);
115115

116116
#if HAS_MUTTER47
@@ -232,11 +232,11 @@ public class Gala.IconGroup : CanvasActor {
232232
0,
233233
width,
234234
height,
235-
InternalUtils.scale_to_int (5, scale_factor)
235+
Utils.scale_to_int (5, scale_factor)
236236
);
237237

238238
var shadow_effect = new ShadowEffect ("", scale_factor) {
239-
border_radius = InternalUtils.scale_to_int (5, scale_factor)
239+
border_radius = Utils.scale_to_int (5, scale_factor)
240240
};
241241

242242
var style_manager = Drawing.StyleManager.get_instance ();
@@ -278,27 +278,27 @@ public class Gala.IconGroup : CanvasActor {
278278
}
279279
}
280280

281-
var scaled_size = InternalUtils.scale_to_int (SIZE, scale_factor);
281+
var scaled_size = Utils.scale_to_int (SIZE, scale_factor);
282282

283283
if (n_windows < 1) {
284284
if (workspace_index != manager.get_n_workspaces () - 1) {
285285
return;
286286
}
287287

288288
var buffer = new Drawing.BufferSurface (scaled_size, scaled_size);
289-
var offset = scaled_size / 2 - InternalUtils.scale_to_int (PLUS_WIDTH, scale_factor) / 2;
289+
var offset = scaled_size / 2 - Utils.scale_to_int (PLUS_WIDTH, scale_factor) / 2;
290290

291291
buffer.context.rectangle (
292-
InternalUtils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - InternalUtils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
292+
Utils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - Utils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
293293
offset,
294-
InternalUtils.scale_to_int (PLUS_SIZE, scale_factor),
295-
InternalUtils.scale_to_int (PLUS_WIDTH, scale_factor)
294+
Utils.scale_to_int (PLUS_SIZE, scale_factor),
295+
Utils.scale_to_int (PLUS_WIDTH, scale_factor)
296296
);
297297

298298
buffer.context.rectangle (offset,
299-
InternalUtils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - InternalUtils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
300-
InternalUtils.scale_to_int (PLUS_WIDTH, scale_factor),
301-
InternalUtils.scale_to_int (PLUS_SIZE, scale_factor)
299+
Utils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - Utils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
300+
Utils.scale_to_int (PLUS_WIDTH, scale_factor),
301+
Utils.scale_to_int (PLUS_SIZE, scale_factor)
302302
);
303303

304304
if (style_manager.prefers_color_scheme == DARK) {
@@ -337,10 +337,10 @@ public class Gala.IconGroup : CanvasActor {
337337
var columns = (int) Math.ceil (Math.sqrt (n_tiled_windows));
338338
var rows = (int) Math.ceil (n_tiled_windows / (double) columns);
339339

340-
int spacing = InternalUtils.scale_to_int (6, scale_factor);
340+
int spacing = Utils.scale_to_int (6, scale_factor);
341341

342-
var width = columns * InternalUtils.scale_to_int (size, scale_factor) + (columns - 1) * spacing;
343-
var height = rows * InternalUtils.scale_to_int (size, scale_factor) + (rows - 1) * spacing;
342+
var width = columns * Utils.scale_to_int (size, scale_factor) + (columns - 1) * spacing;
343+
var height = rows * Utils.scale_to_int (size, scale_factor) + (rows - 1) * spacing;
344344
var x_offset = scaled_size / 2 - width / 2;
345345
var y_offset = scaled_size / 2 - height / 2;
346346

@@ -359,10 +359,10 @@ public class Gala.IconGroup : CanvasActor {
359359

360360
// draw an ellipsis at the 9th position if we need one
361361
if (show_ellipsis && i == 8) {
362-
int top_offset = InternalUtils.scale_to_int (10, scale_factor);
363-
int left_offset = InternalUtils.scale_to_int (2, scale_factor);
364-
int radius = InternalUtils.scale_to_int (2, scale_factor);
365-
int dot_spacing = InternalUtils.scale_to_int (3, scale_factor);
362+
int top_offset = Utils.scale_to_int (10, scale_factor);
363+
int left_offset = Utils.scale_to_int (2, scale_factor);
364+
int radius = Utils.scale_to_int (2, scale_factor);
365+
int dot_spacing = Utils.scale_to_int (3, scale_factor);
366366
cr.arc (left_offset + x, y + top_offset, radius, 0, 2 * Math.PI);
367367
cr.arc (left_offset + x + radius + dot_spacing, y + top_offset, radius, 0, 2 * Math.PI);
368368
cr.arc (left_offset + x + radius * 2 + dot_spacing * 2, y + top_offset, radius, 0, 2 * Math.PI);
@@ -378,10 +378,10 @@ public class Gala.IconGroup : CanvasActor {
378378

379379
window.place (x, y, size, scale_factor);
380380

381-
x += InternalUtils.scale_to_int (size, scale_factor) + spacing;
382-
if (x + InternalUtils.scale_to_int (size, scale_factor) >= scaled_size) {
381+
x += Utils.scale_to_int (size, scale_factor) + spacing;
382+
if (x + Utils.scale_to_int (size, scale_factor) >= scaled_size) {
383383
x = x_offset;
384-
y += InternalUtils.scale_to_int (size, scale_factor) + spacing;
384+
y += Utils.scale_to_int (size, scale_factor) + spacing;
385385
}
386386
}
387387
}

src/Widgets/MultitaskingView/IconGroupContainer.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public class Gala.IconGroupContainer : Clutter.Actor {
115115
* end states into account
116116
*/
117117
public float calculate_total_width () {
118-
var spacing = InternalUtils.scale_to_int (SPACING, scale_factor);
119-
var group_width = InternalUtils.scale_to_int (GROUP_WIDTH, scale_factor);
118+
var spacing = Utils.scale_to_int (SPACING, scale_factor);
119+
var group_width = Utils.scale_to_int (GROUP_WIDTH, scale_factor);
120120

121121
var width = 0.0f;
122122
foreach (var child in get_children ()) {

src/Widgets/MultitaskingView/MultitaskingView.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
248248

249249
var scale = display.get_monitor_scale (display.get_primary_monitor ());
250250
icon_groups.force_reposition ();
251-
icon_groups.y = primary_monitor_container.height - InternalUtils.scale_to_int (WorkspaceClone.BOTTOM_OFFSET - 20, scale);
251+
icon_groups.y = primary_monitor_container.height - Utils.scale_to_int (WorkspaceClone.BOTTOM_OFFSET - 20, scale);
252252
reposition_icon_groups (false);
253253

254254
if (action != MULTITASKING_VIEW) {
@@ -335,8 +335,8 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
335335
// make sure the active workspace's icongroup is always visible
336336
var icon_groups_width = icon_groups.calculate_total_width ();
337337
if (icon_groups_width > primary_monitor_container.width) {
338-
icon_groups.x = (-active_index * InternalUtils.scale_to_int (IconGroupContainer.SPACING + IconGroup.SIZE, scale) + primary_monitor_container.width / 2)
339-
.clamp (primary_monitor_container.width - icon_groups_width - InternalUtils.scale_to_int (64, scale), InternalUtils.scale_to_int (64, scale));
338+
icon_groups.x = (-active_index * Utils.scale_to_int (IconGroupContainer.SPACING + IconGroup.SIZE, scale) + primary_monitor_container.width / 2)
339+
.clamp (primary_monitor_container.width - icon_groups_width - Utils.scale_to_int (64, scale), Utils.scale_to_int (64, scale));
340340
} else
341341
icon_groups.x = primary_monitor_container.width / 2 - icon_groups_width / 2;
342342

0 commit comments

Comments
 (0)