Skip to content

Commit 1f6c709

Browse files
committed
tasks: extend window/taskbar progress coverage
Build on the task_window_progress_cb helper introduced in d1228e6 and propagate the Win32 taskbar progress overlay (and any other platform window progress hook) to more long-running user-visible tasks. Helper relocation: - Move the implementation from task_http.c (HAVE_NETWORKING-gated) to task_file_transfer.c (always built), so non-network tasks can use it without pulling in HAVE_NETWORKING. - Move the prototype in tasks_internal.h out of the HAVE_NETWORKING block for the same reason. - Drop the duplicated copy in task_database.c (task_database_progress_cb) in favour of the shared helper, and the now-unused video_display_server.h include alongside it. New coverage: - task_pl_thumbnail_download.c: the system-wide bulk thumbnail download task. Long, user-initiated, already drives task->progress monotonically across two outer phases. - task_cloudsync.c: cloud sync, which can be very long and reports progress as files are reconciled. - task_core_backup.c: both the backup and restore outer tasks, so user-initiated backup/restore of cores reflects on the taskbar. The single-entry pl_thumbnail outer task and short-running tasks (decompress, disc scan, playlist manager, menu explore) are left unchanged for now -- they finish too quickly for the taskbar indicator to be useful, and adding them is a trivial follow-up if that turns out to be wrong.
1 parent d1228e6 commit 1f6c709

7 files changed

Lines changed: 40 additions & 35 deletions

File tree

tasks/task_cloudsync.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,7 @@ static void task_push_cloud_sync_with_mode(int conflict_resolution)
14391439
task->title = strdup(task_title);
14401440
task->handler = task_cloud_sync_task_handler;
14411441
task->callback = task_cloud_sync_cb;
1442+
task->progress_cb = task_window_progress_cb;
14421443

14431444
task_queue_push(task);
14441445
}

tasks/task_core_backup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "../verbosity.h"
3636
#include "../core_info.h"
3737
#include "../core_backup.h"
38+
#include "tasks_internal.h"
3839

