From 9a7b2015e1a711a57b6e660774c36956ac59a7f6 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Mon, 23 Nov 2020 14:01:23 -0600 Subject: x11: support screen-name and fs-screen-name opts The --screen-name and --fs-screen-name options allow for specifying screens based on their name. For x11, this is the display name reported by xrandr. --screen-name and --fs-screen-name mimic the --screen and --fs-screen options respectively. If --screen is set, then --screen-name will always do nothing. Likewise, --fs-screen-name does nothing if --fs-screen is set. --- video/out/x11_common.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 92b3539aca..1d59b89ea8 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -467,7 +467,8 @@ static void vo_x11_update_screeninfo(struct vo *vo) struct mp_vo_opts *opts = x11->opts; bool all_screens = opts->fullscreen && opts->fsscreen_id == -2; x11->screenrc = (struct mp_rect){.x1 = x11->ws_width, .y1 = x11->ws_height}; - if (opts->screen_id >= -1 && XineramaIsActive(x11->display) && !all_screens) + if ((opts->screen_id >= -1 || opts->screen_name) && XineramaIsActive(x11->display) && + !all_screens) { int screen = opts->fullscreen ? opts->fsscreen_id : opts->screen_id; XineramaScreenInfo *screens; @@ -476,6 +477,23 @@ static void vo_x11_update_screeninfo(struct vo *vo) if (opts->fullscreen && opts->fsscreen_id == -1) screen = opts->screen_id; + if (screen == -1 && (opts->fsscreen_name || opts->screen_name)) { + char *screen_name = opts->fullscreen ? opts->fsscreen_name : opts->screen_name; + if (screen_name) { + bool screen_found = false; + for (int n = 0; n < x11->num_displays; n++) { + char *display_name = x11->displays[n].name; + if (!strcmp(display_name, screen_name)) { + screen = n; + screen_found = true; + break; + } + } + if (!screen_found) + MP_WARN(x11, "Screen name %s not found!\n", screen_name); + } + } + screens = XineramaQueryScreens(x11->display, &num_screens); if (screen >= num_screens) screen = num_screens - 1; -- cgit v1.2.3