mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
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. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1286
This commit is contained in:
parent
612a17443a
commit
4a43e295d2
@ -147,8 +147,8 @@ clutter_input_focus_set_content_purpose (ClutterInputFocus *focus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
clutter_input_focus_filter_key_event (ClutterInputFocus *focus,
|
clutter_input_focus_filter_event (ClutterInputFocus *focus,
|
||||||
const ClutterKeyEvent *key)
|
const ClutterEvent *event)
|
||||||
{
|
{
|
||||||
ClutterInputFocusPrivate *priv;
|
ClutterInputFocusPrivate *priv;
|
||||||
|
|
||||||
@ -157,7 +157,30 @@ clutter_input_focus_filter_key_event (ClutterInputFocus *focus,
|
|||||||
|
|
||||||
priv = clutter_input_focus_get_instance_private (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;
|
||||||
|
}
|
||||||
|
else if (event->type == CLUTTER_IM_PREEDIT)
|
||||||
|
{
|
||||||
|
clutter_input_focus_set_preedit_text (focus, event->im.text,
|
||||||
|
event->im.offset);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -72,8 +72,8 @@ CLUTTER_EXPORT
|
|||||||
void clutter_input_focus_set_content_purpose (ClutterInputFocus *focus,
|
void clutter_input_focus_set_content_purpose (ClutterInputFocus *focus,
|
||||||
ClutterInputContentPurpose purpose);
|
ClutterInputContentPurpose purpose);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
gboolean clutter_input_focus_filter_key_event (ClutterInputFocus *focus,
|
gboolean clutter_input_focus_filter_event (ClutterInputFocus *focus,
|
||||||
const ClutterKeyEvent *key);
|
const ClutterEvent *event);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
void clutter_input_focus_set_can_show_preedit (ClutterInputFocus *focus,
|
void clutter_input_focus_set_can_show_preedit (ClutterInputFocus *focus,
|
||||||
gboolean can_show_preedit);
|
gboolean can_show_preedit);
|
||||||
|
@ -2400,7 +2400,8 @@ clutter_text_key_press (ClutterActor *actor,
|
|||||||
|
|
||||||
if (!(event->flags & CLUTTER_EVENT_FLAG_INPUT_METHOD) &&
|
if (!(event->flags & CLUTTER_EVENT_FLAG_INPUT_METHOD) &&
|
||||||
clutter_input_focus_is_focused (priv->input_focus) &&
|
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_STOP;
|
||||||
|
|
||||||
/* we allow passing synthetic events that only contain
|
/* we allow passing synthetic events that only contain
|
||||||
@ -2469,7 +2470,8 @@ clutter_text_key_release (ClutterActor *actor,
|
|||||||
ClutterTextPrivate *priv = self->priv;
|
ClutterTextPrivate *priv = self->priv;
|
||||||
|
|
||||||
if (clutter_input_focus_is_focused (priv->input_focus) &&
|
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_STOP;
|
||||||
|
|
||||||
return CLUTTER_EVENT_PROPAGATE;
|
return CLUTTER_EVENT_PROPAGATE;
|
||||||
@ -3068,6 +3070,24 @@ clutter_text_resource_scale_changed (ClutterActor *actor)
|
|||||||
clutter_actor_queue_immediate_relayout (actor);
|
clutter_actor_queue_immediate_relayout (actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ||
|
||||||
|
event->type == CLUTTER_IM_PREEDIT))
|
||||||
|
{
|
||||||
|
return clutter_input_focus_filter_event (priv->input_focus, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CLUTTER_EVENT_PROPAGATE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_text_im_focus (ClutterText *text)
|
clutter_text_im_focus (ClutterText *text)
|
||||||
{
|
{
|
||||||
@ -3818,6 +3838,7 @@ clutter_text_class_init (ClutterTextClass *klass)
|
|||||||
actor_class->has_overlaps = clutter_text_has_overlaps;
|
actor_class->has_overlaps = clutter_text_has_overlaps;
|
||||||
actor_class->calculate_resource_scale = clutter_text_calculate_resource_scale;
|
actor_class->calculate_resource_scale = clutter_text_calculate_resource_scale;
|
||||||
actor_class->resource_scale_changed = clutter_text_resource_scale_changed;
|
actor_class->resource_scale_changed = clutter_text_resource_scale_changed;
|
||||||
|
actor_class->event = clutter_text_event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterText:buffer:
|
* ClutterText:buffer:
|
||||||
|
@ -406,6 +406,16 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
|
|||||||
if (meta_wayland_seat_has_touch (seat))
|
if (meta_wayland_seat_has_touch (seat))
|
||||||
return meta_wayland_touch_handle_event (seat->touch, event);
|
return meta_wayland_touch_handle_event (seat->touch, event);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case CLUTTER_IM_COMMIT:
|
||||||
|
case CLUTTER_IM_DELETE:
|
||||||
|
case CLUTTER_IM_PREEDIT:
|
||||||
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -629,6 +629,5 @@ meta_wayland_gtk_text_input_handle_event (MetaWaylandGtkTextInput *text_input,
|
|||||||
!clutter_input_focus_is_focused (text_input->input_focus))
|
!clutter_input_focus_is_focused (text_input->input_focus))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return clutter_input_focus_filter_key_event (text_input->input_focus,
|
return clutter_input_focus_filter_event (text_input->input_focus, event);
|
||||||
(const ClutterKeyEvent *) event);
|
|
||||||
}
|
}
|
||||||
|
@ -737,6 +737,5 @@ meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input,
|
|||||||
!clutter_input_focus_is_focused (text_input->input_focus))
|
!clutter_input_focus_is_focused (text_input->input_focus))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return clutter_input_focus_filter_key_event (text_input->input_focus,
|
return clutter_input_focus_filter_event (text_input->input_focus, event);
|
||||||
(const ClutterKeyEvent *) event);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user