mirror of https://github.com/encounter/SDL.git
wayland: Fix transform and scale handling when setting display mode
This commit is contained in:
parent
2c76433151
commit
3ae2ec34fa
|
@ -247,6 +247,7 @@ display_handle_geometry(void *data,
|
||||||
SDL_VideoDisplay *display = data;
|
SDL_VideoDisplay *display = data;
|
||||||
|
|
||||||
display->name = SDL_strdup(model);
|
display->name = SDL_strdup(model);
|
||||||
|
((SDL_WaylandOutputData*)display->driverdata)->transform = transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -259,18 +260,12 @@ display_handle_mode(void *data,
|
||||||
{
|
{
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
SDL_VideoDisplay *display = data;
|
SDL_VideoDisplay *display = data;
|
||||||
|
SDL_WaylandOutputData* driverdata = display->driverdata;
|
||||||
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);
|
|
||||||
|
|
||||||
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
||||||
display->current_mode = mode;
|
driverdata->width = width;
|
||||||
display->desktop_mode = mode;
|
driverdata->height = height;
|
||||||
|
driverdata->refresh = refresh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +275,23 @@ display_handle_done(void *data,
|
||||||
{
|
{
|
||||||
/* !!! FIXME: this will fail on any further property changes! */
|
/* !!! FIXME: this will fail on any further property changes! */
|
||||||
SDL_VideoDisplay *display = data;
|
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);
|
SDL_AddVideoDisplay(display, SDL_FALSE);
|
||||||
wl_output_set_user_data(output, display->driverdata);
|
wl_output_set_user_data(output, display->driverdata);
|
||||||
SDL_free(display->name);
|
SDL_free(display->name);
|
||||||
|
|
|
@ -90,6 +90,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct wl_output *output;
|
struct wl_output *output;
|
||||||
float scale_factor;
|
float scale_factor;
|
||||||
|
int width, height, refresh, transform;
|
||||||
} SDL_WaylandOutputData;
|
} SDL_WaylandOutputData;
|
||||||
|
|
||||||
#endif /* SDL_waylandvideo_h_ */
|
#endif /* SDL_waylandvideo_h_ */
|
||||||
|
|
Loading…
Reference in New Issue