1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 01:22:30 +00:00

wayland: expose wayland-app-id as a user option

This is extremely similar to x11's WM_CLASS. This commit allows users to
set mpv's app-id at runtime for any of the wayland backends.
This commit is contained in:
Dudemanguy 2020-08-12 09:51:51 -05:00
parent 4b5ead0834
commit 9bce236714
4 changed files with 20 additions and 0 deletions

View File

@ -5338,6 +5338,10 @@ The following video options are currently all specific to ``--vo=gpu`` and
Currently only relevant for ``--gpu-api=d3d11``.
``--wayland-app-id=<string>``
Set the client app id for Wayland-based video output methods. By default, "mpv"
is used.
``--wayland-disable-vsync=<yes|no>``
Disable vsync for the wayland contexts (default: no). Useful for benchmarking
the wayland context when combined with ``video-sync=display-desync``,

View File

@ -124,6 +124,7 @@ static const m_option_t mp_vo_opt_list[] = {
{"window-maximized", OPT_FLAG(window_maximized)},
{"force-window-position", OPT_FLAG(force_window_position)},
{"x11-name", OPT_STRING(winname)},
{"wayland-app-id", OPT_STRING(appid)},
{"monitoraspect", OPT_FLOAT(force_monitor_aspect), M_RANGE(0.0, 9.0)},
{"monitorpixelaspect", OPT_FLOAT(monitor_pixel_aspect),
M_RANGE(1.0/32.0, 32.0)},

View File

@ -23,6 +23,7 @@ typedef struct mp_vo_opts {
int screen_id;
int fsscreen_id;
char *winname;
char *appid;
int x11_netwm;
int x11_bypass_compositor;
int native_keyrepeat;

View File

@ -1060,6 +1060,17 @@ static int create_xdg_surface(struct vo_wayland_state *wl)
return 0;
}
static void update_app_id(struct vo_wayland_state *wl)
{
if (!wl->xdg_toplevel)
return;
if (!wl->vo_opts->appid) {
wl->vo_opts->appid = talloc_strdup(wl->vo_opts, "mpv");
m_config_cache_write_opt(wl->vo_opts_cache, &wl->vo_opts->appid);
}
xdg_toplevel_set_app_id(wl->xdg_toplevel, wl->vo_opts->appid);
}
static void set_border_decorations(struct vo_wayland_state *wl, int state)
{
if (!wl->xdg_toplevel_decoration) {
@ -1126,6 +1137,7 @@ int vo_wayland_init(struct vo *vo)
/* Can't be initialized during registry due to multi-protocol dependence */
if (create_xdg_surface(wl))
return false;
update_app_id(wl);
const char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
if (xdg_current_desktop != NULL && strstr(xdg_current_desktop, "GNOME"))
@ -1511,6 +1523,8 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
toggle_maximized(wl);
if (opt == &opts->border)
set_border_decorations(wl, opts->border);
if (opt == &opts->appid)
update_app_id(wl);
}
return VO_TRUE;
}