clutter: Add ClutterModifierSet argument to key event constructor
This struct contains the pressed/latched/locked set of modifiers applying to the event, and may be filled in by backends generating those events. Other places where we forward modified key events, state may be normally obtained from the original event. Since this constructor is used in a variety of places, this commit updates them all in one go. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3369>
This commit is contained in:
parent
2e897fccd5
commit
38228da550
@ -18,6 +18,7 @@ ClutterEvent * clutter_event_key_new (ClutterEventType type,
|
||||
ClutterEventFlags flags,
|
||||
int64_t timestamp_us,
|
||||
ClutterInputDevice *source_device,
|
||||
ClutterModifierSet raw_modifiers,
|
||||
ClutterModifierType modifiers,
|
||||
uint32_t keyval,
|
||||
uint32_t evcode,
|
||||
|
@ -1858,6 +1858,7 @@ clutter_event_key_new (ClutterEventType type,
|
||||
ClutterEventFlags flags,
|
||||
int64_t timestamp_us,
|
||||
ClutterInputDevice *source_device,
|
||||
ClutterModifierSet raw_modifiers,
|
||||
ClutterModifierType modifiers,
|
||||
uint32_t keyval,
|
||||
uint32_t evcode,
|
||||
@ -1877,6 +1878,7 @@ clutter_event_key_new (ClutterEventType type,
|
||||
|
||||
event->key.time_us = timestamp_us;
|
||||
event->key.flags = flags;
|
||||
event->key.raw_modifiers = raw_modifiers;
|
||||
event->key.modifier_state = modifiers;
|
||||
event->key.keyval = keyval;
|
||||
event->key.hardware_keycode = keycode;
|
||||
|
@ -360,8 +360,14 @@ clutter_input_method_notify_key_event (ClutterInputMethod *im,
|
||||
{
|
||||
if (!filtered)
|
||||
{
|
||||
ClutterModifierSet raw_modifiers;
|
||||
ClutterEvent *copy;
|
||||
|
||||
clutter_event_get_key_state (event,
|
||||
&raw_modifiers.pressed,
|
||||
&raw_modifiers.latched,
|
||||
&raw_modifiers.locked);
|
||||
|
||||
/* XXX: we rely on the IM implementation to notify back of
|
||||
* key events in the exact same order they were given.
|
||||
*/
|
||||
@ -370,6 +376,7 @@ clutter_input_method_notify_key_event (ClutterInputMethod *im,
|
||||
CLUTTER_EVENT_FLAG_INPUT_METHOD,
|
||||
clutter_event_get_time_us (event),
|
||||
clutter_event_get_device (event),
|
||||
raw_modifiers,
|
||||
clutter_event_get_state (event),
|
||||
clutter_event_get_key_symbol (event),
|
||||
clutter_event_get_event_code (event),
|
||||
@ -490,6 +497,7 @@ clutter_input_method_forward_key (ClutterInputMethod *im,
|
||||
CLUTTER_EVENT_FLAG_INPUT_METHOD,
|
||||
time_,
|
||||
keyboard,
|
||||
(ClutterModifierSet) { 0, },
|
||||
state,
|
||||
keyval,
|
||||
keycode - 8,
|
||||
|
@ -275,14 +275,21 @@ trigger_slow_keys (gpointer data)
|
||||
{
|
||||
SlowKeysEventPending *slow_keys_event = data;
|
||||
MetaInputDeviceNative *device = slow_keys_event->device;
|
||||
ClutterModifierSet raw_modifiers;
|
||||
ClutterEvent *event = slow_keys_event->event;
|
||||
ClutterEvent *copy;
|
||||
|
||||
clutter_event_get_key_state (event,
|
||||
&raw_modifiers.pressed,
|
||||
&raw_modifiers.latched,
|
||||
&raw_modifiers.locked);
|
||||
|
||||
/* Alter timestamp and emit the event */
|
||||
copy = clutter_event_key_new (clutter_event_type (event),
|
||||
clutter_event_get_flags (event),
|
||||
g_get_monotonic_time (),
|
||||
clutter_event_get_source_device (event),
|
||||
raw_modifiers,
|
||||
clutter_event_get_state (event),
|
||||
clutter_event_get_key_symbol (event),
|
||||
clutter_event_get_event_code (event),
|
||||
@ -524,6 +531,7 @@ rewrite_stickykeys_event (ClutterEvent *event,
|
||||
{
|
||||
MetaSeatImpl *seat_impl = seat_impl_from_device_native (device);
|
||||
struct xkb_state *xkb_state;
|
||||
ClutterModifierSet raw_modifiers;
|
||||
ClutterEvent *rewritten_event;
|
||||
ClutterModifierType modifiers;
|
||||
|
||||
@ -533,11 +541,18 @@ rewrite_stickykeys_event (ClutterEvent *event,
|
||||
xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE) |
|
||||
seat_impl->button_state;
|
||||
|
||||
raw_modifiers = (ClutterModifierSet) {
|
||||
.pressed = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_DEPRESSED),
|
||||
.latched = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LATCHED),
|
||||
.locked = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LOCKED),
|
||||
};
|
||||
|
||||
rewritten_event =
|
||||
clutter_event_key_new (clutter_event_type (event),
|
||||
clutter_event_get_flags (event),
|
||||
clutter_event_get_time_us (event),
|
||||
clutter_event_get_source_device (event),
|
||||
raw_modifiers,
|
||||
modifiers,
|
||||
clutter_event_get_key_symbol (event),
|
||||
clutter_event_get_event_code (event),
|
||||
|
@ -53,6 +53,7 @@ meta_key_event_new_from_evdev (ClutterInputDevice *device,
|
||||
char buffer[8];
|
||||
gunichar unicode_value;
|
||||
ClutterModifierType modifiers;
|
||||
ClutterModifierSet raw_modifiers;
|
||||
int n;
|
||||
|
||||
/* We use a fixed offset of 8 because evdev starts KEY_* numbering from
|
||||
@ -63,6 +64,12 @@ meta_key_event_new_from_evdev (ClutterInputDevice *device,
|
||||
|
||||
sym = xkb_state_key_get_one_sym (xkb_state, key);
|
||||
|
||||
raw_modifiers = (ClutterModifierSet) {
|
||||
.pressed = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_DEPRESSED),
|
||||
.latched = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LATCHED),
|
||||
.locked = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LOCKED),
|
||||
};
|
||||
|
||||
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE) |
|
||||
button_state;
|
||||
|
||||
@ -85,6 +92,7 @@ meta_key_event_new_from_evdev (ClutterInputDevice *device,
|
||||
flags,
|
||||
time_us,
|
||||
device,
|
||||
raw_modifiers,
|
||||
modifiers,
|
||||
sym,
|
||||
key - 8,
|
||||
|
@ -2111,6 +2111,7 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
||||
MetaKeymapX11 *keymap_x11 = seat->keymap;
|
||||
char buffer[7] = { 0, };
|
||||
uint32_t keyval, evcode, keycode;
|
||||
ClutterModifierSet raw_modifiers;
|
||||
ClutterModifierType state;
|
||||
int len;
|
||||
gunichar unicode_value;
|
||||
@ -2119,6 +2120,12 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
||||
if (!source_device)
|
||||
return NULL;
|
||||
|
||||
raw_modifiers = (ClutterModifierSet) {
|
||||
.pressed = xev->mods.base,
|
||||
.latched = xev->mods.latched,
|
||||
.locked = xev->mods.locked,
|
||||
};
|
||||
|
||||
state = translate_state (&xev->buttons, &xev->mods, &xev->group);
|
||||
|
||||
keycode = xev->detail;
|
||||
@ -2156,6 +2163,7 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
|
||||
CLUTTER_EVENT_NONE,
|
||||
ms2us (xev->time),
|
||||
source_device,
|
||||
raw_modifiers,
|
||||
state,
|
||||
keyval,
|
||||
evcode,
|
||||
|
@ -235,6 +235,7 @@ send_keyval (KeyGroup *group, int keyval)
|
||||
CLUTTER_EVENT_FLAG_SYNTHETIC,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
clutter_seat_get_keyboard (seat),
|
||||
(ClutterModifierSet) { 0, },
|
||||
0,
|
||||
keyval,
|
||||
0, 0, 0);
|
||||
|
@ -339,6 +339,7 @@ send_keyval (ClutterText *text, int keyval)
|
||||
CLUTTER_EVENT_FLAG_SYNTHETIC,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
clutter_seat_get_keyboard (seat),
|
||||
(ClutterModifierSet) { 0, },
|
||||
0, keyval, 0, 0, 0);
|
||||
|
||||
clutter_actor_event (CLUTTER_ACTOR (text), event, FALSE);
|
||||
@ -358,6 +359,7 @@ send_unichar (ClutterText *text, gunichar unichar)
|
||||
CLUTTER_EVENT_FLAG_SYNTHETIC,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
clutter_seat_get_keyboard (seat),
|
||||
(ClutterModifierSet) { 0, },
|
||||
0, 0, 0, 0, unichar);
|
||||
|
||||
clutter_actor_event (CLUTTER_ACTOR (text), event, FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user