summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-10-02 12:33:34 +0200
committerwm4 <wm4@nowhere>2016-10-02 12:33:34 +0200
commit39fc5e1deb0c5753e7123529e4dd5c750aed1e8d (patch)
tree92b460dc2802ccf34c3ea413370daa98428f7a1e /player/playloop.c
parente3a57272a712542e739b97db31efebc4cc17c53a (diff)
downloadmpv-39fc5e1deb0c5753e7123529e4dd5c750aed1e8d.tar.bz2
mpv-39fc5e1deb0c5753e7123529e4dd5c750aed1e8d.tar.xz
player: make --stop-screensaver runtime-changeable
Move the screensaver enable/disable determination to a central place, and call it if the stop-screensaver property is changed. Also, do not stop the screensaver when in idle mode (i.e. no file is loaded). Fixes #3615.
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/player/playloop.c b/player/playloop.c
index fc4cfe859e..18a51f33d0 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -125,8 +125,7 @@ void pause_player(struct MPContext *mpctx)
{
mpctx->opts->pause = 1;
- if (mpctx->video_out)
- vo_control(mpctx->video_out, VOCTRL_RESTORE_SCREENSAVER, NULL);
+ update_screensaver_state(mpctx);
if (mpctx->paused)
goto end;
@@ -152,8 +151,7 @@ void unpause_player(struct MPContext *mpctx)
{
mpctx->opts->pause = 0;
- if (mpctx->video_out && mpctx->opts->stop_screensaver)
- vo_control(mpctx->video_out, VOCTRL_KILL_SCREENSAVER, NULL);
+ update_screensaver_state(mpctx);
if (!mpctx->paused)
goto end;
@@ -177,6 +175,17 @@ end:
mp_notify(mpctx, mpctx->opts->pause ? MPV_EVENT_PAUSE : MPV_EVENT_UNPAUSE, 0);
}
+void update_screensaver_state(struct MPContext *mpctx)
+{
+ if (!mpctx->video_out)
+ return;
+
+ bool saver_state = mpctx->opts->pause || !mpctx->opts->stop_screensaver ||
+ !mpctx->playback_initialized;
+ vo_control(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER
+ : VOCTRL_KILL_SCREENSAVER, NULL);
+}
+
void add_step_frame(struct MPContext *mpctx, int dir)
{
if (!mpctx->vo_chain)