haiku: mouse->ShowMouse method added
authorPeter Kosyh <p.kosyh@gmail.com>
Mon, 11 Nov 2019 22:22:40 -0500
changeset 1323600da92ddae19
parent 13235 7e53f9a1d5e4
child 13237 f5298e605071
haiku: mouse->ShowMouse method added

Partially fixes Bugzilla #4442.
src/main/haiku/SDL_BApp.h
src/video/haiku/SDL_bvideo.cc
     1.1 --- a/src/main/haiku/SDL_BApp.h	Mon Nov 11 22:21:17 2019 -0500
     1.2 +++ b/src/main/haiku/SDL_BApp.h	Mon Nov 11 22:22:40 2019 -0500
     1.3 @@ -244,7 +244,7 @@
     1.4  				be_app->HideCursor();
     1.5  		} else {
     1.6  			SDL_SendMouseMotion(win, 0, 0, x, y);
     1.7 -			if (be_app->IsCursorHidden())
     1.8 +			if (SDL_ShowCursor(-1) && be_app->IsCursorHidden())
     1.9  				be_app->ShowCursor();
    1.10  		}
    1.11  
     2.1 --- a/src/video/haiku/SDL_bvideo.cc	Mon Nov 11 22:21:17 2019 -0500
     2.2 +++ b/src/video/haiku/SDL_bvideo.cc	Mon Nov 11 22:22:40 2019 -0500
     2.3 @@ -19,6 +19,7 @@
     2.4    3. This notice may not be removed or altered from any source distribution.
     2.5  */
     2.6  #include "../../SDL_internal.h"
     2.7 +#include "../../main/haiku/SDL_BApp.h"
     2.8  
     2.9  #if SDL_VIDEO_DRIVER_HAIKU
    2.10  
    2.11 @@ -132,6 +133,33 @@
    2.12      SDL_free(device);
    2.13  }
    2.14  
    2.15 +static int HAIKU_ShowCursor(SDL_Cursor *cur)
    2.16 +{
    2.17 +	SDL_Mouse *mouse = SDL_GetMouse();
    2.18 +	int show;
    2.19 +	if (!mouse)
    2.20 +		return 0;
    2.21 +	show = (cur || !mouse->focus);
    2.22 +	if (show) {
    2.23 +		if (be_app->IsCursorHidden())
    2.24 +			be_app->ShowCursor();
    2.25 +	} else {
    2.26 +		if (!be_app->IsCursorHidden())
    2.27 +			be_app->HideCursor();
    2.28 +	}
    2.29 +	return 0;
    2.30 +}
    2.31 +
    2.32 +static void HAIKU_MouseInit(_THIS)
    2.33 +{
    2.34 +	SDL_Mouse *mouse = SDL_GetMouse();
    2.35 +	if (!mouse)
    2.36 +		return;
    2.37 +	mouse->ShowCursor = HAIKU_ShowCursor;
    2.38 +	mouse->cur_cursor = (SDL_Cursor*)0x1;
    2.39 +	mouse->def_cursor = (SDL_Cursor*)0x2;
    2.40 +}
    2.41 +
    2.42  int HAIKU_VideoInit(_THIS)
    2.43  {
    2.44      /* Initialize the Be Application for appserver interaction */
    2.45 @@ -145,6 +173,8 @@
    2.46      /* Init the keymap */
    2.47      HAIKU_InitOSKeymap();
    2.48  
    2.49 +    HAIKU_MouseInit(_this);
    2.50 +
    2.51  #if SDL_VIDEO_OPENGL
    2.52          /* testgl application doesn't load library, just tries to load symbols */
    2.53          /* is it correct? if so we have to load library here */