1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 12:17:12 +00:00

x11: scale window-scale by DPI

"window-scale" is 1.0 by default; however, x11 implicitly set that to
2.0 on hidpi screens. This made the default 2.0, which was inconsistent
with the option. The "window-scale" property jumped from 1.0 to 2.0 when
a window was created.

Avoid this by factoring the DPI into the window-scale. This makes the
UNFS_WINDOW_SIZE return a virtual size; since this value is used for the
window-scale property only, this is fine and has no further
consequences. (Originally, this was possibly meant to be used for other
purposes, but I'm perfectly fine with redoing this again should that
ever happen.)

This changes user-visible behavior, and it's as if setting window-scale
multiplies its argument by 2 suddenly. Hopefully no user will get angry.
This commit is contained in:
wm4 2019-12-16 02:22:51 +01:00
parent 1d482e42cb
commit 9800855895

View File

@ -1884,21 +1884,23 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
int *s = arg;
if (!x11->window || x11->parent)
return VO_FALSE;
s[0] = x11->fs ? RC_W(x11->nofsrc) : RC_W(x11->winrc);
s[1] = x11->fs ? RC_H(x11->nofsrc) : RC_H(x11->winrc);
s[0] = (x11->fs ? RC_W(x11->nofsrc) : RC_W(x11->winrc)) / x11->dpi_scale;
s[1] = (x11->fs ? RC_H(x11->nofsrc) : RC_H(x11->winrc)) / x11->dpi_scale;
return VO_TRUE;
}
case VOCTRL_SET_UNFS_WINDOW_SIZE: {
int *s = arg;
if (!x11->window || x11->parent)
return VO_FALSE;
int w = s[0] * x11->dpi_scale;
int h = s[1] * x11->dpi_scale;
struct mp_rect rc = x11->winrc;
rc.x1 = rc.x0 + s[0];
rc.y1 = rc.y0 + s[1];
rc.x1 = rc.x0 + w;
rc.y1 = rc.y0 + h;
vo_x11_highlevel_resize(vo, rc);
if (!x11->fs) { // guess new window size, instead of waiting for X
x11->winrc.x1 = x11->winrc.x0 + s[0];
x11->winrc.y1 = x11->winrc.y0 + s[1];
x11->winrc.x1 = x11->winrc.x0 + w;
x11->winrc.y1 = x11->winrc.y0 + h;
}
return VO_TRUE;
}