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.
This commit is contained in:
nanahi 2024-04-13 00:15:56 -04:00 committed by Kacper Michajłow
parent dcd1034529
commit 8c614e0df5
1 changed files with 12 additions and 1 deletions

View File

@ -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);