Skip to content

Commit 2e3fc4f

Browse files
authored
WIN32: Menubar hotkey corrections (#17326)
1 parent b5a62fc commit 2e3fc4f

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

gfx/common/win32_common.c

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -752,39 +752,45 @@ static LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
752752
{
753753
char win32_file[PATH_MAX_LENGTH] = {0};
754754
char *title_cp = NULL;
755+
wchar_t *title_wide = NULL;
755756
size_t converted = 0;
756757
const char *extensions = "All Files (*.*)\0*.*\0\0";
757758
const char *title = msg_hash_to_str(
758759
MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST);
759760
settings_t *settings = config_get_ptr();
760761
const char *initial_dir = settings->paths.directory_menu_content;
762+
bool browser = true;
763+
764+
/* Menubar accelerator hotkey is hijacked always, therefore must
765+
* press the keyboard event manually when blocking the accelerator. */
766+
if ( !settings->bools.ui_menubar_enable
767+
|| (!settings->bools.video_windowed_fullscreen && settings->bools.video_fullscreen))
768+
{
769+
input_keyboard_event(true, RETROK_o,
770+
0, RETROK_LCTRL, RETRO_DEVICE_KEYBOARD);
771+
break;
772+
}
761773

762774
/* Convert UTF8 to UTF16, then back to the
763775
* local code page.
764776
* This is needed for proper multi-byte
765777
* string display until Unicode is
766778
* fully supported.
767779
*/
768-
wchar_t *title_wide = utf8_to_utf16_string_alloc(title);
780+
title_wide = utf8_to_utf16_string_alloc(title);
769781

770782
if (title_wide)
771-
title_cp = utf16_to_utf8_string_alloc(title_wide);
783+
title_cp = utf16_to_utf8_string_alloc(title_wide);
772784

773-
if (!win32_browser(owner, win32_file, sizeof(win32_file),
774-
extensions, title_cp, initial_dir))
775-
{
776-
if (title_wide)
777-
free(title_wide);
778-
if (title_cp)
779-
free(title_cp);
780-
break;
781-
}
785+
browser = win32_browser(owner, win32_file, sizeof(win32_file), extensions, title_cp, initial_dir);
782786

783787
if (title_wide)
784788
free(title_wide);
785789
if (title_cp)
786790
free(title_cp);
787-
win32_load_content_from_gui(win32_file);
791+
792+
if (browser)
793+
win32_load_content_from_gui(win32_file);
788794
}
789795
break;
790796
case ID_M_RESET:
@@ -815,6 +821,18 @@ static LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
815821
command_event(CMD_EVENT_DISK_PREV, NULL);
816822
break;
817823
case ID_M_FULL_SCREEN:
824+
{
825+
/* Menubar accelerator hotkey is hijacked always, therefore must
826+
* press the keyboard event manually when blocking the accelerator. */
827+
settings_t *settings = config_get_ptr();
828+
if ( !settings->bools.ui_menubar_enable
829+
|| (!settings->bools.video_windowed_fullscreen && settings->bools.video_fullscreen))
830+
{
831+
input_keyboard_event(true, RETROK_RETURN,
832+
0, RETROK_LALT, RETRO_DEVICE_KEYBOARD);
833+
break;
834+
}
835+
}
818836
command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
819837
break;
820838
case ID_M_MOUSE_GRAB:

0 commit comments

Comments
 (0)