Don't eagerly set wxKeyEvent position fields.
This results in a noticeable delay when using wxGTK via a remote X11 connection for every key event as a round trip to server is needed to get the mouse pointer position every time a key is pressed or released. Only provide the position on demand. And explain that it's actually not very useful as it's simply the same as the current mouse position. Closes #14361. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1699,10 +1699,10 @@ public:
|
||||
{ return wxPoint(m_x, m_y); }
|
||||
|
||||
// Get X position
|
||||
wxCoord GetX() const { return m_x; }
|
||||
wxCoord GetX() const;
|
||||
|
||||
// Get Y position
|
||||
wxCoord GetY() const { return m_y; }
|
||||
wxCoord GetY() const;
|
||||
|
||||
// Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal
|
||||
// key events even though the event had been handled (by default they would
|
||||
@@ -1766,6 +1766,7 @@ private:
|
||||
{
|
||||
m_x = evt.m_x;
|
||||
m_y = evt.m_y;
|
||||
m_hasPosition = evt.m_hasPosition;
|
||||
|
||||
m_keyCode = evt.m_keyCode;
|
||||
|
||||
@@ -1776,11 +1777,19 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
// Initialize m_x and m_y using the current mouse cursor position if
|
||||
// necessary.
|
||||
void InitPositionIfNecessary() const;
|
||||
|
||||
// If this flag is true, the normal key events should still be generated
|
||||
// even if wxEVT_CHAR_HOOK had been handled. By default it is false as
|
||||
// handling wxEVT_CHAR_HOOK suppresses all the subsequent events.
|
||||
bool m_allowNext;
|
||||
|
||||
// If true, m_x and m_y were already initialized. If false, try to get them
|
||||
// when they're requested.
|
||||
bool m_hasPosition;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxKeyEvent)
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user