diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index be3d1930a2..1755813297 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -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) {