From bd648bd5a3406b87f42035b5e75eea1ccae1b803 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Mon, 11 Nov 2019 22:18:21 -0500 Subject: [PATCH] haiku: Add simple relative mode for mouse. Partially fixes Bugzilla #4442. --- src/main/haiku/SDL_BApp.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/haiku/SDL_BApp.h b/src/main/haiku/SDL_BApp.h index 086c8474a9ff8..f01ccda84c98b 100644 --- a/src/main/haiku/SDL_BApp.h +++ b/src/main/haiku/SDL_BApp.h @@ -230,6 +230,21 @@ class SDL_BApp : public BApplication { win = GetSDLWindow(winID); SDL_SendMouseMotion(win, 0, 0, x, y); + // Simple relative mode support for mouse. + if ((SDL_GetMouse()->relative_mode || + (win->flags & SDL_WINDOW_INPUT_GRABBED)) && + (win->flags & SDL_WINDOW_INPUT_FOCUS)) { + int winWidth, winHeight, winPosX, winPosY; + SDL_GetWindowSize(win, &winWidth, &winHeight); + SDL_GetWindowPosition(win, &winPosX, &winPosY); + set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2)); + if (!be_app->IsCursorHidden()) + be_app->HideCursor(); + } else { + if (be_app->IsCursorHidden()) + be_app->ShowCursor(); + } + /* Tell the application that the mouse passed over, redraw needed */ HAIKU_UpdateWindowFramebuffer(NULL,win,NULL,-1); }