[mutter/wip/carlosg/im-events: 2/3] clutter: Prepare input focus for IM event delivery
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/im-events: 2/3] clutter: Prepare input focus for IM event delivery
- Date: Wed, 3 Jun 2020 10:48:42 +0000 (UTC)
commit 7fa8c103537c9c5c6413c76fe562858c1f33b773
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Feb 17 11:25:14 2020 +0100
clutter: Prepare input focus for IM event delivery
The clutter_input_focus_filter_key_event() function has been made
a more generic filter_event(). Besides its old role about letting
key events go through the IM, it will also process the IM events
that are possibly injected as a result.
Users have been updated to these changes.
clutter/clutter/clutter-input-focus.c | 23 ++++++++++++++++++++---
clutter/clutter/clutter-input-focus.h | 4 ++--
clutter/clutter/clutter-text.c | 22 ++++++++++++++++++++--
src/wayland/meta-wayland-seat.c | 9 +++++++++
src/wayland/meta-wayland-text-input-legacy.c | 3 +--
src/wayland/meta-wayland-text-input.c | 3 +--
6 files changed, 53 insertions(+), 11 deletions(-)
---
diff --git a/clutter/clutter/clutter-input-focus.c b/clutter/clutter/clutter-input-focus.c
index ece1fa59ac..30571ff04f 100644
--- a/clutter/clutter/clutter-input-focus.c
+++ b/clutter/clutter/clutter-input-focus.c
@@ -147,8 +147,8 @@ clutter_input_focus_set_content_purpose (ClutterInputFocus *focus,
}
gboolean
-clutter_input_focus_filter_key_event (ClutterInputFocus *focus,
- const ClutterKeyEvent *key)
+clutter_input_focus_filter_event (ClutterInputFocus *focus,
+ const ClutterEvent *event)
{
ClutterInputFocusPrivate *priv;
@@ -157,7 +157,24 @@ clutter_input_focus_filter_key_event (ClutterInputFocus *focus,
priv = clutter_input_focus_get_instance_private (focus);
- return clutter_input_method_filter_key_event (priv->im, key);
+ if (event->type == CLUTTER_KEY_PRESS ||
+ event->type == CLUTTER_KEY_RELEASE)
+ {
+ return clutter_input_method_filter_key_event (priv->im, &event->key);
+ }
+ else if (event->type == CLUTTER_IM_COMMIT)
+ {
+ clutter_input_focus_commit (focus, event->im.text);
+ return TRUE;
+ }
+ else if (event->type == CLUTTER_IM_DELETE)
+ {
+ clutter_input_focus_delete_surrounding (focus, event->im.offset,
+ event->im.len);
+ return TRUE;
+ }
+
+ return FALSE;
}
void
diff --git a/clutter/clutter/clutter-input-focus.h b/clutter/clutter/clutter-input-focus.h
index 008883af6b..77f5d90767 100644
--- a/clutter/clutter/clutter-input-focus.h
+++ b/clutter/clutter/clutter-input-focus.h
@@ -72,8 +72,8 @@ CLUTTER_EXPORT
void clutter_input_focus_set_content_purpose (ClutterInputFocus *focus,
ClutterInputContentPurpose purpose);
CLUTTER_EXPORT
-gboolean clutter_input_focus_filter_key_event (ClutterInputFocus *focus,
- const ClutterKeyEvent *key);
+gboolean clutter_input_focus_filter_event (ClutterInputFocus *focus,
+ const ClutterEvent *event);
CLUTTER_EXPORT
void clutter_input_focus_set_can_show_preedit (ClutterInputFocus *focus,
gboolean can_show_preedit);
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index 2886016fb6..bc8a66f13f 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -2421,7 +2421,7 @@ clutter_text_key_press (ClutterActor *actor,
if (!(event->flags & CLUTTER_EVENT_FLAG_INPUT_METHOD) &&
clutter_input_focus_is_focused (priv->input_focus) &&
- clutter_input_focus_filter_key_event (priv->input_focus, event))
+ clutter_input_focus_filter_event (priv->input_focus, (ClutterEvent *) event))
return CLUTTER_EVENT_STOP;
/* we allow passing synthetic events that only contain
@@ -2490,7 +2490,7 @@ clutter_text_key_release (ClutterActor *actor,
ClutterTextPrivate *priv = self->priv;
if (clutter_input_focus_is_focused (priv->input_focus) &&
- clutter_input_focus_filter_key_event (priv->input_focus, event))
+ clutter_input_focus_filter_event (priv->input_focus, (ClutterEvent *) event))
return CLUTTER_EVENT_STOP;
return CLUTTER_EVENT_PROPAGATE;
@@ -3066,6 +3066,23 @@ clutter_text_has_overlaps (ClutterActor *self)
return clutter_text_should_draw_cursor ((ClutterText *) self);
}
+static gboolean
+clutter_text_event (ClutterActor *self,
+ ClutterEvent *event)
+{
+ ClutterText *text = CLUTTER_TEXT (self);
+ ClutterTextPrivate *priv = text->priv;
+
+ if (clutter_input_focus_is_focused (priv->input_focus) &&
+ (event->type == CLUTTER_IM_COMMIT ||
+ event->type == CLUTTER_IM_DELETE))
+ {
+ return clutter_input_focus_filter_event (priv->input_focus, event);
+ }
+
+ return CLUTTER_EVENT_PROPAGATE;
+}
+
static void
clutter_text_im_focus (ClutterText *text)
{
@@ -3814,6 +3831,7 @@ clutter_text_class_init (ClutterTextClass *klass)
actor_class->key_focus_in = clutter_text_key_focus_in;
actor_class->key_focus_out = clutter_text_key_focus_out;
actor_class->has_overlaps = clutter_text_has_overlaps;
+ actor_class->event = clutter_text_event;
/**
* ClutterText:buffer:
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 3a76a1b5b9..da3c242c78 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -406,6 +406,15 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
if (meta_wayland_seat_has_touch (seat))
return meta_wayland_touch_handle_event (seat->touch, event);
+ break;
+ case CLUTTER_IM_COMMIT:
+ case CLUTTER_IM_DELETE:
+ if (meta_wayland_text_input_handle_event (seat->text_input, event))
+ return TRUE;
+ if (meta_wayland_gtk_text_input_handle_event (seat->gtk_text_input,
+ event))
+ return TRUE;
+
break;
default:
break;
diff --git a/src/wayland/meta-wayland-text-input-legacy.c b/src/wayland/meta-wayland-text-input-legacy.c
index d8f7d1d82c..442708e0f4 100644
--- a/src/wayland/meta-wayland-text-input-legacy.c
+++ b/src/wayland/meta-wayland-text-input-legacy.c
@@ -629,6 +629,5 @@ meta_wayland_gtk_text_input_handle_event (MetaWaylandGtkTextInput *text_input,
!clutter_input_focus_is_focused (text_input->input_focus))
return FALSE;
- return clutter_input_focus_filter_key_event (text_input->input_focus,
- (const ClutterKeyEvent *) event);
+ return clutter_input_focus_filter_event (text_input->input_focus, event);
}
diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c
index 570dba459b..1f7c8bc922 100644
--- a/src/wayland/meta-wayland-text-input.c
+++ b/src/wayland/meta-wayland-text-input.c
@@ -737,6 +737,5 @@ meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input,
!clutter_input_focus_is_focused (text_input->input_focus))
return FALSE;
- return clutter_input_focus_filter_key_event (text_input->input_focus,
- (const ClutterKeyEvent *) event);
+ return clutter_input_focus_filter_event (text_input->input_focus, event);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]