diff --git a/os/x11/window.cpp b/os/x11/window.cpp index 3de5fe430..34b600d98 100644 --- a/os/x11/window.cpp +++ b/os/x11/window.cpp @@ -34,6 +34,7 @@ #include #include +#include #define KEY_TRACE(...) #define EVENT_TRACE(...) @@ -115,6 +116,10 @@ std::map<::Window, WindowX11*> g_activeWindows; // for the XInput devices. Time g_lastXInputEventTime = 0; +// Set of all currently pressed keys - used during processing KeyPress or KeyRelease +// event +std::set g_pressedKeys; + bool is_mouse_wheel_button(int button) { return (button == Button4 || button == Button5 || @@ -1042,17 +1047,19 @@ void WindowX11::processX11Event(XEvent& event) KEY_TRACE("Xutf8LookupString %s\n", &buf[0]); } - // Check if the key has been pressed, - // and if yes - check if it's the same one key - // as in the previous event. If it's the same one - // - it means key is being held, so set repeat to 1. + + // Check if the key has been pressed, and if yes - check what's + // the previous state of the key symbol - if it was previously + // pressed set repeat count of 1, if it wasn't pressed previously + // it will set repeat count to 0 if (event.type == KeyPress) { - if (keysym == m_pressedKeySym) + if (g_pressedKeys.find(keysym) != g_pressedKeys.end()) ev.setRepeat(1); - m_pressedKeySym = keysym; + else + g_pressedKeys.insert(keysym); } else - m_pressedKeySym = 0; + g_pressedKeys.erase(keysym); // Key event used by the input method (e.g. when the users // presses a dead key). diff --git a/os/x11/window.h b/os/x11/window.h index 5fd9d637b..1625d5d1a 100644 --- a/os/x11/window.h +++ b/os/x11/window.h @@ -128,8 +128,6 @@ class WindowX11 : public Window { bool m_resizable = false; bool m_transparent = false; - KeySym m_pressedKeySym = 0; - // Double-click info Event::MouseButton m_doubleClickButton; base::tick_t m_doubleClickTick;