summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-08-12 09:51:51 -0500
committerDudemanguy <random342@airmail.cc>2020-08-14 13:02:01 +0000
commit9bce2367142c266c1a1512494a03495583964c32 (patch)
treece23d5e25d5a9485a558c4dcaff038f6d6c2b81d
parent4b5ead0834deaf2896c39952daf2e622a5959b4f (diff)
downloadmpv-9bce2367142c266c1a1512494a03495583964c32.tar.bz2
mpv-9bce2367142c266c1a1512494a03495583964c32.tar.xz
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.
-rw-r--r--DOCS/man/options.rst4
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
-rw-r--r--video/out/wayland_common.c14
4 files changed, 20 insertions, 0 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index de4eb08d87..5245e18cae 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -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``,
diff --git a/options/options.c b/options/options.c
index 1e104e886f..6e22de0a07 100644
--- a/options/options.c
+++ b/options/options.c
@@ -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)},
diff --git a/options/options.h b/options/options.h
index ea5ece65a1..00b58dfbff 100644
--- a/options/options.h
+++ b/options/options.h
@@ -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;
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index e00adac338..8e7d8bb7b0 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -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;
}