From d276a01ac3fd8655a48c4a39d3d8574c25e83027 Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Fri, 17 Mar 2017 06:25:32 +0000 Subject: wayland_common: organize and correctly map mouse buttons The function tried to do something clever but ignored the fact that the middle button followed the left button rather than the right. Signed-off-by: Rostislav Pehlivanov --- video/out/wayland_common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'video') diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 35d0dfed51..63f7ac235e 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -445,12 +445,16 @@ static void pointer_handle_button(void *data, { struct vo_wayland_state *wl = data; - mp_input_put_key(wl->vo->input_ctx, (MP_MOUSE_BTN0 + (button - BTN_LEFT)) | - ((state == WL_POINTER_BUTTON_STATE_PRESSED) - ? MP_KEY_STATE_DOWN : MP_KEY_STATE_UP)); + state = state == WL_POINTER_BUTTON_STATE_PRESSED ? MP_KEY_STATE_DOWN + : MP_KEY_STATE_UP; + + button = button == BTN_LEFT ? MP_MOUSE_BTN0 : + button == BTN_MIDDLE ? MP_MOUSE_BTN1 : MP_MOUSE_BTN2; + + mp_input_put_key(wl->vo->input_ctx, button | state); if (!mp_input_test_dragging(wl->vo->input_ctx, wl->window.mouse_x, wl->window.mouse_y) && - (button == BTN_LEFT) && (state == WL_POINTER_BUTTON_STATE_PRESSED)) + (button == MP_MOUSE_BTN0) && (state == MP_KEY_STATE_DOWN)) window_move(wl, serial); } -- cgit v1.2.3