[XCB] Avoid emitting text events when a key press does not generate text
Many keys will generate key press events but return an empty string from `xkb_state_key_get_utf8`, like modifier keys, arrow keys, function keys, etc. This checks if the string retrieved from such a key press is empty before emitting an associated text event for it, to avoid notifying a potentially large number of listeners about an empty string. Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
+7
-2
@@ -148,8 +148,13 @@ namespace AzFramework
|
||||
if (responseType == XCB_KEY_PRESS)
|
||||
{
|
||||
const auto* keyPress = reinterpret_cast<xcb_key_press_event_t*>(event);
|
||||
|
||||
QueueRawTextEvent(TextFromKeycode(m_xkbState.get(), keyPress->detail));
|
||||
{
|
||||
auto text = TextFromKeycode(m_xkbState.get(), keyPress->detail);
|
||||
if (!text.empty())
|
||||
{
|
||||
QueueRawTextEvent(AZStd::move(text));
|
||||
}
|
||||
}
|
||||
|
||||
if (const InputChannelId* key = InputChannelFromKeyEvent(keyPress->detail))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user