Skip to content

Commit d1228e6

Browse files
committed
win32+core_updater: fix taskbar progress overlay during downloads
The Win32 taskbar progress overlay (the green bar drawn on the RetroArch taskbar icon during downloads) never appeared. Two independent bugs were keeping it dark: 1) wndproc: the 'TaskbarButtonCreated' message check was nested inside unrelated 'case' arms (WM_MOUSEMOVE..WM_NCLBUTTONDBLCLK, WM_DROPFILES..WM_COMMAND, and the WM_PAINT branch of the GDI wrappers). Since 'TaskbarButtonCreated' is a registered window message with its own dynamically-allocated value, those arms could never match it, so WIN32_CMN_FLAG_TASKBAR_CREATED was never set and dispserv_win32's set_window_progress() always early-outed without calling ITaskbarList3::SetProgressValue. Move the comparison to the top of each dispatcher (wnd_proc_common, wnd_proc_common_internal, wnd_proc_winraw_common_internal, wnd_proc_common_dinput_internal) so it sees every incoming message. Short-circuit on the flag bit so the comparison only runs until the message arrives once. The HAVE_TASKBAR gate is unchanged; pre-Win7 builds either don't define it or fall back through the existing taskbar_list NULL guard in dispserv_win32. 2) task_core_updater: even with the flag set, the five outer aggregating tasks (get_list, single download, update_installed_cores, play_feature_delivery_install, play_feature_delivery_switch) never set a progress_cb. They spawn inner http transfers with mute=true to suppress per-core on-screen toasts, which also suppresses the inner tasks' progress_cb invocation in task_queue_push_progress(). Net result: video_display_server_set_window_progress() was never being called during a Core Updater run. Promote the existing http progress forwarder (http_transfer_progress_cb in task_http.c) to a public helper named task_window_progress_cb, declare it in tasks_internal.h, and wire it as the progress_cb of all five outer tasks. The aggregating tasks already drive task->progress in 0..100 across their state machines, so no other plumbing is needed. Single-zip update flows (Update Assets, Update Cheats, Update Databases, etc.) were already working because their underlying http transfer is unmuted and titled, and the existing progress_cb fired for those.
1 parent 5f0afac commit d1228e6

4 files changed

Lines changed: 49 additions & 47 deletions

File tree

