diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index 142b64092e80..b52ad14b8af4 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -355,4 +355,11 @@ void ImGui_ImplGlfw_NewFrame() // Update game controllers (if enabled and available) ImGui_ImplGlfw_UpdateGamepads(); + +#ifdef _WIN32 + // Workaround for issue https://github.com/ocornut/imgui/issues/2976 (upstream issue https://github.com/glfw/glfw/issues/1622). + io.KeysDown[GLFW_KEY_LEFT_SUPER] &= (::GetKeyState(VK_LWIN) & 0x8000) != 0; + io.KeysDown[GLFW_KEY_RIGHT_SUPER] &= (::GetKeyState(VK_RWIN) & 0x8000) != 0; + io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER]; +#endif } diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 8a295aaae2a5..6354f3d9719c 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -354,4 +354,11 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window) // Update game controllers (if enabled and available) ImGui_ImplSDL2_UpdateGamepads(); + +#ifdef _WIN32 + // Workaround for issue https://github.com/ocornut/imgui/issues/2976 (upstream issue https://bugzilla.libsdl.org/show_bug.cgi?id=4939). + io.KeysDown[SDL_SCANCODE_LGUI] &= (::GetKeyState(VK_LWIN) & 0x8000) != 0; + io.KeysDown[SDL_SCANCODE_RGUI] &= (::GetKeyState(VK_RWIN) & 0x8000) != 0; + io.KeySuper = io.KeysDown[SDL_SCANCODE_LGUI] || io.KeysDown[SDL_SCANCODE_RGUI]; +#endif } diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index ffe1e8bf7b9a..c83fe9df394d 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -220,7 +220,10 @@ void ImGui_ImplWin32_NewFrame() io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - io.KeySuper = false; + // Workaround for issue https://github.com/ocornut/imgui/issues/2976 (win32 does not send VK_KEYUP sometimes). + io.KeysDown[VK_LWIN] &= (::GetKeyState(VK_LWIN) & 0x8000) != 0; + io.KeysDown[VK_RWIN] &= (::GetKeyState(VK_RWIN) & 0x8000) != 0; + io.KeySuper = io.KeysDown[VK_LWIN] || io.KeysDown[VK_RWIN]; // io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below. // Update OS mouse position