mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-09 08:21:01 -04:00
input: fix assertion when pressing first one mouse button, then another
This commit is contained in:
parent
6e4d29ef71
commit
5f64c5c335
1 changed files with 58 additions and 59 deletions
117
input.c
117
input.c
|
|
@ -1493,77 +1493,76 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case WL_POINTER_BUTTON_STATE_PRESSED: {
|
case WL_POINTER_BUTTON_STATE_PRESSED: {
|
||||||
assert(!seat->mouse.consumed);
|
if (!seat->mouse.consumed) {
|
||||||
|
if (seat->wl_keyboard != NULL) {
|
||||||
|
/* Seat has keyboard - use mouse bindings *with* modifiers */
|
||||||
|
|
||||||
if (seat->wl_keyboard != NULL) {
|
xkb_mod_mask_t mods = xkb_state_serialize_mods(
|
||||||
/* Seat has keyboard - use mouse bindings *with* modifiers */
|
seat->kbd.xkb_state, XKB_STATE_MODS_DEPRESSED);
|
||||||
|
|
||||||
xkb_mod_mask_t mods = xkb_state_serialize_mods(
|
/* Ignore Shift when matching modifiers, since it is
|
||||||
seat->kbd.xkb_state, XKB_STATE_MODS_DEPRESSED);
|
* used to enable selection in mouse grabbing client
|
||||||
|
* applications */
|
||||||
|
mods &= ~(1 << seat->kbd.mod_shift);
|
||||||
|
|
||||||
/* Ignore Shift when matching modifiers, since it is
|
tll_foreach(seat->mouse.bindings, it) {
|
||||||
* used to enable selection in mouse grabbing client
|
const struct mouse_binding *binding = &it->item;
|
||||||
* applications */
|
|
||||||
mods &= ~(1 << seat->kbd.mod_shift);
|
|
||||||
|
|
||||||
tll_foreach(seat->mouse.bindings, it) {
|
if (binding->button != button) {
|
||||||
const struct mouse_binding *binding = &it->item;
|
/* Wrong button */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (binding->button != button) {
|
if (binding->mods != mods) {
|
||||||
/* Wrong button */
|
/* Modifier mismatch */
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binding->count != seat->mouse.count) {
|
||||||
|
/* Not correct click count */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
seat->mouse.consumed = execute_binding(
|
||||||
|
seat, term, binding->action, NULL, serial);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding->mods != mods) {
|
|
||||||
/* Modifier mismatch */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (binding->count != seat->mouse.count) {
|
|
||||||
/* Not correct click count */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
seat->mouse.consumed = execute_binding(
|
|
||||||
seat, term, binding->action, NULL, serial);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
/* Seat does NOT have a keyboard - use mouse bindings *without* modifiers */
|
/* Seat does NOT have a keyboard - use mouse bindings *without* modifiers */
|
||||||
tll_foreach(seat->wayl->conf->bindings.mouse, it) {
|
tll_foreach(seat->wayl->conf->bindings.mouse, it) {
|
||||||
const struct config_mouse_binding *binding = &it->item;
|
const struct config_mouse_binding *binding = &it->item;
|
||||||
|
|
||||||
if (binding->button != button) {
|
if (binding->button != button) {
|
||||||
/* Wrong button */
|
/* Wrong button */
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binding->count != seat->mouse.count) {
|
||||||
|
/* Incorrect click count */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct config_key_modifiers no_mods = {0};
|
||||||
|
if (memcmp(&binding->modifiers, &no_mods, sizeof(no_mods)) != 0) {
|
||||||
|
/* Binding has modifiers */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
seat->mouse.consumed = execute_binding(
|
||||||
|
seat, term, binding->action, NULL, serial);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding->count != seat->mouse.count) {
|
|
||||||
/* Incorrect click count */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct config_key_modifiers no_mods = {0};
|
|
||||||
if (memcmp(&binding->modifiers, &no_mods, sizeof(no_mods)) != 0) {
|
|
||||||
/* Binding has modifiers */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
seat->mouse.consumed = execute_binding(
|
|
||||||
seat, term, binding->action, NULL, serial);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!seat->mouse.consumed &&
|
if (!term_mouse_grabbed(term, seat) &&
|
||||||
!term_mouse_grabbed(term, seat) &&
|
cursor_is_on_grid)
|
||||||
cursor_is_on_grid)
|
{
|
||||||
{
|
term_mouse_down(
|
||||||
term_mouse_down(
|
term, button, seat->mouse.row, seat->mouse.col,
|
||||||
term, button, seat->mouse.row, seat->mouse.col,
|
seat->kbd.shift, seat->kbd.alt, seat->kbd.ctrl);
|
||||||
seat->kbd.shift, seat->kbd.alt, seat->kbd.ctrl);
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue