8bitbubsy / ft2-clone

Fasttracker 2 clone for Windows/macOS/Linux
https://16-bits.org
BSD 3-Clause "New" or "Revised" License
712 stars 48 forks source link

wayland mouse offset #21

Closed oskude closed 3 years ago

oskude commented 3 years ago

on wayland, when using hardware mouse, the mouse click is not registered where the mouse cursor is.

i tinkered a bit and this could be a good fix:

diff --git a/src/ft2_video.c b/src/ft2_video.c
index 026a8e6..49b4f79 100644
--- a/src/ft2_video.c
+++ b/src/ft2_video.c
@@ -1006,10 +1006,10 @@ bool setupRenderer(void)
    else
        SDL_ShowCursor(SDL_FALSE);

-   // Workaround: SDL_GetGlobalMouseState() doesn't work with KMSDRM
+   // Workaround: SDL_GetGlobalMouseState() doesn't work with KMSDRM/Wayland
    video.useDesktopMouseCoords = true;
    const char *videoDriver = SDL_GetCurrentVideoDriver();
-   if (videoDriver != NULL && strcmp("KMSDRM", videoDriver) == 0)
+   if (videoDriver != NULL && (strcmp("KMSDRM", videoDriver) == 0 || strcmp("wayland", videoDriver) == 0))
        video.useDesktopMouseCoords = false;

    SDL_SetRenderDrawColor(video.renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);

i've tested above change in:

and it seems to fix the issue (and not break on xorg).

8bitbubsy commented 3 years ago

Thanks, nice and clean fix. I'll integrate it into the current code base. However, I'm not sure when I'll release a new version, it might not be any time soon...

oskude commented 3 years ago

no rush with release, i can build my packages easily from git :)