wayland: Add unscaled resolutions to the display mode list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 0608f0f..e6dec5e 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -265,12 +265,32 @@ display_handle_mode(void *data,
{
SDL_VideoDisplay *display = data;
SDL_WaylandOutputData* driverdata = display->driverdata;
+ SDL_DisplayMode mode;
if (flags & WL_OUTPUT_MODE_CURRENT) {
driverdata->width = width;
driverdata->height = height;
driverdata->refresh = refresh;
}
+
+ /* Note that the width/height are NOT multiplied by scale_factor!
+ * This is intentional and is designed to get the unscaled modes, which is
+ * important for high-DPI games intending to use the display mode as the
+ * target drawable size. The scaled desktop mode will be added at the end
+ * when display_handle_done is called (see below).
+ */
+ SDL_zero(mode);
+ mode.format = SDL_PIXELFORMAT_RGB888;
+ if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) {
+ mode.w = height;
+ mode.h = width;
+ } else {
+ mode.w = width;
+ mode.h = height;
+ }
+ mode.refresh_rate = refresh / 1000; /* mHz to Hz */
+ mode.driverdata = driverdata->output;
+ SDL_AddDisplayMode(display, &mode);
}
static void
@@ -288,13 +308,14 @@ display_handle_done(void *data,
SDL_zero(mode);
mode.format = SDL_PIXELFORMAT_RGB888;
- mode.w = driverdata->width / driverdata->scale_factor;
- mode.h = driverdata->height / driverdata->scale_factor;
if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) {
mode.w = driverdata->height / driverdata->scale_factor;
mode.h = driverdata->width / driverdata->scale_factor;
+ } else {
+ mode.w = driverdata->width / driverdata->scale_factor;
+ mode.h = driverdata->height / driverdata->scale_factor;
}
- mode.refresh_rate = driverdata->refresh / 1000; // mHz to Hz
+ mode.refresh_rate = driverdata->refresh / 1000; /* mHz to Hz */
mode.driverdata = driverdata->output;
SDL_AddDisplayMode(display, &mode);
display->current_mode = mode;