haiku: Add simple relative mode for mouse.
authorGerasim Troeglazov <3dEyes@gmail.com>
Mon, 11 Nov 2019 22:18:21 -0500
changeset 13234c6c5c0c9ad2b
parent 13233 9dfa95a693ba
child 13235 7e53f9a1d5e4
haiku: Add simple relative mode for mouse.

Partially fixes Bugzilla #4442.
src/main/haiku/SDL_BApp.h
     1.1 --- a/src/main/haiku/SDL_BApp.h	Mon Nov 11 22:14:00 2019 -0500
     1.2 +++ b/src/main/haiku/SDL_BApp.h	Mon Nov 11 22:18:21 2019 -0500
     1.3 @@ -230,6 +230,21 @@
     1.4          win = GetSDLWindow(winID);
     1.5          SDL_SendMouseMotion(win, 0, 0, x, y);
     1.6  
     1.7 +		// Simple relative mode support for mouse.
     1.8 +		if ((SDL_GetMouse()->relative_mode ||
     1.9 +			(win->flags & SDL_WINDOW_INPUT_GRABBED)) &&
    1.10 +			(win->flags & SDL_WINDOW_INPUT_FOCUS)) {
    1.11 +			int winWidth, winHeight, winPosX, winPosY;
    1.12 +			SDL_GetWindowSize(win, &winWidth, &winHeight);
    1.13 +			SDL_GetWindowPosition(win, &winPosX, &winPosY);
    1.14 +			set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2));
    1.15 +			if (!be_app->IsCursorHidden())
    1.16 +				be_app->HideCursor();
    1.17 +		} else {
    1.18 +			if (be_app->IsCursorHidden())
    1.19 +				be_app->ShowCursor();
    1.20 +		}
    1.21 +
    1.22          /* Tell the application that the mouse passed over, redraw needed */
    1.23          HAIKU_UpdateWindowFramebuffer(NULL,win,NULL,-1);
    1.24      }