From 37127276cc74b1918c73635bbefcb67e2bde9eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 3 Jun 2024 03:22:23 +0200 Subject: [PATCH] win32: quantize taskbar playback position into uint8 range Also, if the position is valid, set it to 1 / INF. Windows interprets 0 as non-progress. Progress is quantized into uint8 range, it is good enough for this use-case. This avoids unnecessary vo_control and ITaskbarList3::SetProgressValue calls and should be visually indistinguishable in practice. Fixes #14282 --- player/misc.c | 14 ++++++++------ video/out/vo.h | 2 +- video/out/w32_common.c | 9 ++++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/player/misc.c b/player/misc.c index 116ed37fbb..f5cbc2f0ce 100644 --- a/player/misc.c +++ b/player/misc.c @@ -15,10 +15,11 @@ * License along with mpv. If not, see . */ -#include -#include -#include #include +#include +#include +#include +#include #include "mpv_talloc.h" @@ -191,17 +192,18 @@ void update_vo_playback_state(struct MPContext *mpctx) { if (mpctx->video_out && mpctx->video_out->config_ok) { struct voctrl_playback_state oldstate = mpctx->vo_playback_state; + double pos = get_current_pos_ratio(mpctx, false); struct voctrl_playback_state newstate = { - .taskbar_progress = mpctx->opts->vo->taskbar_progress, + .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0, .playing = mpctx->playing, .paused = mpctx->paused, - .percent_pos = get_percent_pos(mpctx), + .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0, }; if (oldstate.taskbar_progress != newstate.taskbar_progress || oldstate.playing != newstate.playing || oldstate.paused != newstate.paused || - oldstate.percent_pos != newstate.percent_pos) + oldstate.position != newstate.position) { // Don't update progress bar if it was and still is hidden if ((oldstate.playing && oldstate.taskbar_progress) || diff --git a/video/out/vo.h b/video/out/vo.h index 313c08aafc..3afbd6ea21 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -149,7 +149,7 @@ struct voctrl_playback_state { bool taskbar_progress; bool playing; bool paused; - int percent_pos; + uint8_t position; }; // VOCTRL_PERFORMANCE_DATA diff --git a/video/out/w32_common.c b/video/out/w32_common.c index a4eaadf170..e6d84b52e1 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -767,8 +767,15 @@ static void update_playback_state(struct vo_w32_state *w32) return; } + ULONGLONG completed = pstate->position; + ULONGLONG total = UINT8_MAX; + if (!pstate->position) { + completed = 1; + total = MAXULONGLONG; + } + ITaskbarList3_SetProgressValue(w32->taskbar_list3, w32->window, - pstate->percent_pos, 100); + completed, total); ITaskbarList3_SetProgressState(w32->taskbar_list3, w32->window, pstate->paused ? TBPF_PAUSED : TBPF_NORMAL);