mirror of
https://github.com/mpv-player/mpv
synced 2024-12-29 02:22:19 +00:00
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.
This commit is contained in:
parent
2f4c550b4b
commit
93708a9d38
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user