particle/on-click: support next/previous buttons

This commit is contained in:
Peter Rice 2022-09-24 00:31:44 -04:00 committed by Daniel Eklöf
parent 8d5deda4e4
commit 6ed576c719
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 22 additions and 0 deletions

View file

@ -27,11 +27,13 @@
* new module: disk-io.
* alsa: `dB` tag ([#202][202])
* mpd: `file` tag ([#219][219]).
* on-click: support `next`/`previous` mouse buttons ([#228][228]).
[153]: https://codeberg.org/dnkl/yambar/issues/153
[159]: https://codeberg.org/dnkl/yambar/issues/159
[202]: https://codeberg.org/dnkl/yambar/issues/202
[219]: https://codeberg.org/dnkl/yambar/pulls/219
[228]: https://codeberg.org/dnkl/yambar/pulls/228
### Changed

View file

@ -292,6 +292,8 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
case BTN_LEFT: btn = MOUSE_BTN_LEFT; break;
case BTN_MIDDLE: btn = MOUSE_BTN_MIDDLE; break;
case BTN_RIGHT: btn = MOUSE_BTN_RIGHT; break;
case BTN_SIDE: btn = MOUSE_BTN_PREVIOUS; break;
case BTN_EXTRA: btn = MOUSE_BTN_NEXT; break;
default:
return;
}

View file

@ -188,6 +188,8 @@ conf_verify_on_click(keychain_t *chain, const struct yml_node *node)
{"right", false, &conf_verify_string},
{"wheel-up", false, &conf_verify_string},
{"wheel-down", false, &conf_verify_string},
{"previous", false, &conf_verify_string},
{"next", false, &conf_verify_string},
{NULL, false, NULL},
};

View file

@ -236,6 +236,10 @@ conf_to_particle(const struct yml_node *node, struct conf_inherit inherited)
on_click_templates[MOUSE_BTN_WHEEL_UP] = template;
else if (strcmp(key, "wheel-down") == 0)
on_click_templates[MOUSE_BTN_WHEEL_DOWN] = template;
else if (strcmp(key, "previous") == 0)
on_click_templates[MOUSE_BTN_PREVIOUS] = template;
else if (strcmp(key, "next") == 0)
on_click_templates[MOUSE_BTN_NEXT] = template;
else
assert(false);
}

View file

@ -68,6 +68,14 @@ following attributes are supported by all particles:
: string
: no
: Command to execute every time a 'wheel-down' event is triggered.
| on-click.previous
: string
: no
: Command to execute when the particle is clicked with the 'previous' button.
| on-click.next
: string
: no
: Command to execute when the particle is clicked with the 'next' button.
| deco
: decoration
: no

View file

@ -165,6 +165,8 @@ exposable_default_on_mouse(struct exposable *exposable, struct bar *bar,
[MOUSE_BTN_COUNT] = "count",
[MOUSE_BTN_WHEEL_UP] = "wheel-up",
[MOUSE_BTN_WHEEL_DOWN] = "wheel-down",
[MOUSE_BTN_PREVIOUS] = "previous",
[MOUSE_BTN_NEXT] = "next",
};
LOG_DBG("on_mouse: exposable=%p, event=%s, btn=%s, x=%d, y=%d (on-click=%s)",
exposable, event == ON_MOUSE_MOTION ? "motion" : "click",

View file

@ -20,6 +20,8 @@ enum mouse_button {
MOUSE_BTN_RIGHT,
MOUSE_BTN_WHEEL_UP,
MOUSE_BTN_WHEEL_DOWN,
MOUSE_BTN_PREVIOUS,
MOUSE_BTN_NEXT,
MOUSE_BTN_COUNT,
};