diff options
author | Dudemanguy <random342@airmail.cc> | 2020-11-23 14:01:23 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2020-12-06 17:36:43 +0000 |
commit | 9a7b2015e1a711a57b6e660774c36956ac59a7f6 (patch) | |
tree | 4691b68936b0945a8c05c364558a71fdde13abea | |
parent | 08848e76d9219a097b8ca4d493ab1df7eb693162 (diff) | |
download | mpv-9a7b2015e1a711a57b6e660774c36956ac59a7f6.tar.bz2 mpv-9a7b2015e1a711a57b6e660774c36956ac59a7f6.tar.xz |
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.
-rw-r--r-- | video/out/x11_common.c | 20 |
1 files changed, 19 insertions, 1 deletions
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; |