haiku: Add simple relative mode for mouse.

Partially fixes Bugzilla #4442.
Gerasim Troeglazov 2019-11-11 22:18:21 -05:00
parent 3b516e633b
commit bd648bd5a3
1 changed files with 15 additions and 0 deletions

View File

@ -230,6 +230,21 @@ private:
win = GetSDLWindow(winID); win = GetSDLWindow(winID);
SDL_SendMouseMotion(win, 0, 0, x, y); 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 */ /* Tell the application that the mouse passed over, redraw needed */
HAIKU_UpdateWindowFramebuffer(NULL,win,NULL,-1); HAIKU_UpdateWindowFramebuffer(NULL,win,NULL,-1);
} }