Mercurial > repos > blastem
comparison render_sdl.c @ 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 | 9264c847ceb7 |
children | 6f8400ce7a0f |
comparison
equal
deleted
inserted
replaced
2391:664c3e749428 | 2392:a71176b9903d |
---|---|
37 static window_close_handler *close_handlers; | 37 static window_close_handler *close_handlers; |
38 static uint8_t num_textures; | 38 static uint8_t num_textures; |
39 static SDL_Rect main_clip; | 39 static SDL_Rect main_clip; |
40 static SDL_GLContext *main_context; | 40 static SDL_GLContext *main_context; |
41 | 41 |
42 static int main_width, main_height, windowed_width, windowed_height, is_fullscreen; | 42 static int main_width, main_height, windowed_width, windowed_height; |
43 | 43 |
44 static uint8_t render_gl = 1; | 44 static uint8_t render_gl = 1; |
45 static uint8_t scanlines = 0; | 45 static uint8_t scanlines, is_fullscreen, force_cursor; |
46 | 46 |
47 static uint32_t last_frame = 0; | 47 static uint32_t last_frame = 0; |
48 | 48 |
49 static SDL_mutex *audio_mutex, *frame_mutex, *free_buffer_mutex; | 49 static SDL_mutex *audio_mutex, *frame_mutex, *free_buffer_mutex; |
50 static SDL_cond *audio_ready, *frame_ready; | 50 static SDL_cond *audio_ready, *frame_ready; |
273 int render_height() | 273 int render_height() |
274 { | 274 { |
275 return main_height; | 275 return main_height; |
276 } | 276 } |
277 | 277 |
278 int render_fullscreen() | 278 uint8_t render_fullscreen() |
279 { | 279 { |
280 return is_fullscreen; | 280 return is_fullscreen; |
281 } | 281 } |
282 | 282 |
283 uint32_t render_map_color(uint8_t r, uint8_t g, uint8_t b) | 283 uint32_t render_map_color(uint8_t r, uint8_t g, uint8_t b) |
1035 warning("Unsupported audio sample format: %X\n", actual.format); | 1035 warning("Unsupported audio sample format: %X\n", actual.format); |
1036 } | 1036 } |
1037 render_audio_initialized(format, actual.freq, actual.channels, actual.samples, SDL_AUDIO_BITSIZE(actual.format) / 8); | 1037 render_audio_initialized(format, actual.freq, actual.channels, actual.samples, SDL_AUDIO_BITSIZE(actual.format) / 8); |
1038 } | 1038 } |
1039 | 1039 |
1040 void window_setup(void) | 1040 static void update_cursor(void) |
1041 { | |
1042 SDL_ShowCursor((is_fullscreen && !force_cursor) ? SDL_DISABLE : SDL_ENABLE); | |
1043 } | |
1044 | |
1045 void render_force_cursor(uint8_t force) | |
1046 { | |
1047 if (force != force_cursor) { | |
1048 force_cursor = force; | |
1049 update_cursor(); | |
1050 } | |
1051 } | |
1052 | |
1053 static void window_setup(void) | |
1041 { | 1054 { |
1042 uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; | 1055 uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; |
1043 if (is_fullscreen) { | 1056 if (is_fullscreen) { |
1044 flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; | 1057 flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
1045 } | 1058 } |
1059 update_cursor(); | |
1046 | 1060 |
1047 tern_val def = {.ptrval = "audio"}; | 1061 tern_val def = {.ptrval = "audio"}; |
1048 if (external_sync) { | 1062 if (external_sync) { |
1049 sync_src = SYNC_EXTERNAL; | 1063 sync_src = SYNC_EXTERNAL; |
1050 } else { | 1064 } else { |
2128 //This needs to happen before the fullscreen transition to have any effect | 2142 //This needs to happen before the fullscreen transition to have any effect |
2129 //because SDL does not apply window size changes in fullscreen | 2143 //because SDL does not apply window size changes in fullscreen |
2130 SDL_SetWindowSize(main_window, mode.w, mode.h); | 2144 SDL_SetWindowSize(main_window, mode.w, mode.h); |
2131 } | 2145 } |
2132 SDL_SetWindowFullscreen(main_window, is_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); | 2146 SDL_SetWindowFullscreen(main_window, is_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); |
2147 update_cursor(); | |
2133 //Since we change the window size on transition to full screen | 2148 //Since we change the window size on transition to full screen |
2134 //we need to set it back to normal so we can also go back to windowed mode | 2149 //we need to set it back to normal so we can also go back to windowed mode |
2135 //normally you would think that this should only be done when actually transitioning | 2150 //normally you would think that this should only be done when actually transitioning |
2136 //but something is screwy in the guts of SDL (at least on Linux) and setting it each time | 2151 //but something is screwy in the guts of SDL (at least on Linux) and setting it each time |
2137 //is the only thing that seems to work reliably | 2152 //is the only thing that seems to work reliably |