mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 02:45:36 +00:00
wayland: Fix DPI calculation with scaled outputs
`driverdata->width` and `driverdata->height` represent the width and height in logical pixels on scaled outputs with xdg_output. However, to correctly calculate the display's DPI value, we need to use its native resolution. For example, on a 27" 4K screen with 175% scaling, we have `width` == 2192 and `height` == 1233, resulting in a bogus value of 92dpi, whereas 162dpi are correct for 3840x2160 pixels at 27 inches. Tested on GNOME mutter 45.1.
This commit is contained in:
parent
f3419d8c04
commit
63e9827b90
|
@ -619,17 +619,17 @@ static void display_handle_done(void *data,
|
|||
|
||||
/* Calculate the display DPI */
|
||||
if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) {
|
||||
driverdata->hdpi = driverdata->physical_height ? (((float)driverdata->height) * 25.4f / driverdata->physical_height) : 0.0f;
|
||||
driverdata->vdpi = driverdata->physical_width ? (((float)driverdata->width) * 25.4f / driverdata->physical_width) : 0.0f;
|
||||
driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->height,
|
||||
driverdata->width,
|
||||
driverdata->hdpi = driverdata->physical_height ? (((float)driverdata->native_height) * 25.4f / driverdata->physical_height) : 0.0f;
|
||||
driverdata->vdpi = driverdata->physical_width ? (((float)driverdata->native_width) * 25.4f / driverdata->physical_width) : 0.0f;
|
||||
driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->native_height,
|
||||
driverdata->native_width,
|
||||
((float)driverdata->physical_height) / 25.4f,
|
||||
((float)driverdata->physical_width) / 25.4f);
|
||||
} else {
|
||||
driverdata->hdpi = driverdata->physical_width ? (((float)driverdata->width) * 25.4f / driverdata->physical_width) : 0.0f;
|
||||
driverdata->vdpi = driverdata->physical_height ? (((float)driverdata->height) * 25.4f / driverdata->physical_height) : 0.0f;
|
||||
driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->width,
|
||||
driverdata->height,
|
||||
driverdata->hdpi = driverdata->physical_width ? (((float)driverdata->native_width) * 25.4f / driverdata->physical_width) : 0.0f;
|
||||
driverdata->vdpi = driverdata->physical_height ? (((float)driverdata->native_height) * 25.4f / driverdata->physical_height) : 0.0f;
|
||||
driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->native_width,
|
||||
driverdata->native_height,
|
||||
((float)driverdata->physical_width) / 25.4f,
|
||||
((float)driverdata->physical_height) / 25.4f);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue