summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-04-18 23:01:49 -0400
committerKacper Michajłow <kasper93@gmail.com>2024-04-27 03:02:00 +0200
commit93708a9d3838d47da1ebffe846d4cbd5e07fab4a (patch)
treec40cbc546ed9e72e29ae49af2a55a2e8829b2c6f
parent2f4c550b4b46e1c79663679bd39516cf7df153bc (diff)
downloadmpv-93708a9d3838d47da1ebffe846d4cbd5e07fab4a.tar.bz2
mpv-93708a9d3838d47da1ebffe846d4cbd5e07fab4a.tar.xz
w32_common: fix show-in-taskbar toggling after explorer is restarted
After explorer is restarted while show-in-taskbar is false, toggling show-in-taskbar no longer puts mpv back to the taskbar until it's unfocused and refocused. My guess of how this works is that the HWND of the taskbar is cached, and setting the WS_EX_TOOLWINDOW style internally uses this value to show/hide the taskbar button. But after explorer is restarted it no longer works until its taskbar state needs to change (such as focusing). Only then it realizes the HWND is no longer valid and refreshes it. Fix this by following MS documentation on this: the window needs to be hidden before changing the style, and be shown after that. This unfortunately can sometimes introduce a brief window flash, but it fixes the problem.
-rw-r--r--video/out/w32_common.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index 6d89355a70..f7af24fcc3 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -2182,11 +2182,17 @@ 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->show_in_taskbar)
+ changed_option == &vo_opts->title_bar)
{
update_window_style(w32);
update_window_state(w32);
+ } else if (changed_option == &vo_opts->show_in_taskbar) {
+ // This hide and show is apparently required according to the documentation:
+ // https://learn.microsoft.com/en-us/windows/win32/shell/taskbar#managing-taskbar-buttons
+ ShowWindow(w32->window, SW_HIDE);
+ update_window_style(w32);
+ ShowWindow(w32->window, SW_SHOW);
+ update_window_state(w32);
} else if (changed_option == &vo_opts->window_minimized) {
update_minimized_state(w32);
} else if (changed_option == &vo_opts->window_maximized) {