1
0
Эх сурвалжийг харах

Added support for extended buttons on Wayland

Fixes https://github.com/libsdl-org/SDL/issues/14681
Sam Lantinga 2 сар өмнө
parent
commit
9fe5c1512f

+ 8 - 8
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) {