History

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

Kacper Michajłow committed 2 years ago

Commit 37127271 parent d3b251b3 files · +17 −8Browse files

Unified · Split

3 files
  1. player/misc.c +8 −6
  2. video/out/vo.h +1 −1
  3. video/out/w32_common.c +8 −1
player/misc.c+8−6
@@ -15,10 +15,11 @@ · 14 unmodified lines
1515 * License along with mpv. If not, see <http://www.gnu.org/licenses/>.
1616 */
1717
18−#include <stddef.h>
19−#include <stdbool.h>
20−#include <errno.h>
2118 #include <assert.h>
19+#include <errno.h>
20+#include <math.h>
21+#include <stdbool.h>
22+#include <stddef.h>
2223
2324 #include "mpv_talloc.h"
2425
@@ -191,17 +192,18 @@ void update_vo_playback_state(struct MPContext *mpctx) · 166 unmodified lines
191192 {
192193 if (mpctx->video_out && mpctx->video_out->config_ok) {
193194 struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
195+ double pos = get_current_pos_ratio(mpctx, false);
194196 struct voctrl_playback_state newstate = {
195− .taskbar_progress = mpctx->opts->vo->taskbar_progress,
197+ .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0,
196198 .playing = mpctx->playing,
197199 .paused = mpctx->paused,
198− .percent_pos = get_percent_pos(mpctx),
200+ .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0,
199201 };
200202
201203 if (oldstate.taskbar_progress != newstate.taskbar_progress ||
202204 oldstate.playing != newstate.playing ||
203205 oldstate.paused != newstate.paused ||
204− oldstate.percent_pos != newstate.percent_pos)
206+ oldstate.position != newstate.position)
205207 {
206208 // Don't update progress bar if it was and still is hidden
207209 if ((oldstate.playing && oldstate.taskbar_progress) ||
video/out/vo.h+1−1
@@ -149,7 +149,7 @@ struct voctrl_playback_state { · 148 unmodified lines
149149 bool taskbar_progress;
150150 bool playing;
151151 bool paused;
152− int percent_pos;
152+ uint8_t position;
153153 };
154154
155155 // VOCTRL_PERFORMANCE_DATA
video/out/w32_common.c+8−1
@@ -767,8 +767,15 @@ static void update_playback_state(struct vo_w32_state *w32) · 766 unmodified lines
767767 return;
768768 }
769769
770+ ULONGLONG completed = pstate->position;
771+ ULONGLONG total = UINT8_MAX;
772+ if (!pstate->position) {
773+ completed = 1;
774+ total = MAXULONGLONG;
775+ }
776+
770777 ITaskbarList3_SetProgressValue(w32->taskbar_list3, w32->window,
771− pstate->percent_pos, 100);
778+ completed, total);
772779 ITaskbarList3_SetProgressState(w32->taskbar_list3, w32->window,
773780 pstate->paused ? TBPF_PAUSED :
774781 TBPF_NORMAL);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t