From d3b845902ee15c7cb8cedaf89638a07b0b139297 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 17 Feb 2020 10:43:29 +0100 Subject: [PATCH] clutter: Add IM events These will be used to make IM commands into something that is processed in a fixed order relative to key events. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1286 --- clutter/clutter/clutter-actor.c | 7 +++++++ clutter/clutter/clutter-enums.h | 3 +++ clutter/clutter/clutter-event.c | 24 ++++++++++++++++++++++++ clutter/clutter/clutter-event.h | 15 +++++++++++++++ clutter/clutter/clutter-main.c | 3 +++ 5 files changed, 52 insertions(+) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 8805b35b1..da610f4cf 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -1097,6 +1097,7 @@ static GQuark quark_touch = 0; static GQuark quark_touchpad = 0; static GQuark quark_proximity = 0; static GQuark quark_pad = 0; +static GQuark quark_im = 0; G_DEFINE_TYPE_WITH_CODE (ClutterActor, clutter_actor, @@ -6043,6 +6044,7 @@ clutter_actor_class_init (ClutterActorClass *klass) quark_touchpad = g_quark_from_static_string ("touchpad"); quark_proximity = g_quark_from_static_string ("proximity"); quark_pad = g_quark_from_static_string ("pad"); + quark_im = g_quark_from_static_string ("im"); object_class->constructor = clutter_actor_constructor; object_class->set_property = clutter_actor_set_property; @@ -12752,6 +12754,11 @@ clutter_actor_event (ClutterActor *actor, signal_num = -1; detail = quark_stage; break; + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_DELETE: + case CLUTTER_IM_PREEDIT: + signal_num = -1; + detail = quark_im; case CLUTTER_DEVICE_ADDED: case CLUTTER_DEVICE_REMOVED: break; diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h index 24e961a18..36ecf0b1a 100644 --- a/clutter/clutter/clutter-enums.h +++ b/clutter/clutter/clutter-enums.h @@ -908,6 +908,9 @@ typedef enum /*< prefix=CLUTTER >*/ CLUTTER_PAD_RING, CLUTTER_DEVICE_ADDED, CLUTTER_DEVICE_REMOVED, + CLUTTER_IM_COMMIT, + CLUTTER_IM_DELETE, + CLUTTER_IM_PREEDIT, CLUTTER_EVENT_LAST /* helper */ } ClutterEventType; diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 2bc6baff3..51bec8881 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -416,6 +416,9 @@ clutter_event_get_position (const ClutterEvent *event, case CLUTTER_PAD_RING: case CLUTTER_DEVICE_ADDED: case CLUTTER_DEVICE_REMOVED: + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_DELETE: + case CLUTTER_IM_PREEDIT: graphene_point_init (position, 0.f, 0.f); break; @@ -491,6 +494,9 @@ clutter_event_set_coords (ClutterEvent *event, case CLUTTER_PAD_RING: case CLUTTER_DEVICE_ADDED: case CLUTTER_DEVICE_REMOVED: + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_DELETE: + case CLUTTER_IM_PREEDIT: break; case CLUTTER_ENTER: @@ -1108,6 +1114,9 @@ clutter_event_set_device (ClutterEvent *event, case CLUTTER_DESTROY_NOTIFY: case CLUTTER_CLIENT_MESSAGE: case CLUTTER_EVENT_LAST: + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_DELETE: + case CLUTTER_IM_PREEDIT: break; case CLUTTER_ENTER: @@ -1208,6 +1217,9 @@ clutter_event_get_device (const ClutterEvent *event) case CLUTTER_STAGE_STATE: case CLUTTER_DESTROY_NOTIFY: case CLUTTER_CLIENT_MESSAGE: + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_DELETE: + case CLUTTER_IM_PREEDIT: case CLUTTER_EVENT_LAST: break; @@ -1425,6 +1437,10 @@ clutter_event_copy (const ClutterEvent *event) case CLUTTER_DEVICE_REMOVED: new_event->device.device = event->device.device; break; + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_PREEDIT: + new_event->im.text = g_strdup (event->im.text); + break; default: break; @@ -1481,6 +1497,11 @@ clutter_event_free (ClutterEvent *event) g_free (event->touch.axes); break; + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_PREEDIT: + g_free (event->im.text); + break; + default: break; } @@ -1777,6 +1798,9 @@ clutter_event_get_axes (const ClutterEvent *event, case CLUTTER_PAD_BUTTON_RELEASE: case CLUTTER_PAD_STRIP: case CLUTTER_PAD_RING: + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_DELETE: + case CLUTTER_IM_PREEDIT: break; } diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 22dc6b7c5..0f65c2adc 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -122,6 +122,7 @@ typedef struct _ClutterPadButtonEvent ClutterPadButtonEvent; typedef struct _ClutterPadStripEvent ClutterPadStripEvent; typedef struct _ClutterPadRingEvent ClutterPadRingEvent; typedef struct _ClutterDeviceEvent ClutterDeviceEvent; +typedef struct _ClutterIMEvent ClutterIMEvent; /** * ClutterAnyEvent: @@ -556,6 +557,19 @@ struct _ClutterDeviceEvent ClutterInputDevice *device; }; +struct _ClutterIMEvent +{ + ClutterEventType type; + uint32_t time; + ClutterEventFlags flags; + ClutterStage *stage; + ClutterActor *source; + + char *text; + int32_t offset; + uint32_t len; +}; + /** * ClutterEvent: * @@ -583,6 +597,7 @@ union _ClutterEvent ClutterPadStripEvent pad_strip; ClutterPadRingEvent pad_ring; ClutterDeviceEvent device; + ClutterIMEvent im; }; /** diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index a2adc0d0f..b95f1c8e6 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -1590,6 +1590,9 @@ _clutter_process_event_details (ClutterActor *stage, case CLUTTER_PAD_BUTTON_RELEASE: case CLUTTER_PAD_STRIP: case CLUTTER_PAD_RING: + case CLUTTER_IM_COMMIT: + case CLUTTER_IM_DELETE: + case CLUTTER_IM_PREEDIT: { ClutterActor *actor = NULL;