gfx/common/win32_common.c

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,14 @@ static LRESULT CALLBACK wnd_proc_common(
508508
bool *quit, HWND hwnd, UINT message,
509509
WPARAM wparam, LPARAM lparam)
510510
{
511+
#ifdef HAVE_TASKBAR
512+
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
513+
if ( !(g_win32_flags & WIN32_CMN_FLAG_TASKBAR_CREATED)
514+
&& g_win32->taskbar_message
515+
&& message == g_win32->taskbar_message)
516+
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
517+
#endif
518+
511519
switch (message)
512520
{
513521
case WM_SYSCOMMAND:
@@ -709,6 +717,13 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
709717
bool quit = false;
710718
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
711719

720+
#ifdef HAVE_TASKBAR
721+
if ( !(g_win32_flags & WIN32_CMN_FLAG_TASKBAR_CREATED)
722+
&& g_win32->taskbar_message
723+
&& message == g_win32->taskbar_message)
724+
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
725+
#endif
726+
712727
switch (message)
713728
{
714729
case WM_KEYUP: /* Key released */
@@ -771,10 +786,6 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
771786
case WM_MOUSEWHEEL:
772787
case WM_MOUSEHWHEEL:
773788
case WM_NCLBUTTONDBLCLK:
774-
#ifdef HAVE_TASKBAR
775-
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
776-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
777-
#endif
778789
break;
779790
case WM_DROPFILES:
780791
case WM_SYSCOMMAND:
@@ -793,10 +804,6 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
793804
ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam);
794805
if (quit)
795806
return ret;
796-
#ifdef HAVE_TASKBAR
797-
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
798-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
799-
#endif
800807
break;
801808
case WM_SETFOCUS:
802809
#ifdef HAVE_CLIP_WINDOW
@@ -830,6 +837,13 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd,
830837
bool quit = false;
831838
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
832839

840+
#ifdef HAVE_TASKBAR
841+
if ( !(g_win32_flags & WIN32_CMN_FLAG_TASKBAR_CREATED)
842+
&& g_win32->taskbar_message
843+
&& message == g_win32->taskbar_message)
844+
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
845+
#endif
846+
833847
switch (message)
834848
{
835849
case WM_KEYUP: /* Key released */
@@ -857,10 +871,6 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd,
857871
case WM_MOUSEWHEEL:
858872
case WM_MOUSEHWHEEL:
859873
case WM_NCLBUTTONDBLCLK:
860-
#ifdef HAVE_TASKBAR
861-
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
862-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
863-
#endif
864874
break;
865875
case WM_DROPFILES:
866876
case WM_SYSCOMMAND:
@@ -879,10 +889,6 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd,
879889
ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam);
880890
if (quit)
881891
return ret;
882-
#ifdef HAVE_TASKBAR
883-
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
884-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
885-
#endif
886892
break;
887893
case WM_SETFOCUS:
888894
#ifdef HAVE_CLIP_WINDOW
@@ -936,6 +942,13 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
936942
bool quit = false;
937943
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
938944

945+
#ifdef HAVE_TASKBAR
946+
if ( !(g_win32_flags & WIN32_CMN_FLAG_TASKBAR_CREATED)
947+
&& g_win32->taskbar_message
948+
&& message == g_win32->taskbar_message)
949+
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
950+
#endif
951+
939952
switch (message)
940953
{
941954
case WM_IME_ENDCOMPOSITION:
@@ -1074,10 +1087,6 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
10741087
case WM_MOUSEWHEEL:
10751088
case WM_MOUSEHWHEEL:
10761089
case WM_NCLBUTTONDBLCLK:
1077-
#ifdef HAVE_TASKBAR
1078-
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
1079-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
1080-
#endif
10811090
#if !defined(_XBOX)
10821091
{
10831092
void* input_data = (void*)(LONG_PTR)GetWindowLongPtr(main_window.hwnd, GWLP_USERDATA);
@@ -1104,10 +1113,6 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
11041113
ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam);
11051114
if (quit)
11061115
return ret;
1107-
#ifdef HAVE_TASKBAR
1108-
if (g_win32->taskbar_message && message == g_win32->taskbar_message)
1109-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
1110-
#endif
11111116
break;
11121117
case WM_SETFOCUS:
11131118
#ifdef HAVE_CLIP_WINDOW
@@ -1342,7 +1347,6 @@ LRESULT CALLBACK wnd_proc_gdi_dinput(HWND hwnd, UINT message,
13421347
return wnd_proc_wm_gdi_create(hwnd);
13431348
else if (message == WM_PAINT)
13441349
{
1345-
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
13461350
gdi_t *gdi = (gdi_t*)video_driver_get_ptr();
13471351

13481352
if (gdi && gdi->memDC)
@@ -1365,12 +1369,6 @@ LRESULT CALLBACK wnd_proc_gdi_dinput(HWND hwnd, UINT message,
13651369

13661370
SelectObject(gdi->memDC, gdi->bmp_old);
13671371
}
1368-
1369-
#ifdef HAVE_TASKBAR
1370-
if ( g_win32->taskbar_message
1371-
&& message == g_win32->taskbar_message)
1372-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
1373-
#endif
13741372
}
13751373

13761374
return wnd_proc_common_dinput_internal(hwnd, message, wparam, lparam);
@@ -1385,7 +1383,6 @@ LRESULT CALLBACK wnd_proc_gdi_winraw(HWND hwnd, UINT message,
13851383
return wnd_proc_wm_gdi_create(hwnd);
13861384
else if (message == WM_PAINT)
13871385
{
1388-
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
13891386
gdi_t *gdi = (gdi_t*)video_driver_get_ptr();
13901387

13911388
if (gdi && gdi->memDC)
@@ -1408,12 +1405,6 @@ LRESULT CALLBACK wnd_proc_gdi_winraw(HWND hwnd, UINT message,
14081405

14091406
SelectObject(gdi->memDC, gdi->bmp_old);
14101407
}
1411-
1412-
#ifdef HAVE_TASKBAR
1413-
if ( g_win32->taskbar_message
1414-
&& message == g_win32->taskbar_message)
1415-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
1416-
#endif
14171408
}
14181409

14191410
return wnd_proc_winraw_common_internal(hwnd, message, wparam, lparam);
@@ -1427,7 +1418,6 @@ LRESULT CALLBACK wnd_proc_gdi_common(HWND hwnd, UINT message,
14271418
return wnd_proc_wm_gdi_create(hwnd);
14281419
else if (message == WM_PAINT)
14291420
{
1430-
win32_common_state_t *g_win32 = (win32_common_state_t*)&win32_st;
14311421
gdi_t *gdi = (gdi_t*)video_driver_get_ptr();
14321422

14331423
if (gdi && gdi->memDC)
@@ -1450,12 +1440,6 @@ LRESULT CALLBACK wnd_proc_gdi_common(HWND hwnd, UINT message,
14501440

14511441
SelectObject(gdi->memDC, gdi->bmp_old);
14521442
}
1453-
1454-
#ifdef HAVE_TASKBAR
1455-
if ( g_win32->taskbar_message
1456-
&& message == g_win32->taskbar_message)
1457-
g_win32_flags |= WIN32_CMN_FLAG_TASKBAR_CREATED;
1458-
#endif
14591443
}
14601444

14611445
return wnd_proc_common_internal(hwnd, message, wparam, lparam);

tasks/task_core_updater.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ void *task_push_get_core_updater_list(
476476
task->state = list_handle;
477477
task->title = strdup(msg_hash_to_str(MSG_FETCHING_CORE_LIST));
478478
task->progress = 0;
479+
task->progress_cb = task_window_progress_cb;
479480
task->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
480481
if (mute)
481482
task->flags |= RETRO_TASK_FLG_MUTE;
@@ -1118,6 +1119,7 @@ void *task_push_core_updater_download(
11181119
task->state = download_handle;
11191120
task->title = strdup(task_title);
11201121
task->progress = 0;
1122+
task->progress_cb = task_window_progress_cb;
11211123
task->callback = cb_task_core_updater_download;
11221124
task->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
11231125
if (mute)
@@ -1547,6 +1549,7 @@ void task_push_update_installed_cores(
15471549
task->state = update_installed_handle;
15481550
task->title = strdup(msg_hash_to_str(MSG_FETCHING_CORE_LIST));
15491551
task->progress = 0;
1552+
task->progress_cb = task_window_progress_cb;
15501553
task->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
15511554

15521555
/* Push task */
@@ -1869,6 +1872,7 @@ void *task_push_play_feature_delivery_core_install(
18691872
task->state = pfd_install_handle;
18701873
task->title = strdup(task_title);
18711874
task->progress = 0;
1875+
task->progress_cb = task_window_progress_cb;
18721876
task->callback = cb_task_core_updater_download;
18731877
task->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
18741878
if (mute)
@@ -2239,6 +2243,7 @@ void task_push_play_feature_delivery_switch_installed_cores(
22392243
task->state = pfd_switch_cores_handle;
22402244
task->title = strdup(msg_hash_to_str(MSG_SCANNING_CORES));
22412245
task->progress = 0;
2246+
task->progress_cb = task_window_progress_cb;
22422247
task->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
22432248

22442249
/* Push task */

tasks/task_http.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,12 @@ static bool task_http_finder(retro_task_t *task, void *user_data)
243243
return false;
244244
}
245245

246-
static void http_transfer_progress_cb(retro_task_t *task)
246+
/* Forward task progress to the platform's window/taskbar progress
247+
* indicator (e.g. ITaskbarList3 on Win32). Exposed via tasks_internal.h
248+
* so non-HTTP tasks (such as the Core Updater's outer aggregating tasks)
249+
* can wire it as their progress_cb and have the desktop reflect their
250+
* progress, the same way titled HTTP transfers already do. */
251+
void task_window_progress_cb(retro_task_t *task)
247252
{
248253
#ifdef RARCH_INTERNAL
249254
if (task)
@@ -312,7 +317,7 @@ static void *task_push_http_transfer_generic_titled(
312317
t->handler = task_http_transfer_handler;
313318
t->state = http;
314319
t->callback = cb;
315-
t->progress_cb = http_transfer_progress_cb;
320+
t->progress_cb = task_window_progress_cb;
316321
t->cleanup = task_http_transfer_cleanup;
317322
t->user_data = user_data;
318323
t->progress = -1;

tasks/tasks_internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ typedef struct
6161
int status;
6262
} http_transfer_data_t;
6363

64+
/* Generic progress_cb that forwards a task's progress (0-100) to the
65+
* platform's window/taskbar progress indicator. Set this on any task
66+
* whose progress should be reflected on the taskbar -- aggregating
67+
* tasks (e.g. the Core Updater's outer task) need to do this manually
68+
* because their inner http transfers run muted and so their own
69+
* progress callbacks never fire. */
70+
void task_window_progress_cb(retro_task_t *task);
71+
6472
void *task_push_http_transfer(const char *url, bool mute, const char *type,
6573
retro_task_callback_t cb, void *userdata);
6674

0 commit comments

Comments
 (0)