From 511d1686a6ac3e3e0d66fb67b62620ba2a6575c8 Mon Sep 17 00:00:00 2001 From: Minh Phan Date: Tue, 29 Nov 2022 19:37:22 +0700 Subject: [PATCH] xwayland/output: properly return the current emulated mode when queried This fixes an issue with GLFW-based games failing to set the resolution when the user request to switch back to the native display mode. Signed-off-by: Minh Phan Acked-by: Olivier Fourdan --- hw/xwayland/xwayland-output.c | 16 ++++++++++++++++ hw/xwayland/xwayland-output.h | 1 + 2 files changed, 17 insertions(+) diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c index 818df6d08..9109145ab 100644 --- a/hw/xwayland/xwayland-output.c +++ b/hw/xwayland/xwayland-output.c @@ -271,6 +271,7 @@ xwl_output_add_emulated_mode_for_client(struct xwl_output *xwl_output, emulated_mode->server_output_id = xwl_output->server_output_id; emulated_mode->width = mode->mode.width; emulated_mode->height = mode->mode.height; + emulated_mode->id = mode->mode.id; emulated_mode->from_vidmode = from_vidmode; } @@ -936,6 +937,20 @@ xwl_randr_crtc_set(ScreenPtr pScreen, return TRUE; } +static void +xwl_randr_crtc_get(ScreenPtr pScreen, + RRCrtcPtr crtc, + xRRGetCrtcInfoReply *rep) +{ + struct xwl_output *xwl_output = crtc->devPrivate; + + struct xwl_emulated_mode *mode = xwl_output_get_emulated_mode_for_client( + xwl_output, GetCurrentClient()); + + if (mode) + rep->mode = mode->id; +} + static Bool xwl_randr_crtc_set_gamma(ScreenPtr pScreen, RRCrtcPtr crtc) { @@ -996,6 +1011,7 @@ xwl_screen_init_output(struct xwl_screen *xwl_screen) #if RANDR_12_INTERFACE rp->rrScreenSetSize = xwl_randr_screen_set_size; rp->rrCrtcSet = xwl_randr_crtc_set; + rp->rrCrtcGet = xwl_randr_crtc_get; rp->rrCrtcSetGamma = xwl_randr_crtc_set_gamma; rp->rrCrtcGetGamma = xwl_randr_crtc_get_gamma; rp->rrOutputSetProperty = xwl_randr_output_set_property; diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h index 603b54527..e975dfbf6 100644 --- a/hw/xwayland/xwayland-output.h +++ b/hw/xwayland/xwayland-output.h @@ -69,6 +69,7 @@ struct xwl_emulated_mode { uint32_t server_output_id; int32_t width; int32_t height; + RRMode id; Bool from_vidmode; };