Skip to content

Commit

Permalink
atari:gem: Remember mouse cursor used, to avoid changing it each time…
Browse files Browse the repository at this point in the history
… we check
  • Loading branch information
pmandin committed Oct 2, 2017
1 parent 2cac29f commit d2a3b51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/video/gem/SDL_gemmouse.c
Expand Up @@ -51,8 +51,9 @@ void GEM_FreeWMCursor(_THIS, WMcursor *cursor)

if (cursor == NULL)
return;

graf_mouse(ARROW, NULL);
GEM_prev_cursor = NULL;

if (cursor->mform_p != NULL)
SDL_free(cursor->mform_p);
Expand Down Expand Up @@ -88,7 +89,7 @@ WMcursor *GEM_CreateWMCursor(_THIS,
}

/* Allocate mform */
new_mform = (MFORM *)SDL_malloc(sizeof(MFORM));
new_mform = (MFORM *)SDL_malloc(sizeof(MFORM));
if (new_mform == NULL) {
SDL_free(cursor);
SDL_OutOfMemory();
Expand Down Expand Up @@ -157,8 +158,8 @@ void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
/* This seems to work only on AES 3.4 (Falcon) */

EVNTREC warpevent;
warpevent.ap_event = APPEVNT_MOUSE;

warpevent.ap_event = APPEVNT_MOUSE;
warpevent.ap_value = (x << 16) | y;

appl_tplay(&warpevent, 1, 1000);
Expand All @@ -185,7 +186,10 @@ void GEM_CheckMouseMode(_THIS)
/* Application defined cursor only over the application window */
if ((SDL_GetAppState() & full_focus) == full_focus) {
if (GEM_cursor) {
graf_mouse(USER_DEF, GEM_cursor->mform_p);
if (GEM_cursor != GEM_prev_cursor) {
graf_mouse(USER_DEF, GEM_cursor->mform_p);
GEM_prev_cursor = GEM_cursor;
}
set_system_cursor = 0;
} else {
hide_system_cursor = SDL_TRUE;
Expand All @@ -204,7 +208,8 @@ void GEM_CheckMouseMode(_THIS)
GEM_cursor_hidden = hide_system_cursor;
}

if (set_system_cursor) {
if (set_system_cursor && GEM_prev_cursor) {
graf_mouse(ARROW, NULL);
GEM_prev_cursor = NULL;
}
}
2 changes: 1 addition & 1 deletion src/video/gem/SDL_gemvideo.c
Expand Up @@ -440,7 +440,7 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)

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

/* Init chunky to planar routine */
SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
Expand Down
2 changes: 2 additions & 0 deletions src/video/gem/SDL_gemvideo.h
Expand Up @@ -92,6 +92,7 @@ struct SDL_PrivateVideoData {
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 */
WMcursor *prev_cursor; /* Previous cursor */

SDL_bool fullscreen; /* Fullscreen or windowed mode ? */
SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */
Expand Down Expand Up @@ -146,6 +147,7 @@ struct SDL_PrivateVideoData {
#define GEM_menubar (this->hidden->menubar)
#define GEM_usedevmouse (this->hidden->use_dev_mouse)
#define GEM_cursor (this->hidden->cursor)
#define GEM_prev_cursor (this->hidden->prev_cursor)

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

0 comments on commit d2a3b51

Please sign in to comment.