Skip to content

Commit

Permalink
Fix mouse cursor change
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Jun 14, 2006
1 parent 02d908f commit bc511e1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/video/gem/SDL_gemevents.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -186,8 +186,18 @@ void GEM_PumpEvents(_THIS)
if (this->input_grab == SDL_GRAB_OFF) { if (this->input_grab == SDL_GRAB_OFF) {
if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) {
SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
graf_mouse(ARROW, NULL);
}
} else { } else {
SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); 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);
}
}
} }
} }
} }
Expand Down
39 changes: 28 additions & 11 deletions src/video/gem/SDL_gemmouse.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
#include "../SDL_cursor_c.h" #include "../SDL_cursor_c.h"
#include "SDL_gemmouse_c.h" #include "SDL_gemmouse_c.h"
#include "SDL_gemvideo.h"


/* Defines */ /* Defines */


Expand All @@ -41,14 +42,12 @@
#define MAXCURWIDTH 16 #define MAXCURWIDTH 16
#define MAXCURHEIGHT 16 #define MAXCURHEIGHT 16


/* The implementation dependent data for the window manager cursor */
struct WMcursor {
MFORM *mform_p;
};


void GEM_FreeWMCursor(_THIS, WMcursor *cursor) void GEM_FreeWMCursor(_THIS, WMcursor *cursor)
{ {
#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: free cursor\n");
#endif

if (cursor == NULL) if (cursor == NULL)
return; return;


Expand All @@ -67,6 +66,12 @@ WMcursor *GEM_CreateWMCursor(_THIS,
MFORM *new_mform; MFORM *new_mform;
int i; int i;


#ifdef DEBUG_VIDEO_GEM
Uint16 *data1, *mask1;

printf("sdl:video:gem: create cursor\n");
#endif

/* Check the size */ /* Check the size */
if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) { if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) {
SDL_SetError("Only cursors of dimension (%dx%d) are allowed", SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
Expand Down Expand Up @@ -100,6 +105,12 @@ WMcursor *GEM_CreateWMCursor(_THIS,
for (i=0;i<MAXCURHEIGHT;i++) { for (i=0;i<MAXCURHEIGHT;i++) {
new_mform->mf_mask[i]=0; new_mform->mf_mask[i]=0;
new_mform->mf_data[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) { if (w<=8) {
Expand All @@ -109,14 +120,15 @@ WMcursor *GEM_CreateWMCursor(_THIS,
} }
} else { } else {
for (i=0;i<h;i++) { for (i=0;i<h;i++) {
new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(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]; new_mform->mf_data[i]= (data[i<<1]<<8) | data[(i<<1)+1];
} }
} }


#ifdef DEBUG_VIDEO_GEM #ifdef DEBUG_VIDEO_GEM
for (i=0; i<h ;i++) { 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"); printf("sdl:video:gem: CreateWMCursor(): done\n");
Expand All @@ -127,13 +139,14 @@ WMcursor *GEM_CreateWMCursor(_THIS,


int GEM_ShowWMCursor(_THIS, WMcursor *cursor) int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
{ {
/* GEM_cursor = cursor;
if (cursor == NULL) { if (cursor == NULL) {
graf_mouse(M_OFF, NULL); graf_mouse(M_OFF, NULL);
GEM_cursor = (void *) -1;
} else if (cursor->mform_p) { } else if (cursor->mform_p) {
graf_mouse(USER_DEF, cursor->mform_p); graf_mouse(USER_DEF, cursor->mform_p);
} }
*/
#ifdef DEBUG_VIDEO_GEM #ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
#endif #endif
Expand All @@ -157,6 +170,10 @@ void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)


void GEM_CheckMouseMode(_THIS) 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 the mouse is hidden and input is grabbed, we use relative mode */
if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) && if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) &&
/*(this->input_grab != SDL_GRAB_OFF) && */ /* Damn GEM can not grab */ /*(this->input_grab != SDL_GRAB_OFF) && */ /* Damn GEM can not grab */
Expand Down
1 change: 1 addition & 0 deletions src/video/gem/SDL_gemvideo.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)


/* Set mouse cursor to arrow */ /* Set mouse cursor to arrow */
graf_mouse(ARROW, NULL); graf_mouse(ARROW, NULL);
GEM_cursor = NULL;


/* Init chunky to planar routine */ /* Init chunky to planar routine */
SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
Expand Down
7 changes: 7 additions & 0 deletions src/video/gem/SDL_gemvideo.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "../SDL_sysvideo.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 */ /* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this #define _THIS SDL_VideoDevice *this


Expand Down Expand Up @@ -82,6 +87,7 @@ struct SDL_PrivateVideoData {
short message[8]; /* To self-send an AES message */ short message[8]; /* To self-send an AES message */
void *menubar; /* Menu bar save buffer when going fullscreen */ void *menubar; /* Menu bar save buffer when going fullscreen */
SDL_bool use_dev_mouse; /* Use /dev/mouse ? */ 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_bool fullscreen; /* Fullscreen or windowed mode ? */
SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */ SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */
Expand Down Expand Up @@ -131,6 +137,7 @@ struct SDL_PrivateVideoData {
#define GEM_fullscreen (this->hidden->fullscreen) #define GEM_fullscreen (this->hidden->fullscreen)
#define GEM_menubar (this->hidden->menubar) #define GEM_menubar (this->hidden->menubar)
#define GEM_usedevmouse (this->hidden->use_dev_mouse) #define GEM_usedevmouse (this->hidden->use_dev_mouse)
#define GEM_cursor (this->hidden->cursor)


#define GEM_buffer1 (this->hidden->buffer1) #define GEM_buffer1 (this->hidden->buffer1)
#define GEM_buffer2 (this->hidden->buffer2) #define GEM_buffer2 (this->hidden->buffer2)
Expand Down

0 comments on commit bc511e1

Please sign in to comment.