Add support binding on-click handlers to other buttons than LEFT

One can now bind the left/middle/right mouse buttons to on-click. In
fact, you can have all three buttons bound to different handlers for
the same particle. The new syntax is

    on-click:
        left: <command>
        middle: <command>
        right: <command>

Leaving one out is the same thing as not mapping it at
all. Furthermore,

    on-click: <command>

is still valid, and is a shorthand for

    on-click:
        left: <commsnd>
This commit is contained in:
Daniel Eklöf 2021-06-22 19:04:13 +02:00
parent af163d3f77
commit c79ffbe057
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
15 changed files with 163 additions and 90 deletions

View file

@ -272,26 +272,25 @@ static void
wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
{
if (state != WL_POINTER_BUTTON_STATE_PRESSED)
return;
struct seat *seat = data;
struct wayland_backend *backend = seat->backend;
backend->active_seat = seat;
if (state == WL_POINTER_BUTTON_STATE_PRESSED)
backend->active_seat = seat;
else {
enum mouse_button btn;
enum mouse_button btn;
switch (button) {
case BTN_LEFT: btn = MOUSE_BTN_LEFT; break;
case BTN_MIDDLE: btn = MOUSE_BTN_MIDDLE; break;
case BTN_RIGHT: btn = MOUSE_BTN_RIGHT; break;
default:
return;
}
switch (button) {
case BTN_LEFT: btn = MOUSE_BTN_LEFT; break;
case BTN_MIDDLE: btn = MOUSE_BTN_MIDDLE; break;
case BTN_RIGHT: btn = MOUSE_BTN_RIGHT; break;
default:
return;
backend->bar_on_mouse(
backend->bar, ON_MOUSE_CLICK, btn, seat->pointer.x, seat->pointer.y);
}
backend->bar_on_mouse(
backend->bar, ON_MOUSE_CLICK, btn, seat->pointer.x, seat->pointer.y);
}
static void