From 8c614e0df52f87b9c0b559abb47e62cad4ace057 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sat, 13 Apr 2024 00:15:56 -0400 Subject: [PATCH] w32_common: implement --show-in-taskbar option When the window style changes, use WS_EX_TOOLWINDOW style to exclude the window from the taskbar and Alt+Tab switching. --- video/out/w32_common.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 36f48b9be7..6d89355a70 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -954,6 +954,14 @@ static DWORD update_style(struct vo_w32_state *w32, DWORD style) return style; } +static DWORD update_exstyle(struct vo_w32_state *w32, DWORD exstyle) +{ + exstyle &= ~(WS_EX_TOOLWINDOW); + if (!w32->opts->show_in_taskbar) + exstyle |= WS_EX_TOOLWINDOW; + return exstyle; +} + static void update_window_style(struct vo_w32_state *w32) { if (w32->parent) @@ -963,7 +971,9 @@ static void update_window_style(struct vo_w32_state *w32) // has to be saved now and restored after setting the new style. const RECT wr = w32->windowrc; const DWORD style = GetWindowLongPtrW(w32->window, GWL_STYLE); + const DWORD exstyle = GetWindowLongPtrW(w32->window, GWL_EXSTYLE); SetWindowLongPtrW(w32->window, GWL_STYLE, update_style(w32, style)); + SetWindowLongPtrW(w32->window, GWL_EXSTYLE, update_exstyle(w32, exstyle)); w32->windowrc = wr; } @@ -2172,7 +2182,8 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) } else if (changed_option == &vo_opts->cursor_passthrough) { update_cursor_passthrough(w32); } else if (changed_option == &vo_opts->border || - changed_option == &vo_opts->title_bar) + changed_option == &vo_opts->title_bar || + changed_option == &vo_opts->show_in_taskbar) { update_window_style(w32); update_window_state(w32);