mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-15 06:59:43 -05:00
seat/pointer: handle duplicate presses/releases correctly
This commit is contained in:
parent
775817e278
commit
8730ca9661
3 changed files with 36 additions and 17 deletions
|
|
@ -6,7 +6,6 @@
|
|||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "types/wlr_seat.h"
|
||||
#include "util/set.h"
|
||||
|
||||
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
|
||||
struct wlr_surface *surface, double sx, double sy) {
|
||||
|
|
@ -463,14 +462,38 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
|
|||
pointer_state->grab_button = button;
|
||||
pointer_state->grab_time = time;
|
||||
}
|
||||
set_add(pointer_state->buttons, &pointer_state->button_count,
|
||||
WLR_POINTER_BUTTONS_CAP, button);
|
||||
for (size_t i = 0; i < pointer_state->button_count; i++) {
|
||||
struct wlr_seat_pointer_button *pointer_button = &pointer_state->buttons[i];
|
||||
if (pointer_button->button == button) {
|
||||
++pointer_button->n_pressed;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (pointer_state->button_count == WLR_POINTER_BUTTONS_CAP) {
|
||||
return 0;
|
||||
}
|
||||
pointer_state->buttons[pointer_state->button_count++] = (struct wlr_seat_pointer_button){
|
||||
.button = button,
|
||||
.n_pressed = 1,
|
||||
};
|
||||
} else {
|
||||
set_remove(pointer_state->buttons, &pointer_state->button_count,
|
||||
WLR_POINTER_BUTTONS_CAP, button);
|
||||
bool found = false;
|
||||
for (size_t i = 0; i < pointer_state->button_count; i++) {
|
||||
struct wlr_seat_pointer_button *pointer_button = &pointer_state->buttons[i];
|
||||
if (pointer_button->button == button) {
|
||||
if (--pointer_button->n_pressed > 0) {
|
||||
return 0;
|
||||
}
|
||||
*pointer_button = pointer_state->buttons[--pointer_state->button_count];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct wlr_seat_pointer_grab *grab = pointer_state->grab;
|
||||
uint32_t serial = grab->interface->button(grab, time, button, state);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue