From 83aab1d4be67fceb8c0cd27297cca086f1a9c3c5 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Wed, 5 Nov 2014 15:58:24 -0800 Subject: vo/x11: implement VOCTRL_GET_DISPLAY_NAMES with xrandr names (e.g., "LVDS1") XRRGetOutputInfo contains a "name" element which corresponds to to the display names given to the user by the "xrandr" command line utility. Copy it into the xrandr_display struct for each display. On VOCTRL_GET_DISPLAY_NAMES, send a copy of the names of the displays spanned by the mpv window on. --- video/out/vo.h | 4 ++++ video/out/x11_common.c | 20 ++++++++++++++++++-- video/out/x11_common.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/video/out/vo.h b/video/out/vo.h index 6906cab222..60e887444c 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -87,6 +87,10 @@ enum mp_voctrl { VOCTRL_GET_WIN_STATE, // int* (VO_WIN_STATE_* flags) + // char *** (NULL terminated array compatible with CONF_TYPE_STRING_LIST) + // names for displays the window is on + VOCTRL_GET_DISPLAY_NAMES, + // The VO is supposed to set "known" fields, and leave the others // untouched or set to 0. // imgfmt/w/h/d_w/d_h can be omitted for convenience. diff --git a/video/out/x11_common.c b/video/out/x11_common.c index fb3fbe14ff..b8544ef398 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -330,6 +330,9 @@ static int vo_wm_detect(struct vo *vo) static void xrandr_read(struct vo_x11_state *x11) { #if HAVE_XRANDR + for(int i = 0; i < x11->num_displays; i++) + talloc_free(x11->displays[i].name); + x11->num_displays = 0; if (x11->xrandr_event < 0) { @@ -375,10 +378,11 @@ static void xrandr_read(struct vo_x11_state *x11) .rc = { crtc->x, crtc->y, crtc->x + crtc->width, crtc->y + crtc->height }, .fps = m.dotClock / (m.hTotal * vTotal), + .name = talloc_strdup(x11, out->name), }; int num = x11->num_displays++; - MP_VERBOSE(x11, "Display %d: [%d, %d, %d, %d] @ %f FPS\n", - num, d.rc.x0, d.rc.y0, d.rc.x1, d.rc.y1, d.fps); + MP_VERBOSE(x11, "Display %d (%s): [%d, %d, %d, %d] @ %f FPS\n", + num, d.name, d.rc.x0, d.rc.y0, d.rc.x1, d.rc.y1, d.fps); x11->displays[num] = d; } } @@ -1601,6 +1605,18 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg) } return VO_TRUE; } + case VOCTRL_GET_DISPLAY_NAMES: { + char **names = NULL; + int displays_spanned = 0; + for (int n = 0; n < x11->num_displays; n++) { + if (rc_overlaps(x11->displays[n].rc, x11->winrc)) + MP_TARRAY_APPEND(NULL, names, displays_spanned, + talloc_strdup(NULL, x11->displays[n].name)); + } + MP_TARRAY_APPEND(NULL, names, displays_spanned, NULL); + *(char ***)arg = names; + return VO_TRUE; + } case VOCTRL_SET_CURSOR_VISIBILITY: vo_set_cursor_hidden(vo, !(*(bool *)arg)); return VO_TRUE; diff --git a/video/out/x11_common.h b/video/out/x11_common.h index 34fa1ff07a..9d14cae33c 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -34,6 +34,7 @@ struct mp_log; struct xrandr_display { struct mp_rect rc; double fps; + char *name; }; struct vo_x11_state { -- cgit v1.2.3