mirror of https://github.com/encounter/SDL.git
wayland: Work around a GNOME xdg_output scaling issue
This commit is contained in:
parent
94ed6b0a54
commit
40417b188a
|
@ -294,6 +294,7 @@ xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output
|
||||||
|
|
||||||
driverdata->x = x;
|
driverdata->x = x;
|
||||||
driverdata->y = y;
|
driverdata->y = y;
|
||||||
|
driverdata->has_logical_position = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -302,8 +303,25 @@ xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output,
|
||||||
{
|
{
|
||||||
SDL_WaylandOutputData* driverdata = data;
|
SDL_WaylandOutputData* driverdata = data;
|
||||||
|
|
||||||
|
if (driverdata->width != 0 && driverdata->height != 0) {
|
||||||
|
/* FIXME: GNOME has a bug where the logical size does not account for
|
||||||
|
* scale, resulting in bogus viewport sizes.
|
||||||
|
*
|
||||||
|
* Until this is fixed, validate the scale, then override if necessary.
|
||||||
|
* -flibit
|
||||||
|
*/
|
||||||
|
const float scale = (float) driverdata->width / (float) width;
|
||||||
|
if (scale != driverdata->scale_factor) {
|
||||||
|
SDL_LogWarn(
|
||||||
|
SDL_LOG_CATEGORY_VIDEO,
|
||||||
|
"xdg_output scale did not match, overriding with wl_output scale"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
driverdata->width = width;
|
driverdata->width = width;
|
||||||
driverdata->height = height;
|
driverdata->height = height;
|
||||||
|
driverdata->has_logical_size = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -371,7 +389,7 @@ display_handle_geometry(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply the change from wl-output only if xdg-output is not supported */
|
/* Apply the change from wl-output only if xdg-output is not supported */
|
||||||
if (driverdata->xdg_output) {
|
if (driverdata->has_logical_position) {
|
||||||
driverdata->x = x;
|
driverdata->x = x;
|
||||||
driverdata->y = y;
|
driverdata->y = y;
|
||||||
}
|
}
|
||||||
|
@ -428,7 +446,7 @@ display_handle_mode(void *data,
|
||||||
* Don't rotate this yet, wl-output coordinates are transformed in
|
* Don't rotate this yet, wl-output coordinates are transformed in
|
||||||
* handle_done and xdg-output coordinates are pre-transformed.
|
* handle_done and xdg-output coordinates are pre-transformed.
|
||||||
*/
|
*/
|
||||||
if (!driverdata->xdg_output) {
|
if (!driverdata->has_logical_size) {
|
||||||
driverdata->width = width;
|
driverdata->width = width;
|
||||||
driverdata->height = height;
|
driverdata->height = height;
|
||||||
}
|
}
|
||||||
|
@ -485,7 +503,7 @@ display_handle_done(void *data,
|
||||||
SDL_zero(mode);
|
SDL_zero(mode);
|
||||||
mode.format = SDL_PIXELFORMAT_RGB888;
|
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||||
|
|
||||||
if (driverdata->xdg_output) {
|
if (driverdata->has_logical_size) {
|
||||||
/* xdg-output dimensions are already transformed, so no need to rotate. */
|
/* xdg-output dimensions are already transformed, so no need to rotate. */
|
||||||
mode.w = driverdata->width;
|
mode.w = driverdata->width;
|
||||||
mode.h = driverdata->height;
|
mode.h = driverdata->height;
|
||||||
|
|
|
@ -105,6 +105,7 @@ struct SDL_WaylandOutputData {
|
||||||
SDL_DisplayOrientation orientation;
|
SDL_DisplayOrientation orientation;
|
||||||
int physical_width, physical_height;
|
int physical_width, physical_height;
|
||||||
float ddpi, hdpi, vdpi;
|
float ddpi, hdpi, vdpi;
|
||||||
|
SDL_bool has_logical_position, has_logical_size;
|
||||||
int index;
|
int index;
|
||||||
SDL_VideoDisplay placeholder;
|
SDL_VideoDisplay placeholder;
|
||||||
int wl_output_done_count;
|
int wl_output_done_count;
|
||||||
|
|
Loading…
Reference in New Issue