InternalUtils: Remove pixel_align method, and just round (#1633)

This commit is contained in:
David Hewitt 2023-04-07 17:32:18 +01:00 committed by GitHub
parent 4393018d4d
commit 051534a29f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 13 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);
@ -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);
}