summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2018-05-14 13:55:04 +0200
committerJan Ekström <jeebjp@gmail.com>2018-06-02 23:34:38 +0300
commit7f625ea29b1082248bcd17d6f1ee1a8b150e2bc7 (patch)
tree9107e06186bb86818f8baef79b13ffa4f20eea85
parent5056777b861230abb45c66b50bd2198846915f29 (diff)
downloadmpv-7f625ea29b1082248bcd17d6f1ee1a8b150e2bc7.tar.bz2
mpv-7f625ea29b1082248bcd17d6f1ee1a8b150e2bc7.tar.xz
vo_sdl: add support for screensaver VOCTRL's
Previously vo_sdl would unconditonally disable the screensaver, ignoring the `stop-screensaver` option.
-rw-r--r--video/out/vo_sdl.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index 1667b2c633..a7450e571c 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -180,6 +180,7 @@ struct priv {
int brightness, contrast;
char *window_title;
Uint32 wakeup_event;
+ bool screensaver_enabled;
// options
int allow_sw;
@@ -402,10 +403,22 @@ static void check_resize(struct vo *vo)
resize(vo, w, h);
}
+static inline void set_screensaver(bool enabled)
+{
+ if (!!enabled == !!SDL_IsScreenSaverEnabled())
+ return;
+
+ if (enabled)
+ SDL_EnableScreenSaver();
+ else
+ SDL_DisableScreenSaver();
+}
+
static void set_fullscreen(struct vo *vo)
{
struct priv *vc = vo->priv;
int fs = vo->opts->fullscreen;
+ SDL_bool prev_screensaver_state = SDL_IsScreenSaverEnabled();
Uint32 fs_flag;
if (vc->switch_mode)
@@ -428,7 +441,7 @@ static void set_fullscreen(struct vo *vo)
}
// toggling fullscreen might recreate the window, so better guard for this
- SDL_DisableScreenSaver();
+ set_screensaver(prev_screensaver_state);
force_resize(vo);
}
@@ -507,8 +520,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
resize(vo, win_w, win_h);
- SDL_DisableScreenSaver();
-
+ set_screensaver(vc->screensaver_enabled);
set_fullscreen(vo);
SDL_ShowWindow(vc->window);
@@ -917,6 +929,14 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_SET_CURSOR_VISIBILITY:
SDL_ShowCursor(*(bool *)data);
return true;
+ case VOCTRL_KILL_SCREENSAVER:
+ vc->screensaver_enabled = false;
+ set_screensaver(vc->screensaver_enabled);
+ return VO_TRUE;
+ case VOCTRL_RESTORE_SCREENSAVER:
+ vc->screensaver_enabled = true;
+ set_screensaver(vc->screensaver_enabled);
+ return VO_TRUE;
case VOCTRL_UPDATE_WINDOW_TITLE:
talloc_free(vc->window_title);
vc->window_title = talloc_strdup(vc, (char *)data);
@@ -936,6 +956,7 @@ const struct vo_driver video_out_sdl = {
.priv_defaults = &(const struct priv) {
.renderer_index = -1,
.vsync = 1,
+ .screensaver_enabled = false,
},
.options = (const struct m_option []){
OPT_FLAG("sw", allow_sw, 0),