From a5cbc93fd9e2c67a15372e32d8ec044dce507edc Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 13 Aug 2014 11:01:21 +0200 Subject: [PATCH] atari:gem: Use flag to only call system function to hide/show cursor when state changes. --- src/video/gem/SDL_gemmouse.c | 13 +++++++++---- src/video/gem/SDL_gemvideo.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/video/gem/SDL_gemmouse.c b/src/video/gem/SDL_gemmouse.c index c876cffe5..7fa848aac 100644 --- a/src/video/gem/SDL_gemmouse.c +++ b/src/video/gem/SDL_gemmouse.c @@ -168,7 +168,8 @@ void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y) void GEM_CheckMouseMode(_THIS) { const Uint8 full_focus = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); - int set_system_cursor = 1, show_system_cursor = 1; + int set_system_cursor = 1; + SDL_bool hide_system_cursor = SDL_FALSE; #ifdef DEBUG_VIDEO_GEM printf("sdl:video:gem: check mouse mode\n"); @@ -187,18 +188,22 @@ void GEM_CheckMouseMode(_THIS) graf_mouse(USER_DEF, GEM_cursor->mform_p); set_system_cursor = 0; } else { - show_system_cursor = 0; + hide_system_cursor = SDL_TRUE; } } } else { /* Mouse cursor hidden only over the application window */ if ((SDL_GetAppState() & full_focus) == full_focus) { set_system_cursor = 0; - show_system_cursor = 0; + hide_system_cursor = SDL_TRUE; } } - graf_mouse(show_system_cursor ? M_ON : M_OFF, NULL); + if (hide_system_cursor != GEM_cursor_hidden) { + graf_mouse(hide_system_cursor ? M_OFF : M_ON, NULL); + GEM_cursor_hidden = hide_system_cursor; + } + if (set_system_cursor) { graf_mouse(ARROW, NULL); } diff --git a/src/video/gem/SDL_gemvideo.h b/src/video/gem/SDL_gemvideo.h index f3a195453..6bc8cfa7c 100644 --- a/src/video/gem/SDL_gemvideo.h +++ b/src/video/gem/SDL_gemvideo.h @@ -84,6 +84,7 @@ struct SDL_PrivateVideoData { SDL_bool mouse_relative; /* Report relative mouse movement */ SDL_bool locked; /* AES locked for fullscreen ? */ SDL_bool lock_redraw; /* Prevent redraw till buffers are setup */ + SDL_bool cursor_hidden; /* Mouse cursor hidden flag */ 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 ? */ @@ -131,6 +132,7 @@ struct SDL_PrivateVideoData { #define GEM_mouse_relative (this->hidden->mouse_relative) #define GEM_locked (this->hidden->locked) #define GEM_lock_redraw (this->hidden->lock_redraw) +#define GEM_cursor_hidden (this->hidden->cursor_hidden) #define GEM_message (this->hidden->message) #define SDL_modelist (this->hidden->SDL_modelist) #define GEM_icon (this->hidden->icon)