HotCorners: Support floating point scale factors (#1627)

This commit is contained in:
David Hewitt 2023-04-06 14:17:33 +01:00 committed by GitHub
parent 9bf04d24f5
commit fb2d244112
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 15 deletions

View File

@ -62,8 +62,8 @@ public class Gala.HotCorner : Object {
private bool triggered = false;
private uint32 triggered_time;
public HotCorner (Meta.Display display, float x, float y, string hot_corner_position) {
add_barriers (display, x, y, hot_corner_position);
public HotCorner (Meta.Display display, float x, float y, float scale, string hot_corner_position) {
add_barriers (display, x, y, scale, hot_corner_position);
}
public void destroy_barriers () {
@ -76,9 +76,9 @@ public class Gala.HotCorner : Object {
}
}
private void add_barriers (Meta.Display display, float x, float y, string hot_corner_position) {
var vrect = get_barrier_rect (x, y, hot_corner_position, Clutter.Orientation.VERTICAL);
var hrect = get_barrier_rect (x, y, hot_corner_position, Clutter.Orientation.HORIZONTAL);
private void add_barriers (Meta.Display display, float x, float y, float scale, string hot_corner_position) {
var vrect = get_barrier_rect (x, y, scale, hot_corner_position, Clutter.Orientation.VERTICAL);
var hrect = get_barrier_rect (x, y, scale, hot_corner_position, Clutter.Orientation.HORIZONTAL);
var vdir = get_barrier_direction (hot_corner_position, Clutter.Orientation.VERTICAL);
var hdir = get_barrier_direction (hot_corner_position, Clutter.Orientation.HORIZONTAL);
@ -107,9 +107,8 @@ public class Gala.HotCorner : Object {
}
}
private static Meta.Rectangle get_barrier_rect (float x, float y, string hot_corner_position, Clutter.Orientation orientation) {
var scale = InternalUtils.get_ui_scaling_factor ();
var barrier_size = BARRIER_SIZE * scale;
private static Meta.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);
int x1 = (int) x;
int y1 = (int) y;

View File

@ -40,13 +40,15 @@ public class Gala.HotCornerManager : Object {
return;
}
var geometry = display.get_monitor_geometry (display.get_primary_monitor ());
var primary = display.get_primary_monitor ();
var geometry = display.get_monitor_geometry (primary);
var scale = display.get_monitor_scale (primary);
remove_all_hot_corners ();
add_hotcorner (geometry.x, geometry.y, HotCorner.POSITION_TOP_LEFT);
add_hotcorner (geometry.x + geometry.width, geometry.y, HotCorner.POSITION_TOP_RIGHT);
add_hotcorner (geometry.x, geometry.y + geometry.height, HotCorner.POSITION_BOTTOM_LEFT);
add_hotcorner (geometry.x + geometry.width, geometry.y + geometry.height, HotCorner.POSITION_BOTTOM_RIGHT);
add_hotcorner (geometry.x, geometry.y, scale, HotCorner.POSITION_TOP_LEFT);
add_hotcorner (geometry.x + geometry.width, geometry.y, scale, HotCorner.POSITION_TOP_RIGHT);
add_hotcorner (geometry.x, geometry.y + geometry.height, scale, HotCorner.POSITION_BOTTOM_LEFT);
add_hotcorner (geometry.x + geometry.width, geometry.y + geometry.height, scale, HotCorner.POSITION_BOTTOM_RIGHT);
this.on_configured ();
}
@ -59,14 +61,14 @@ public class Gala.HotCornerManager : Object {
hot_corners.remove_range (0, hot_corners.length);
}
private void add_hotcorner (float x, float y, string hot_corner_position) {
private void add_hotcorner (float x, float y, float scale, string hot_corner_position) {
var action_type = (ActionType) behavior_settings.get_enum (hot_corner_position);
if (action_type == ActionType.NONE) {
return;
}
unowned Meta.Display display = wm.get_display ();
var hot_corner = new HotCorner (display, (int) x, (int) y, hot_corner_position);
var hot_corner = new HotCorner (display, (int) x, (int) y, scale, hot_corner_position);
hot_corner.trigger.connect (() => {
if (action_type == ActionType.CUSTOM_COMMAND) {