Fix mouse cursor change
authorPatrice Mandin <patmandin@gmail.com>
Wed, 14 Jun 2006 18:57:58 +0000
changeset 1857417f2af2bd52
parent 1856 21f13c787b46
child 1858 d3ac464fb3c1
Fix mouse cursor change
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemmouse.c
src/video/gem/SDL_gemvideo.c
src/video/gem/SDL_gemvideo.h
     1.1 --- a/src/video/gem/SDL_gemevents.c	Tue May 23 15:07:56 2006 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Wed Jun 14 18:57:58 2006 +0000
     1.3 @@ -186,8 +186,18 @@
     1.4  			if (this->input_grab == SDL_GRAB_OFF) {
     1.5  				if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) {
     1.6  					SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
     1.7 +					if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
     1.8 +						graf_mouse(ARROW, NULL);
     1.9 +					}
    1.10  				} else {
    1.11  					SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.12 +					if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
    1.13 +						if (GEM_cursor == (void *) -1) {
    1.14 +							graf_mouse(M_OFF, NULL);
    1.15 +						} else if (GEM_cursor) {
    1.16 +							graf_mouse(USER_DEF, GEM_cursor->mform_p);
    1.17 +						}
    1.18 +					}
    1.19  				}
    1.20  			}
    1.21  		}
     2.1 --- a/src/video/gem/SDL_gemmouse.c	Tue May 23 15:07:56 2006 +0000
     2.2 +++ b/src/video/gem/SDL_gemmouse.c	Wed Jun 14 18:57:58 2006 +0000
     2.3 @@ -33,6 +33,7 @@
     2.4  #include "../../events/SDL_events_c.h"
     2.5  #include "../SDL_cursor_c.h"
     2.6  #include "SDL_gemmouse_c.h"
     2.7 +#include "SDL_gemvideo.h"
     2.8  
     2.9  /* Defines */
    2.10  
    2.11 @@ -41,14 +42,12 @@
    2.12  #define MAXCURWIDTH 16
    2.13  #define MAXCURHEIGHT 16
    2.14  
    2.15 -/* The implementation dependent data for the window manager cursor */
    2.16 -struct WMcursor {
    2.17 -	MFORM *mform_p;
    2.18 -};
    2.19 -
    2.20 -
    2.21  void GEM_FreeWMCursor(_THIS, WMcursor *cursor)
    2.22  {
    2.23 +#ifdef DEBUG_VIDEO_GEM
    2.24 +	printf("sdl:video:gem: free cursor\n");
    2.25 +#endif
    2.26 +
    2.27  	if (cursor == NULL)
    2.28  		return;
    2.29  	
    2.30 @@ -67,6 +66,12 @@
    2.31  	MFORM *new_mform;
    2.32  	int i;
    2.33  
    2.34 +#ifdef DEBUG_VIDEO_GEM
    2.35 +	Uint16 *data1, *mask1;
    2.36 +
    2.37 +	printf("sdl:video:gem: create cursor\n");
    2.38 +#endif
    2.39 +
    2.40  	/* Check the size */
    2.41  	if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) {
    2.42  		SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
    2.43 @@ -100,6 +105,12 @@
    2.44  	for (i=0;i<MAXCURHEIGHT;i++) {
    2.45  		new_mform->mf_mask[i]=0;
    2.46  		new_mform->mf_data[i]=0;
    2.47 +#ifdef DEBUG_VIDEO_GEM
    2.48 +		data1 = (Uint16 *) &data[i<<1];
    2.49 +		mask1 = (Uint16 *) &mask[i<<1];
    2.50 +		printf("sdl:video:gem: source: line %d: data=0x%04x, mask=0x%04x\n",
    2.51 +			i, data1[i], mask1[i]);
    2.52 +#endif
    2.53  	}
    2.54  
    2.55  	if (w<=8) {
    2.56 @@ -109,14 +120,15 @@
    2.57  		}
    2.58  	} else {
    2.59  		for (i=0;i<h;i++) {
    2.60 -			new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1];
    2.61 -			new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1];
    2.62 +			new_mform->mf_mask[i]= (mask[i<<1]<<8) | mask[(i<<1)+1];
    2.63 +			new_mform->mf_data[i]= (data[i<<1]<<8) | data[(i<<1)+1];
    2.64  		}
    2.65  	}
    2.66  
    2.67  #ifdef DEBUG_VIDEO_GEM
    2.68  	for (i=0; i<h ;i++) {
    2.69 -		printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i, new_mform->mf_mask[i]);
    2.70 +		printf("sdl:video:gem: cursor: line %d: data=0x%04x, mask=0x%04x\n",
    2.71 +			i, new_mform->mf_data[i], new_mform->mf_mask[i]);
    2.72  	}
    2.73  
    2.74  	printf("sdl:video:gem: CreateWMCursor(): done\n");
    2.75 @@ -127,13 +139,14 @@
    2.76  
    2.77  int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
    2.78  {
    2.79 -/*
    2.80 +	GEM_cursor = cursor;
    2.81  	if (cursor == NULL) {
    2.82  		graf_mouse(M_OFF, NULL);
    2.83 +		GEM_cursor = (void *) -1;
    2.84  	} else if (cursor->mform_p) {
    2.85  		graf_mouse(USER_DEF, cursor->mform_p);
    2.86  	}
    2.87 -*/
    2.88 +
    2.89  #ifdef DEBUG_VIDEO_GEM
    2.90  	printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
    2.91  #endif
    2.92 @@ -157,6 +170,10 @@
    2.93  
    2.94  void GEM_CheckMouseMode(_THIS)
    2.95  {
    2.96 +#ifdef DEBUG_VIDEO_GEM
    2.97 +	printf("sdl:video:gem: check mouse mode\n");
    2.98 +#endif
    2.99 +
   2.100  	/* If the mouse is hidden and input is grabbed, we use relative mode */
   2.101  	if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) &&
   2.102  		/*(this->input_grab != SDL_GRAB_OFF) && */ /* Damn GEM can not grab */
     3.1 --- a/src/video/gem/SDL_gemvideo.c	Tue May 23 15:07:56 2006 +0000
     3.2 +++ b/src/video/gem/SDL_gemvideo.c	Wed Jun 14 18:57:58 2006 +0000
     3.3 @@ -440,6 +440,7 @@
     3.4  
     3.5  	/* Set mouse cursor to arrow */
     3.6  	graf_mouse(ARROW, NULL);
     3.7 +	GEM_cursor = NULL;
     3.8  
     3.9  	/* Init chunky to planar routine */
    3.10  	SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
     4.1 --- a/src/video/gem/SDL_gemvideo.h	Tue May 23 15:07:56 2006 +0000
     4.2 +++ b/src/video/gem/SDL_gemvideo.h	Wed Jun 14 18:57:58 2006 +0000
     4.3 @@ -27,6 +27,11 @@
     4.4  #include "SDL_mutex.h"
     4.5  #include "../SDL_sysvideo.h"
     4.6  
     4.7 +/* The implementation dependent data for the window manager cursor */
     4.8 +struct WMcursor {
     4.9 +	MFORM *mform_p;
    4.10 +};
    4.11 +
    4.12  /* Hidden "this" pointer for the video functions */
    4.13  #define _THIS	SDL_VideoDevice *this
    4.14  
    4.15 @@ -82,6 +87,7 @@
    4.16  	short message[8];			/* To self-send an AES message */
    4.17  	void *menubar;				/* Menu bar save buffer when going fullscreen */
    4.18  	SDL_bool use_dev_mouse;		/* Use /dev/mouse ? */
    4.19 +	WMcursor *cursor;			/* To restore cursor when leaving/entering window */
    4.20  
    4.21  	SDL_bool fullscreen;		/* Fullscreen or windowed mode ? */
    4.22  	SDL_Rect *SDL_modelist[SDL_NUMMODES+1];	/* Mode list */
    4.23 @@ -131,6 +137,7 @@
    4.24  #define GEM_fullscreen		(this->hidden->fullscreen)
    4.25  #define GEM_menubar			(this->hidden->menubar)
    4.26  #define GEM_usedevmouse		(this->hidden->use_dev_mouse)
    4.27 +#define GEM_cursor			(this->hidden->cursor)
    4.28  
    4.29  #define GEM_buffer1			(this->hidden->buffer1)
    4.30  #define GEM_buffer2			(this->hidden->buffer2)