mirror of
https://github.com/mpv-player/mpv
synced 2025-01-02 21:12:23 +00:00
vo: remove vo_mouse_movement() wrapper
So that VO backends don't have to access the VO just for that.
This commit is contained in:
parent
89391e7c94
commit
4c533fbb16
@ -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,
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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,
|
||||
|
@ -29,8 +29,6 @@ typedef struct mp_vo_opts {
|
||||
int keepaspect;
|
||||
int border;
|
||||
|
||||
int enable_mouse_movements;
|
||||
|
||||
int64_t WinID;
|
||||
|
||||
float force_monitor_aspect;
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user