summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-16 02:22:51 +0100
committerwm4 <wm4@nowhere>2019-12-16 02:22:51 +0100
commit98008558950c3eb99bad031cb478afa287e428aa (patch)
tree7b7f668f888c982156f7a5518fb6c8d83795b178
parent1d482e42cbfca3a81a17184c8bcb4674b58a195d (diff)
downloadmpv-98008558950c3eb99bad031cb478afa287e428aa.tar.bz2
mpv-98008558950c3eb99bad031cb478afa287e428aa.tar.xz
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.
-rw-r--r--video/out/x11_common.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 38fdca73df..09248ddfd0 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -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;
}