diff options
author | nanahi <130121847+na-na-hi@users.noreply.github.com> | 2024-04-13 00:00:40 -0400 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2024-04-18 00:09:09 +0200 |
commit | dcd10345291a3ecd573decc5125de243bcb1351b (patch) | |
tree | 1bff9c7bed0d1b8f13de85fc011e4e72084b3416 /video/out/x11_common.c | |
parent | 3a92d7ba3bedbab1a1f7128fd692cd64083b8227 (diff) | |
download | mpv-dcd10345291a3ecd573decc5125de243bcb1351b.tar.bz2 mpv-dcd10345291a3ecd573decc5125de243bcb1351b.tar.xz |
x11_common: implement --show-in-taskbar option
This adds a new option --show-in-taskbar, which controls whether
mpv appears in taskbars. This is useful for picture-in-picture
setups where the video window should not appear in taskbars.
On X11, this can be controled by setting the
_NET_WM_STATE_SKIP_TASKBAR window state.
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r-- | video/out/x11_common.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c index f0588bcbf3..a483186bdc 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -149,6 +149,7 @@ static void set_screensaver(struct vo_x11_state *x11, bool enabled); static void vo_x11_selectinput_witherr(struct vo *vo, Display *display, Window w, long event_mask); static void vo_x11_setlayer(struct vo *vo, bool ontop); +static void vo_x11_set_in_taskbar(struct vo *vo, bool in); static void vo_x11_xembed_handle_message(struct vo *vo, XClientMessageEvent *ce); static void vo_x11_xembed_send_message(struct vo_x11_state *x11, long m[4]); static void vo_x11_move_resize(struct vo *vo, bool move, bool resize, @@ -1832,6 +1833,8 @@ void vo_x11_config_vo_window(struct vo *vo) if (opts->ontop) vo_x11_setlayer(vo, opts->ontop); + if (!opts->show_in_taskbar) + vo_x11_set_in_taskbar(vo, opts->show_in_taskbar); vo_x11_fullscreen(vo); @@ -1892,6 +1895,19 @@ static void vo_x11_setlayer(struct vo *vo, bool ontop) } } +static void vo_x11_set_in_taskbar(struct vo *vo, bool in) +{ + struct vo_x11_state *x11 = vo->x11; + if (x11->parent || !x11->window) + return; + + if (x11->wm_type & (vo_wm_SKIP_TASKBAR)) { + char *state = "_NET_WM_STATE_SKIP_TASKBAR"; + x11_set_ewmh_state(x11, state, !in); + MP_VERBOSE(x11, "NET style set skip taskbar (%d).\n", !in); + } +} + static bool rc_overlaps(struct mp_rect rc1, struct mp_rect rc2) { return mp_rect_intersection(&rc1, &rc2); // changes the first argument @@ -2076,6 +2092,8 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg) vo_x11_fullscreen(vo); if (opt == &opts->ontop) vo_x11_setlayer(vo, opts->ontop); + if (opt == &opts->show_in_taskbar) + vo_x11_set_in_taskbar(vo, opts->show_in_taskbar); if (opt == &opts->border || opt == &opts->title_bar) vo_x11_decoration(vo, opts->border, opts->title_bar); if (opt == &opts->all_workspaces) |