mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
c920a3920e
commit
83aab1d4be
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -34,6 +34,7 @@ struct mp_log;
|
|||
struct xrandr_display {
|
||||
struct mp_rect rc;
|
||||
double fps;
|
||||
char *name;
|
||||
};
|
||||
|
||||
struct vo_x11_state {
|
||||
|
|
Loading…
Reference in New Issue