wayland: Advertise MetaMonitor as wl_output

With the logical size of outputs being handled by xdg-output, we don't
need to "lie" to Wayland clients anymore about the output size, so
advertise the real mode size as wl_output regardless of the scale, as it
should be (and like other Wayland compositors do).

https://bugzilla.gnome.org/show_bug.cgi?id=787363
https://gitlab.gnome.org/GNOME/mutter/merge_requests/994
This commit is contained in:
Olivier Fourdan 2017-09-20 11:25:55 +02:00 committed by Robert Mader
parent 438f75e6b3
commit 98d7a542b0
2 changed files with 32 additions and 5 deletions

View File

@ -168,6 +168,21 @@ is_different_rotation (MetaLogicalMonitor *a,
meta_monitor_transform_is_rotated (b->transform)); meta_monitor_transform_is_rotated (b->transform));
} }
static void
get_native_output_mode_resolution (MetaLogicalMonitor *logical_monitor,
MetaMonitorMode *mode,
int *mode_width,
int *mode_height)
{
MetaMonitorTransform transform;
transform = meta_logical_monitor_get_transform (logical_monitor);
if (meta_monitor_transform_is_rotated (transform))
meta_monitor_mode_get_resolution (mode, mode_height, mode_width);
else
meta_monitor_mode_get_resolution (mode, mode_width, mode_height);
}
static void static void
send_output_events (struct wl_resource *resource, send_output_events (struct wl_resource *resource,
MetaWaylandOutput *wayland_output, MetaWaylandOutput *wayland_output,
@ -185,6 +200,7 @@ send_output_events (struct wl_resource *resource,
gint old_scale; gint old_scale;
float old_refresh_rate; float old_refresh_rate;
float refresh_rate; float refresh_rate;
int new_width, new_height;
old_logical_monitor = wayland_output->logical_monitor; old_logical_monitor = wayland_output->logical_monitor;
old_mode_flags = wayland_output->mode_flags; old_mode_flags = wayland_output->mode_flags;
@ -246,16 +262,20 @@ send_output_events (struct wl_resource *resource,
if (current_mode == preferred_mode) if (current_mode == preferred_mode)
mode_flags |= WL_OUTPUT_MODE_PREFERRED; mode_flags |= WL_OUTPUT_MODE_PREFERRED;
get_native_output_mode_resolution (logical_monitor,
current_mode,
&new_width,
&new_height);
if (need_all_events || if (need_all_events ||
old_logical_monitor->rect.width != logical_monitor->rect.width || wayland_output->mode_width != new_width ||
old_logical_monitor->rect.height != logical_monitor->rect.height || wayland_output->mode_height != new_height ||
old_refresh_rate != refresh_rate || old_refresh_rate != refresh_rate ||
old_mode_flags != mode_flags) old_mode_flags != mode_flags)
{ {
wl_output_send_mode (resource, wl_output_send_mode (resource,
mode_flags, mode_flags,
logical_monitor->rect.width, new_width,
logical_monitor->rect.height, new_height,
(int32_t) (refresh_rate * 1000)); (int32_t) (refresh_rate * 1000));
need_done = TRUE; need_done = TRUE;
} }
@ -312,7 +332,8 @@ bind_output (struct wl_client *client,
logical_monitor, logical_monitor,
meta_monitor_get_product (monitor), meta_monitor_get_product (monitor),
logical_monitor->rect.x, logical_monitor->rect.y, logical_monitor->rect.x, logical_monitor->rect.y,
logical_monitor->rect.width, logical_monitor->rect.height, wayland_output->mode_width,
wayland_output->mode_height,
wayland_output->refresh_rate); wayland_output->refresh_rate);
#endif #endif
@ -349,6 +370,10 @@ meta_wayland_output_set_logical_monitor (MetaWaylandOutput *wayland_output,
wayland_output->refresh_rate = meta_monitor_mode_get_refresh_rate (current_mode); wayland_output->refresh_rate = meta_monitor_mode_get_refresh_rate (current_mode);
wayland_output->winsys_id = logical_monitor->winsys_id; wayland_output->winsys_id = logical_monitor->winsys_id;
get_native_output_mode_resolution (logical_monitor,
current_mode,
&wayland_output->mode_width,
&wayland_output->mode_height);
} }
static void static void

View File

@ -41,6 +41,8 @@ struct _MetaWaylandOutput
guint mode_flags; guint mode_flags;
float refresh_rate; float refresh_rate;
gint scale; gint scale;
int mode_width;
int mode_height;
GList *resources; GList *resources;
GList *xdg_output_resources; GList *xdg_output_resources;