Mercurial > repos > blastem
changeset 2392:a71176b9903d
Hide cursor in fullscreen when UI is not active
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 29 Nov 2023 23:06:50 -0800 |
parents | 664c3e749428 |
children | 5f4917b9ecfa |
files | nuklear_ui/blastem_nuklear.c render.h render_sdl.c |
diffstat | 3 files changed, 24 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/nuklear_ui/blastem_nuklear.c Wed Nov 29 22:56:36 2023 -0800 +++ b/nuklear_ui/blastem_nuklear.c Wed Nov 29 23:06:50 2023 -0800 @@ -2445,6 +2445,7 @@ void blastem_nuklear_render(void) { if (current_view != view_play || (current_system && current_system->type == SYSTEM_MEDIA_PLAYER)) { + render_force_cursor(1); nk_input_end(context); current_view(context); if (fb_context) { @@ -2457,6 +2458,8 @@ #endif } nk_input_begin(context); + } else { + render_force_cursor(0); } }
--- a/render.h Wed Nov 29 22:56:36 2023 -0800 +++ b/render.h Wed Nov 29 23:06:50 2023 -0800 @@ -118,7 +118,8 @@ void process_events(); int render_width(); int render_height(); -int render_fullscreen(); +uint8_t render_fullscreen(); +void render_force_cursor(uint8_t force); void render_set_drag_drop_handler(drop_handler handler); void process_events(); int32_t render_translate_input_name(int32_t controller, char *name, uint8_t is_axis);
--- a/render_sdl.c Wed Nov 29 22:56:36 2023 -0800 +++ b/render_sdl.c Wed Nov 29 23:06:50 2023 -0800 @@ -39,10 +39,10 @@ static SDL_Rect main_clip; static SDL_GLContext *main_context; -static int main_width, main_height, windowed_width, windowed_height, is_fullscreen; +static int main_width, main_height, windowed_width, windowed_height; static uint8_t render_gl = 1; -static uint8_t scanlines = 0; +static uint8_t scanlines, is_fullscreen, force_cursor; static uint32_t last_frame = 0; @@ -275,7 +275,7 @@ return main_height; } -int render_fullscreen() +uint8_t render_fullscreen() { return is_fullscreen; } @@ -1037,12 +1037,26 @@ render_audio_initialized(format, actual.freq, actual.channels, actual.samples, SDL_AUDIO_BITSIZE(actual.format) / 8); } -void window_setup(void) +static void update_cursor(void) +{ + SDL_ShowCursor((is_fullscreen && !force_cursor) ? SDL_DISABLE : SDL_ENABLE); +} + +void render_force_cursor(uint8_t force) +{ + if (force != force_cursor) { + force_cursor = force; + update_cursor(); + } +} + +static void window_setup(void) { uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; if (is_fullscreen) { flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } + update_cursor(); tern_val def = {.ptrval = "audio"}; if (external_sync) { @@ -2130,6 +2144,7 @@ SDL_SetWindowSize(main_window, mode.w, mode.h); } SDL_SetWindowFullscreen(main_window, is_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); + update_cursor(); //Since we change the window size on transition to full screen //we need to set it back to normal so we can also go back to windowed mode //normally you would think that this should only be done when actually transitioning