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
2 changes: 1 addition & 1 deletion lib/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ namespace Gala {
* Multiplies an integer by a floating scaling factor, and then
* returns the result rounded to the nearest integer
*/
public static int scale_to_int (int value, float scale_factor) {
public static int scale_to_int (int value, float scale_factor) {
return (int) (Math.round ((float)value * scale_factor));
}

Expand Down
2 changes: 1 addition & 1 deletion src/DesktopIntegration.vala
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public class Gala.DesktopIntegration : GLib.Object {
transition.set_to_value (0);
transition.set_key_frames ( { 0.5, -0.5 } );

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

transition.stopped.connect (() => {
Expand Down
2 changes: 1 addition & 1 deletion src/HotCorners/HotCorner.vala
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class Gala.HotCorner : Object {
}

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

int x1 = (int) x;
int y1 = (int) y;
Expand Down
8 changes: 0 additions & 8 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,6 @@ namespace Gala {
}
}

/**
* Multiplies an integer by a floating scaling factor, and then
* returns the result rounded to the nearest integer
*/
public static int scale_to_int (int value, float scale_factor) {
return (int) (Math.round ((float)value * scale_factor));
}

/**
* Returns the workspaces geometry following the only_on_primary settings.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/NotificationStack.vala
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class Gala.NotificationStack : Object {
notification_x_pos = 0;
}

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

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

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

stack_y = area.y;
}

private void update_positions (float scale, float add_y = 0.0f) {
var y = stack_y + TOP_OFFSET + add_y + InternalUtils.scale_to_int (ADDITIONAL_MARGIN, scale);
var y = stack_y + TOP_OFFSET + add_y + Utils.scale_to_int (ADDITIONAL_MARGIN, scale);
var i = notifications.size;
var delay_step = i > 0 ? 150 / i : 0;
var iterator = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ShellClients/HideTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public class Gala.HideTracker : Object {
private void setup_barrier () {
var monitor_geom = display.get_monitor_geometry (display.get_primary_monitor ());
var scale = display.get_monitor_scale (display.get_primary_monitor ());
var offset = InternalUtils.scale_to_int (BARRIER_OFFSET, scale);
var offset = Utils.scale_to_int (BARRIER_OFFSET, scale);

switch (panel.anchor) {
case TOP:
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/DwellClickTimer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class Gala.DwellClickTimer : Clutter.Actor, Clutter.Animatable {

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

var cr = new Cairo.Context (surface);

Expand Down
48 changes: 24 additions & 24 deletions src/Widgets/MultitaskingView/IconGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class Gala.IconGroup : CanvasActor {
}

private void resize () {
var size = InternalUtils.scale_to_int (SIZE, scale_factor);
var size = Utils.scale_to_int (SIZE, scale_factor);

width = size;
height = size;
Expand All @@ -107,10 +107,10 @@ public class Gala.IconGroup : CanvasActor {
return;
}

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

#if HAS_MUTTER47
Expand Down Expand Up @@ -232,11 +232,11 @@ public class Gala.IconGroup : CanvasActor {
0,
width,
height,
InternalUtils.scale_to_int (5, scale_factor)
Utils.scale_to_int (5, scale_factor)
);

var shadow_effect = new ShadowEffect ("", scale_factor) {
border_radius = InternalUtils.scale_to_int (5, scale_factor)
border_radius = Utils.scale_to_int (5, scale_factor)
};

var style_manager = Drawing.StyleManager.get_instance ();
Expand Down Expand Up @@ -278,27 +278,27 @@ public class Gala.IconGroup : CanvasActor {
}
}

var scaled_size = InternalUtils.scale_to_int (SIZE, scale_factor);
var scaled_size = Utils.scale_to_int (SIZE, scale_factor);

if (n_windows < 1) {
if (workspace_index != manager.get_n_workspaces () - 1) {
return;
}

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

buffer.context.rectangle (
InternalUtils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - InternalUtils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
Utils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - Utils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
offset,
InternalUtils.scale_to_int (PLUS_SIZE, scale_factor),
InternalUtils.scale_to_int (PLUS_WIDTH, scale_factor)
Utils.scale_to_int (PLUS_SIZE, scale_factor),
Utils.scale_to_int (PLUS_WIDTH, scale_factor)
);

buffer.context.rectangle (offset,
InternalUtils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - InternalUtils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
InternalUtils.scale_to_int (PLUS_WIDTH, scale_factor),
InternalUtils.scale_to_int (PLUS_SIZE, scale_factor)
Utils.scale_to_int (PLUS_WIDTH / 2, scale_factor) - Utils.scale_to_int (PLUS_SIZE / 2, scale_factor) + offset,
Utils.scale_to_int (PLUS_WIDTH, scale_factor),
Utils.scale_to_int (PLUS_SIZE, scale_factor)
);

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

int spacing = InternalUtils.scale_to_int (6, scale_factor);
int spacing = Utils.scale_to_int (6, scale_factor);

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

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

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

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

x += InternalUtils.scale_to_int (size, scale_factor) + spacing;
if (x + InternalUtils.scale_to_int (size, scale_factor) >= scaled_size) {
x += Utils.scale_to_int (size, scale_factor) + spacing;
if (x + Utils.scale_to_int (size, scale_factor) >= scaled_size) {
x = x_offset;
y += InternalUtils.scale_to_int (size, scale_factor) + spacing;
y += Utils.scale_to_int (size, scale_factor) + spacing;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/MultitaskingView/IconGroupContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public class Gala.IconGroupContainer : Clutter.Actor {
* end states into account
*/
public float calculate_total_width () {
var spacing = InternalUtils.scale_to_int (SPACING, scale_factor);
var group_width = InternalUtils.scale_to_int (GROUP_WIDTH, scale_factor);
var spacing = Utils.scale_to_int (SPACING, scale_factor);
var group_width = Utils.scale_to_int (GROUP_WIDTH, scale_factor);

var width = 0.0f;
foreach (var child in get_children ()) {
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/MultitaskingView/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/MultitaskingView/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
var monitor_index = display.get_monitor_index_for_rect (Mtk.Rectangle.from_graphene_rect (rect, ROUND));
var monitor_scale = display.get_monitor_scale (monitor_index);

float window_title_max_width = box.get_width () - InternalUtils.scale_to_int (TITLE_MAX_WIDTH_MARGIN, monitor_scale);
float window_title_max_width = box.get_width () - Utils.scale_to_int (TITLE_MAX_WIDTH_MARGIN, monitor_scale);
float window_title_height, window_title_nat_width;
window_title.get_preferred_size (null, null, out window_title_nat_width, out window_title_height);

var window_title_width = window_title_nat_width.clamp (0, window_title_max_width);

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

var window_title_alloc = InternalUtils.actor_box_from_rect (window_title_x, window_title_y, window_title_width, window_title_height);
window_title.allocate (window_title_alloc);
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/MultitaskingView/WindowIconActor.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Gala.WindowIconActor : Clutter.Actor {
_icon_size = value;
cur_icon_scale = desired_icon_scale;

var scaled_size = InternalUtils.scale_to_int (_icon_size, cur_icon_scale);
var scaled_size = Utils.scale_to_int (_icon_size, cur_icon_scale);
set_size (scaled_size, scaled_size);

fade_new_icon ();
Expand Down
8 changes: 4 additions & 4 deletions src/Widgets/MultitaskingView/WorkspaceClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ public class Gala.WorkspaceClone : ActorTarget {

var monitor = display.get_monitor_geometry (display.get_primary_monitor ());

var scale = (float)(monitor.height - InternalUtils.scale_to_int (TOP_OFFSET + BOTTOM_OFFSET, monitor_scale)) / monitor.height;
var pivot_y = InternalUtils.scale_to_int (TOP_OFFSET, monitor_scale) / (monitor.height - monitor.height * scale);
var scale = (float)(monitor.height - Utils.scale_to_int (TOP_OFFSET + BOTTOM_OFFSET, monitor_scale)) / monitor.height;
var pivot_y = Utils.scale_to_int (TOP_OFFSET, monitor_scale) / (monitor.height - monitor.height * scale);
background.set_pivot_point (0.5f, pivot_y);

var initial_width = monitor.width;
Expand All @@ -297,10 +297,10 @@ public class Gala.WorkspaceClone : ActorTarget {
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-x", typeof (double), 1d, (double) scale));
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-y", typeof (double), 1d, (double) scale));

window_container.padding_top = InternalUtils.scale_to_int (TOP_OFFSET, monitor_scale);
window_container.padding_top = Utils.scale_to_int (TOP_OFFSET, monitor_scale);
window_container.padding_left =
window_container.padding_right = (int)(monitor.width - monitor.width * scale) / 2;
window_container.padding_bottom = InternalUtils.scale_to_int (BOTTOM_OFFSET, monitor_scale);
window_container.padding_bottom = Utils.scale_to_int (BOTTOM_OFFSET, monitor_scale);
}

public override void update_progress (GestureAction action, double progress) {
Expand Down
10 changes: 5 additions & 5 deletions src/Widgets/MultitaskingView/WorkspaceInsertThumb.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public class Gala.WorkspaceInsertThumb : Clutter.Actor {
}

private void reallocate () {
width = InternalUtils.scale_to_int (IconGroupContainer.SPACING, scale_factor);
height = InternalUtils.scale_to_int (IconGroupContainer.GROUP_WIDTH, scale_factor);
y = InternalUtils.scale_to_int (IconGroupContainer.GROUP_WIDTH - IconGroupContainer.SPACING, scale_factor) / 2;
width = Utils.scale_to_int (IconGroupContainer.SPACING, scale_factor);
height = Utils.scale_to_int (IconGroupContainer.GROUP_WIDTH, scale_factor);
y = Utils.scale_to_int (IconGroupContainer.GROUP_WIDTH - IconGroupContainer.SPACING, scale_factor) / 2;
}

public void set_window_thumb (Meta.Window window) {
Expand Down Expand Up @@ -83,12 +83,12 @@ public class Gala.WorkspaceInsertThumb : Clutter.Actor {
if (!expand) {
remove_transition ("pulse");
opacity = 0;
width = InternalUtils.scale_to_int (IconGroupContainer.SPACING, scale_factor);
width = Utils.scale_to_int (IconGroupContainer.SPACING, scale_factor);
expanded = false;
} else {
add_pulse_animation ();
opacity = 200;
width = InternalUtils.scale_to_int (IconGroupContainer.GROUP_WIDTH + IconGroupContainer.SPACING * 2, scale_factor);
width = Utils.scale_to_int (IconGroupContainer.GROUP_WIDTH + IconGroupContainer.SPACING * 2, scale_factor);
expanded = true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/PointerLocator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class Gala.PointerLocator : Clutter.Actor, Clutter.Animatable {
private void update_surface (float cur_scale) {
if (surface == null || cur_scale != scaling_factor) {
scaling_factor = cur_scale;
surface_width = InternalUtils.scale_to_int (WIDTH_PX, scaling_factor);
surface_height = InternalUtils.scale_to_int (HEIGHT_PX, scaling_factor);
surface_width = Utils.scale_to_int (WIDTH_PX, scaling_factor);
surface_height = Utils.scale_to_int (HEIGHT_PX, scaling_factor);

surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, surface_width, surface_height);

Expand All @@ -62,7 +62,7 @@ public class Gala.PointerLocator : Clutter.Actor, Clutter.Animatable {
var radius = int.min (surface_width / 2, surface_height / 2);

var cr = new Cairo.Context (surface);
var border_width = InternalUtils.scale_to_int (BORDER_WIDTH_PX, scaling_factor);
var border_width = Utils.scale_to_int (BORDER_WIDTH_PX, scaling_factor);

// Clear the surface
cr.save ();
Expand Down
10 changes: 5 additions & 5 deletions src/Widgets/WindowSwitcher/WindowSwitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
};

shadow_effect = new ShadowEffect ("window-switcher", scaling_factor) {
border_radius = InternalUtils.scale_to_int (9, scaling_factor),
border_radius = Utils.scale_to_int (9, scaling_factor),
shadow_opacity = 100
};
add_effect (shadow_effect);
Expand All @@ -121,7 +121,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {

shadow_effect.monitor_scale = scaling_factor;

var margin = InternalUtils.scale_to_int (WRAPPER_PADDING, scaling_factor);
var margin = Utils.scale_to_int (WRAPPER_PADDING, scaling_factor);

container.margin_left = margin;
container.margin_right = margin;
Expand All @@ -147,7 +147,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
container.get_preferred_size (null, null, out container_nat_width, null);

var max_width = float.min (
geom.width - InternalUtils.scale_to_int (MIN_OFFSET, scaling_factor) * 2, //Don't overflow the monitor
geom.width - Utils.scale_to_int (MIN_OFFSET, scaling_factor) * 2, //Don't overflow the monitor
container_nat_width //Ellipsize the label if it's longer than the icons
);

Expand Down Expand Up @@ -188,7 +188,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
ctx, 0.5, 0.5,
width - stroke_width,
height - stroke_width,
InternalUtils.scale_to_int (9, scaling_factor)
Utils.scale_to_int (9, scaling_factor)
);

ctx.set_source_rgba (
Expand All @@ -214,7 +214,7 @@ public class Gala.WindowSwitcher : CanvasActor, GestureTarget, RootTarget {
ctx, stroke_width + 0.5, stroke_width + 0.5,
width - stroke_width * 2 - 1,
height - stroke_width * 2 - 1,
InternalUtils.scale_to_int (8, scaling_factor)
Utils.scale_to_int (8, scaling_factor)
);

ctx.set_line_width (stroke_width);
Expand Down
Loading
Loading