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 +++ options/options.c | 2 -- options/options.h | 2 -- video/out/cocoa_common.m | 2 +- video/out/vo.c | 14 -------------- video/out/vo.h | 3 --- video/out/vo_caca.c | 8 +++----- video/out/vo_sdl.c | 2 +- video/out/w32_common.c | 4 ++-- video/out/wayland_common.c | 4 ++-- video/out/x11_common.c | 5 +++-- 12 files changed, 33 insertions(+), 34 deletions(-) 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. */ diff --git a/options/options.c b/options/options.c index 1e3c98c087..955526f740 100644 --- a/options/options.c +++ b/options/options.c @@ -510,7 +510,6 @@ const m_option_t mp_opts[] = { OPT_FLAG("slave-broken", slave_mode, CONF_GLOBAL), OPT_FLAG("idle", player_idle_mode, M_OPT_GLOBAL), OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL), - OPT_FLAG("input-cursor", vo.enable_mouse_movements, CONF_GLOBAL), OPT_SUBSTRUCT("screenshot", screenshot_image_opts, image_writer_conf, 0), OPT_STRING("screenshot-template", screenshot_template, 0), @@ -550,7 +549,6 @@ const struct MPOpts mp_default_opts = { .monitor_pixel_aspect = 1.0, .screen_id = -1, .fsscreen_id = -1, - .enable_mouse_movements = 1, .panscan = 0.0f, .keepaspect = 1, .border = 1, diff --git a/options/options.h b/options/options.h index 81c7e394a2..51867b9cc9 100644 --- a/options/options.h +++ b/options/options.h @@ -29,8 +29,6 @@ typedef struct mp_vo_opts { int keepaspect; int border; - int enable_mouse_movements; - int64_t WinID; float force_monitor_aspect; diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 2c3b5dafb2..094236884b 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -716,7 +716,7 @@ void *vo_cocoa_cgl_pixel_format(struct vo *vo) } - (void)signalMouseMovement:(NSPoint)point { - vo_mouse_movement(self.vout, point.x, point.y); + mp_input_set_mouse_pos(self.vout->input_ctx, point.x, point.y); [self recalcMovableByWindowBackground:point]; } diff --git a/video/out/vo.c b/video/out/vo.c index db6a97eb26..2a640d8ea3 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -405,20 +405,6 @@ const char *vo_get_window_title(struct vo *vo) return vo->window_title; } -/** - * Generates a mouse movement message if those are enable and sends it - * to the "main" MPlayer. - * - * \param posx new x position of mouse - * \param posy new y position of mouse - */ -void vo_mouse_movement(struct vo *vo, int posx, int posy) -{ - if (!vo->opts->enable_mouse_movements) - return; - mp_input_set_mouse_pos(vo->input_ctx, posx, posy); -} - /** * \brief lookup an integer in a table, table must have 0 as the last key * \param key key to search for diff --git a/video/out/vo.h b/video/out/vo.h index cc1fd6c23a..409ee926dc 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -293,9 +293,6 @@ struct mp_keymap { }; int lookup_keymap_table(const struct mp_keymap *map, int key); -void vo_mouse_movement(struct vo *vo, int posx, int posy); -void vo_drop_files(struct vo *vo, int num_files, char **files); - struct mp_osd_res; void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, struct mp_rect *out_dst, struct mp_osd_res *out_osd); diff --git a/video/out/vo_caca.c b/video/out/vo_caca.c index 00b9e23123..bcef78534c 100644 --- a/video/out/vo_caca.c +++ b/video/out/vo_caca.c @@ -178,16 +178,14 @@ static void check_events(struct vo *vo) mp_input_put_key(vo->input_ctx, MP_KEY_CLOSE_WIN); break; case CACA_EVENT_MOUSE_MOTION: - vo_mouse_movement(vo, cev.data.mouse.x, cev.data.mouse.y); + mp_input_set_mouse_pos(vo->input_ctx, cev.data.mouse.x, cev.data.mouse.y); break; case CACA_EVENT_MOUSE_PRESS: - if (vo->opts->enable_mouse_movements) - mp_input_put_key(vo->input_ctx, + mp_input_put_key(vo->input_ctx, (MP_MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_STATE_DOWN); break; case CACA_EVENT_MOUSE_RELEASE: - if (vo->opts->enable_mouse_movements) - mp_input_put_key(vo->input_ctx, + mp_input_put_key(vo->input_ctx, (MP_MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_STATE_UP); break; case CACA_EVENT_KEY_PRESS: diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 6fe09d2691..9b52fc08be 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -603,7 +603,7 @@ static void check_events(struct vo *vo) break; } case SDL_MOUSEMOTION: - vo_mouse_movement(vo, ev.motion.x, ev.motion.y); + mp_input_set_mouse_pos(vo->input_ctx, ev.motion.x, ev.motion.y); break; case SDL_MOUSEBUTTONDOWN: mp_input_put_key(vo->input_ctx, diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 6d894000f5..33b6cdfa63 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -623,7 +623,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, if (x != w32->mouse_x || y != w32->mouse_y) { w32->mouse_x = x; w32->mouse_y = y; - vo_mouse_movement(w32->vo, x, y); + mp_input_set_mouse_pos(w32->input_ctx, x, y); } break; } @@ -664,7 +664,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, mouse_button |= mod_state(w32); mp_input_put_key(w32->input_ctx, mouse_button); - if (w32->opts->enable_mouse_movements) { + if (mp_input_mouse_enabled(w32->input_ctx)) { int x = GET_X_LPARAM(lParam); int y = GET_Y_LPARAM(lParam); diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index fe6142c89a..1feb0080d4 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -340,8 +340,8 @@ static void pointer_handle_motion(void *data, wl->window.mouse_x = wl_fixed_to_int(sx_w); wl->window.mouse_y = wl_fixed_to_int(sy_w); - vo_mouse_movement(wl->vo, wl->window.mouse_x, - wl->window.mouse_y); + mp_input_set_mouse_pos(wl->vo->input_ctx, wl->window.mouse_x, + wl->window.mouse_y); } static void pointer_handle_button(void *data, diff --git a/video/out/x11_common.c b/video/out/x11_common.c index f43c5c03a8..539d66e641 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -835,7 +835,8 @@ int vo_x11_check_events(struct vo *vo) }; x11_send_ewmh_msg(x11, "_NET_WM_MOVERESIZE", params); } else { - vo_mouse_movement(vo, Event.xmotion.x, Event.xmotion.y); + mp_input_set_mouse_pos(vo->input_ctx, Event.xmotion.x, + Event.xmotion.y); } x11->win_drag_button1_down = false; break; @@ -1560,7 +1561,7 @@ static void vo_x11_selectinput_witherr(struct vo *vo, Window w, long event_mask) { - if (!vo->opts->enable_mouse_movements) + if (!mp_input_mouse_enabled(vo->input_ctx)) event_mask &= ~(PointerMotionMask | ButtonPressMask | ButtonReleaseMask); XSelectInput(display, w, NoEventMask); -- cgit v1.2.3