Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HotCorners: Support floating point scale factors #1627

Merged
merged 1 commit into from Apr 6, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/HotCorners/HotCorner.vala
Expand Up @@ -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 () {
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
16 changes: 9 additions & 7 deletions src/HotCorners/HotCornerManager.vala
Expand Up @@ -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 ();
}
Expand All @@ -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) {
Expand Down