[mutter/wip/carlosg/im-events: 18/20] clutter: Add IM events



commit e901f0568f7c7692e4fd1095f4f6824db6ae040c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Feb 17 10:43:29 2020 +0100

    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 |  6 ++++++
 clutter/clutter/clutter-enums.h |  2 ++
 clutter/clutter/clutter-event.c | 18 ++++++++++++++++++
 clutter/clutter/clutter-event.h | 15 +++++++++++++++
 clutter/clutter/clutter-main.c  |  2 ++
 5 files changed, 43 insertions(+)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index da0f68ba5c..062c627302 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -1137,6 +1137,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,
@@ -6397,6 +6398,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;
@@ -13673,6 +13675,10 @@ clutter_actor_event (ClutterActor       *actor,
         case CLUTTER_PAD_RING:
           detail = quark_pad;
           break;
+        case CLUTTER_IM_COMMIT:
+        case CLUTTER_IM_DELETE:
+          detail = quark_im;
+          break;
         case CLUTTER_EVENT_LAST:  /* Just keep compiler warnings quiet */
           break;
         }
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
index 4b9b62bcf5..4df7753be7 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
@@ -908,6 +908,8 @@ typedef enum /*< prefix=CLUTTER >*/
   CLUTTER_PAD_BUTTON_RELEASE,
   CLUTTER_PAD_STRIP,
   CLUTTER_PAD_RING,
+  CLUTTER_IM_COMMIT,
+  CLUTTER_IM_DELETE,
 
   CLUTTER_EVENT_LAST            /* helper */
 } ClutterEventType;
diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c
index 9ccc0da1c5..52dcdd378e 100644
--- a/clutter/clutter/clutter-event.c
+++ b/clutter/clutter/clutter-event.c
@@ -415,6 +415,8 @@ clutter_event_get_position (const ClutterEvent *event,
     case CLUTTER_PAD_BUTTON_RELEASE:
     case CLUTTER_PAD_STRIP:
     case CLUTTER_PAD_RING:
+    case CLUTTER_IM_COMMIT:
+    case CLUTTER_IM_DELETE:
       graphene_point_init (position, 0.f, 0.f);
       break;
 
@@ -489,6 +491,8 @@ clutter_event_set_coords (ClutterEvent *event,
     case CLUTTER_PAD_BUTTON_RELEASE:
     case CLUTTER_PAD_STRIP:
     case CLUTTER_PAD_RING:
+    case CLUTTER_IM_COMMIT:
+    case CLUTTER_IM_DELETE:
       break;
 
     case CLUTTER_ENTER:
@@ -1107,6 +1111,8 @@ clutter_event_set_device (ClutterEvent       *event,
     case CLUTTER_CLIENT_MESSAGE:
     case CLUTTER_DELETE:
     case CLUTTER_EVENT_LAST:
+    case CLUTTER_IM_COMMIT:
+    case CLUTTER_IM_DELETE:
       break;
 
     case CLUTTER_ENTER:
@@ -1203,6 +1209,8 @@ clutter_event_get_device (const ClutterEvent *event)
     case CLUTTER_DESTROY_NOTIFY:
     case CLUTTER_CLIENT_MESSAGE:
     case CLUTTER_DELETE:
+    case CLUTTER_IM_COMMIT:
+    case CLUTTER_IM_DELETE:
     case CLUTTER_EVENT_LAST:
       break;
 
@@ -1411,6 +1419,10 @@ clutter_event_copy (const ClutterEvent *event)
                                           sizeof (gdouble) * n_axes);
       break;
 
+    case CLUTTER_IM_COMMIT:
+      new_event->im.text = g_strdup (event->im.text);
+      break;
+
     default:
       break;
     }
@@ -1466,6 +1478,10 @@ clutter_event_free (ClutterEvent *event)
           g_free (event->touch.axes);
           break;
 
+        case CLUTTER_IM_COMMIT:
+          g_free (event->im.text);
+          break;
+
         default:
           break;
         }
@@ -1761,6 +1777,8 @@ 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:
       break;
     }
 
diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h
index f090ca8e11..e65463c65f 100644
--- a/clutter/clutter/clutter-event.h
+++ b/clutter/clutter/clutter-event.h
@@ -121,6 +121,7 @@ typedef struct _ClutterProximityEvent   ClutterProximityEvent;
 typedef struct _ClutterPadButtonEvent   ClutterPadButtonEvent;
 typedef struct _ClutterPadStripEvent    ClutterPadStripEvent;
 typedef struct _ClutterPadRingEvent     ClutterPadRingEvent;
+typedef struct _ClutterIMEvent          ClutterIMEvent;
 
 /**
  * ClutterAnyEvent:
@@ -544,6 +545,19 @@ struct _ClutterPadRingEvent
   guint32 mode;
 };
 
+struct _ClutterIMEvent
+{
+  ClutterEventType type;
+  guint32 time;
+  ClutterEventFlags flags;
+  ClutterStage *stage;
+  ClutterActor *source;
+
+  char *text;
+  int32_t offset;
+  uint32_t len;
+};
+
 /**
  * ClutterEvent:
  *
@@ -570,6 +584,7 @@ union _ClutterEvent
   ClutterPadButtonEvent pad_button;
   ClutterPadStripEvent pad_strip;
   ClutterPadRingEvent pad_ring;
+  ClutterIMEvent im;
 };
 
 /**
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 0114244b8c..f4a7663bed 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -1749,6 +1749,8 @@ _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:
         {
           ClutterActor *actor = NULL;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]