summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-10 15:57:36 +0200
committersfan5 <sfan5@live.de>2018-05-25 10:17:06 +0200
commiteb08cd75c1f821e55a6c56eec574c058815384bc (patch)
treec8a79edc694f5891fcae4dcd57622918dc5c114f
parent25525cee62cdf863b1b7db768e7d594a20df21c7 (diff)
downloadmpv-eb08cd75c1f821e55a6c56eec574c058815384bc.tar.bz2
mpv-eb08cd75c1f821e55a6c56eec574c058815384bc.tar.xz
input: add a define for the number of mouse buttons and use it
(Why the fuck are there up to 20 mouse buttons?)
-rw-r--r--input/keycodes.h2
-rw-r--r--player/command.c2
-rw-r--r--video/out/x11_common.c4
3 files changed, 7 insertions, 1 deletions
diff --git a/input/keycodes.h b/input/keycodes.h
index 740ca873fc..604fee53dc 100644
--- a/input/keycodes.h
+++ b/input/keycodes.h
@@ -135,6 +135,8 @@
#define MP_KEY_IS_MOUSE_BTN_DBL(code) \
((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
+#define MP_KEY_MOUSE_BTN_COUNT (MP_MBTN_END - MP_MBTN_BASE)
+
// Apple Remote input module
#define MP_AR_BASE (MP_KEY_BASE+0xE0)
#define MP_AR_PLAY (MP_AR_BASE + 0)
diff --git a/player/command.c b/player/command.c
index cc8b609c50..60fb7447e1 100644
--- a/player/command.c
+++ b/player/command.c
@@ -5757,7 +5757,7 @@ static void cmd_mouse(void *p)
mp_input_set_mouse_pos_artificial(mpctx->input, x, y);
return;
}
- if (button < 0 || button >= 20) {// invalid button
+ if (button < 0 || button >= MP_KEY_MOUSE_BTN_COUNT) {// invalid button
MP_ERR(mpctx, "%d is not a valid mouse button number.\n", button);
cmd->success = false;
return;
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 79aac3f136..25325e760c 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1133,6 +1133,8 @@ void vo_x11_check_events(struct vo *vo)
mp_input_put_key(x11->input_ctx, MP_KEY_MOUSE_ENTER);
break;
case ButtonPress:
+ if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT)
+ break;
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = true;
mp_input_put_key(x11->input_ctx,
@@ -1142,6 +1144,8 @@ void vo_x11_check_events(struct vo *vo)
vo_x11_xembed_send_message(x11, msg);
break;
case ButtonRelease:
+ if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT)
+ break;
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = false;
mp_input_put_key(x11->input_ctx,