diff --git a/include/resource.h b/include/resource.h index 2a685397b25..4a7ee3b8624 100644 --- a/include/resource.h +++ b/include/resource.h @@ -714,4 +714,7 @@ #define ID_GLIDE_EMU_OPENGL 818 #define ID_GLIDE_EMU_AUTO 819 #define ID_ALWAYS_ON_TOP 820 - + +#if defined(WIN32) +# define ID_WIN_SYSMENU_RESTOREMENU 0x0F00 +#endif diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index ad0c7f9614d..db640a46065 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -738,6 +738,32 @@ void Mount_Img(char drive, std::string realpath) { } } +void DOSBox_SetSysMenu(void) { + MENUITEMINFO mii; + HMENU sysmenu; + BOOL s; + + sysmenu = GetSystemMenu(GetHWND(), TRUE); // revert, so we can reapply menu items + sysmenu = GetSystemMenu(GetHWND(), FALSE); + if (sysmenu == NULL) return; + + s = AppendMenu(sysmenu, MF_SEPARATOR, -1, ""); + + { + const char *msg = "Show menu &bar"; + + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE; + mii.fState = MFS_ENABLED; + mii.wID = ID_WIN_SYSMENU_RESTOREMENU; + mii.dwTypeData = (LPTSTR)(msg); + mii.cch = strlen(msg)+1; + + s = InsertMenuItem(sysmenu, GetMenuItemCount(sysmenu), TRUE, &mii); + } +} + void DOSBox_SetMenu(void) { if(!menu.gui) return; @@ -791,6 +817,7 @@ void DOSBox_RefreshMenu(void) { DrawMenuBar(GetHWND()); return; } + DOSBox_SetSysMenu(); if(menu.toggle) DOSBox_SetMenu(); else @@ -835,6 +862,7 @@ void ToggleMenu(bool pressed) { menu.toggle=false; DOSBox_NoMenu(); } + DOSBox_SetSysMenu(); } void MENU_Check_Drive(HMENU handle, int cdrom, int floppy, int local, int image, int automount, int umount, char drive) { diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 8277f30f140..48226d27455 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -3624,7 +3624,6 @@ void GFX_Events() { switch (event.type) { #ifdef __WIN32__ case SDL_SYSWMEVENT : { - if(menu_compatible) break; switch( event.syswm.msg->msg ) { case WM_SYSCOMMAND: switch (event.syswm.msg->wParam) { @@ -3639,6 +3638,9 @@ void GFX_Events() { GFX_SwitchFullScreen(); menu.maxwindow=false; break; + case ID_WIN_SYSMENU_RESTOREMENU: + DOSBox_SetMenu(); + break; } case WM_MOVE: break; @@ -3654,7 +3656,7 @@ void GFX_Events() { } #endif case SDL_ACTIVEEVENT: - if (event.active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) { + if (event.active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) { if (event.active.gain) { if (sdl.desktop.fullscreen && !sdl.mouse.locked) GFX_CaptureMouse(); @@ -3664,7 +3666,8 @@ void GFX_Events() { if (sdl.mouse.locked) GFX_CaptureMouse(); #if defined(WIN32) - GFX_ForceFullscreenExit(); + if (sdl.desktop.fullscreen) + GFX_ForceFullscreenExit(); #endif SetPriority(sdl.priority.nofocus); @@ -5056,6 +5059,8 @@ int main(int argc, char* argv[]) { #if !defined(C_SDL2) /* -- -- decide whether to set menu */ + void DOSBox_SetSysMenu(void); + DOSBox_SetSysMenu(); if (menu_gui && !control->opt_nomenu) DOSBox_SetMenu(); #endif