1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-09 16:37:24 +00:00

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 <atomnuker@gmail.com>
This commit is contained in:
Rostislav Pehlivanov 2017-03-17 06:25:32 +00:00
parent 38872463a0
commit d276a01ac3

View File

@ -445,12 +445,16 @@ static void pointer_handle_button(void *data,
{ {
struct vo_wayland_state *wl = data; struct vo_wayland_state *wl = data;
mp_input_put_key(wl->vo->input_ctx, (MP_MOUSE_BTN0 + (button - BTN_LEFT)) | state = state == WL_POINTER_BUTTON_STATE_PRESSED ? MP_KEY_STATE_DOWN
((state == WL_POINTER_BUTTON_STATE_PRESSED) : MP_KEY_STATE_UP;
? 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) && 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); window_move(wl, serial);
} }