From 9bce2367142c266c1a1512494a03495583964c32 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Wed, 12 Aug 2020 09:51:51 -0500 Subject: 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. --- video/out/wayland_common.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'video') 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; } -- cgit v1.2.3