mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 03:20:46 -05:00
wayland: use monitors info for outputs instead of kms outputs
Wayland shouldn't use KMS outputs, it should use the monitor infos to show its outputs, this will make tiled monitors work with wayland.
This commit is contained in:
parent
4d80a4cc31
commit
e2d6028924
@ -32,7 +32,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MetaOutput *output;
|
MetaMonitorInfo *monitor_info;
|
||||||
struct wl_global *global;
|
struct wl_global *global;
|
||||||
int x, y;
|
int x, y;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
@ -56,9 +56,10 @@ bind_output (struct wl_client *client,
|
|||||||
guint32 id)
|
guint32 id)
|
||||||
{
|
{
|
||||||
MetaWaylandOutput *wayland_output = data;
|
MetaWaylandOutput *wayland_output = data;
|
||||||
MetaOutput *output = wayland_output->output;
|
MetaMonitorInfo *monitor_info = wayland_output->monitor_info;
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
guint mode_flags;
|
guint mode_flags;
|
||||||
|
MetaOutput *output = monitor_info->outputs[0];
|
||||||
|
|
||||||
resource = wl_resource_create (client, &wl_output_interface, version, id);
|
resource = wl_resource_create (client, &wl_output_interface, version, id);
|
||||||
wayland_output->resources = g_list_prepend (wayland_output->resources, resource);
|
wayland_output->resources = g_list_prepend (wayland_output->resources, resource);
|
||||||
@ -66,17 +67,17 @@ bind_output (struct wl_client *client,
|
|||||||
wl_resource_set_user_data (resource, wayland_output);
|
wl_resource_set_user_data (resource, wayland_output);
|
||||||
wl_resource_set_destructor (resource, output_resource_destroy);
|
wl_resource_set_destructor (resource, output_resource_destroy);
|
||||||
|
|
||||||
meta_verbose ("Binding output %p/%s (%u, %u, %u, %u) x %f\n",
|
meta_verbose ("Binding monitor %p/%s (%u, %u, %u, %u) x %f\n",
|
||||||
output, output->name,
|
monitor_info, output->name,
|
||||||
output->crtc->rect.x, output->crtc->rect.y,
|
monitor_info->rect.x, monitor_info->rect.y,
|
||||||
output->crtc->rect.width, output->crtc->rect.height,
|
monitor_info->rect.width, monitor_info->rect.height,
|
||||||
output->crtc->current_mode->refresh_rate);
|
monitor_info->refresh_rate);
|
||||||
|
|
||||||
wl_output_send_geometry (resource,
|
wl_output_send_geometry (resource,
|
||||||
(int)output->crtc->rect.x,
|
(int)monitor_info->rect.x,
|
||||||
(int)output->crtc->rect.y,
|
(int)monitor_info->rect.y,
|
||||||
output->width_mm,
|
monitor_info->width_mm,
|
||||||
output->height_mm,
|
monitor_info->height_mm,
|
||||||
/* Cogl values reflect XRandR values,
|
/* Cogl values reflect XRandR values,
|
||||||
and so does wayland */
|
and so does wayland */
|
||||||
output->subpixel_order,
|
output->subpixel_order,
|
||||||
@ -92,9 +93,9 @@ bind_output (struct wl_client *client,
|
|||||||
|
|
||||||
wl_output_send_mode (resource,
|
wl_output_send_mode (resource,
|
||||||
mode_flags,
|
mode_flags,
|
||||||
(int)output->crtc->current_mode->width,
|
(int)monitor_info->rect.width,
|
||||||
(int)output->crtc->current_mode->height,
|
(int)monitor_info->rect.height,
|
||||||
(int)output->crtc->current_mode->refresh_rate);
|
(int)monitor_info->refresh_rate);
|
||||||
|
|
||||||
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
|
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
|
||||||
wl_output_send_scale (resource, output->scale);
|
wl_output_send_scale (resource, output->scale);
|
||||||
@ -128,14 +129,13 @@ wl_output_transform_from_meta_monitor_transform (MetaMonitorTransform transform)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
wayland_output_update_for_output (MetaWaylandOutput *wayland_output,
|
wayland_output_update_for_output (MetaWaylandOutput *wayland_output,
|
||||||
MetaOutput *output)
|
MetaMonitorInfo *monitor_info)
|
||||||
{
|
{
|
||||||
GList *iter;
|
GList *iter;
|
||||||
guint mode_flags;
|
guint mode_flags;
|
||||||
|
MetaOutput *output = monitor_info->outputs[0];
|
||||||
enum wl_output_transform wl_transform = wl_output_transform_from_meta_monitor_transform (output->crtc->transform);
|
enum wl_output_transform wl_transform = wl_output_transform_from_meta_monitor_transform (output->crtc->transform);
|
||||||
|
|
||||||
g_assert (output->crtc->current_mode != NULL);
|
|
||||||
|
|
||||||
mode_flags = WL_OUTPUT_MODE_CURRENT;
|
mode_flags = WL_OUTPUT_MODE_CURRENT;
|
||||||
if (output->crtc->current_mode == output->preferred_mode)
|
if (output->crtc->current_mode == output->preferred_mode)
|
||||||
mode_flags |= WL_OUTPUT_MODE_PREFERRED;
|
mode_flags |= WL_OUTPUT_MODE_PREFERRED;
|
||||||
@ -144,15 +144,15 @@ wayland_output_update_for_output (MetaWaylandOutput *wayland_output,
|
|||||||
{
|
{
|
||||||
struct wl_resource *resource = iter->data;
|
struct wl_resource *resource = iter->data;
|
||||||
|
|
||||||
if (wayland_output->x != output->crtc->rect.x ||
|
if (wayland_output->x != monitor_info->rect.x ||
|
||||||
wayland_output->y != output->crtc->rect.y ||
|
wayland_output->y != monitor_info->rect.y ||
|
||||||
wayland_output->transform != wl_transform)
|
wayland_output->transform != wl_transform)
|
||||||
{
|
{
|
||||||
wl_output_send_geometry (resource,
|
wl_output_send_geometry (resource,
|
||||||
(int)output->crtc->rect.x,
|
(int)monitor_info->rect.x,
|
||||||
(int)output->crtc->rect.y,
|
(int)monitor_info->rect.y,
|
||||||
output->width_mm,
|
monitor_info->width_mm,
|
||||||
output->height_mm,
|
monitor_info->height_mm,
|
||||||
output->subpixel_order,
|
output->subpixel_order,
|
||||||
output->vendor,
|
output->vendor,
|
||||||
output->product,
|
output->product,
|
||||||
@ -161,16 +161,16 @@ wayland_output_update_for_output (MetaWaylandOutput *wayland_output,
|
|||||||
|
|
||||||
wl_output_send_mode (resource,
|
wl_output_send_mode (resource,
|
||||||
mode_flags,
|
mode_flags,
|
||||||
(int)output->crtc->current_mode->width,
|
(int)monitor_info->rect.width,
|
||||||
(int)output->crtc->current_mode->height,
|
(int)monitor_info->rect.height,
|
||||||
(int)output->crtc->current_mode->refresh_rate);
|
(int)monitor_info->refresh_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It's very important that we change the output pointer here, as
|
/* It's very important that we change the output pointer here, as
|
||||||
the old structure is about to be freed by MetaMonitorManager */
|
the old structure is about to be freed by MetaMonitorManager */
|
||||||
wayland_output->output = output;
|
wayland_output->monitor_info = monitor_info;
|
||||||
wayland_output->x = output->crtc->rect.x;
|
wayland_output->x = monitor_info->rect.x;
|
||||||
wayland_output->y = output->crtc->rect.y;
|
wayland_output->y = monitor_info->rect.y;
|
||||||
wayland_output->transform = wl_transform;
|
wayland_output->transform = wl_transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,30 +178,26 @@ static GHashTable *
|
|||||||
meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
|
meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
|
||||||
MetaMonitorManager *monitors)
|
MetaMonitorManager *monitors)
|
||||||
{
|
{
|
||||||
MetaOutput *outputs;
|
unsigned int i;
|
||||||
unsigned int i, n_outputs;
|
|
||||||
GHashTable *new_table;
|
GHashTable *new_table;
|
||||||
|
MetaMonitorInfo *monitor_infos;
|
||||||
|
unsigned int n_monitor_infos;
|
||||||
|
|
||||||
outputs = meta_monitor_manager_get_outputs (monitors, &n_outputs);
|
monitor_infos = meta_monitor_manager_get_monitor_infos (monitors, &n_monitor_infos);
|
||||||
new_table = g_hash_table_new_full (NULL, NULL, NULL, wayland_output_destroy_notify);
|
new_table = g_hash_table_new_full (NULL, NULL, NULL, wayland_output_destroy_notify);
|
||||||
|
|
||||||
for (i = 0; i < n_outputs; i++)
|
for (i = 0; i < n_monitor_infos; i++)
|
||||||
{
|
{
|
||||||
MetaOutput *output = &outputs[i];
|
MetaMonitorInfo *info = &monitor_infos[i];
|
||||||
MetaWaylandOutput *wayland_output;
|
MetaWaylandOutput *wayland_output;
|
||||||
|
|
||||||
/* wayland does not expose disabled outputs */
|
if (info->winsys_id == 0)
|
||||||
if (output->crtc == NULL)
|
|
||||||
{
|
|
||||||
g_hash_table_remove (compositor->outputs, GSIZE_TO_POINTER (output->winsys_id));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
wayland_output = g_hash_table_lookup (compositor->outputs, GSIZE_TO_POINTER (info->winsys_id));
|
||||||
|
|
||||||
wayland_output = g_hash_table_lookup (compositor->outputs, GSIZE_TO_POINTER (output->winsys_id));
|
|
||||||
|
|
||||||
if (wayland_output)
|
if (wayland_output)
|
||||||
{
|
{
|
||||||
g_hash_table_steal (compositor->outputs, GSIZE_TO_POINTER (output->winsys_id));
|
g_hash_table_steal (compositor->outputs, GSIZE_TO_POINTER (info->winsys_id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -212,8 +208,8 @@ meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
|
|||||||
wayland_output, bind_output);
|
wayland_output, bind_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
wayland_output_update_for_output (wayland_output, output);
|
wayland_output_update_for_output (wayland_output, info);
|
||||||
g_hash_table_insert (new_table, GSIZE_TO_POINTER (output->winsys_id), wayland_output);
|
g_hash_table_insert (new_table, GSIZE_TO_POINTER (info->winsys_id), wayland_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_destroy (compositor->outputs);
|
g_hash_table_destroy (compositor->outputs);
|
||||||
|
Loading…
Reference in New Issue
Block a user