1
mirror of https://github.com/mpv-player/mpv synced 2024-11-14 22:48:35 +01:00

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.
This commit is contained in:
Dudemanguy 2020-11-23 14:01:23 -06:00
parent 08848e76d9
commit 9a7b2015e1

View File

@ -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;