wayland/output: Rotate physical dimensions as well

For Wayland outputs, we do not expose the actual transformation because
mutter does not support wl_surface.set_buffer_transform yet, instead we
swap the logical width and height when the output is rotated.

However, a client wishing to use the physical size would get confused,
so if the output is rotated, rotate the physical dimensions as well for
consistency.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/369
This commit is contained in:
Olivier Fourdan 2018-11-07 10:13:24 +01:00
parent 6c5baf89ed
commit bda9c359af

View File

@ -131,6 +131,39 @@ calculate_wayland_output_scale (MetaLogicalMonitor *logical_monitor)
return ceilf (scale); return ceilf (scale);
} }
static void
get_rotated_physical_dimensions (MetaMonitor *monitor,
int *width_mm,
int *height_mm)
{
int monitor_width_mm, monitor_height_mm;
MetaLogicalMonitor *logical_monitor;
meta_monitor_get_physical_dimensions (monitor,
&monitor_width_mm,
&monitor_height_mm);
logical_monitor = meta_monitor_get_logical_monitor (monitor);
if (meta_monitor_transform_is_rotated (logical_monitor->transform))
{
*width_mm = monitor_height_mm;
*height_mm = monitor_width_mm;
}
else
{
*width_mm = monitor_width_mm;
*height_mm = monitor_height_mm;
}
}
static gboolean
is_different_rotation (MetaLogicalMonitor *a,
MetaLogicalMonitor *b)
{
return (meta_monitor_transform_is_rotated (a->transform) !=
meta_monitor_transform_is_rotated (b->transform));
}
static void static void
send_output_events (struct wl_resource *resource, send_output_events (struct wl_resource *resource,
MetaWaylandOutput *wayland_output, MetaWaylandOutput *wayland_output,
@ -163,7 +196,8 @@ send_output_events (struct wl_resource *resource,
if (need_all_events || if (need_all_events ||
old_logical_monitor->rect.x != logical_monitor->rect.x || old_logical_monitor->rect.x != logical_monitor->rect.x ||
old_logical_monitor->rect.y != logical_monitor->rect.y) old_logical_monitor->rect.y != logical_monitor->rect.y ||
is_different_rotation (old_logical_monitor, logical_monitor))
{ {
int width_mm, height_mm; int width_mm, height_mm;
const char *vendor; const char *vendor;
@ -178,7 +212,7 @@ send_output_events (struct wl_resource *resource,
* Arbitrarily use whatever monitor is the first in the logical monitor * Arbitrarily use whatever monitor is the first in the logical monitor
* and use that for these details. * and use that for these details.
*/ */
meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm); get_rotated_physical_dimensions (monitor, &width_mm, &height_mm);
vendor = meta_monitor_get_vendor (monitor); vendor = meta_monitor_get_vendor (monitor);
product = meta_monitor_get_product (monitor); product = meta_monitor_get_product (monitor);