[mutter/wip/carlosg/im-forward-key: 3/3] clutter: Add clutter_input_method_forward_key() method.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/im-forward-key: 3/3] clutter: Add clutter_input_method_forward_key() method.
- Date: Thu, 27 Sep 2018 19:17:14 +0000 (UTC)
commit 7d3846611b65345c599c98c2754b044310d78538
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Sep 27 21:06:52 2018 +0200
clutter: Add clutter_input_method_forward_key() method.
This allows input methods to inject key events with specific keyval/keycode,
those events will be flagged with CLUTTER_EVENT_FLAG_INPUT_METHOD so they
won't be processed by the IM again.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/531
clutter/clutter/clutter-input-method.c | 42 ++++++++++++++++++++++++++++++++++
clutter/clutter/clutter-input-method.h | 7 ++++++
2 files changed, 49 insertions(+)
---
diff --git a/clutter/clutter/clutter-input-method.c b/clutter/clutter/clutter-input-method.c
index 11d726d7b..ea4d4fa83 100644
--- a/clutter/clutter/clutter-input-method.c
+++ b/clutter/clutter/clutter-input-method.c
@@ -25,6 +25,7 @@
#include "clutter/clutter-input-method.h"
#include "clutter/clutter-input-method-private.h"
#include "clutter/clutter-input-focus-private.h"
+#include "clutter/clutter-device-manager-private.h"
typedef struct _ClutterInputMethodPrivate ClutterInputMethodPrivate;
@@ -442,3 +443,44 @@ clutter_input_method_filter_key_event (ClutterInputMethod *im,
return im_class->filter_key_event (im, (const ClutterEvent *) key);
}
+
+void
+clutter_input_method_forward_key (ClutterInputMethod *im,
+ uint32_t keyval,
+ uint32_t keycode,
+ uint32_t state,
+ gboolean press)
+{
+ ClutterInputMethodPrivate *priv;
+ ClutterDeviceManager *device_manager;
+ ClutterInputDevice *keyboard;
+ ClutterStage *stage;
+ ClutterEvent *event;
+
+ g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
+
+ priv = clutter_input_method_get_instance_private (im);
+ if (!priv->focus)
+ return;
+
+ device_manager = clutter_device_manager_get_default ();
+ keyboard = clutter_device_manager_get_core_device (device_manager,
+ CLUTTER_KEYBOARD_DEVICE);
+ stage = _clutter_input_device_get_stage (keyboard);
+ if (stage == NULL)
+ return;
+
+ event = clutter_event_new (press ? CLUTTER_KEY_PRESS : CLUTTER_KEY_RELEASE);
+ event->key.time = clutter_get_current_event_time ();
+ event->key.flags = CLUTTER_EVENT_FLAG_INPUT_METHOD;
+ event->key.modifier_state = state;
+ event->key.keyval = keyval;
+ event->key.hardware_keycode = keycode;
+
+ clutter_event_set_device (event, keyboard);
+ clutter_event_set_source_device (event, keyboard);
+ clutter_event_set_stage (event, stage);
+
+ clutter_event_put (event);
+ clutter_event_free (event);
+}
diff --git a/clutter/clutter/clutter-input-method.h b/clutter/clutter/clutter-input-method.h
index d37522d14..9853f1e1e 100644
--- a/clutter/clutter/clutter-input-method.h
+++ b/clutter/clutter/clutter-input-method.h
@@ -85,4 +85,11 @@ void clutter_input_method_notify_key_event (ClutterInputMethod *im,
CLUTTER_AVAILABLE_IN_MUTTER
void clutter_input_method_request_toggle_input_panel (ClutterInputMethod *im);
+CLUTTER_AVAILABLE_IN_MUTTER
+void clutter_input_method_forward_key (ClutterInputMethod *im,
+ uint32_t keyval,
+ uint32_t keycode,
+ uint32_t state,
+ gboolean press);
+
#endif /* __CLUTTER_INPUT_METHOD_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]