xserver: Branch 'master' - 4 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Feb 13 14:32:23 UTC 2023
hw/xwayland/xwayland-output.c | 56 ++++++++++++++++++++++++++++++++++++------
hw/xwayland/xwayland-output.h | 3 +-
hw/xwayland/xwayland-screen.c | 2 -
3 files changed, 52 insertions(+), 9 deletions(-)
New commits:
commit 0c93394d726131b1badcdc1d8ca8c8fe8037d85c
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Thu Feb 2 15:16:58 2023 +0100
xwayland: Use wl_output.name for XRandR
If wl_output provides us with an output name, use that as well.
If we have both xdg_output.name and wl_output.name (from version >= 4),
prefer the latter.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>#
See-also: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/189
Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index f864f5ba5..afc416560 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -694,11 +694,28 @@ output_handle_scale(void *data, struct wl_output *wl_output, int32_t factor)
{
}
+static void
+output_handle_name(void *data, struct wl_output *wl_output,
+ const char *name)
+{
+ struct xwl_output *xwl_output = data;
+
+ xwl_output_set_name(xwl_output, name);
+}
+
+static void
+output_handle_description(void *data, struct wl_output *wl_output,
+ const char *description)
+{
+}
+
static const struct wl_output_listener output_listener = {
output_handle_geometry,
output_handle_mode,
output_handle_done,
- output_handle_scale
+ output_handle_scale,
+ output_handle_name,
+ output_handle_description,
};
static void
@@ -738,6 +755,9 @@ xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
{
struct xwl_output *xwl_output = data;
+ if (wl_output_get_version(xwl_output->output) >= 4)
+ return; /* wl_output.name is preferred */
+
xwl_output_set_name(xwl_output, name);
}
@@ -804,7 +824,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
}
xwl_output->output = wl_registry_bind(xwl_screen->registry, id,
- &wl_output_interface, min(version, 2));
+ &wl_output_interface, min(version, 4));
if (!xwl_output->output) {
ErrorF("Failed binding wl_output\n");
goto err;
commit b63ef10f188936506e8050015d3654aa324f6e43
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Tue Feb 7 15:05:34 2023 +0100
xwayland: Pass the wl_output version
With the wl_output protocol, the actual bind to the interface is done in
xwl_output_create().
Pass the version number from the registry so we can bind to the minimum
version.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 8e387e760..f864f5ba5 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -791,7 +791,8 @@ xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
}
struct xwl_output *
-xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr)
+xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
+ Bool with_xrandr, uint32_t version)
{
struct xwl_output *xwl_output;
char name[MAX_OUTPUT_NAME];
@@ -803,7 +804,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr)
}
xwl_output->output = wl_registry_bind(xwl_screen->registry, id,
- &wl_output_interface, 2);
+ &wl_output_interface, min(version, 2));
if (!xwl_output->output) {
ErrorF("Failed binding wl_output\n");
goto err;
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index e975dfbf6..a95288e4f 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -84,7 +84,8 @@ struct xwl_output *xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
struct wl_output* wl_output);
struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
- uint32_t id, Bool with_xrandr);
+ uint32_t id, Bool with_xrandr,
+ uint32_t version);
void xwl_output_destroy(struct xwl_output *xwl_output);
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index 94085af34..46ab4fed7 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -432,7 +432,7 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
NULL);
}
else if (strcmp(interface, "wl_output") == 0 && version >= 2) {
- if (xwl_output_create(xwl_screen, id, (xwl_screen->fixed_output == NULL)))
+ if (xwl_output_create(xwl_screen, id, (xwl_screen->fixed_output == NULL), version))
xwl_screen->expecting_event++;
}
else if (strcmp(interface, "zxdg_output_manager_v1") == 0) {
commit 3c07a01c42d56c882bde33b7456c367781fabfee
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Thu Feb 2 14:17:30 2023 +0100
xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.
Luckily, xdg-output provides us with a name for the outputs.
Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.
So we could use the xdg-output name for the XRandR reported name for the
output.
Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.
So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.
Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 24c554b57..8e387e760 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -35,6 +35,8 @@
#include "xdg-output-unstable-v1-client-protocol.h"
+#define MAX_OUTPUT_NAME 256
+
static void xwl_output_get_xdg_output(struct xwl_output *xwl_output);
static Rotation
@@ -658,6 +660,21 @@ apply_output_change(struct xwl_output *xwl_output)
RRTellChanged(xwl_screen->screen);
}
+static void
+xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
+{
+ if (xwl_output->randr_output == NULL)
+ return; /* rootful */
+
+ /* Check whether the compositor is sending us something useful */
+ if (!name || !strlen(name)) {
+ ErrorF("Not using the provided output name, invalid");
+ return;
+ }
+
+ snprintf(xwl_output->randr_output->name, MAX_OUTPUT_NAME, "%s", name);
+}
+
static void
output_handle_done(void *data, struct wl_output *wl_output)
{
@@ -719,6 +736,9 @@ static void
xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
const char *name)
{
+ struct xwl_output *xwl_output = data;
+
+ xwl_output_set_name(xwl_output, name);
}
static void
@@ -774,7 +794,7 @@ struct xwl_output *
xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr)
{
struct xwl_output *xwl_output;
- char name[256];
+ char name[MAX_OUTPUT_NAME];
xwl_output = calloc(1, sizeof *xwl_output);
if (xwl_output == NULL) {
@@ -795,7 +815,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr)
xwl_output->xwl_screen = xwl_screen;
if (with_xrandr) {
- snprintf(name, sizeof name, "XWAYLAND%d",
+ snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
xwl_screen_get_next_output_serial(xwl_screen));
xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
@@ -806,7 +826,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr)
RRCrtcSetRotations (xwl_output->randr_crtc, ALL_ROTATIONS);
xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
- strlen(name), xwl_output);
+ MAX_OUTPUT_NAME, xwl_output);
if (!xwl_output->randr_output) {
ErrorF("Failed creating RandR Output\n");
goto err;
commit ddcbb46f9740425910cccdede374f41a3bee2dd7
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Fri Feb 3 12:07:50 2023 +0100
xwayland: Tell RR has changed only when done
Since commit 204f10c2, we notify XRandR clients that the randr
configuration has changes as soon as an new output is created.
Yet, this might be premature, considering that at that point, we are
still to receive the wl_output and xdg-output events that will most
likely change the setup.
So instead of calling RRTellChanged() from xwl_output_create(), wait
until we get to call apply_output_change(), which occurs after the done
events from both xdg-output and wl_output are received.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 7a9352f58..24c554b57 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -654,6 +654,8 @@ apply_output_change(struct xwl_output *xwl_output)
if (xwl_screen->fixed_output == NULL)
update_screen_size(xwl_screen, width, height);
+ else
+ RRTellChanged(xwl_screen->screen);
}
static void
@@ -814,7 +816,6 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr)
RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
RROutputSetConnection(xwl_output->randr_output, RR_Connected);
- RRTellChanged(xwl_screen->screen);
}
/* We want the output to be in the list as soon as created so we can
* use it when binding to the xdg-output protocol...
More information about the xorg-commit
mailing list