From 4c533fbb16b99c4b28fbd968d81bb0b44e3084b5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 27 Jul 2014 21:53:29 +0200 Subject: vo: remove vo_mouse_movement() wrapper So that VO backends don't have to access the VO just for that. --- input/input.c | 18 ++++++++++++++++++ input/input.h | 3 +++ 2 files changed, 21 insertions(+) (limited to 'input') diff --git a/input/input.c b/input/input.c index 97943e05b3..324f9f250d 100644 --- a/input/input.c +++ b/input/input.c @@ -122,6 +122,7 @@ struct input_ctx { bool mainthread_set; struct mp_log *log; struct mpv_global *global; + struct input_opts *opts; bool using_alt_gr; bool using_ar; @@ -209,6 +210,7 @@ struct input_opts { int use_appleremote; int use_media_keys; int default_bindings; + int enable_mouse_movements; int test; }; @@ -228,6 +230,7 @@ const struct m_sub_options input_config = { OPT_FLAG("lirc", use_lirc, CONF_GLOBAL), OPT_FLAG("right-alt-gr", use_alt_gr, CONF_GLOBAL), OPT_INTRANGE("key-fifo-size", key_fifo_size, CONF_GLOBAL, 2, 65000), + OPT_FLAG("cursor", enable_mouse_movements, CONF_GLOBAL), #if HAVE_LIRC OPT_STRING("lirc-conf", lirc_configfile, CONF_GLOBAL), #endif @@ -245,6 +248,7 @@ const struct m_sub_options input_config = { .ar_rate = 40, .use_lirc = 1, .use_alt_gr = 1, + .enable_mouse_movements = 1, #if HAVE_COCOA .use_appleremote = 1, .use_media_keys = 1, @@ -755,11 +759,24 @@ void mp_input_set_mouse_transform(struct input_ctx *ictx, struct mp_rect *dst, input_unlock(ictx); } +bool mp_input_mouse_enabled(struct input_ctx *ictx) +{ + input_lock(ictx); + bool r = ictx->opts->enable_mouse_movements; + input_unlock(ictx); + return r; +} + void mp_input_set_mouse_pos(struct input_ctx *ictx, int x, int y) { input_lock(ictx); MP_DBG(ictx, "mouse move %d/%d\n", x, y); + if (!ictx->opts->enable_mouse_movements) { + input_unlock(ictx); + return; + } + if (ictx->mouse_mangle) { struct mp_rect *src = &ictx->mouse_src; struct mp_rect *dst = &ictx->mouse_dst; @@ -1517,6 +1534,7 @@ struct input_ctx *mp_input_init(struct mpv_global *global) struct input_ctx *ictx = talloc_ptrtype(NULL, ictx); *ictx = (struct input_ctx){ .global = global, + .opts = input_conf, .log = mp_log_new(ictx, global->log, "input"), .key_fifo_size = input_conf->key_fifo_size, .doubleclick_time = input_conf->doubleclick_time, diff --git a/input/input.h b/input/input.h index 2c572fa788..de363cf33b 100644 --- a/input/input.h +++ b/input/input.h @@ -133,6 +133,9 @@ void mp_input_set_mouse_pos(struct input_ctx *ictx, int x, int y); void mp_input_get_mouse_pos(struct input_ctx *ictx, int *x, int *y); +// Return whether we want/accept mouse input. +bool mp_input_mouse_enabled(struct input_ctx *ictx); + /* Make mp_input_set_mouse_pos() mangle the mouse coordinates. Hack for certain * VOs. dst=NULL, src=NULL reset it. src can be NULL. */ -- cgit v1.2.3