summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-02 22:50:09 +0100
committerwm4 <wm4@nowhere>2013-03-03 15:36:56 +0100
commitca893689fefdac74338b41aa21fbc601ae102ff6 (patch)
treedfab3405dffcf5327e8f624e7205bb36e3a066d4 /video/out/x11_common.c
parent9efe32120b4d5aaa88eccf4767fa7d7c5c700fd1 (diff)
downloadmpv-ca893689fefdac74338b41aa21fbc601ae102ff6.tar.bz2
mpv-ca893689fefdac74338b41aa21fbc601ae102ff6.tar.xz
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.
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r--video/out/x11_common.c42
1 files changed, 22 insertions, 20 deletions
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;