clutter: Push commit/delete_sourrounding as IM events
These are not given directly to the input focus anymore, instead queued up as events. This way, all actions triggered by the input method (commit and preedit buffer ones, but also synthesized key events) queue up the same way, and are thus processed in the exact same order than they are given to us. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1286
This commit is contained in:
parent
4a43e295d2
commit
98c1a469ad
@ -277,17 +277,45 @@ clutter_input_method_get_focus (ClutterInputMethod *im)
|
|||||||
return priv->focus;
|
return priv->focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_input_method_put_im_event (ClutterInputMethod *im,
|
||||||
|
ClutterEventType event_type,
|
||||||
|
const char *text,
|
||||||
|
int32_t offset,
|
||||||
|
uint32_t len)
|
||||||
|
{
|
||||||
|
ClutterInputDevice *keyboard;
|
||||||
|
ClutterSeat *seat;
|
||||||
|
ClutterStage *stage;
|
||||||
|
ClutterEvent *event;
|
||||||
|
|
||||||
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||||
|
keyboard = clutter_seat_get_keyboard (seat);
|
||||||
|
stage = _clutter_input_device_get_stage (keyboard);
|
||||||
|
if (stage == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
event = clutter_event_new (event_type);
|
||||||
|
event->im.text = g_strdup (text);
|
||||||
|
event->im.offset = offset;
|
||||||
|
event->im.len = len;
|
||||||
|
clutter_event_set_device (event, keyboard);
|
||||||
|
clutter_event_set_source_device (event, keyboard);
|
||||||
|
clutter_event_set_flags (event, CLUTTER_EVENT_FLAG_INPUT_METHOD);
|
||||||
|
|
||||||
|
clutter_event_set_stage (event, stage);
|
||||||
|
|
||||||
|
clutter_event_put (event);
|
||||||
|
clutter_event_free (event);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
clutter_input_method_commit (ClutterInputMethod *im,
|
clutter_input_method_commit (ClutterInputMethod *im,
|
||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
ClutterInputMethodPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
|
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
|
||||||
|
|
||||||
priv = clutter_input_method_get_instance_private (im);
|
clutter_input_method_put_im_event (im, CLUTTER_IM_COMMIT, text, 0, 0);
|
||||||
if (priv->focus)
|
|
||||||
clutter_input_focus_commit (priv->focus, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -295,13 +323,9 @@ clutter_input_method_delete_surrounding (ClutterInputMethod *im,
|
|||||||
int offset,
|
int offset,
|
||||||
guint len)
|
guint len)
|
||||||
{
|
{
|
||||||
ClutterInputMethodPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
|
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
|
||||||
|
|
||||||
priv = clutter_input_method_get_instance_private (im);
|
clutter_input_method_put_im_event (im, CLUTTER_IM_DELETE, NULL, offset, len);
|
||||||
if (priv->focus)
|
|
||||||
clutter_input_focus_delete_surrounding (priv->focus, offset, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -329,13 +353,9 @@ clutter_input_method_set_preedit_text (ClutterInputMethod *im,
|
|||||||
const gchar *preedit,
|
const gchar *preedit,
|
||||||
guint cursor)
|
guint cursor)
|
||||||
{
|
{
|
||||||
ClutterInputMethodPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
|
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
|
||||||
|
|
||||||
priv = clutter_input_method_get_instance_private (im);
|
clutter_input_method_put_im_event (im, CLUTTER_IM_PREEDIT, preedit, cursor, 0);
|
||||||
if (priv->focus)
|
|
||||||
clutter_input_focus_set_preedit_text (priv->focus, preedit, cursor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user