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
169 {"keepaspect-window", OPT_BOOL(keepaspect_window)},169 {"keepaspect-window", OPT_BOOL(keepaspect_window)},
170 {"hidpi-window-scale", OPT_BOOL(hidpi_window_scale)},170 {"hidpi-window-scale", OPT_BOOL(hidpi_window_scale)},
171 {"native-fs", OPT_BOOL(native_fs)},171 {"native-fs", OPT_BOOL(native_fs)},
172 {"show-in-taskbar", OPT_BOOL(show_in_taskbar)},
172 {"display-fps-override", OPT_DOUBLE(display_fps_override),173 {"display-fps-override", OPT_DOUBLE(display_fps_override),
173 M_RANGE(0, DBL_MAX)},174 M_RANGE(0, DBL_MAX)},
174 {"video-timing-offset", OPT_DOUBLE(timing_offset), M_RANGE(0.0, 1.0)},175 {"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
243 .keepaspect_window = true,244 .keepaspect_window = true,
244 .native_fs = true,245 .native_fs = true,
245 .taskbar_progress = true,246 .taskbar_progress = true,
247 .show_in_taskbar = true,
246 .border = true,248 .border = true,
247 .title_bar = true,249 .title_bar = true,
248 .appid = "mpv",250 .appid = "mpv",
options/options.h+1−0
@@ -56,6 +56,7 @@ typedef struct mp_vo_opts { · 55 unmodified lines
56 bool keepaspect_window;56 bool keepaspect_window;
57 bool hidpi_window_scale;57 bool hidpi_window_scale;
58 bool native_fs;58 bool native_fs;
59 bool show_in_taskbar;
59 60
60 int64_t WinID;61 int64_t WinID;
61 62
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
149static void vo_x11_selectinput_witherr(struct vo *vo, Display *display,149static void vo_x11_selectinput_witherr(struct vo *vo, Display *display,
150 Window w, long event_mask);150 Window w, long event_mask);
151static void vo_x11_setlayer(struct vo *vo, bool ontop);151static void vo_x11_setlayer(struct vo *vo, bool ontop);
152static void vo_x11_set_in_taskbar(struct vo *vo, bool in);
152static void vo_x11_xembed_handle_message(struct vo *vo, XClientMessageEvent *ce);153static void vo_x11_xembed_handle_message(struct vo *vo, XClientMessageEvent *ce);
153static void vo_x11_xembed_send_message(struct vo_x11_state *x11, long m[4]);154static void vo_x11_xembed_send_message(struct vo_x11_state *x11, long m[4]);
154static void vo_x11_move_resize(struct vo *vo, bool move, bool resize,155static 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
1832 1833
1833 if (opts->ontop)1834 if (opts->ontop)
1834 vo_x11_setlayer(vo, opts->ontop);1835 vo_x11_setlayer(vo, opts->ontop);
1836 if (!opts->show_in_taskbar)
1837 vo_x11_set_in_taskbar(vo, opts->show_in_taskbar);
1835 1838
1836 vo_x11_fullscreen(vo);1839 vo_x11_fullscreen(vo);
1837 1840
@@ -1892,6 +1895,19 @@ static void vo_x11_setlayer(struct vo *vo, bool ontop) · 54 unmodified lines
1892 }1895 }
1893}1896}
1894 1897
1898static 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
1895static bool rc_overlaps(struct mp_rect rc1, struct mp_rect rc2)1911static bool rc_overlaps(struct mp_rect rc1, struct mp_rect rc2)
1896{1912{
1897 return mp_rect_intersection(&rc1, &rc2); // changes the first argument1913 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
2076 vo_x11_fullscreen(vo);2092 vo_x11_fullscreen(vo);
2077 if (opt == &opts->ontop)2093 if (opt == &opts->ontop)
2078 vo_x11_setlayer(vo, opts->ontop);2094 vo_x11_setlayer(vo, opts->ontop);
2095 if (opt == &opts->show_in_taskbar)
2096 vo_x11_set_in_taskbar(vo, opts->show_in_taskbar);
2079 if (opt == &opts->border || opt == &opts->title_bar)2097 if (opt == &opts->border || opt == &opts->title_bar)
2080 vo_x11_decoration(vo, opts->border, opts->title_bar);2098 vo_x11_decoration(vo, opts->border, opts->title_bar);
2081 if (opt == &opts->all_workspaces)2099 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