History

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.

nanahi committed 2 years ago

Commit dcd10341 parent 3a92d7b3 files · +21 −0Browse files

Unified · Split

3 files
  1. options/options.c +2 −0
  2. options/options.h +1 −0
  3. video/out/x11_common.c +18 −0
options/options.c+2−0
@@ -169,6 +169,7 @@ static const m_option_t mp_vo_opt_list[] = { · 168 unmodified lines
169169 {"keepaspect-window", OPT_BOOL(keepaspect_window)},
170170 {"hidpi-window-scale", OPT_BOOL(hidpi_window_scale)},
171171 {"native-fs", OPT_BOOL(native_fs)},
172+ {"show-in-taskbar", OPT_BOOL(show_in_taskbar)},
172173 {"display-fps-override", OPT_DOUBLE(display_fps_override),
173174 M_RANGE(0, DBL_MAX)},
174175 {"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 = { · 68 unmodified lines
243244 .keepaspect_window = true,
244245 .native_fs = true,
245246 .taskbar_progress = true,
247+ .show_in_taskbar = true,
246248 .border = true,
247249 .title_bar = true,
248250 .appid = "mpv",
options/options.h+1−0
@@ -56,6 +56,7 @@ typedef struct mp_vo_opts { · 55 unmodified lines
5656 bool keepaspect_window;
5757 bool hidpi_window_scale;
5858 bool native_fs;
59+ bool show_in_taskbar;
5960
6061 int64_t WinID;
6162
video/out/x11_common.c+18−0
@@ -149,6 +149,7 @@ static void set_screensaver(struct vo_x11_state *x11, bool enabled); · 148 unmodified lines
149149 static void vo_x11_selectinput_witherr(struct vo *vo, Display *display,
150150 Window w, long event_mask);
151151 static void vo_x11_setlayer(struct vo *vo, bool ontop);
152+static void vo_x11_set_in_taskbar(struct vo *vo, bool in);
152153 static void vo_x11_xembed_handle_message(struct vo *vo, XClientMessageEvent *ce);
153154 static void vo_x11_xembed_send_message(struct vo_x11_state *x11, long m[4]);
154155 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) · 1677 unmodified lines
18321833
18331834 if (opts->ontop)
18341835 vo_x11_setlayer(vo, opts->ontop);
1836+ if (!opts->show_in_taskbar)
1837+ vo_x11_set_in_taskbar(vo, opts->show_in_taskbar);
18351838
18361839 vo_x11_fullscreen(vo);
18371840
@@ -1892,6 +1895,19 @@ static void vo_x11_setlayer(struct vo *vo, bool ontop) · 54 unmodified lines
18921895 }
18931896 }
18941897
1898+static void vo_x11_set_in_taskbar(struct vo *vo, bool in)
1899+{
1900+ struct vo_x11_state *x11 = vo->x11;
1901+ if (x11->parent || !x11->window)
1902+ return;
1903+
1904+ if (x11->wm_type & (vo_wm_SKIP_TASKBAR)) {
1905+ char *state = "_NET_WM_STATE_SKIP_TASKBAR";
1906+ x11_set_ewmh_state(x11, state, !in);
1907+ MP_VERBOSE(x11, "NET style set skip taskbar (%d).\n", !in);
1908+ }
1909+}
1910+
18951911 static bool rc_overlaps(struct mp_rect rc1, struct mp_rect rc2)
18961912 {
18971913 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) · 178 unmodified lines
20762092 vo_x11_fullscreen(vo);
20772093 if (opt == &opts->ontop)
20782094 vo_x11_setlayer(vo, opts->ontop);
2095+ if (opt == &opts->show_in_taskbar)
2096+ vo_x11_set_in_taskbar(vo, opts->show_in_taskbar);
20792097 if (opt == &opts->border || opt == &opts->title_bar)
20802098 vo_x11_decoration(vo, opts->border, opts->title_bar);
20812099 if (opt == &opts->all_workspaces)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t