Commit ee2ff937 authored by Guido Gunther's avatar Guido Gunther
Browse files

monitor: Allow to get fractional scale

This is derived from the logical size as described in
https://wayland.app/protocols/xdg-output-unstable-v1#zxdg_output_v1:event:logical_size

Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent f10df68e
......@@ -168,7 +168,6 @@ xdg_output_v1_handle_logical_size (void *data,
g_debug ("Monitor %p: Logical size: %dx%d", self, width, height);
self->logical.width = width;
self->logical.height = height;
}
......@@ -609,3 +608,32 @@ phosh_monitor_get_wl_output (PhoshMonitor *self)
return self->wl_output;
}
/**
* phosh_monitor_get_fractional_scale:
* @self: The monitor
*
* Get the fractinoal scale determined from the output width and the
* current logical width.
* Returns: the fractional scale
*/
float
phosh_monitor_get_fractional_scale (PhoshMonitor *self)
{
float width;
g_return_val_if_fail (PHOSH_IS_MONITOR (self), 1.0);
g_return_val_if_fail (phosh_monitor_is_configured (self), 1.0);
switch (self->transform) {
case PHOSH_MONITOR_TRANSFORM_NORMAL:
case PHOSH_MONITOR_TRANSFORM_180:
case PHOSH_MONITOR_TRANSFORM_FLIPPED:
case PHOSH_MONITOR_TRANSFORM_FLIPPED_180:
width = self->logical.width;
break;
default:
width = self->logical.height;
}
return self->width / width;
}
......@@ -155,5 +155,6 @@ PhoshMonitorPowerSaveMode phosh_monitor_get_power_save_mode (PhoshMonitor *self)
PhoshMonitorConnectorType phosh_monitor_connector_type_from_name (const char *name);
gboolean phosh_monitor_connector_is_builtin (PhoshMonitorConnectorType type);
struct wl_output * phosh_monitor_get_wl_output (PhoshMonitor *self);
float phosh_monitor_get_fractional_scale (PhoshMonitor *self);
G_END_DECLS
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