|
@@ -16,7 +16,8 @@
|
|
|
|
|
|
// CHANGELOG
|
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
-// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after iniitializing backend.
|
|
|
+// 2022-03-23: Inputs: Fixed a regression in 1.87 which resulted in keyboard modifiers events being reported incorrectly on Linux/X11.
|
|
|
+// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after initializing backend.
|
|
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
|
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
|
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
|
@@ -244,6 +245,19 @@ static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static int ImGui_ImplGlfw_KeyToModifier(int key)
|
|
|
+{
|
|
|
+ if (key == GLFW_KEY_LEFT_CONTROL || key == GLFW_KEY_RIGHT_CONTROL)
|
|
|
+ return GLFW_MOD_CONTROL;
|
|
|
+ if (key == GLFW_KEY_LEFT_SHIFT || key == GLFW_KEY_RIGHT_SHIFT)
|
|
|
+ return GLFW_MOD_SHIFT;
|
|
|
+ if (key == GLFW_KEY_LEFT_ALT || key == GLFW_KEY_RIGHT_ALT)
|
|
|
+ return GLFW_MOD_ALT;
|
|
|
+ if (key == GLFW_KEY_LEFT_SUPER || key == GLFW_KEY_RIGHT_SUPER)
|
|
|
+ return GLFW_MOD_SUPER;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static void ImGui_ImplGlfw_UpdateKeyModifiers(int mods)
|
|
|
{
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
@@ -312,6 +326,9 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int keycode, int scancode, i
|
|
|
if (action != GLFW_PRESS && action != GLFW_RELEASE)
|
|
|
return;
|
|
|
|
|
|
+ // Workaround: X11 does not include current pressed/released modifier key in 'mods' flags. https://github.com/glfw/glfw/issues/1630
|
|
|
+ if (int keycode_to_mod = ImGui_ImplGlfw_KeyToModifier(keycode))
|
|
|
+ mods = (action == GLFW_PRESS) ? (mods | keycode_to_mod) : (mods & ~keycode_to_mod);
|
|
|
ImGui_ImplGlfw_UpdateKeyModifiers(mods);
|
|
|
|
|
|
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
|