diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 61ec2d356..64e5774cf 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -105,6 +105,8 @@ bool OpenGL_using(void); using namespace std; +bool window_was_maximized = false; + Bitu userResizeWindowWidth = 0, userResizeWindowHeight = 0; Bitu currentWindowWidth = 640, currentWindowHeight = 480; @@ -1741,9 +1743,13 @@ static LRESULT CALLBACK WinExtHookKeyboardHookProc(int nCode,WPARAM wParam,LPARA wParam = WM_USER + 0x101; } + DWORD lParam = + (st_hook->scanCode << 8U) + + ((st_hook->flags & LLKHF_EXTENDED) ? 0x01000000 : 0) + + ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) ? 0xC0000000 : 0); + // catch the keystroke, post it to ourself, do not pass it on - PostMessage(myHwnd, wParam, st_hook->vkCode, - (st_hook->flags & 0x80/*transition state*/) ? 0x0000 : 0xA000/*bits 13&15 are set*/); + PostMessage(myHwnd, wParam, st_hook->vkCode, lParam); return TRUE; } } @@ -3067,7 +3073,7 @@ static void HandleVideoResize(void * event) { /* assume the resize comes from user preference UNLESS the window * is fullscreen or maximized */ - if (!menu.maxwindow && !sdl.desktop.fullscreen && !sdl.init_ignore && NonUserResizeCounter == 0) { + if (!menu.maxwindow && !sdl.desktop.fullscreen && !sdl.init_ignore && NonUserResizeCounter == 0 && !window_was_maximized) { UpdateWindowDimensions(); UpdateWindowDimensions(ResizeEvent->w, ResizeEvent->h); @@ -3084,6 +3090,7 @@ static void HandleVideoResize(void * event) { UpdateWindowDimensions(); } + window_was_maximized = menu.maxwindow; if (NonUserResizeCounter > 0) NonUserResizeCounter--; diff --git a/vs2015/sdl/src/video/windib/SDL_dibevents.c b/vs2015/sdl/src/video/windib/SDL_dibevents.c index 44134d178..9a31bc14c 100644 --- a/vs2015/sdl/src/video/windib/SDL_dibevents.c +++ b/vs2015/sdl/src/video/windib/SDL_dibevents.c @@ -50,6 +50,8 @@ #define NO_GETKEYBOARDSTATE #endif +static HKL hLayout = NULL; + /* The translation table from a Microsoft VK keysym to a SDL keysym */ static SDLKey VK_keymap[SDLK_LAST]; static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed); @@ -192,6 +194,13 @@ LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar ShowWindow(ParentWindowHWND, SW_RESTORE); } break; + /* FIXME: I like how Microsoft defines a perfectly reasonable message but does not send it to us + when the user selects a different language from the language bar. >:( */ + case WM_INPUTLANGCHANGE: + hLayout = (HKL)wParam; + return(1); + case WM_INPUTLANGCHANGEREQUEST: /* We must use DefWindowProc() or else Windows will not notify us of input layout changes */ + return DefWindowProc(hwnd, msg, wParam, lParam); case WM_SYSKEYDOWN: case WM_KEYDOWN: { @@ -460,40 +469,12 @@ void DIB_CheckMouse(void) { last_dib_mouse_motion = SDL_GetTicks(); } -static HKL hLayoutUS = NULL; - void DIB_InitOSKeymap(_THIS) { int i; -#ifndef _WIN32_WCE - char current_layout[KL_NAMELENGTH]; - GetKeyboardLayoutName(current_layout); - //printf("Initial Keyboard Layout Name: '%s'\n", current_layout); + hLayout = GetKeyboardLayout(0); - hLayoutUS = LoadKeyboardLayout("00000409", KLF_NOTELLSHELL); - - if (!hLayoutUS) { - //printf("Failed to load US keyboard layout. Using current.\n"); - hLayoutUS = GetKeyboardLayout(0); - } - LoadKeyboardLayout(current_layout, KLF_ACTIVATE); -#else -#if _WIN32_WCE >=420 - TCHAR current_layout[KL_NAMELENGTH]; - - GetKeyboardLayoutName(current_layout); - //printf("Initial Keyboard Layout Name: '%s'\n", current_layout); - - hLayoutUS = LoadKeyboardLayout(L"00000409", 0); - - if (!hLayoutUS) { - //printf("Failed to load US keyboard layout. Using current.\n"); - hLayoutUS = GetKeyboardLayout(0); - } - LoadKeyboardLayout(current_layout, 0); -#endif // _WIN32_WCE >=420 -#endif /* Map the VK keysyms */ for ( i=0; isym, vkey, scancode, - MapVirtualKeyEx(sc, 1, hLayoutUS), - MapVirtualKeyEx(sc, 3, hLayoutUS), - MapVirtualKeyEx(sc, 1, hLayoutCurrent), - MapVirtualKeyEx(sc, 3, hLayoutCurrent) - ); - } -#endif return(keysym); }