1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 00:42:57 +00:00

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.
This commit is contained in:
wm4 2013-09-08 02:46:19 +02:00
parent 68e331851a
commit cecbd8864e
5 changed files with 31 additions and 19 deletions

View File

@ -566,6 +566,11 @@
``no`` will disable cursor autohide. ``always`` means the cursor will stay
hidden.
``--cursor-autohide-fs-only``
If this option is given, the cursor is always visible in windowed mode. In
fullscreen mode, the cursor is shown or hidden according to
``--cursor-autohide``.
``--audio-delay=<sec>``
Audio delay in seconds (positive or negative float value). Negative values
delay the audio, and positive values delay the video.

View File

@ -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;

View File

@ -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();

View File

@ -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),

View File

@ -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;