summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordudemanguy <random342@airmail.cc>2019-07-11 09:02:33 -0500
committerwm4 <1387750+wm4@users.noreply.github.com>2019-09-21 14:35:03 +0200
commitf54ad8eb055771a080f079964504cb0f32fc4014 (patch)
treedcc81316e3c72952ee4eb28de3bb69380ac7ffb6
parenta41f1a21d67b3d3dd6b173e563176f90074f589e (diff)
downloadmpv-f54ad8eb055771a080f079964504cb0f32fc4014.tar.bz2
mpv-f54ad8eb055771a080f079964504cb0f32fc4014.tar.xz
wayland: add mouse buttons and fix axis scaling
Previously, the only mouse buttons supported in wayland were left, right, and middle click. This adds the thumb back/forward buttons as valid bindings. Also it removes the old, default behavior of always sending a right click if an unrecognized mouse button is clicked. In a related but different fix, the magnitude of an axis event in wayland is not important to mpv since it internally handles all scaling. The only thing we care about is getting the sign when the event occurs.
-rw-r--r--video/out/wayland_common.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index ab5594b4e4..df64578e5c 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -137,10 +137,30 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
state = state == WL_POINTER_BUTTON_STATE_PRESSED ? MP_KEY_STATE_DOWN
: MP_KEY_STATE_UP;
- button = button == BTN_LEFT ? MP_MBTN_LEFT :
- button == BTN_MIDDLE ? MP_MBTN_MID : MP_MBTN_RIGHT;
+ switch (button) {
+ case BTN_LEFT:
+ button = MP_MBTN_LEFT;
+ break;
+ case BTN_MIDDLE:
+ button = MP_MBTN_MID;
+ break;
+ case BTN_RIGHT:
+ button = MP_MBTN_RIGHT;
+ break;
+ case BTN_SIDE:
+ button = MP_MBTN_BACK;
+ break;
+ case BTN_EXTRA:
+ button = MP_MBTN_FORWARD;
+ break;
+ default:
+ button = 0;
+ break;
+ }
- mp_input_put_key(wl->vo->input_ctx, button | state);
+ if (button) {
+ mp_input_put_key(wl->vo->input_ctx, button | state);
+ }
if (!mp_input_test_dragging(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y) &&
(button == MP_MBTN_LEFT) && (state == MP_KEY_STATE_DOWN))
@@ -151,7 +171,7 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
struct vo_wayland_state *wl = data;
- double val = wl_fixed_to_double(value)*0.1;
+ double val = wl_fixed_to_double(value)/abs(wl_fixed_to_double(value));
switch (axis) {
case WL_POINTER_AXIS_VERTICAL_SCROLL:
if (value > 0)