3940
#if defined(RARCH_INTERNAL) && defined(HAVE_MENU)
4041
#include "../menu/menu_driver.h"
@@ -631,6 +632,7 @@ void *task_push_core_backup(
631632
task->state = backup_handle;
632633
task->title = strdup(task_title);
633634
task->progress = 0;
635+
task->progress_cb = task_window_progress_cb;
634636

635637
if (mute)
636638
task->flags |= RETRO_TASK_FLG_MUTE;
@@ -1085,6 +1087,7 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
10851087
task->state = backup_handle;
10861088
task->title = strdup(task_title);
10871089
task->progress = 0;
1090+
task->progress_cb = task_window_progress_cb;
10881091
task->callback = cb_task_core_restore;
10891092
task->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
10901093

tasks/task_database.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "../playlist.h"
4040
#include "../configuration.h"
4141
#include "../ui/ui_companion_driver.h"
42-
#include "../gfx/video_display_server.h"
4342
#ifdef HAVE_MENU
4443
#include "../menu/menu_driver.h"
4544
#endif
@@ -1667,13 +1666,6 @@ static void scan_results_batch_update_playlists(scan_results_t *sr,
16671666
}
16681667

16691668
#ifdef HAVE_LIBRETRODB
1670-
static void task_database_progress_cb(retro_task_t *task)
1671-
{
1672-
if (task)
1673-
video_display_server_set_window_progress(task->progress,
1674-
((task->flags & RETRO_TASK_FLG_FINISHED) > 0));
1675-
}
1676-
16771669
bool task_push_dbscan(
16781670
const char *playlist_directory, /* always from settings */
16791671
const char *content_database, /* always from settings */
@@ -2607,8 +2599,8 @@ bool task_push_manual_content_scan(
26072599
task->state = manual_scan;
26082600
task->title = strdup(task_title);
26092601
task->progress = 0;
2610-
#ifdef HAVE_LIBRETRODB
2611-
task->progress_cb = task_database_progress_cb;
2602+
#ifdef HAVE_LIBRETRODB
2603+
task->progress_cb = task_window_progress_cb;
26122604
#else
26132605
task->progress_cb = NULL;
26142606
#endif

tasks/task_file_transfer.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,29 @@
2424
#include "task_file_transfer.h"
2525
#include "tasks_internal.h"
2626

27+
#ifdef RARCH_INTERNAL
28+
#include "../gfx/video_display_server.h"
29+
#endif
30+
2731
bool task_image_load_handler(retro_task_t *task);
2832

33+
/* Forward task progress to the platform's window/taskbar progress
34+
* indicator (e.g. ITaskbarList3 on Win32). Wire this as a task's
35+
* progress_cb to have the desktop reflect that task's progress.
36+
*
37+
* Lives in this always-built TU (rather than the network-gated
38+
* task_http.c where it originated) so non-network tasks -- core
39+
* backup, manual content scan, etc. -- can use it without pulling
40+
* in HAVE_NETWORKING. */
41+
void task_window_progress_cb(retro_task_t *task)
42+
{
43+
#ifdef RARCH_INTERNAL
44+
if (task)
45+
video_display_server_set_window_progress(task->progress,
46+
((task->flags & RETRO_TASK_FLG_FINISHED) > 0));
47+
#endif
48+
}
49+
2950
/* Default number of nbio_iterate() calls per handler tick.
3051
* Callers may override by setting nbio->pos_increment to a
3152
* non-zero value before queuing the task. A value of 0 (the

tasks/task_http.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#include <retro_timers.h>
2424
#include <retro_miscellaneous.h>
2525

26-
#ifdef RARCH_INTERNAL
27-
#include "../gfx/video_display_server.h"
28-
#endif
2926
#include "task_file_transfer.h"
3027
#include "tasks_internal.h"
3128

@@ -243,20 +240,6 @@ static bool task_http_finder(retro_task_t *task, void *user_data)
243240
return false;
244241
}
245242

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)
252-
{
253-
#ifdef RARCH_INTERNAL
254-
if (task)
255-
video_display_server_set_window_progress(task->progress,
256-
((task->flags & RETRO_TASK_FLG_FINISHED) > 0));
257-
#endif
258-
}
259-
260243
static void *task_push_http_transfer_generic_titled(
261244
struct http_connection_t *conn,
262245
const char *url, bool mute, bool headers_accept_err,

tasks/task_pl_thumbnail_download.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ bool task_push_pl_thumbnail_download(
617617
task->state = pl_thumb;
618618
task->title = strdup(system);
619619
task->progress = 0;
620+
task->progress_cb = task_window_progress_cb;
620621
task->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
621622

622623
task_queue_push(task);

tasks/tasks_internal.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ typedef struct nbio_buf
5252
unsigned bufsize;
5353
} nbio_buf_t;
5454

55+
/* Generic progress_cb that forwards a task's progress (0-100) to the
56+
* platform's window/taskbar progress indicator (e.g. ITaskbarList3 on
57+
* Win32). Set this on any task whose progress should be reflected on
58+
* the taskbar -- aggregating tasks (e.g. the Core Updater's outer
59+
* task) need to do this manually because their inner http transfers
60+
* run muted and so their own progress callbacks never fire.
61+
*
62+
* Available regardless of HAVE_NETWORKING: implementation lives in
63+
* task_file_transfer.c so non-network long-running tasks (manual
64+
* content scan, core backup, ...) can use it too. */
65+
void task_window_progress_cb(retro_task_t *task);
66+
5567
#ifdef HAVE_NETWORKING
5668
typedef struct
5769
{
@@ -61,14 +73,6 @@ typedef struct
6173
int status;
6274
} http_transfer_data_t;
6375

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-
7276
void *task_push_http_transfer(const char *url, bool mute, const char *type,
7377
retro_task_callback_t cb, void *userdata);
7478

0 commit comments

Comments
 (0)