mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
3a92d7ba3b
commit
dcd1034529
|
@ -169,6 +169,7 @@ static const m_option_t mp_vo_opt_list[] = {
|
||||||
{"keepaspect-window", OPT_BOOL(keepaspect_window)},
|
{"keepaspect-window", OPT_BOOL(keepaspect_window)},
|
||||||
{"hidpi-window-scale", OPT_BOOL(hidpi_window_scale)},
|
{"hidpi-window-scale", OPT_BOOL(hidpi_window_scale)},
|
||||||
{"native-fs", OPT_BOOL(native_fs)},
|
{"native-fs", OPT_BOOL(native_fs)},
|
||||||
|
{"show-in-taskbar", OPT_BOOL(show_in_taskbar)},
|
||||||
{"display-fps-override", OPT_DOUBLE(display_fps_override),
|
{"display-fps-override", OPT_DOUBLE(display_fps_override),
|
||||||
M_RANGE(0, DBL_MAX)},
|
M_RANGE(0, DBL_MAX)},
|
||||||
{"video-timing-offset", OPT_DOUBLE(timing_offset), M_RANGE(0.0, 1.0)},
|
{"video-timing-offset", OPT_DOUBLE(timing_offset), M_RANGE(0.0, 1.0)},
|
||||||
|
@ -243,6 +244,7 @@ const struct m_sub_options vo_sub_opts = {
|
||||||
.keepaspect_window = true,
|
.keepaspect_window = true,
|
||||||
.native_fs = true,
|
.native_fs = true,
|
||||||
.taskbar_progress = true,
|
.taskbar_progress = true,
|
||||||
|
.show_in_taskbar = true,
|
||||||
.border = true,
|
.border = true,
|
||||||
.title_bar = true,
|
.title_bar = true,
|
||||||
.appid = "mpv",
|
.appid = "mpv",
|
||||||
|
|
|
@ -56,6 +56,7 @@ typedef struct mp_vo_opts {
|
||||||
bool keepaspect_window;
|
bool keepaspect_window;
|
||||||
bool hidpi_window_scale;
|
bool hidpi_window_scale;
|
||||||
bool native_fs;
|
bool native_fs;
|
||||||
|
bool show_in_taskbar;
|
||||||
|
|
||||||
int64_t WinID;
|
int64_t WinID;
|
||||||
|
|
||||||
|
|
|
@ -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,
|
static void vo_x11_selectinput_witherr(struct vo *vo, Display *display,
|
||||||
Window w, long event_mask);
|
Window w, long event_mask);
|
||||||
static void vo_x11_setlayer(struct vo *vo, bool ontop);
|
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_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_xembed_send_message(struct vo_x11_state *x11, long m[4]);
|
||||||
static void vo_x11_move_resize(struct vo *vo, bool move, bool resize,
|
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)
|
if (opts->ontop)
|
||||||
vo_x11_setlayer(vo, 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);
|
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)
|
static bool rc_overlaps(struct mp_rect rc1, struct mp_rect rc2)
|
||||||
{
|
{
|
||||||
return mp_rect_intersection(&rc1, &rc2); // changes the first argument
|
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);
|
vo_x11_fullscreen(vo);
|
||||||
if (opt == &opts->ontop)
|
if (opt == &opts->ontop)
|
||||||
vo_x11_setlayer(vo, 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)
|
if (opt == &opts->border || opt == &opts->title_bar)
|
||||||
vo_x11_decoration(vo, opts->border, opts->title_bar);
|
vo_x11_decoration(vo, opts->border, opts->title_bar);
|
||||||
if (opt == &opts->all_workspaces)
|
if (opt == &opts->all_workspaces)
|
||||||
|
|
Loading…
Reference in New Issue