Skip to content

Commit

Permalink
InternalUtils: Remove pixel_align method, and just round (#1633)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmhewitt committed Apr 7, 2023
1 parent 4393018 commit 051534a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Gestures/GestureTracker.vala
Expand Up @@ -195,7 +195,7 @@ public class Gala.GestureTracker : Object {
float value = ((target_value - initial_value) * (float) percentage) + initial_value;

if (rounded) {
value = (float) InternalUtils.pixel_align (value);
value = Math.roundf (value);
}

return value;
Expand Down
8 changes: 0 additions & 8 deletions src/InternalUtils.vala
Expand Up @@ -297,14 +297,6 @@ namespace Gala {
return Meta.Backend.get_backend ().get_settings ().get_ui_scaling_factor ();
}

/**
* Round the value to match physical pixels.
*/
public static int pixel_align (float value) {
var scale_factor = InternalUtils.get_ui_scaling_factor ();
return (int) Math.round (value * scale_factor) / scale_factor;
}

/**
* Multiplies an integer by a floating scaling factor, and then
* returns the result rounded to the nearest integer
Expand Down
8 changes: 4 additions & 4 deletions src/Widgets/WindowClone.vala
Expand Up @@ -775,8 +775,8 @@ public class Gala.WindowClone : Clutter.Actor {
var y = window_height - (size * 0.75f);

if (aligned) {
x = InternalUtils.pixel_align (x);
y = InternalUtils.pixel_align (y);
x = (int) Math.round (x);
y = (int) Math.round (y);
}

window_icon.set_size (size, size);
Expand All @@ -785,8 +785,8 @@ public class Gala.WindowClone : Clutter.Actor {

private void set_window_title_position (float window_width, float window_height) {
var scale_factor = InternalUtils.get_ui_scaling_factor ();
var x = InternalUtils.pixel_align ((window_width - window_title.width) / 2);
var y = InternalUtils.pixel_align (window_height - (WINDOW_ICON_SIZE * scale_factor) * 0.75f - (window_title.height / 2) - (18 * scale_factor));
var x = (int)Math.round ((window_width - window_title.width) / 2);
var y = (int)Math.round (window_height - (WINDOW_ICON_SIZE * scale_factor) * 0.75f - (window_title.height / 2) - (18 * scale_factor));
window_title.set_position (x, y);
}

Expand Down

0 comments on commit 051534a

Please sign in to comment.