Преглед на файлове

Treat a button press location as an implicit mouse move

This fixes having the incorrect location for mouse button presses on Steam Deck under gamescope. This works around a bug where the mouse motion appears to come at the next button press, and comes from the xwayland-pointer device instead of the xwayland-relative-pointer device which is delivering mouse button events.
Sam Lantinga преди 6 месеца
родител
ревизия
cbbad4051b
променени са 1 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. 7 0
      src/video/x11/SDL_x11events.c

+ 7 - 0
src/video/x11/SDL_x11events.c

@@ -894,6 +894,13 @@ void X11_HandleButtonPress(SDL_VideoDevice *_this, SDL_WindowData *windowdata, S
 #ifdef DEBUG_XEVENTS
     SDL_Log("window 0x%lx: ButtonPress (X11 button = %d)\n", windowdata->xwindow, button);
 #endif
+
+    SDL_Mouse *mouse = SDL_GetMouse();
+    if ((!mouse->relative_mode || mouse->relative_mode_warp) && (x != mouse->x || y != mouse->y)) {
+        X11_ProcessHitTest(_this, windowdata, x, y, false);
+        SDL_SendMouseMotion(0, window, mouseID, false, x, y);
+    }
+
     if (X11_IsWheelEvent(display, button, &xticks, &yticks)) {
         SDL_SendMouseWheel(0, window, mouseID, (float)-xticks, (float)yticks, SDL_MOUSEWHEEL_NORMAL);
     } else {