core: simplify monitor model helpers

parent 39be2437
......@@ -52,22 +52,6 @@ namespace TunerDisplays {
backend_apply_mode(monitor, monitor.modes[0]);
}
protected static double backend_logical_width(MonitorConfig monitor) {
if (monitor.scale <= 0)
return monitor.width;
return backend_is_rotated(monitor) ? monitor.height / monitor.scale : monitor.width / monitor.scale;
}
protected static double backend_logical_height(MonitorConfig monitor) {
if (monitor.scale <= 0)
return monitor.height;
return backend_is_rotated(monitor) ? monitor.width / monitor.scale : monitor.height / monitor.scale;
}
protected static bool backend_is_rotated(MonitorConfig monitor) {
return monitor.transform.index_of("90") >= 0 || monitor.transform.index_of("270") >= 0;
}
protected static string backend_format_double(double value, int precision = 2) {
return ("%." + precision.to_string() + "f").printf(value).replace(",", ".");
}
......
......@@ -446,7 +446,7 @@ namespace TunerDisplays {
foreach (var monitor in enabled) {
monitor.x = x;
monitor.y = 0;
x += (int) Math.round(logical_width(monitor));
x += (int) Math.round(monitor.logical_width);
}
}
......@@ -477,12 +477,12 @@ namespace TunerDisplays {
private static bool monitors_touch(MonitorConfig a, MonitorConfig b) {
var ax1 = (double) a.x;
var ay1 = (double) a.y;
var ax2 = ax1 + logical_width(a);
var ay2 = ay1 + logical_height(a);
var ax2 = ax1 + a.logical_width;
var ay2 = ay1 + a.logical_height;
var bx1 = (double) b.x;
var by1 = (double) b.y;
var bx2 = bx1 + logical_width(b);
var by2 = by1 + logical_height(b);
var bx2 = bx1 + b.logical_width;
var by2 = by1 + b.logical_height;
var vertical_overlap = ay1 < by2 && ay2 > by1;
var horizontal_overlap = ax1 < bx2 && ax2 > bx1;
......@@ -527,7 +527,7 @@ namespace TunerDisplays {
monitor.height = compatible.height;
monitor.refresh = compatible.refresh;
monitor.variable_refresh_rate = compatible.variable_refresh_rate;
monitor.scale = mode_supports_scale(compatible, scale) ? scale : compatible.preferred_scale;
monitor.scale = compatible.supports_scale(scale) ? scale : compatible.preferred_scale;
if (monitor.scale <= 0)
monitor.scale = 1.0;
monitor.x = 0;
......@@ -577,15 +577,6 @@ namespace TunerDisplays {
return null;
}
private static bool mode_supports_scale(DisplayMode mode, double scale) {
foreach (var supported in mode.supported_scales) {
if (Math.fabs(supported - scale) < 0.01)
return true;
}
return false;
}
private static MonitorConfig? primary_monitor(Gee.ArrayList<MonitorConfig> monitors) {
foreach (var monitor in monitors) {
if (monitor.enabled && monitor.primary)
......@@ -604,18 +595,6 @@ namespace TunerDisplays {
return null;
}
private static double logical_width(MonitorConfig monitor) {
if (monitor.transform.index_of("90") >= 0 || monitor.transform.index_of("270") >= 0)
return monitor.height / monitor.scale;
return monitor.width / monitor.scale;
}
private static double logical_height(MonitorConfig monitor) {
if (monitor.transform.index_of("90") >= 0 || monitor.transform.index_of("270") >= 0)
return monitor.width / monitor.scale;
return monitor.height / monitor.scale;
}
private static void place_disabled_after_enabled(Gee.ArrayList<MonitorConfig> monitors) {
int x = 0;
bool found_enabled = false;
......@@ -624,7 +603,7 @@ namespace TunerDisplays {
if (!monitor.enabled)
continue;
var right = monitor.x + (int) Math.round(logical_width(monitor));
var right = monitor.x + (int) Math.round(monitor.logical_width);
if (!found_enabled || right > x)
x = right;
found_enabled = true;
......@@ -636,7 +615,7 @@ namespace TunerDisplays {
monitor.x = x;
monitor.y = 0;
x += (int) Math.round(logical_width(monitor));
x += (int) Math.round(monitor.logical_width);
}
}
......
......@@ -27,7 +27,7 @@ namespace TunerDisplays {
var monitors = new Gee.ArrayList<MonitorConfig>();
var active = read_active_names();
var saved = read_saved_monitors();
var root = parse_json(ShellCommand.run("hyprctl -j monitors all"));
var root = backend_parse_json(ShellCommand.run("hyprctl -j monitors all"));
if (root.get_node_type() != Json.NodeType.ARRAY)
throw new BackendError.PARSE_FAILED("hyprctl monitors all returned non-array JSON");
......@@ -38,22 +38,22 @@ namespace TunerDisplays {
var monitor = new MonitorConfig();
monitor.name = obj.get_string_member("name");
monitor.enabled = active.contains(monitor.name);
monitor.description = get_string(obj, "description");
monitor.x = (int) get_double(obj, "x", 0);
monitor.y = (int) get_double(obj, "y", 0);
monitor.width = (int) get_double(obj, "width", 0);
monitor.height = (int) get_double(obj, "height", 0);
monitor.refresh = get_double(obj, "refreshRate", 0);
monitor.scale = get_double(obj, "scale", 1);
monitor.transform = transform_from_code((int) get_double(obj, "transform", 0));
monitor.dpms = get_bool(obj, "dpmsStatus", true);
monitor.bitdepth = is_ten_bit_format(get_string(obj, "currentFormat")) ? 10 : 8;
monitor.vrr = get_bool(obj, "vrr", false) ? 1 : 0;
monitor.color_management_preset = get_string(obj, "colorManagementPreset", "srgb");
monitor.sdr_brightness = get_double(obj, "sdrBrightness", 1);
monitor.sdr_saturation = get_double(obj, "sdrSaturation", 1);
monitor.sdr_min_luminance = get_double(obj, "sdrMinLuminance", 0.2);
monitor.sdr_max_luminance = (int) get_double(obj, "sdrMaxLuminance", 80);
monitor.description = backend_get_string(obj, "description");
monitor.x = (int) backend_get_double(obj, "x", 0);
monitor.y = (int) backend_get_double(obj, "y", 0);
monitor.width = (int) backend_get_double(obj, "width", 0);
monitor.height = (int) backend_get_double(obj, "height", 0);
monitor.refresh = backend_get_double(obj, "refreshRate", 0);
monitor.scale = backend_get_double(obj, "scale", 1);
monitor.transform = transform_from_code((int) backend_get_double(obj, "transform", 0));
monitor.dpms = backend_get_bool(obj, "dpmsStatus", true);
monitor.bitdepth = is_ten_bit_format(backend_get_string(obj, "currentFormat")) ? 10 : 8;
monitor.vrr = backend_get_bool(obj, "vrr", false) ? 1 : 0;
monitor.color_management_preset = backend_get_string(obj, "colorManagementPreset", "srgb");
monitor.sdr_brightness = backend_get_double(obj, "sdrBrightness", 1);
monitor.sdr_saturation = backend_get_double(obj, "sdrSaturation", 1);
monitor.sdr_min_luminance = backend_get_double(obj, "sdrMinLuminance", 0.2);
monitor.sdr_max_luminance = (int) backend_get_double(obj, "sdrMaxLuminance", 80);
if (obj.has_member("availableModes")) {
var modes = obj.get_array_member("availableModes");
......@@ -82,7 +82,7 @@ namespace TunerDisplays {
}
if (monitor.width <= 0 || monitor.height <= 0)
apply_first_available_mode(monitor);
backend_apply_first_available_mode(monitor);
monitors.add(monitor);
}
......@@ -107,11 +107,11 @@ namespace TunerDisplays {
builder.append(" mode = %dx%d@%s\n".printf(
monitor.width,
monitor.height,
format_double(monitor.refresh)
backend_format_double(monitor.refresh)
));
}
builder.append(" position = %dx%d\n".printf(monitor.x, monitor.y));
builder.append(" scale = %s\n".printf(format_double(monitor.scale)));
builder.append(" scale = %s\n".printf(backend_format_double(monitor.scale)));
if (monitor.mirror != "")
builder.append(" mirror = %s\n".printf(monitor.mirror));
......@@ -132,20 +132,20 @@ namespace TunerDisplays {
builder.append(" sdr_eotf = %s\n".printf(monitor.sdr_eotf));
if (!double_equal(monitor.sdr_brightness, 1.0))
builder.append(" sdrbrightness = %s\n".printf(format_double(monitor.sdr_brightness)));
builder.append(" sdrbrightness = %s\n".printf(backend_format_double(monitor.sdr_brightness)));
if (!double_equal(monitor.sdr_saturation, 1.0))
builder.append(" sdrsaturation = %s\n".printf(format_double(monitor.sdr_saturation)));
builder.append(" sdrsaturation = %s\n".printf(backend_format_double(monitor.sdr_saturation)));
if (monitor.supports_wide_color != 0)
builder.append(" supports_wide_color = %d\n".printf(monitor.supports_wide_color));
if (monitor.supports_hdr != 0)
builder.append(" supports_hdr = %d\n".printf(monitor.supports_hdr));
if (monitor.sdr_min_luminance != 0.2)
builder.append(" sdr_min_luminance = %s\n".printf(format_double(monitor.sdr_min_luminance)));
builder.append(" sdr_min_luminance = %s\n".printf(backend_format_double(monitor.sdr_min_luminance)));
if (monitor.sdr_max_luminance != 80)
builder.append(" sdr_max_luminance = %d\n".printf(monitor.sdr_max_luminance));
if (monitor.min_luminance >= 0)
builder.append(" min_luminance = %s\n".printf(format_double(monitor.min_luminance)));
builder.append(" min_luminance = %s\n".printf(backend_format_double(monitor.min_luminance)));
if (monitor.max_luminance >= 0)
builder.append(" max_luminance = %d\n".printf(monitor.max_luminance));
if (monitor.max_avg_luminance >= 0)
......@@ -166,15 +166,9 @@ namespace TunerDisplays {
}
}
private static Json.Node parse_json(string text) throws Error {
var parser = new Json.Parser();
parser.load_from_data(text);
return parser.get_root();
}
private static Gee.HashSet<string> read_active_names() throws Error {
var names = new Gee.HashSet<string>();
var root = parse_json(ShellCommand.run("hyprctl -j monitors"));
var root = backend_parse_json(ShellCommand.run("hyprctl -j monitors"));
var array = root.get_array();
for (uint i = 0; i < array.get_length(); i++)
names.add(array.get_object_element(i).get_string_member("name"));
......@@ -308,16 +302,6 @@ namespace TunerDisplays {
return null;
}
private static void apply_first_available_mode(MonitorConfig monitor) {
if (monitor.modes.size == 0)
return;
var mode = monitor.modes[0];
monitor.width = mode.width;
monitor.height = mode.height;
monitor.refresh = mode.refresh;
}
private static string monitors_path() {
return Path.build_filename(Environment.get_user_config_dir(), "hypr", "monitors.conf");
}
......@@ -350,26 +334,10 @@ namespace TunerDisplays {
return 0;
}
private static string get_string(Json.Object obj, string name, string fallback = "") {
return obj.has_member(name) ? obj.get_string_member(name) : fallback;
}
private static double get_double(Json.Object obj, string name, double fallback) {
return obj.has_member(name) ? obj.get_double_member(name) : fallback;
}
private static bool get_bool(Json.Object obj, string name, bool fallback) {
return obj.has_member(name) ? obj.get_boolean_member(name) : fallback;
}
private static bool is_ten_bit_format(string format) {
return format == "XRGB2101010" || format == "XBGR2101010";
}
private static string format_double(double value) {
return "%.2f".printf(value).replace(",", ".");
}
private static string output_identifier(MonitorConfig monitor) {
if (!monitor.use_description)
return monitor.name;
......
......@@ -184,7 +184,7 @@ namespace TunerDisplays {
} else if (line.has_prefix("mode ")) {
parse_saved_mode(line, current);
} else if (line.has_prefix("scale ")) {
current.scale = parse_double_token(line.substring(6), 1.0);
current.scale = parse_double_token(line.substring(6));
current.has_scale = true;
} else if (line.has_prefix("position ")) {
parse_saved_position(line, current);
......@@ -325,7 +325,7 @@ namespace TunerDisplays {
if (!monitor.enabled)
continue;
var monitor_right = monitor.x + (int) Math.round(backend_logical_width(monitor));
var monitor_right = monitor.x + (int) Math.round(monitor.logical_width);
if (!found_enabled || monitor_right > right)
right = monitor_right;
found_enabled = true;
......@@ -339,7 +339,7 @@ namespace TunerDisplays {
monitor.x = found_enabled ? right : 0;
monitor.y = 0;
right += (int) Math.round(backend_logical_width(monitor));
right += (int) Math.round(monitor.logical_width);
}
}
......@@ -381,7 +381,7 @@ namespace TunerDisplays {
monitor.width = int.parse(value.substring(0, x));
monitor.height = int.parse(value.substring(x + 1, at - x - 1));
monitor.refresh = parse_double_token(value.substring(at + 1), 0);
monitor.refresh = parse_double_token(value.substring(at + 1));
monitor.has_mode = monitor.width > 0 && monitor.height > 0 && monitor.refresh > 0;
}
......@@ -397,7 +397,7 @@ namespace TunerDisplays {
monitor.has_position = true;
}
private static double parse_double_token(string value, double fallback) {
private static double parse_double_token(string value) {
return double.parse(value.strip().replace(",", "."));
}
......
......@@ -14,6 +14,15 @@ namespace TunerDisplays {
return "%dx%d@%.2f".printf(width, height, refresh);
}
}
public bool supports_scale(double scale) {
foreach (var supported in supported_scales) {
if (Math.fabs(supported - scale) < 0.01)
return true;
}
return false;
}
}
public class MonitorConfig : Object {
......@@ -81,8 +90,78 @@ namespace TunerDisplays {
}
}
public double logical_width {
get {
if (scale <= 0)
return width;
return is_rotated() ? height / scale : width / scale;
}
}
public double logical_height {
get {
if (scale <= 0)
return height;
return is_rotated() ? width / scale : height / scale;
}
}
public void copy_from(MonitorConfig source) {
description = source.description;
vendor = source.vendor;
product = source.product;
serial = source.serial;
enabled = source.enabled;
primary = source.primary;
x = source.x;
y = source.y;
width = source.width;
height = source.height;
refresh = source.refresh;
scale = source.scale;
transform = source.transform;
mirror = source.mirror;
mirrored = source.mirrored;
use_description = source.use_description;
bitdepth = source.bitdepth;
vrr = source.vrr;
color_management_preset = source.color_management_preset;
sdr_eotf = source.sdr_eotf;
sdr_brightness = source.sdr_brightness;
sdr_saturation = source.sdr_saturation;
supports_wide_color = source.supports_wide_color;
supports_hdr = source.supports_hdr;
sdr_min_luminance = source.sdr_min_luminance;
sdr_max_luminance = source.sdr_max_luminance;
min_luminance = source.min_luminance;
max_luminance = source.max_luminance;
max_avg_luminance = source.max_avg_luminance;
icc = source.icc;
underscanning = source.underscanning;
color_mode = source.color_mode;
supports_variable_refresh_rate = source.supports_variable_refresh_rate;
variable_refresh_rate = source.variable_refresh_rate;
dpms = source.dpms;
niri_focus_at_startup = source.niri_focus_at_startup;
niri_backdrop_color = source.niri_backdrop_color;
niri_hot_corners = source.niri_hot_corners;
niri_has_saved_position = source.niri_has_saved_position;
modes.clear();
foreach (var mode in source.modes)
modes.add(mode);
supported_color_modes.clear();
foreach (var mode in source.supported_color_modes)
supported_color_modes.add(mode);
}
private bool is_builtin() {
return name.has_prefix("eDP-") || name.has_prefix("LVDS-") || name.has_prefix("DSI-");
}
private bool is_rotated() {
return transform.index_of("90") >= 0 || transform.index_of("270") >= 0;
}
}
}
......@@ -247,7 +247,7 @@ namespace TunerDisplays {
monitor.height = mode.height;
monitor.refresh = mode.refresh;
monitor.variable_refresh_rate = mode.variable_refresh_rate;
if (!mode_supports_scale(mode, monitor.scale))
if (!mode.supports_scale(monitor.scale))
monitor.scale = mode.preferred_scale;
}
rebuild_rows();
......@@ -442,7 +442,7 @@ namespace TunerDisplays {
bool supported = true;
foreach (var monitor in monitors) {
var compatible = find_compatible_mirror_mode(monitor, mode);
if (compatible == null || !mode_supports_scale(compatible, scale)) {
if (compatible == null || !compatible.supports_scale(scale)) {
supported = false;
break;
}
......@@ -489,7 +489,7 @@ namespace TunerDisplays {
if (monitor == null)
monitor = loaded_monitor;
else
copy_monitor(loaded_monitor, monitor);
monitor.copy_from(loaded_monitor);
merged.add(monitor);
}
......@@ -505,56 +505,6 @@ namespace TunerDisplays {
return null;
}
private static void copy_monitor(MonitorConfig source, MonitorConfig target) {
target.description = source.description;
target.vendor = source.vendor;
target.product = source.product;
target.serial = source.serial;
target.enabled = source.enabled;
target.primary = source.primary;
target.x = source.x;
target.y = source.y;
target.width = source.width;
target.height = source.height;
target.refresh = source.refresh;
target.scale = source.scale;
target.transform = source.transform;
target.mirror = source.mirror;
target.mirrored = source.mirrored;
target.use_description = source.use_description;
target.bitdepth = source.bitdepth;
target.vrr = source.vrr;
target.color_management_preset = source.color_management_preset;
target.sdr_eotf = source.sdr_eotf;
target.sdr_brightness = source.sdr_brightness;
target.sdr_saturation = source.sdr_saturation;
target.supports_wide_color = source.supports_wide_color;
target.supports_hdr = source.supports_hdr;
target.sdr_min_luminance = source.sdr_min_luminance;
target.sdr_max_luminance = source.sdr_max_luminance;
target.min_luminance = source.min_luminance;
target.max_luminance = source.max_luminance;
target.max_avg_luminance = source.max_avg_luminance;
target.icc = source.icc;
target.underscanning = source.underscanning;
target.color_mode = source.color_mode;
target.supports_variable_refresh_rate = source.supports_variable_refresh_rate;
target.variable_refresh_rate = source.variable_refresh_rate;
target.dpms = source.dpms;
target.niri_focus_at_startup = source.niri_focus_at_startup;
target.niri_backdrop_color = source.niri_backdrop_color;
target.niri_hot_corners = source.niri_hot_corners;
target.niri_has_saved_position = source.niri_has_saved_position;
target.modes.clear();
foreach (var mode in source.modes)
target.modes.add(mode);
target.supported_color_modes.clear();
foreach (var mode in source.supported_color_modes)
target.supported_color_modes.add(mode);
}
}
}
......@@ -202,8 +202,8 @@ namespace TunerDisplays {
return;
}
var width = get_logical_width(monitor);
var height = get_logical_height(monitor);
var width = monitor.logical_width;
var height = monitor.logical_height;
var snap_units = SNAP_DISTANCE / zoom;
double best_x_distance = snap_units + 1;
double best_y_distance = snap_units + 1;
......@@ -214,8 +214,8 @@ namespace TunerDisplays {
if (other == monitor)
continue;
var other_width = get_logical_width(other);
var other_height = get_logical_height(other);
var other_width = other.logical_width;
var other_height = other.logical_height;
var right = x + width;
var bottom = y + height;
var other_right = other.x + other_width;
......@@ -237,8 +237,8 @@ namespace TunerDisplays {
}
private void snap_connected_position(MonitorConfig monitor, ref int x, ref int y) {
var width = get_logical_width(monitor);
var height = get_logical_height(monitor);
var width = monitor.logical_width;
var height = monitor.logical_height;
var snap_units = enabled_count() <= 2 ? double.MAX : SNAP_DISTANCE / zoom;
double best_distance = double.MAX;
int best_x = x;
......@@ -250,8 +250,8 @@ namespace TunerDisplays {
if (other == monitor || !other.enabled)
continue;
var other_width = get_logical_width(other);
var other_height = get_logical_height(other);
var other_width = other.logical_width;
var other_height = other.logical_height;
var other_right = other.x + other_width;
var other_bottom = other.y + other_height;
var top = (int) Math.round(other.y - height);
......@@ -320,8 +320,8 @@ namespace TunerDisplays {
if (view_width <= 0 || view_height <= 0 || zoom <= 0)
return;
var logical_width = get_logical_width(monitor);
var logical_height = get_logical_height(monitor);
var logical_width = monitor.logical_width;
var logical_height = monitor.logical_height;
var min_x = (EDGE_PADDING - offset_x) / zoom;
var min_y = (EDGE_PADDING - offset_y) / zoom;
var max_x = (view_width - EDGE_PADDING - offset_x) / zoom - logical_width;
......@@ -337,15 +337,15 @@ namespace TunerDisplays {
}
private bool overlaps_any(MonitorConfig monitor, int x, int y) {
var width = get_logical_width(monitor);
var height = get_logical_height(monitor);
var width = monitor.logical_width;
var height = monitor.logical_height;
foreach (var other in monitors) {
if (other == monitor)
continue;
if (rects_overlap(
x, y, width, height,
other.x, other.y, get_logical_width(other), get_logical_height(other)
other.x, other.y, other.logical_width, other.logical_height
)) {
return true;
}
......@@ -412,8 +412,8 @@ namespace TunerDisplays {
bool first = true;
foreach (var monitor in monitors) {
var logical_width = get_logical_width(monitor);
var logical_height = get_logical_height(monitor);
var logical_width = monitor.logical_width;
var logical_height = monitor.logical_height;
max_monitor_width = double.max(max_monitor_width, logical_width);
max_monitor_height = double.max(max_monitor_height, logical_height);
if (first) {
......@@ -443,24 +443,8 @@ namespace TunerDisplays {
private void rect_for_monitor(MonitorConfig monitor, out double x, out double y, out double w, out double h) {
x = offset_x + monitor.x * zoom;
y = offset_y + monitor.y * zoom;
w = double.max(48, get_logical_width(monitor) * zoom);
h = double.max(36, get_logical_height(monitor) * zoom);
}
private static double get_logical_width(MonitorConfig monitor) {
if (is_rotated(monitor))
return monitor.height / monitor.scale;
return monitor.width / monitor.scale;
}
private static double get_logical_height(MonitorConfig monitor) {
if (is_rotated(monitor))
return monitor.width / monitor.scale;
return monitor.height / monitor.scale;
}
private static bool is_rotated(MonitorConfig monitor) {
return monitor.transform.index_of("90") >= 0 || monitor.transform.index_of("270") >= 0;
w = double.max(48, monitor.logical_width * zoom);
h = double.max(36, monitor.logical_height * zoom);
}
private static void rounded_rectangle(Cairo.Context cr, double x, double y, double w, double h, double radius) {
......
......@@ -98,7 +98,7 @@ namespace TunerDisplays {
monitor.width = mode.width;
monitor.height = mode.height;
monitor.refresh = mode.refresh;
if (backend_id == "gnome" && !mode_supports_scale(mode, monitor.scale))
if (backend_id == "gnome" && !mode.supports_scale(monitor.scale))
monitor.scale = mode.preferred_scale;
emit_changed();
}
......@@ -143,7 +143,7 @@ namespace TunerDisplays {
monitor.height = mode.height;
monitor.refresh = mode.refresh;
monitor.variable_refresh_rate = mode.variable_refresh_rate;
if (!mode_supports_scale(mode, monitor.scale))
if (!mode.supports_scale(monitor.scale))
monitor.scale = mode.preferred_scale;
if (gnome_variable_refresh_row != null)
gnome_variable_refresh_row.visible = has_variable_mode_for_resolution();
......@@ -176,7 +176,7 @@ namespace TunerDisplays {
var mode = gnome_refresh_values[index];
monitor.refresh = mode.refresh;
monitor.variable_refresh_rate = false;
if (!mode_supports_scale(mode, monitor.scale))
if (!mode.supports_scale(monitor.scale))
monitor.scale = mode.preferred_scale;
sync_gnome_refresh_state();
emit_changed();
......@@ -197,14 +197,14 @@ namespace TunerDisplays {
var mode = find_variable_mode_for_resolution();
if (mode != null) {
monitor.refresh = mode.refresh;
if (!mode_supports_scale(mode, monitor.scale))
if (!mode.supports_scale(monitor.scale))
monitor.scale = mode.preferred_scale;
}
} else {
var mode = find_best_fixed_mode_for_resolution(monitor.width, monitor.height);
if (mode != null) {
monitor.refresh = mode.refresh;
if (!mode_supports_scale(mode, monitor.scale))
if (!mode.supports_scale(monitor.scale))
monitor.scale = mode.preferred_scale;
}
}
......
......@@ -12,7 +12,7 @@ namespace TunerDisplays {
if (other == monitor || !other.enabled)
continue;
var right = other.x + (int) Math.round(logical_width_for_monitor(other));
var right = other.x + (int) Math.round(other.logical_width);
if (!found_active || right > max_x)
max_x = right;
found_active = true;
......@@ -22,21 +22,6 @@ namespace TunerDisplays {
monitor.y = 0;
}
private static double logical_width_for_monitor(MonitorConfig monitor) {
if (monitor.transform.index_of("90") >= 0 || monitor.transform.index_of("270") >= 0)
return monitor.height / monitor.scale;
return monitor.width / monitor.scale;
}
private static bool mode_supports_scale(DisplayMode mode, double scale) {
foreach (var supported in mode.supported_scales) {
if (Math.fabs(supported - scale) < 0.01)
return true;
}
return false;
}
private static bool has_resolution(Gee.ArrayList<DisplayMode> modes, int width, int height) {
foreach (var mode in modes) {
if (mode.width == width && mode.height == height)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment