Skip to content

Commit

Permalink
haiku: Add simple relative mode for mouse.
Browse files Browse the repository at this point in the history
Partially fixes Bugzilla #4442.
  • Loading branch information
threedeyes committed Nov 12, 2019
1 parent 3b516e6 commit bd648bd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/haiku/SDL_BApp.h
Expand Up @@ -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);
}
Expand Down

0 comments on commit bd648bd

Please sign in to comment.