Skip to content

Commit

Permalink
Fix mouse warping on wayland. (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
codecnotsupported authored Jul 3, 2024
1 parent 3cbbbb0 commit f3001b2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rts/System/Input/MouseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ bool IMouseInput::SetPos(int2 pos)

bool IMouseInput::WarpPos(int2 pos)
{
#if __unix__
/* Needed for SDL2+Wayland where warping isn't allowed otherwise, works fine with X11.
* One would think there should be a corresponding `SDL_ShowCursor(SDL_ENABLE);` below,
* but apparently this prevents this work-around from working (?!). */
SDL_ShowCursor(SDL_DISABLE);
#endif

SDL_WarpMouseInWindow(globalRendering->GetWindow(), pos.x, pos.y);

// SDL_WarpMouse generates SDL_MOUSEMOTION events
Expand Down

0 comments on commit f3001b2

Please sign in to comment.