changeset 1857:417f2af2bd52

Fix mouse cursor change
author Patrice Mandin <patmandin@gmail.com>
date Wed, 14 Jun 2006 18:57:58 +0000
parents 21f13c787b46
children d3ac464fb3c1
files src/video/gem/SDL_gemevents.c src/video/gem/SDL_gemmouse.c src/video/gem/SDL_gemvideo.c src/video/gem/SDL_gemvideo.h
diffstat 4 files changed, 46 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/gem/SDL_gemevents.c	Tue May 23 15:07:56 2006 +0000
+++ b/src/video/gem/SDL_gemevents.c	Wed Jun 14 18:57:58 2006 +0000
@@ -186,8 +186,18 @@
 			if (this->input_grab == SDL_GRAB_OFF) {
 				if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) {
 					SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+					if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
+						graf_mouse(ARROW, NULL);
+					}
 				} else {
 					SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+					if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
+						if (GEM_cursor == (void *) -1) {
+							graf_mouse(M_OFF, NULL);
+						} else if (GEM_cursor) {
+							graf_mouse(USER_DEF, GEM_cursor->mform_p);
+						}
+					}
 				}
 			}
 		}
--- a/src/video/gem/SDL_gemmouse.c	Tue May 23 15:07:56 2006 +0000
+++ b/src/video/gem/SDL_gemmouse.c	Wed Jun 14 18:57:58 2006 +0000
@@ -33,6 +33,7 @@
 #include "../../events/SDL_events_c.h"
 #include "../SDL_cursor_c.h"
 #include "SDL_gemmouse_c.h"
+#include "SDL_gemvideo.h"
 
 /* Defines */
 
@@ -41,14 +42,12 @@
 #define MAXCURWIDTH 16
 #define MAXCURHEIGHT 16
 
-/* The implementation dependent data for the window manager cursor */
-struct WMcursor {
-	MFORM *mform_p;
-};
-
-
 void GEM_FreeWMCursor(_THIS, WMcursor *cursor)
 {
+#ifdef DEBUG_VIDEO_GEM
+	printf("sdl:video:gem: free cursor\n");
+#endif
+
 	if (cursor == NULL)
 		return;
 	
@@ -67,6 +66,12 @@
 	MFORM *new_mform;
 	int i;
 
+#ifdef DEBUG_VIDEO_GEM
+	Uint16 *data1, *mask1;
+
+	printf("sdl:video:gem: create cursor\n");
+#endif
+
 	/* Check the size */
 	if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) {
 		SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
@@ -100,6 +105,12 @@
 	for (i=0;i<MAXCURHEIGHT;i++) {
 		new_mform->mf_mask[i]=0;
 		new_mform->mf_data[i]=0;
+#ifdef DEBUG_VIDEO_GEM
+		data1 = (Uint16 *) &data[i<<1];
+		mask1 = (Uint16 *) &mask[i<<1];
+		printf("sdl:video:gem: source: line %d: data=0x%04x, mask=0x%04x\n",
+			i, data1[i], mask1[i]);
+#endif
 	}
 
 	if (w<=8) {
@@ -109,14 +120,15 @@
 		}
 	} else {
 		for (i=0;i<h;i++) {
-			new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1];
-			new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1];
+			new_mform->mf_mask[i]= (mask[i<<1]<<8) | mask[(i<<1)+1];
+			new_mform->mf_data[i]= (data[i<<1]<<8) | data[(i<<1)+1];
 		}
 	}
 
 #ifdef DEBUG_VIDEO_GEM
 	for (i=0; i<h ;i++) {
-		printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i, new_mform->mf_mask[i]);
+		printf("sdl:video:gem: cursor: line %d: data=0x%04x, mask=0x%04x\n",
+			i, new_mform->mf_data[i], new_mform->mf_mask[i]);
 	}
 
 	printf("sdl:video:gem: CreateWMCursor(): done\n");
@@ -127,13 +139,14 @@
 
 int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
 {
-/*
+	GEM_cursor = cursor;
 	if (cursor == NULL) {
 		graf_mouse(M_OFF, NULL);
+		GEM_cursor = (void *) -1;
 	} else if (cursor->mform_p) {
 		graf_mouse(USER_DEF, cursor->mform_p);
 	}
-*/
+
 #ifdef DEBUG_VIDEO_GEM
 	printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
 #endif
@@ -157,6 +170,10 @@
 
 void GEM_CheckMouseMode(_THIS)
 {
+#ifdef DEBUG_VIDEO_GEM
+	printf("sdl:video:gem: check mouse mode\n");
+#endif
+
 	/* If the mouse is hidden and input is grabbed, we use relative mode */
 	if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) &&
 		/*(this->input_grab != SDL_GRAB_OFF) && */ /* Damn GEM can not grab */
--- a/src/video/gem/SDL_gemvideo.c	Tue May 23 15:07:56 2006 +0000
+++ b/src/video/gem/SDL_gemvideo.c	Wed Jun 14 18:57:58 2006 +0000
@@ -440,6 +440,7 @@
 
 	/* Set mouse cursor to arrow */
 	graf_mouse(ARROW, NULL);
+	GEM_cursor = NULL;
 
 	/* Init chunky to planar routine */
 	SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
--- a/src/video/gem/SDL_gemvideo.h	Tue May 23 15:07:56 2006 +0000
+++ b/src/video/gem/SDL_gemvideo.h	Wed Jun 14 18:57:58 2006 +0000
@@ -27,6 +27,11 @@
 #include "SDL_mutex.h"
 #include "../SDL_sysvideo.h"
 
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	MFORM *mform_p;
+};
+
 /* Hidden "this" pointer for the video functions */
 #define _THIS	SDL_VideoDevice *this
 
@@ -82,6 +87,7 @@
 	short message[8];			/* To self-send an AES message */
 	void *menubar;				/* Menu bar save buffer when going fullscreen */
 	SDL_bool use_dev_mouse;		/* Use /dev/mouse ? */
+	WMcursor *cursor;			/* To restore cursor when leaving/entering window */
 
 	SDL_bool fullscreen;		/* Fullscreen or windowed mode ? */
 	SDL_Rect *SDL_modelist[SDL_NUMMODES+1];	/* Mode list */
@@ -131,6 +137,7 @@
 #define GEM_fullscreen		(this->hidden->fullscreen)
 #define GEM_menubar			(this->hidden->menubar)
 #define GEM_usedevmouse		(this->hidden->use_dev_mouse)
+#define GEM_cursor			(this->hidden->cursor)
 
 #define GEM_buffer1			(this->hidden->buffer1)
 #define GEM_buffer2			(this->hidden->buffer2)