Added support for extended buttons on Wayland
Some checks failed
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled

Fixes https://github.com/libsdl-org/SDL/issues/14681
This commit is contained in:
Sam Lantinga
2025-12-27 14:50:43 -08:00
parent 89dd2426cf
commit 9fe5c1512f

View File

@@ -871,7 +871,12 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer,
SDL_WaylandSeat *seat = (SDL_WaylandSeat *)data;
seat->pointer.focus = NULL;
seat->pointer.buttons_pressed = 0;
for (int i = 0; seat->pointer.buttons_pressed; ++i) {
if (seat->pointer.buttons_pressed & SDL_BUTTON_MASK(i)) {
SDL_SendMouseButton(0, window->sdlwindow, seat->pointer.sdl_id, i, false);
seat->pointer.buttons_pressed &= ~SDL_BUTTON_MASK(i);
}
}
SDL_SendMouseButton(0, window->sdlwindow, seat->pointer.sdl_id, SDL_BUTTON_LEFT, false);
SDL_SendMouseButton(0, window->sdlwindow, seat->pointer.sdl_id, SDL_BUTTON_RIGHT, false);
SDL_SendMouseButton(0, window->sdlwindow, seat->pointer.sdl_id, SDL_BUTTON_MIDDLE, false);
@@ -992,14 +997,9 @@ static void pointer_handle_button_common(SDL_WaylandSeat *seat, uint32_t serial,
case BTN_RIGHT:
sdl_button = SDL_BUTTON_RIGHT;
break;
case BTN_SIDE:
sdl_button = SDL_BUTTON_X1;
break;
case BTN_EXTRA:
sdl_button = SDL_BUTTON_X2;
break;
default:
return;
sdl_button = SDL_BUTTON_X1 + (button - BTN_SIDE);
break;
}
if (window) {