xwayland: Set primary monitor using connector name
We know let Xwayland set the RANDR names from the connectors. To stop relying on layouts and coordinates to match the primary logical monitor, instead use the connector name of the first monitor. Also make the X11 client sanity checking check that the right X11 output is primary as part of the monitor tests. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3567>
This commit is contained in:
parent
9af1926056
commit
1333d92fa5
2 changed files with 51 additions and 22 deletions
|
@ -226,11 +226,52 @@ check_test_client_state (MetaTestClient *test_client)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_test_client_x11_state (MetaTestClient *test_client)
|
||||
{
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (test_backend);
|
||||
MetaLogicalMonitor *primary_logical_monitor;
|
||||
MetaMonitor *primary_monitor = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
primary_logical_monitor =
|
||||
meta_monitor_manager_get_primary_logical_monitor (monitor_manager);
|
||||
|
||||
if (primary_logical_monitor)
|
||||
{
|
||||
GList *monitors;
|
||||
|
||||
monitors = meta_logical_monitor_get_monitors (primary_logical_monitor);
|
||||
primary_monitor = g_list_first (monitors)->data;
|
||||
}
|
||||
|
||||
if (!meta_test_client_do (test_client, &error,
|
||||
"sync",
|
||||
NULL))
|
||||
{
|
||||
g_error ("Failed to sync test client '%s': %s",
|
||||
meta_test_client_get_id (test_client), error->message);
|
||||
}
|
||||
|
||||
if (!meta_test_client_do (test_client, &error,
|
||||
"assert_primary_monitor",
|
||||
primary_monitor
|
||||
? meta_monitor_get_connector (primary_monitor)
|
||||
: "(none)",
|
||||
NULL))
|
||||
{
|
||||
g_error ("Failed to assert primary monitor in X11 test client '%s': %s",
|
||||
meta_test_client_get_id (test_client), error->message);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_monitor_test_clients_state (void)
|
||||
{
|
||||
check_test_client_state (wayland_monitor_test_client);
|
||||
check_test_client_state (x11_monitor_test_client);
|
||||
check_test_client_x11_state (x11_monitor_test_client);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1216,15 +1216,19 @@ meta_xwayland_set_primary_output (MetaX11Display *x11_display)
|
|||
MetaMonitorManager *monitor_manager =
|
||||
monitor_manager_from_x11_display (x11_display);
|
||||
XRRScreenResources *resources;
|
||||
MetaLogicalMonitor *primary_monitor;
|
||||
MetaLogicalMonitor *primary_logical_monitor;
|
||||
GList *monitors;
|
||||
MetaMonitor *primary_monitor;
|
||||
int i;
|
||||
|
||||
primary_monitor =
|
||||
primary_logical_monitor =
|
||||
meta_monitor_manager_get_primary_logical_monitor (monitor_manager);
|
||||
|
||||
if (!primary_monitor)
|
||||
if (!primary_logical_monitor)
|
||||
return;
|
||||
|
||||
monitors = meta_logical_monitor_get_monitors (primary_logical_monitor);
|
||||
primary_monitor = g_list_first (monitors)->data;
|
||||
|
||||
resources = XRRGetScreenResourcesCurrent (xdisplay,
|
||||
DefaultRootWindow (xdisplay));
|
||||
if (!resources)
|
||||
|
@ -1235,29 +1239,13 @@ meta_xwayland_set_primary_output (MetaX11Display *x11_display)
|
|||
{
|
||||
RROutput output_id = resources->outputs[i];
|
||||
XRROutputInfo *xrandr_output;
|
||||
XRRCrtcInfo *crtc_info = NULL;
|
||||
MtkRectangle crtc_geometry;
|
||||
|
||||
xrandr_output = XRRGetOutputInfo (xdisplay, resources, output_id);
|
||||
if (!xrandr_output)
|
||||
continue;
|
||||
|
||||
if (xrandr_output->crtc)
|
||||
crtc_info = XRRGetCrtcInfo (xdisplay, resources, xrandr_output->crtc);
|
||||
|
||||
XRRFreeOutputInfo (xrandr_output);
|
||||
|
||||
if (!crtc_info)
|
||||
continue;
|
||||
|
||||
crtc_geometry.x = crtc_info->x;
|
||||
crtc_geometry.y = crtc_info->y;
|
||||
crtc_geometry.width = crtc_info->width;
|
||||
crtc_geometry.height = crtc_info->height;
|
||||
|
||||
XRRFreeCrtcInfo (crtc_info);
|
||||
|
||||
if (mtk_rectangle_equal (&crtc_geometry, &primary_monitor->rect))
|
||||
if (g_strcmp0 (xrandr_output->name,
|
||||
meta_monitor_get_connector (primary_monitor)) == 0)
|
||||
{
|
||||
XRRSetOutputPrimary (xdisplay, DefaultRootWindow (xdisplay),
|
||||
output_id);
|
||||
|
|
Loading…
Add table
Reference in a new issue