mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
Allow only synthetic events with keyval 0
We allow KeyEvents with a key symbol of '0' to fall through only if they are marked as synthetic. Otherwise we discard them without mercy. Synthetic events are useful to test ClutterText behaviour; in fact, we do use them inside the test suite exactly for that reason.
This commit is contained in:
parent
77b3b9d5f4
commit
786bc4d4d5
@ -920,20 +920,36 @@ clutter_text_key_press (ClutterActor *actor,
|
||||
pool = clutter_binding_pool_find (G_OBJECT_TYPE_NAME (actor));
|
||||
g_assert (pool != NULL);
|
||||
|
||||
res = clutter_binding_pool_activate (pool, keyval,
|
||||
event->modifier_state,
|
||||
G_OBJECT (actor));
|
||||
/* we allow passing synthetic events that only contain
|
||||
* the Unicode value and not the key symbol
|
||||
*/
|
||||
if (keyval == 0 && (event->flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
|
||||
res = FALSE;
|
||||
else
|
||||
res = clutter_binding_pool_activate (pool, keyval,
|
||||
event->modifier_state,
|
||||
G_OBJECT (actor));
|
||||
|
||||
/* if the key binding has handled the event we bail out
|
||||
* as fast as we can; otherwise, we try to insert the
|
||||
* Unicode character inside the key event into the text
|
||||
* actor
|
||||
*/
|
||||
if (res)
|
||||
return TRUE;
|
||||
else
|
||||
{
|
||||
gunichar key_unichar = clutter_key_event_unicode (event);
|
||||
|
||||
if (key_unichar == '\r') /* return is reported as CR we want LF */
|
||||
/* return is reported as CR, but we want LF */
|
||||
if (key_unichar == '\r')
|
||||
key_unichar = '\n';
|
||||
|
||||
if (g_unichar_validate (key_unichar))
|
||||
{
|
||||
/* truncate the eventual selection so that the
|
||||
* Unicode character can replace it
|
||||
*/
|
||||
clutter_text_truncate_selection (self);
|
||||
clutter_text_insert_unichar (self, key_unichar);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user