[mutter/wip/carlosg/im-events: 9/11] clutter: Push commit/delete_sourrounding as IM events
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/im-events: 9/11] clutter: Push commit/delete_sourrounding as IM events
- Date: Mon, 31 Aug 2020 08:40:13 +0000 (UTC)
commit 51760692b0f263327dfa64e042726edde4d18d2d
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Feb 17 11:03:51 2020 +0100
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
clutter/clutter/clutter-input-method.c | 50 ++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/clutter/clutter/clutter-input-method.c b/clutter/clutter/clutter-input-method.c
index 031b103df5..438edfe5ce 100644
--- a/clutter/clutter/clutter-input-method.c
+++ b/clutter/clutter/clutter-input-method.c
@@ -277,17 +277,45 @@ clutter_input_method_get_focus (ClutterInputMethod *im)
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
clutter_input_method_commit (ClutterInputMethod *im,
const gchar *text)
{
- ClutterInputMethodPrivate *priv;
-
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
- priv = clutter_input_method_get_instance_private (im);
- if (priv->focus)
- clutter_input_focus_commit (priv->focus, text);
+ clutter_input_method_put_im_event (im, CLUTTER_IM_COMMIT, text, 0, 0);
}
void
@@ -295,13 +323,9 @@ clutter_input_method_delete_surrounding (ClutterInputMethod *im,
int offset,
guint len)
{
- ClutterInputMethodPrivate *priv;
-
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
- priv = clutter_input_method_get_instance_private (im);
- if (priv->focus)
- clutter_input_focus_delete_surrounding (priv->focus, offset, len);
+ clutter_input_method_put_im_event (im, CLUTTER_IM_DELETE, NULL, offset, len);
}
void
@@ -329,13 +353,9 @@ clutter_input_method_set_preedit_text (ClutterInputMethod *im,
const gchar *preedit,
guint cursor)
{
- ClutterInputMethodPrivate *priv;
-
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
- priv = clutter_input_method_get_instance_private (im);
- if (priv->focus)
- clutter_input_focus_set_preedit_text (priv->focus, preedit, cursor);
+ clutter_input_method_put_im_event (im, CLUTTER_IM_PREEDIT, preedit, cursor, 0);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]