Skip to content

Commit 8f27f4c

Browse files
Don't apply scale twice when using fractional scaling (#2664)
When using fractional scaling actor sizes, margins, monitor geometry, etc. are already in logical units, i.e. with the scale applied so manually multiplying with the scale again will result in it being applied twice. In the future this will probably be the only mode (e.g. GNOME doesn't support per monitor scaling for its Shell UI without 'scale-monitor-framebuffer' because they argue it's not worth the effort given that it will be not needed in the future: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1864) which will then let us remove all our custom scale handling but until then this introduces no regressions while improving the behavior for fractional scale enabled. Fixes #2412 Co-authored-by: Leo <[email protected]>
1 parent 5287628 commit 8f27f4c

File tree

15 files changed

+31
-33
lines changed

15 files changed

+31
-33
lines changed

lib/Utils.vala

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ namespace Gala {
293293
*
294294
* @param workspace The workspace on which to count the windows
295295
* @param exclude a window to not count
296-
*
296+
*
297297
*/
298298
public static uint get_n_windows (Meta.Workspace workspace, bool on_primary = false, Meta.Window? exclude = null) {
299299
var n = 0;
@@ -350,16 +350,6 @@ namespace Gala {
350350
return container;
351351
}
352352

353-
/**
354-
* DEPRECATED: When used with Mutter 44, this will always return 1.
355-
* Get the scaling factor for the monitor you are drawing to with
356-
* `Meta.Display.get_monitor_scale` instead
357-
*/
358-
[Version (deprecated = true, deprecated_since = "7.0.3", replacement = "Meta.Display.get_monitor_scale")]
359-
public static int get_ui_scaling_factor () {
360-
return 1;
361-
}
362-
363353
/**
364354
* Returns the pixbuf that is used for resize buttons throughout gala at a
365355
* size of 36px
@@ -505,5 +495,13 @@ namespace Gala {
505495

506496
return framebuffer_is_logical;
507497
}
498+
499+
public static float get_ui_scaling_factor (Meta.Display display, int monitor_index) {
500+
if (get_framebuffer_is_logical ()) {
501+
return 1.0f;
502+
} else {
503+
return display.get_monitor_scale (monitor_index);
504+
}
505+
}
508506
}
509507
}

src/Background/BackgroundManager.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
9999
};
100100

101101
new_content.set_rounded_clip_bounds (clip_bounds);
102-
new_content.rounded_clip_radius = Utils.scale_to_int (6, display.get_monitor_scale (monitor_index));
102+
new_content.rounded_clip_radius = Utils.scale_to_int (6, Utils.get_ui_scaling_factor (display, monitor_index));
103103
}
104104

105105
swap_background_actor (animate);
@@ -119,7 +119,7 @@ public class Gala.BackgroundManager : Meta.BackgroundGroup, Gala.BackgroundManag
119119
};
120120

121121
new_content.set_rounded_clip_bounds (clip_bounds);
122-
new_content.rounded_clip_radius = Utils.scale_to_int (6, display.get_monitor_scale (monitor_index));
122+
new_content.rounded_clip_radius = Utils.scale_to_int (6, Utils.get_ui_scaling_factor (display, monitor_index));
123123
}
124124

125125
swap_background_actor (animate);

src/BlurManager.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class Gala.BlurManager : Object {
7474
var x_shadow_size = frame_rect.x - buffer_rect.x;
7575
var y_shadow_size = frame_rect.y - buffer_rect.y;
7676

77-
var monitor_scale = Utils.get_framebuffer_is_logical () ? 1.0f : window.display.get_monitor_scale (window.get_monitor ());
77+
var monitor_scale = Utils.get_ui_scaling_factor (window.display, window.get_monitor ());
7878
var inverse_monitor_scale = 1.0f / monitor_scale;
7979

8080
blur_data.actor.set_position (

src/DesktopIntegration.vala

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

223-
var offset = Utils.scale_to_int (15, display.get_monitor_scale (window.get_monitor ()));
223+
var offset = Utils.scale_to_int (15, Utils.get_ui_scaling_factor (display, window.get_monitor ()));
224224
transition.set_values ( { -offset, offset });
225225

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

src/HotCorners/HotCornerManager.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class Gala.HotCornerManager : Object {
4242

4343
var primary = display.get_primary_monitor ();
4444
var geometry = display.get_monitor_geometry (primary);
45-
var scale = display.get_monitor_scale (primary);
45+
var scale = Utils.get_ui_scaling_factor (display, primary);
4646

4747
remove_all_hot_corners ();
4848
add_hotcorner (geometry.x, geometry.y, scale, HotCorner.POSITION_TOP_LEFT);

src/NotificationStack.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class Gala.NotificationStack : Object {
9595

9696
var primary = display.get_primary_monitor ();
9797
var area = display.get_workspace_manager ().get_active_workspace ().get_work_area_for_monitor (primary);
98-
var scale = display.get_monitor_scale (primary);
98+
var scale = Utils.get_ui_scaling_factor (display, primary);
9999

100100
int notification_x_pos = area.x + area.width - window_rect.width;
101101
if (Clutter.get_default_text_direction () == Clutter.TextDirection.RTL) {
@@ -110,7 +110,7 @@ public class Gala.NotificationStack : Object {
110110
var primary = display.get_primary_monitor ();
111111
var area = display.get_workspace_manager ().get_active_workspace ().get_work_area_for_monitor (primary);
112112

113-
var scale = display.get_monitor_scale (primary);
113+
var scale = Utils.get_ui_scaling_factor (display, primary);
114114
stack_width = Utils.scale_to_int (WIDTH + MARGIN, scale);
115115

116116
stack_y = area.y;
@@ -119,7 +119,7 @@ public class Gala.NotificationStack : Object {
119119
}
120120

121121
private void update_positions (float add_y = 0.0f) {
122-
var scale = display.get_monitor_scale (display.get_primary_monitor ());
122+
var scale = Utils.get_ui_scaling_factor (display, display.get_primary_monitor ());
123123

124124
var y = stack_y + TOP_OFFSET + add_y + Utils.scale_to_int (ADDITIONAL_MARGIN, scale);
125125
var i = notifications.size;

src/ShellClients/HideTracker.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public class Gala.HideTracker : Object {
160160

161161
private void setup_barrier () {
162162
var monitor_geom = display.get_monitor_geometry (display.get_primary_monitor ());
163-
var scale = display.get_monitor_scale (display.get_primary_monitor ());
163+
var scale = Utils.get_ui_scaling_factor (display, display.get_primary_monitor ());
164164
var offset = Utils.scale_to_int (BARRIER_OFFSET, scale);
165165

166166
switch (panel.anchor) {

src/Widgets/DwellClickTimer.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class Gala.DwellClickTimer : Clutter.Actor, Clutter.Animatable {
6262
seat.set_pointer_a11y_dwell_click_type (Clutter.PointerA11yDwellClickType.PRIMARY);
6363

6464
seat.ptr_a11y_timeout_started.connect ((device, type, timeout) => {
65-
var scale = display.get_monitor_scale (display.get_current_monitor ());
65+
var scale = Utils.get_ui_scaling_factor (display, display.get_current_monitor ());
6666
update_cursor_size (scale);
6767

6868
#if HAS_MUTTER48

src/Widgets/MultitaskingView/MonitorClone.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ public class Gala.MonitorClone : ActorTarget {
5858
set_position (monitor_geometry.x, monitor_geometry.y);
5959
set_size (monitor_geometry.width, monitor_geometry.height);
6060

61-
monitor_scale = display.get_monitor_scale (monitor);
61+
monitor_scale = Utils.get_ui_scaling_factor (display, monitor);
6262
}
6363
}

src/Widgets/MultitaskingView/MultitaskingView.vala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
7878
add_gesture_controller (workspaces_gesture_controller);
7979

8080
#if OLD_ICON_GROUPS
81-
icon_groups = new IconGroupContainer (display.get_monitor_scale (display.get_primary_monitor ()));
81+
icon_groups = new IconGroupContainer (Utils.get_ui_scaling_factor (display, display.get_primary_monitor ()));
8282
#endif
8383

8484
update_blurred_bg ();
@@ -151,7 +151,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
151151
}
152152

153153
var primary_geometry = display.get_monitor_geometry (primary);
154-
var scale = display.get_monitor_scale (primary);
154+
var scale = Utils.get_ui_scaling_factor (display, primary);
155155
#if OLD_ICON_GROUPS
156156
icon_groups.scale_factor = scale;
157157
#endif
@@ -272,7 +272,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
272272
modal_proxy.allow_actions ({ MULTITASKING_VIEW, SWITCH_WORKSPACE, ZOOM });
273273

274274
#if OLD_ICON_GROUPS
275-
var scale = display.get_monitor_scale (display.get_primary_monitor ());
275+
var scale = Utils.get_ui_scaling_factor (display, display.get_primary_monitor ());
276276
icon_groups.force_reposition ();
277277
icon_groups.y = primary_monitor_container.height - Utils.scale_to_int (WorkspaceClone.BOTTOM_OFFSET - 20, scale);
278278
reposition_icon_groups (false);
@@ -363,7 +363,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
363363
icon_groups.set_easing_duration (200);
364364
}
365365

366-
var scale = display.get_monitor_scale (display.get_primary_monitor ());
366+
var scale = Utils.get_ui_scaling_factor (display, display.get_primary_monitor ());
367367
// make sure the active workspace's icongroup is always visible
368368
var icon_groups_width = icon_groups.calculate_total_width ();
369369
if (icon_groups_width > primary_monitor_container.width) {
@@ -380,7 +380,7 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
380380

381381
private void add_workspace (int num) {
382382
unowned var manager = display.get_workspace_manager ();
383-
var scale = display.get_monitor_scale (display.get_primary_monitor ());
383+
var scale = Utils.get_ui_scaling_factor (display, display.get_primary_monitor ());
384384

385385
var workspace = new WorkspaceClone (wm, manager.get_workspace_by_index (num), scale);
386386
workspaces.insert_child_at_index (workspace, num);

0 commit comments

Comments
 (0)