-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't enter characters with Alt-Gr modifier on Ubuntu #6034
Comments
Hello,
I also cannot seem to repro this on Windows with the GLFW backend. Does it makes a difference whether you have
Not your issue per-se, but one little thing to clarify: if the InputText() field is submitted before ShowDemoWindow(), you may not see the display in Other than that, I am failing to understand why the What you can do to help:
Then debug step into the const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
....
if (io.InputQueueCharacters.Size > 0)
{
if (!ignore_char_inputs && !is_readonly && !input_requested_by_nav)
for (int n = 0; n < io.InputQueueCharacters.Size; n++)
{
// Insert character if they pass filtering
unsigned int c = (unsigned int)io.InputQueueCharacters[n];
if (c == '\t') // Skip Tab, see above.
continue;
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard))
state->OnKeyPressed((int)c);
}
... The most likely reason I can imagine is if perhaps X-Window or GLFW alter mods at the time character submission. You may also use Demo->Tools->Debug Log and click "IO" to visualize events. Thank you! and happy new year! |
Thank you for the quick response and a Happy New Year! I completely forgot about the IO config flags and checked the When it's enabled (like in the example_glfw_opengl3 from the docking branch), ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls I'm unable to enter the the characters which include the Alt-Gr flag. I've noticed in debugging on my Linux machine, that your referenced part of the When I disable the flag I'm successfully able to enter the characters on Linux. I've validated this in debugging on my Linux machine that in this case the Enabling/disabling the
Under keys down only RightAlt and 7 are reported, key mods only reports ALT for a short time. This is output of the Demo->Tools->Debug Log for a Alt-GR + 7 press:
Ctrl and Alt in the debug printf statement are always |
Going to investigate, but in the meanwhile: could you try with the SDL backend, both in latest version and with a version older than 1.86 ? See if the bug happens with either. |
It seems incorrect that GLFW Bug/Discussion: glfw/glfw#1630 + glfw/glfw#2155 Prior to the 1.87 work we did extrapolate modifiers from keys: // Modifiers are not reliable across systems
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
#ifdef _WIN32
io.KeySuper = false;
#else
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
#endif Further commits e.g. ecd212c massaged it to e.g. static void ImGui_ImplGlfw_UpdateKeyModifiers()
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGuiIO& io = ImGui::GetIO();
io.KeyShift = ((glfwGetKey(bd->Window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS));
io.KeyCtrl = ((glfwGetKey(bd->Window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS));
io.KeyAlt = ((glfwGetKey(bd->Window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS));
io.KeySuper = ((glfwGetKey(bd->Window, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS));
} And then commit 0755767 started switching to relying on mods provided by GLFW, which probably introduced the bug. Looking for the source of "// Modifiers are not reliable across systems" comment I tracked it to 71429d3 (very old) and the code itself to 4b7be31 (very old) which has no related issue/comments. But TL;DR;
A possible fix may be to change static void ImGui_ImplGlfw_UpdateKeyModifiers(int mods)
{
(void)mods; // UNUSED
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
io.AddKeyEvent(ImGuiMod_Ctrl, (glfwGetKey(bd->Window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS));
io.AddKeyEvent(ImGuiMod_Shift, (glfwGetKey(bd->Window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS));
io.AddKeyEvent(ImGuiMod_Alt, (glfwGetKey(bd->Window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS));
io.AddKeyEvent(ImGuiMod_Super, (glfwGetKey(bd->Window, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS));
} Can you test this? |
One problem with aforementioned change is:
One possible thing is we apply the change above (if it works) making GLFW backends slightly inconsistent, hoping it doesn't matter. Another possible thing is we conditionally only apply it on Linux. I would think it is better to it everywhere so we are most likely to detect issues (Linux+German+GLFW is a rarer combination that German+GLFW). And if we end up finding another issue we can decide if we want Linux only workaround later. |
Sure, I will test it tonight. |
I've done some quick testing with your proposed fix to the
I'm aware, that the Alt-Gr key and functionality is something special due to language and keyboard layout, where other regions don't have it or it's behavior is different. I'm honest, that I would like to see a general GLFW fix for it, as this seems to be a lower problem and (I guess) it also affects other people then me. I don't know, if I should report this issue to GLFW, as looking into the issues glfw/glfw#1630 and glfw/glfw#1502 suggests, that It's a known problem. Reading those two issues I'm still unclear what the current progress / status of those issues are. When I have some spare time the coming days I will still try the SDL backend (with the two ImGui versions) on Linux and see how that backend behaves. Initially I've chosen the GLFW backend as it's smaller than SDL, I have no need for audio and the support for the desktop platforms is enough for me as the goal was to create a cross platform GUI application that looks quite same on Windows & Linux and isn't bloated (like Qt). |
…. German keyboard layout), (#6034) Amend 0755767, 1ad8ad6 Ref maybe glfw/glfw#1630
The fix essentially gets us back to mods polling we used before January 2022, I am fine with it. Pushed fix as 1f6e62a I think it may be worth reporting this to GLFW separately I am not sure 100% this is the same as their other issues. Thanks for reporting and helping to look into that. Hopefully it won't bite us back again :) |
…. German keyboard layout), (ocornut#6034) Amend 0755767, 1ad8ad6 Ref maybe glfw/glfw#1630
Version/Branch of Dear ImGui:
Version: 1.89.2 (18916)
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: g++
Operating System: Ubuntu 22.04
My Issue/Question:
When entering characters on a keyboard with German-Layout (ISO-Layout, DE-de) that require the use of the Alt-Gr-Key, those get recognized by ImGui, but don't get entered/displayed in InputText fields. Example characters are
@
or}
. It can be checked, that the right characters are recognized underInputs/Chars queue
in the demo window. When entering those characters, it sometimes tries to do window navigation. Rendering of those characters works perfectly in regular text fields. This issue only exists on Ubuntu, on Windows 10 (same backend with MinGW64 g++ and same code) I'm able to enter those characters.Further testing I've done:
Expected result: Enter the characters into InputText.
Screenshots/Video
Preview from the
Inputs/Chars queue
section in the demo window on UbuntuStandalone, minimal, complete and verifiable example:
Try entering characters ,which require the Alt-Gr modifier, to reproduce it.
Note:
Thanks for the great work on ImGui! This is my first issue to a larger project. I hope I've provided all important information. If further information is needed, I'm happy to help.
The text was updated successfully, but these errors were encountered: