summaryrefslogtreecommitdiffstats
path: root/core/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-16 23:17:46 +0200
committerwm4 <wm4@nowhere>2013-05-26 16:44:19 +0200
commit3c8f8b7714331746233e288206b247366257cb99 (patch)
tree2a42c1d9c60bf24e5a680ec7e6d599ff33e60232 /core/mplayer.c
parent8df780cb50ec4bb615ac25987de52bb3b4126de9 (diff)
downloadmpv-3c8f8b7714331746233e288206b247366257cb99.tar.bz2
mpv-3c8f8b7714331746233e288206b247366257cb99.tar.xz
core: do mouse cursor hiding business in frontend
Do this so that not every VO backend has to setup a timer for cursor hiding and interpret the --cursor-autohide option.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r--core/mplayer.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index c0415093e2..5036d1e476 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -2555,6 +2555,10 @@ int reinit_video_chain(struct MPContext *mpctx)
"the selected video_out (-vo) device.\n");
goto err_out;
}
+ if (opts->vo.cursor_autohide_delay != -1) {
+ vo_control(mpctx->video_out, VOCTRL_SET_CURSOR_VISIBILITY,
+ &(bool){false});
+ }
mpctx->initialized_flags |= INITIALIZED_VO;
}
@@ -3503,6 +3507,27 @@ static void run_playloop(struct MPContext *mpctx)
// ================================================================
vo_check_events(vo);
+ unsigned int mouse_last_time =
+ mp_input_get_last_mouse_event_time(mpctx->input);
+ if (mpctx->mouse_last_time != mouse_last_time) {
+ mpctx->mouse_last_time = mouse_last_time;
+ if (opts->vo.cursor_autohide_delay > -1) {
+ vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &(bool){true});
+ if (opts->vo.cursor_autohide_delay >= 0) {
+ mpctx->mouse_waiting_hide = 1;
+ mpctx->mouse_timer =
+ GetTimerMS() + opts->vo.cursor_autohide_delay;
+ }
+ }
+ }
+
+ if (mpctx->mouse_waiting_hide == 1 &&
+ GetTimerMS() >= mpctx->mouse_timer)
+ {
+ vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &(bool){false});
+ mpctx->mouse_waiting_hide = 2;
+ }
+
if (opts->heartbeat_cmd) {
unsigned now = GetTimerMS();
if (now - mpctx->last_heartbeat >
@@ -3751,6 +3776,10 @@ static void run_playloop(struct MPContext *mpctx)
if (mpctx->sh_video) {
unsigned int vo_sleep = vo_get_sleep_time(mpctx->video_out);
sleep_ms = FFMIN(sleep_ms, vo_sleep);
+ if (mpctx->mouse_waiting_hide) {
+ vo_sleep = mpctx->mouse_timer - GetTimerMS();
+ sleep_ms = FFMIN(sleep_ms, vo_sleep);
+ }
}
mp_input_get_cmd(mpctx->input, sleep_ms, true);
}