Skip to content
Permalink
Browse files
wayland: Fix transform and scale handling when setting display mode
  • Loading branch information
dos1 committed Feb 10, 2021
1 parent 2c76433 commit 3ae2ec34fa3a8aec0471ad49c1941b6b4966f41e
Showing 2 changed files with 23 additions and 10 deletions.
@@ -247,6 +247,7 @@ display_handle_geometry(void *data,
SDL_VideoDisplay *display = data;

display->name = SDL_strdup(model);
((SDL_WaylandOutputData*)display->driverdata)->transform = transform;
}

static void
@@ -259,18 +260,12 @@ display_handle_mode(void *data,
{
SDL_DisplayMode mode;
SDL_VideoDisplay *display = data;

SDL_zero(mode);
mode.format = SDL_PIXELFORMAT_RGB888;
mode.w = width;
mode.h = height;
mode.refresh_rate = refresh / 1000; // mHz to Hz
mode.driverdata = ((SDL_WaylandOutputData*)display->driverdata)->output;
SDL_AddDisplayMode(display, &mode);
SDL_WaylandOutputData* driverdata = display->driverdata;

if (flags & WL_OUTPUT_MODE_CURRENT) {
display->current_mode = mode;
display->desktop_mode = mode;
driverdata->width = width;
driverdata->height = height;
driverdata->refresh = refresh;
}
}

@@ -280,6 +275,23 @@ display_handle_done(void *data,
{
/* !!! FIXME: this will fail on any further property changes! */
SDL_VideoDisplay *display = data;
SDL_WaylandOutputData* driverdata = display->driverdata;
SDL_DisplayMode mode;

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;
}
mode.refresh_rate = driverdata->refresh / 1000; // mHz to Hz
mode.driverdata = driverdata->output;
SDL_AddDisplayMode(display, &mode);
display->current_mode = mode;
display->desktop_mode = mode;

SDL_AddVideoDisplay(display, SDL_FALSE);
wl_output_set_user_data(output, display->driverdata);
SDL_free(display->name);
@@ -90,6 +90,7 @@ typedef struct {
typedef struct {
struct wl_output *output;
float scale_factor;
int width, height, refresh, transform;
} SDL_WaylandOutputData;

#endif /* SDL_waylandvideo_h_ */

0 comments on commit 3ae2ec3

Please sign in to comment.