From ca893689fefdac74338b41aa21fbc601ae102ff6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 2 Mar 2013 22:50:09 +0100 Subject: x11_common: fix --cursor-autohide when paused When paused, --cursor-autohide worked with a precision of 500ms, which is the main loop's default sleep time when paused. Cursor hiding is polled in x11_common, and the main loop never called the X11 code at the right time. Fix this by allowing the VO to set a time when it should be called next. --- video/out/x11_common.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'video/out/x11_common.c') diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 7d5ef0da33..0fa8f2ad47 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -665,6 +665,20 @@ void vo_x11_uninit(struct vo *vo) vo->x11 = NULL; } +static void vo_x11_unhide_cursor(struct vo *vo) +{ + struct vo_x11_state *x11 = vo->x11; + struct MPOpts *opts = vo->opts; + + if (opts->cursor_autohide_delay > -2) { + vo_showcursor(x11->display, x11->window); + if (opts->cursor_autohide_delay >= 0) { + x11->mouse_waiting_hide = 1; + x11->mouse_timer = GetTimerMS() + opts->cursor_autohide_delay; + } + } +} + static void update_vo_size(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; @@ -679,13 +693,10 @@ static void update_vo_size(struct vo *vo) int vo_x11_check_events(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; - struct MPOpts *opts = vo->opts; Display *display = vo->x11->display; XEvent Event; - if (x11->mouse_waiting_hide && opts->cursor_autohide_delay != -1 && - (GetTimerMS() - x11->mouse_timer >= opts->cursor_autohide_delay)) - { + if (x11->mouse_waiting_hide && GetTimerMS() >= x11->mouse_timer) { vo_hidecursor(display, x11->window); x11->mouse_waiting_hide = 0; } @@ -740,29 +751,16 @@ int vo_x11_check_events(struct vo *vo) break; case MotionNotify: vo_mouse_movement(vo, Event.xmotion.x, Event.xmotion.y); - - if (opts->cursor_autohide_delay > -2) { - vo_showcursor(display, x11->window); - x11->mouse_waiting_hide = 1; - x11->mouse_timer = GetTimerMS(); - } + vo_x11_unhide_cursor(vo); break; case ButtonPress: - if (opts->cursor_autohide_delay > -2) { - vo_showcursor(display, x11->window); - x11->mouse_waiting_hide = 1; - x11->mouse_timer = GetTimerMS(); - } + vo_x11_unhide_cursor(vo); mplayer_put_key(vo->key_fifo, (MP_MOUSE_BTN0 + Event.xbutton.button - 1) | MP_KEY_STATE_DOWN); break; case ButtonRelease: - if (opts->cursor_autohide_delay > -2) { - vo_showcursor(display, x11->window); - x11->mouse_waiting_hide = 1; - x11->mouse_timer = GetTimerMS(); - } + vo_x11_unhide_cursor(vo); mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN0 + Event.xbutton.button - 1); break; @@ -795,6 +793,10 @@ int vo_x11_check_events(struct vo *vo) break; } } + + if (x11->mouse_waiting_hide) + vo->next_wakeup_time = FFMIN(vo->next_wakeup_time, x11->mouse_timer); + update_vo_size(vo); if (WinID >= 0 && (x11->pending_vo_events & VO_EVENT_RESIZE)) { int x = x11->win_x, y = x11->win_y; -- cgit v1.2.3