diff options
author | Dudemanguy <random342@airmail.cc> | 2021-04-12 12:51:41 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2021-05-06 17:36:55 +0000 |
commit | a88fdfde0c91c16c84e6057b19bdc2fb9e666e24 (patch) | |
tree | 64bb28b8c231040510adfef3630a62bac592e5ae /video/out | |
parent | 8edfe70b83acba3de91d41bf1c46921e969ea265 (diff) | |
download | mpv-a88fdfde0c91c16c84e6057b19bdc2fb9e666e24.tar.bz2 mpv-a88fdfde0c91c16c84e6057b19bdc2fb9e666e24.tar.xz |
command: add display-width/display-height property
For some reason, this never existed before. Add VOCTRL_GET_DISPLAY_RES
and use it to obtain the current display's resolution from each
vo/windowing backend if applicable. Users can then access the current
display resolution as display-width and display-height as per the client
api. Note that macOS/cocoa was not attempted in this commit since the
author has no clue how to write swift.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/opengl/context_drm_egl.c | 5 | ||||
-rw-r--r-- | video/out/vo.h | 1 | ||||
-rw-r--r-- | video/out/vo_drm.c | 5 | ||||
-rw-r--r-- | video/out/vo_rpi.c | 4 | ||||
-rw-r--r-- | video/out/w32_common.c | 5 | ||||
-rw-r--r-- | video/out/wayland_common.c | 7 | ||||
-rw-r--r-- | video/out/x11_common.c | 7 |
7 files changed, 34 insertions, 0 deletions
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c index 86ce57122c..4bae27f1a7 100644 --- a/video/out/opengl/context_drm_egl.c +++ b/video/out/opengl/context_drm_egl.c @@ -880,6 +880,11 @@ static int drm_egl_control(struct ra_ctx *ctx, int *events, int request, *(double*)arg = fps; return VO_TRUE; } + case VOCTRL_GET_DISPLAY_RES: { + ((int *)arg)[0] = p->kms->mode.mode.hdisplay; + ((int *)arg)[1] = p->kms->mode.mode.vdisplay; + return VO_TRUE; + } case VOCTRL_PAUSE: ctx->vo->want_redraw = true; p->paused = true; diff --git a/video/out/vo.h b/video/out/vo.h index 7efec53ba0..8e17b3cf42 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -120,6 +120,7 @@ enum mp_voctrl { VOCTRL_GET_AMBIENT_LUX, // int* VOCTRL_GET_DISPLAY_FPS, // double* VOCTRL_GET_HIDPI_SCALE, // double* + VOCTRL_GET_DISPLAY_RES, // int[2] /* private to vo_gpu */ VOCTRL_EXTERNAL_RESIZE, diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c index a2c6fc8652..a2fada99d1 100644 --- a/video/out/vo_drm.c +++ b/video/out/vo_drm.c @@ -654,6 +654,11 @@ static int control(struct vo *vo, uint32_t request, void *arg) *(double*)arg = fps; return VO_TRUE; } + case VOCTRL_GET_DISPLAY_RES: { + ((int *)arg)[0] = p->kms->mode.mode.hdisplay; + ((int *)arg)[1] = p->kms->mode.mode.vdisplay; + return VO_TRUE; + } case VOCTRL_PAUSE: vo->want_redraw = true; p->paused = true; diff --git a/video/out/vo_rpi.c b/video/out/vo_rpi.c index 4d5de1d84d..8d921e83e3 100644 --- a/video/out/vo_rpi.c +++ b/video/out/vo_rpi.c @@ -748,6 +748,10 @@ static int control(struct vo *vo, uint32_t request, void *data) case VOCTRL_GET_DISPLAY_FPS: *(double *)data = p->display_fps; return VO_TRUE; + case VOCTRL_GET_DISPLAY_RES: + ((int *)arg)[0] = p->w; + ((int *)arg)[1] = p->h; + return VO_TRUE; } return VO_NOTIMPL; diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 59cfd6199d..c819803a63 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1768,6 +1768,11 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) update_display_info(w32); *(double*) arg = w32->display_fps; return VO_TRUE; + case VOCTRL_GET_DISPLAY_RES: ; + RECT r = get_screen_area(w32); + ((int *)arg)[0] = r.right; + ((int *)arg)[1] = r.bottom; + return VO_TRUE; case VOCTRL_GET_DISPLAY_NAMES: *(char ***)arg = get_disp_names(w32); return VO_TRUE; diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 94e839ef34..1902475ead 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1754,6 +1754,13 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) *(double *)arg = wl->current_output->refresh_rate; return VO_TRUE; } + case VOCTRL_GET_DISPLAY_RES: { + if (!wl->current_output) + return VO_NOTAVAIL; + ((int *)arg)[0] = wl->current_output->geometry.x1; + ((int *)arg)[1] = wl->current_output->geometry.y1; + return VO_TRUE; + } case VOCTRL_GET_HIDPI_SCALE: { if (!wl->scaling) return VO_NOTAVAIL; diff --git a/video/out/x11_common.c b/video/out/x11_common.c index ac551fae8e..12d2648d4e 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1982,6 +1982,13 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg) *(double *)arg = fps; return VO_TRUE; } + case VOCTRL_GET_DISPLAY_RES: { + if (!x11->window || x11->parent) + return VO_NOTAVAIL; + ((int *)arg)[0] = x11->screenrc.x1; + ((int *)arg)[1] = x11->screenrc.y1; + return VO_TRUE; + } case VOCTRL_GET_HIDPI_SCALE: *(double *)arg = x11->dpi_scale; return VO_TRUE; |