@@ -70,26 +70,44 @@ static std::string pending_dialog_path;
7070static bool dialog_active = false ;
7171static int pending_dialog_int_param1 = 0 ;
7272static int pending_dialog_int_param2 = 0 ;
73+ #if !defined(__APPLE__)
74+ static bool was_exclusive_fullscreen = false ;
75+ #endif
7376
7477static void SDLCALL file_dialog_callback (void * userdata, const char * const * filelist, int filter);
7578static void process_dialog_result (FileDialogID id, const char * path);
7679
77- void gui_file_dialog_open_rom (void )
80+ static bool begin_dialog (void )
7881{
7982 if (dialog_active)
80- return ;
83+ return false ;
8184 dialog_active = true ;
8285
86+ #if !defined(__APPLE__)
87+ if (config_emulator.fullscreen && config_emulator.fullscreen_mode == 1 )
88+ {
89+ was_exclusive_fullscreen = true ;
90+ application_trigger_fullscreen (false );
91+ }
92+ #endif
93+
94+ return true ;
95+ }
96+
97+ void gui_file_dialog_open_rom (void )
98+ {
99+ if (!begin_dialog ())
100+ return ;
101+
83102 SDL_DialogFileFilter filters[] = { { " ROM/CD Files" , " pce;sgx;hes;cue;chd;zip" } };
84103 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
85104 SDL_ShowOpenFileDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_OpenROM, application_sdl_window, filters, 1 , default_path, false );
86105}
87106
88107void gui_file_dialog_load_ram (void )
89108{
90- if (dialog_active )
109+ if (! begin_dialog () )
91110 return ;
92- dialog_active = true ;
93111
94112 SDL_DialogFileFilter filters[] = { { " BRAM Files" , " sav;bram;ram;srm" } };
95113 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
@@ -98,9 +116,8 @@ void gui_file_dialog_load_ram(void)
98116
99117void gui_file_dialog_save_ram (void )
100118{
101- if (dialog_active )
119+ if (! begin_dialog () )
102120 return ;
103- dialog_active = true ;
104121
105122 SDL_DialogFileFilter filters[] = { { " BRAM Files" , " sav;bram;srm" } };
106123 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
@@ -109,9 +126,8 @@ void gui_file_dialog_save_ram(void)
109126
110127void gui_file_dialog_load_state (void )
111128{
112- if (dialog_active )
129+ if (! begin_dialog () )
113130 return ;
114- dialog_active = true ;
115131
116132 SDL_DialogFileFilter filters[] = { { " Save State Files" , " state;state1;state2;state3;state4;state5" } };
117133 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
@@ -120,9 +136,8 @@ void gui_file_dialog_load_state(void)
120136
121137void gui_file_dialog_save_state (void )
122138{
123- if (dialog_active )
139+ if (! begin_dialog () )
124140 return ;
125- dialog_active = true ;
126141
127142 SDL_DialogFileFilter filters[] = { { " Save State Files" , " state" } };
128143 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
@@ -131,49 +146,44 @@ void gui_file_dialog_save_state(void)
131146
132147void gui_file_dialog_choose_savestate_path (void )
133148{
134- if (dialog_active )
149+ if (! begin_dialog () )
135150 return ;
136- dialog_active = true ;
137151
138152 const char * default_path = config_emulator.savestates_path .empty () ? NULL : config_emulator.savestates_path .c_str ();
139153 SDL_ShowOpenFolderDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_ChooseSavestatePath, application_sdl_window, default_path, false );
140154}
141155
142156void gui_file_dialog_choose_screenshot_path (void )
143157{
144- if (dialog_active )
158+ if (! begin_dialog () )
145159 return ;
146- dialog_active = true ;
147160
148161 const char * default_path = config_emulator.screenshots_path .empty () ? NULL : config_emulator.screenshots_path .c_str ();
149162 SDL_ShowOpenFolderDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_ChooseScreenshotPath, application_sdl_window, default_path, false );
150163}
151164
152165void gui_file_dialog_choose_backup_ram_path (void )
153166{
154- if (dialog_active )
167+ if (! begin_dialog () )
155168 return ;
156- dialog_active = true ;
157169
158170 const char * default_path = config_emulator.backup_ram_path .empty () ? NULL : config_emulator.backup_ram_path .c_str ();
159171 SDL_ShowOpenFolderDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_ChooseBackupRamPath, application_sdl_window, default_path, false );
160172}
161173
162174void gui_file_dialog_choose_mb128_path (void )
163175{
164- if (dialog_active )
176+ if (! begin_dialog () )
165177 return ;
166- dialog_active = true ;
167178
168179 const char * default_path = config_emulator.mb128_path .empty () ? NULL : config_emulator.mb128_path .c_str ();
169180 SDL_ShowOpenFolderDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_ChooseMB128Path, application_sdl_window, default_path, false );
170181}
171182
172183void gui_file_dialog_load_bios (bool syscard)
173184{
174- if (dialog_active )
185+ if (! begin_dialog () )
175186 return ;
176- dialog_active = true ;
177187
178188 FileDialogID id = syscard ? FileDialog_LoadBIOSSyscard : FileDialog_LoadBIOSGameExpress;
179189 SDL_DialogFileFilter filters[] = { { " BIOS Files" , " pce;rom;bios" } };
@@ -183,38 +193,34 @@ void gui_file_dialog_load_bios(bool syscard)
183193
184194void gui_file_dialog_load_symbols (void )
185195{
186- if (dialog_active )
196+ if (! begin_dialog () )
187197 return ;
188- dialog_active = true ;
189198
190199 SDL_ShowOpenFileDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_LoadSymbols, application_sdl_window, NULL , 0 , NULL , false );
191200}
192201
193202void gui_file_dialog_save_screenshot (void )
194203{
195- if (dialog_active )
204+ if (! begin_dialog () )
196205 return ;
197- dialog_active = true ;
198206
199207 SDL_DialogFileFilter filters[] = { { " PNG Files" , " png" } };
200208 SDL_ShowSaveFileDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_SaveScreenshot, application_sdl_window, filters, 1 , NULL );
201209}
202210
203211void gui_file_dialog_save_vgm (void )
204212{
205- if (dialog_active )
213+ if (! begin_dialog () )
206214 return ;
207- dialog_active = true ;
208215
209216 SDL_DialogFileFilter filters[] = { { " VGM Files" , " vgm" } };
210217 SDL_ShowSaveFileDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_SaveVGM, application_sdl_window, filters, 1 , NULL );
211218}
212219
213220void gui_file_dialog_save_sprite (int vdc, int index)
214221{
215- if (dialog_active )
222+ if (! begin_dialog () )
216223 return ;
217- dialog_active = true ;
218224
219225 pending_dialog_int_param1 = vdc;
220226 pending_dialog_int_param2 = index;
@@ -224,19 +230,17 @@ void gui_file_dialog_save_sprite(int vdc, int index)
224230
225231void gui_file_dialog_save_all_sprites (int vdc)
226232{
227- if (dialog_active )
233+ if (! begin_dialog () )
228234 return ;
229- dialog_active = true ;
230235
231236 pending_dialog_int_param1 = vdc;
232237 SDL_ShowOpenFolderDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_SaveAllSprites, application_sdl_window, NULL , false );
233238}
234239
235240void gui_file_dialog_save_background (int vdc)
236241{
237- if (dialog_active )
242+ if (! begin_dialog () )
238243 return ;
239- dialog_active = true ;
240244
241245 pending_dialog_int_param1 = vdc;
242246 SDL_DialogFileFilter filters[] = { { " PNG Files" , " png" } };
@@ -245,9 +249,8 @@ void gui_file_dialog_save_background(int vdc)
245249
246250void gui_file_dialog_save_memory_dump (bool binary)
247251{
248- if (dialog_active )
252+ if (! begin_dialog () )
249253 return ;
250- dialog_active = true ;
251254
252255 FileDialogID id = binary ? FileDialog_SaveMemoryDumpBinary : FileDialog_SaveMemoryDumpText;
253256 SDL_DialogFileFilter filters[] = { { " Memory Dump Files" , binary ? " bin" : " txt" } };
@@ -256,9 +259,8 @@ void gui_file_dialog_save_memory_dump(bool binary)
256259
257260void gui_file_dialog_save_disassembler (bool full)
258261{
259- if (dialog_active )
262+ if (! begin_dialog () )
260263 return ;
261- dialog_active = true ;
262264
263265 FileDialogID id = full ? FileDialog_SaveDisassemblerFull : FileDialog_SaveDisassemblerVisible;
264266 SDL_DialogFileFilter filters[] = { { " Disassembler Files" , " txt" } };
@@ -267,19 +269,17 @@ void gui_file_dialog_save_disassembler(bool full)
267269
268270void gui_file_dialog_save_log (void )
269271{
270- if (dialog_active )
272+ if (! begin_dialog () )
271273 return ;
272- dialog_active = true ;
273274
274275 SDL_DialogFileFilter filters[] = { { " Log Files" , " txt" } };
275276 SDL_ShowSaveFileDialog (file_dialog_callback, (void *)(intptr_t )FileDialog_SaveLog, application_sdl_window, filters, 1 , NULL );
276277}
277278
278279void gui_file_dialog_save_debug_settings (void )
279280{
280- if (dialog_active )
281+ if (! begin_dialog () )
281282 return ;
282- dialog_active = true ;
283283
284284 SDL_DialogFileFilter filters[] = { { " Debug Settings Files" , " ggdebug" } };
285285 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
@@ -288,9 +288,8 @@ void gui_file_dialog_save_debug_settings(void)
288288
289289void gui_file_dialog_load_debug_settings (void )
290290{
291- if (dialog_active )
291+ if (! begin_dialog () )
292292 return ;
293- dialog_active = true ;
294293
295294 SDL_DialogFileFilter filters[] = { { " Debug Settings Files" , " ggdebug" } };
296295 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
@@ -299,9 +298,8 @@ void gui_file_dialog_load_debug_settings(void)
299298
300299void gui_file_dialog_load_palette (void )
301300{
302- if (dialog_active )
301+ if (! begin_dialog () )
303302 return ;
304- dialog_active = true ;
305303
306304 SDL_DialogFileFilter filters[] = { { " Palette Files" , " pal;bin" } };
307305 const char * default_path = config_emulator.last_open_path .empty () ? NULL : config_emulator.last_open_path .c_str ();
@@ -310,6 +308,14 @@ void gui_file_dialog_load_palette(void)
310308
311309void gui_file_dialog_process_results (void )
312310{
311+ #if !defined(__APPLE__)
312+ if (was_exclusive_fullscreen && !dialog_active)
313+ {
314+ was_exclusive_fullscreen = false ;
315+ application_trigger_fullscreen (true );
316+ }
317+ #endif
318+
313319 if (pending_dialog_id != FileDialog_None)
314320 {
315321 FileDialogID id = pending_dialog_id;
0 commit comments