summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-08 02:46:19 +0200
committerwm4 <wm4@nowhere>2013-09-08 03:03:58 +0200
commitcecbd8864ec9e03f8fc14f0a92bead310de946a9 (patch)
tree07e59d9260a67900569784bea439884c3ced7bfa /mpvcore
parent68e331851ad206b7504353e864d5720c9d0d73e1 (diff)
downloadmpv-cecbd8864ec9e03f8fc14f0a92bead310de946a9.tar.bz2
mpv-cecbd8864ec9e03f8fc14f0a92bead310de946a9.tar.xz
mplayer: add --cursor-autohide-fs-only option
This option makes the cursor always visible in windowed mode. Apparently, this is what (some?) Windows and OSX users expect. It's disabled by default for now. Restructure the cursor hide logic a bit for this purpose.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/mp_core.h2
-rw-r--r--mpvcore/mplayer.c41
-rw-r--r--mpvcore/options.c1
-rw-r--r--mpvcore/options.h1
4 files changed, 26 insertions, 19 deletions
diff --git a/mpvcore/mp_core.h b/mpvcore/mp_core.h
index cb426425b1..777e04945a 100644
--- a/mpvcore/mp_core.h
+++ b/mpvcore/mp_core.h
@@ -246,7 +246,7 @@ typedef struct MPContext {
double mouse_timer;
unsigned int mouse_event_ts;
- int mouse_waiting_hide;
+ bool mouse_cursor_visible;
// used to prevent hanging in some error cases
double start_timestamp;
diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c
index 3a2b65b31c..c9b51c8272 100644
--- a/mpvcore/mplayer.c
+++ b/mpvcore/mplayer.c
@@ -2402,10 +2402,7 @@ int reinit_video_chain(struct MPContext *mpctx)
"the selected video_out (-vo) device.\n");
goto err_out;
}
- if (opts->cursor_autohide_delay != -1) {
- vo_control(mpctx->video_out, VOCTRL_SET_CURSOR_VISIBILITY,
- &(bool){false});
- }
+ mpctx->mouse_cursor_visible = true;
mpctx->initialized_flags |= INITIALIZED_VO;
}
@@ -3454,25 +3451,33 @@ static void run_playloop(struct MPContext *mpctx)
// ================================================================
vo_check_events(vo);
+ bool mouse_cursor_visible = mpctx->mouse_cursor_visible;
+ if (opts->cursor_autohide_delay == -1)
+ mouse_cursor_visible = true;
+
unsigned mouse_event_ts = mp_input_get_mouse_event_counter(mpctx->input);
if (mpctx->mouse_event_ts != mouse_event_ts) {
mpctx->mouse_event_ts = mouse_event_ts;
- if (opts->cursor_autohide_delay > -1) {
- vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &(bool){true});
- if (opts->cursor_autohide_delay >= 0) {
- mpctx->mouse_waiting_hide = 1;
- mpctx->mouse_timer =
- mp_time_sec() + opts->cursor_autohide_delay / 1000.0;
- }
- }
+ mpctx->mouse_timer =
+ mp_time_sec() + opts->cursor_autohide_delay / 1000.0;
+ mouse_cursor_visible = true;
}
- if (mpctx->mouse_waiting_hide == 1 &&
- mp_time_sec() >= mpctx->mouse_timer)
- {
- vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &(bool){false});
- mpctx->mouse_waiting_hide = 2;
- }
+ if (mp_time_sec() >= mpctx->mouse_timer)
+ mouse_cursor_visible = false;
+
+ if (opts->cursor_autohide_delay == -1)
+ mouse_cursor_visible = true;
+
+ if (opts->cursor_autohide_delay == -2)
+ mouse_cursor_visible = false;
+
+ if (opts->cursor_autohide_fs && !opts->vo.fullscreen)
+ mouse_cursor_visible = true;
+
+ if (mouse_cursor_visible != mpctx->mouse_cursor_visible)
+ vo_control(vo, VOCTRL_SET_CURSOR_VISIBILITY, &mouse_cursor_visible);
+ mpctx->mouse_cursor_visible = mouse_cursor_visible;
if (opts->heartbeat_cmd) {
double now = mp_time_sec();
diff --git a/mpvcore/options.c b/mpvcore/options.c
index 9f87186066..cf09702dcb 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -606,6 +606,7 @@ const m_option_t mp_opts[] = {
OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0,
0, 30000, ({"no", -1}, {"always", -2})),
+ OPT_FLAG("cursor-autohide-fs-only", cursor_autohide_fs, 0),
OPT_FLAG("stop-screensaver", stop_screensaver, 0),
OPT_INT64("wid", vo.WinID, CONF_GLOBAL),
diff --git a/mpvcore/options.h b/mpvcore/options.h
index a0fe23f050..25ff391615 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -69,6 +69,7 @@ typedef struct MPOpts {
int stop_screensaver;
int cursor_autohide_delay;
+ int cursor_autohide_fs;
int requested_colorspace;
int requested_input_range;