Flutter Engine
fl_text_input_plugin.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/shell/platform/linux/fl_text_input_plugin.h"
6 
7 #include <gtk/gtk.h>
8 
9 #include "flutter/shell/platform/common/cpp/text_input_model.h"
10 #include "flutter/shell/platform/linux/public/flutter_linux/fl_json_method_codec.h"
11 #include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
12 
13 static constexpr char kChannelName[] = "flutter/textinput";
14 
15 static constexpr char kBadArgumentsError[] = "Bad Arguments";
16 
17 static constexpr char kSetClientMethod[] = "TextInput.setClient";
18 static constexpr char kShowMethod[] = "TextInput.show";
19 static constexpr char kSetEditingStateMethod[] = "TextInput.setEditingState";
20 static constexpr char kClearClientMethod[] = "TextInput.clearClient";
21 static constexpr char kHideMethod[] = "TextInput.hide";
22 static constexpr char kUpdateEditingStateMethod[] =
23  "TextInputClient.updateEditingState";
24 static constexpr char kPerformActionMethod[] = "TextInputClient.performAction";
25 static constexpr char kSetEditableSizeAndTransform[] =
26  "TextInput.setEditableSizeAndTransform";
27 static constexpr char kSetMarkedTextRect[] = "TextInput.setMarkedTextRect";
28 
29 static constexpr char kInputActionKey[] = "inputAction";
30 static constexpr char kTextInputTypeKey[] = "inputType";
31 static constexpr char kTextInputTypeNameKey[] = "name";
32 static constexpr char kTextKey[] = "text";
33 static constexpr char kSelectionBaseKey[] = "selectionBase";
34 static constexpr char kSelectionExtentKey[] = "selectionExtent";
35 static constexpr char kSelectionAffinityKey[] = "selectionAffinity";
36 static constexpr char kSelectionIsDirectionalKey[] = "selectionIsDirectional";
37 static constexpr char kComposingBaseKey[] = "composingBase";
38 static constexpr char kComposingExtentKey[] = "composingExtent";
39 
40 static constexpr char kTransform[] = "transform";
41 
42 static constexpr char kTextAffinityDownstream[] = "TextAffinity.downstream";
43 static constexpr char kMultilineInputType[] = "TextInputType.multiline";
44 
45 static constexpr int64_t kClientIdUnset = -1;
46 
48  GObject parent_instance;
49 
50  FlMethodChannel* channel;
51 
52  // Client ID provided by Flutter to report events with.
53  int64_t client_id;
54 
55  // Input action to perform when enter pressed.
56  gchar* input_action;
57 
58  // Send newline when multi-line and enter is pressed.
59  gboolean input_multiline;
60 
61  // Input method.
62  GtkIMContext* im_context;
63 
65 
66  // The owning Flutter view.
67  FlView* view;
68 
69  // A 4x4 matrix that maps from `EditableText` local coordinates to the
70  // coordinate system of `PipelineOwner.rootNode`.
71  double editabletext_transform[4][4];
72 
73  // The smallest rect, in local coordinates, of the text in the composing
74  // range, or of the caret in the case where there is no current composing
75  // range. This value is updated via `TextInput.setMarkedTextRect` messages
76  // over the text input channel.
77  GdkRectangle composing_rect;
78 };
79 
80 G_DEFINE_TYPE(FlTextInputPlugin, fl_text_input_plugin, G_TYPE_OBJECT)
81 
82 // Completes method call and returns TRUE if the call was successful.
83 static gboolean finish_method(GObject* object,
84  GAsyncResult* result,
85  GError** error) {
86  g_autoptr(FlMethodResponse) response = fl_method_channel_invoke_method_finish(
87  FL_METHOD_CHANNEL(object), result, error);
88  if (response == nullptr) {
89  return FALSE;
90  }
91  return fl_method_response_get_result(response, error) != nullptr;
92 }
93 
94 // Called when a response is received from TextInputClient.updateEditingState()
95 static void update_editing_state_response_cb(GObject* object,
96  GAsyncResult* result,
97  gpointer user_data) {
98  g_autoptr(GError) error = nullptr;
99  if (!finish_method(object, result, &error)) {
100  g_warning("Failed to call %s: %s", kUpdateEditingStateMethod,
101  error->message);
102  }
103 }
104 
105 // Informs Flutter of text input changes.
106 static void update_editing_state(FlTextInputPlugin* self) {
107  g_autoptr(FlValue) args = fl_value_new_list();
108  fl_value_append_take(args, fl_value_new_int(self->client_id));
109  g_autoptr(FlValue) value = fl_value_new_map();
110 
111  TextRange selection = self->text_model->selection();
113  value, kTextKey,
114  fl_value_new_string(self->text_model->GetText().c_str()));
116  fl_value_new_int(selection.base()));
118  fl_value_new_int(selection.extent()));
119 
120  int composing_base = self->text_model->composing()
121  ? self->text_model->composing_range().base()
122  : -1;
123  int composing_extent = self->text_model->composing()
124  ? self->text_model->composing_range().extent()
125  : -1;
127  fl_value_new_int(composing_base));
129  fl_value_new_int(composing_extent));
130 
131  // The following keys are not implemented and set to default values.
135  fl_value_new_bool(FALSE));
136 
137  fl_value_append(args, value);
138 
140  args, nullptr,
142 }
143 
144 // Called when a response is received from TextInputClient.performAction()
145 static void perform_action_response_cb(GObject* object,
146  GAsyncResult* result,
147  gpointer user_data) {
148  g_autoptr(GError) error = nullptr;
149  if (!finish_method(object, result, &error)) {
150  g_warning("Failed to call %s: %s", kPerformActionMethod, error->message);
151  }
152 }
153 
154 // Inform Flutter that the input has been activated.
155 static void perform_action(FlTextInputPlugin* self) {
156  g_return_if_fail(FL_IS_TEXT_INPUT_PLUGIN(self));
157  g_return_if_fail(self->client_id != 0);
158  g_return_if_fail(self->input_action != nullptr);
159 
160  g_autoptr(FlValue) args = fl_value_new_list();
161  fl_value_append_take(args, fl_value_new_int(self->client_id));
162  fl_value_append_take(args, fl_value_new_string(self->input_action));
163 
165  nullptr, perform_action_response_cb, self);
166 }
167 
168 // Signal handler for GtkIMContext::preedit-start
169 static void im_preedit_start_cb(FlTextInputPlugin* self) {
170  self->text_model->BeginComposing();
171 
172  // Set the top-level window used for system input method windows.
173  GdkWindow* window =
174  gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self->view)));
175  gtk_im_context_set_client_window(self->im_context, window);
176 }
177 
178 // Signal handler for GtkIMContext::preedit-changed
179 static void im_preedit_changed_cb(FlTextInputPlugin* self) {
180  g_autofree gchar* buf = nullptr;
181  gint cursor_offset = 0;
182  gtk_im_context_get_preedit_string(self->im_context, &buf, nullptr,
183  &cursor_offset);
184  cursor_offset += self->text_model->composing_range().base();
185  self->text_model->UpdateComposingText(buf);
186  self->text_model->SetSelection(TextRange(cursor_offset, cursor_offset));
187 
188  update_editing_state(self);
189 }
190 
191 // Signal handler for GtkIMContext::commit
192 static void im_commit_cb(FlTextInputPlugin* self, const gchar* text) {
193  self->text_model->AddText(text);
194  if (self->text_model->composing()) {
195  self->text_model->CommitComposing();
196  }
197  update_editing_state(self);
198 }
199 
200 // Signal handler for GtkIMContext::preedit-end
201 static void im_preedit_end_cb(FlTextInputPlugin* self) {
202  self->text_model->EndComposing();
203  update_editing_state(self);
204 }
205 
206 // Signal handler for GtkIMContext::retrieve-surrounding
207 static gboolean im_retrieve_surrounding_cb(FlTextInputPlugin* self) {
208  auto text = self->text_model->GetText();
209  size_t cursor_offset = self->text_model->GetCursorOffset();
210  gtk_im_context_set_surrounding(self->im_context, text.c_str(), -1,
211  cursor_offset);
212  return TRUE;
213 }
214 
215 // Signal handler for GtkIMContext::delete-surrounding
216 static gboolean im_delete_surrounding_cb(FlTextInputPlugin* self,
217  gint offset,
218  gint n_chars) {
219  if (self->text_model->DeleteSurrounding(offset, n_chars)) {
220  update_editing_state(self);
221  }
222  return TRUE;
223 }
224 
225 // Called when the input method client is set up.
226 static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) {
227  if (fl_value_get_type(args) != FL_VALUE_TYPE_LIST ||
228  fl_value_get_length(args) < 2) {
229  return FL_METHOD_RESPONSE(fl_method_error_response_new(
230  kBadArgumentsError, "Expected 2-element list", nullptr));
231  }
232 
233  self->client_id = fl_value_get_int(fl_value_get_list_value(args, 0));
234  FlValue* config_value = fl_value_get_list_value(args, 1);
235  g_free(self->input_action);
236  FlValue* input_action_value =
238  if (fl_value_get_type(input_action_value) == FL_VALUE_TYPE_STRING) {
239  self->input_action = g_strdup(fl_value_get_string(input_action_value));
240  }
241 
242  // Clear the multiline flag, then set it only if the field is multiline.
243  self->input_multiline = FALSE;
244  FlValue* input_type_value =
246  if (fl_value_get_type(input_type_value) == FL_VALUE_TYPE_MAP) {
247  FlValue* input_type_name =
249  if (fl_value_get_type(input_type_name) == FL_VALUE_TYPE_STRING &&
250  g_strcmp0(fl_value_get_string(input_type_name), kMultilineInputType) ==
251  0) {
252  self->input_multiline = TRUE;
253  }
254  }
255 
256  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
257 }
258 
259 // Shows the input method.
260 static FlMethodResponse* show(FlTextInputPlugin* self) {
261  gtk_im_context_focus_in(self->im_context);
262 
263  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
264 }
265 
266 // Updates the editing state from Flutter.
267 static FlMethodResponse* set_editing_state(FlTextInputPlugin* self,
268  FlValue* args) {
269  const gchar* text =
271  self->text_model->SetText(text);
272 
273  int64_t selection_base =
275  int64_t selection_extent =
277  // Flutter uses -1/-1 for invalid; translate that to 0/0 for the model.
278  if (selection_base == -1 && selection_extent == -1) {
279  selection_base = selection_extent = 0;
280  }
281 
282  self->text_model->SetText(text);
283  self->text_model->SetSelection(TextRange(selection_base, selection_extent));
284 
285  int64_t composing_base =
287  int64_t composing_extent =
289  if (composing_base == -1 && composing_extent == -1) {
290  self->text_model->EndComposing();
291  } else {
292  size_t composing_start = std::min(composing_base, composing_extent);
293  size_t cursor_offset = selection_base - composing_start;
294  self->text_model->SetComposingRange(
295  TextRange(composing_base, composing_extent), cursor_offset);
296  }
297 
298  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
299 }
300 
301 // Called when the input method client is complete.
302 static FlMethodResponse* clear_client(FlTextInputPlugin* self) {
303  self->client_id = kClientIdUnset;
304 
305  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
306 }
307 
308 // Hides the input method.
309 static FlMethodResponse* hide(FlTextInputPlugin* self) {
310  gtk_im_context_focus_out(self->im_context);
311 
312  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
313 }
314 
315 // Update the IM cursor position.
316 //
317 // As text is input by the user, the framework sends two streams of updates
318 // over the text input channel: updates to the composing rect (cursor rect when
319 // not in IME composing mode) and updates to the matrix transform from local
320 // coordinates to Flutter root coordinates. This function is called after each
321 // of these updates. It transforms the composing rect to GTK window coordinates
322 // and notifies GTK of the updated cursor position.
323 static void update_im_cursor_position(FlTextInputPlugin* self) {
324  // Skip update if not composing to avoid setting to position 0.
325  if (!self->text_model->composing()) {
326  return;
327  }
328 
329  // Transform the x, y positions of the cursor from local coordinates to
330  // Flutter view coordinates.
331  gint x = self->composing_rect.x * self->editabletext_transform[0][0] +
332  self->composing_rect.y * self->editabletext_transform[1][0] +
333  self->editabletext_transform[3][0] + self->composing_rect.width;
334  gint y = self->composing_rect.x * self->editabletext_transform[0][1] +
335  self->composing_rect.y * self->editabletext_transform[1][1] +
336  self->editabletext_transform[3][1] + self->composing_rect.height;
337 
338  // Transform from Flutter view coordinates to GTK window coordinates.
339  GdkRectangle preedit_rect;
340  gtk_widget_translate_coordinates(
341  GTK_WIDGET(self->view), gtk_widget_get_toplevel(GTK_WIDGET(self->view)),
342  x, y, &preedit_rect.x, &preedit_rect.y);
343 
344  // Set the cursor location in window coordinates so that GTK can position any
345  // system input method windows.
346  gtk_im_context_set_cursor_location(self->im_context, &preedit_rect);
347 }
348 
349 // Handles updates to the EditableText size and position from the framework.
350 //
351 // On changes to the size or position of the RenderObject underlying the
352 // EditableText, this update may be triggered. It provides an updated size and
353 // transform from the local coordinate system of the EditableText to root
354 // Flutter coordinate system.
355 static FlMethodResponse* set_editable_size_and_transform(
356  FlTextInputPlugin* self,
357  FlValue* args) {
359  size_t transform_len = fl_value_get_length(transform);
360  g_warn_if_fail(transform_len == 16);
361 
362  for (size_t i = 0; i < transform_len; ++i) {
363  double val = fl_value_get_float(fl_value_get_list_value(transform, i));
364  self->editabletext_transform[i / 4][i % 4] = val;
365  }
367 
368  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
369 }
370 
371 // Handles updates to the composing rect from the framework.
372 //
373 // On changes to the state of the EditableText in the framework, this update
374 // may be triggered. It provides an updated rect for the composing region in
375 // local coordinates of the EditableText. In the case where there is no
376 // composing region, the cursor rect is sent.
377 static FlMethodResponse* set_marked_text_rect(FlTextInputPlugin* self,
378  FlValue* args) {
379  self->composing_rect.x =
381  self->composing_rect.y =
383  self->composing_rect.width =
385  self->composing_rect.height =
388 
389  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
390 }
391 
392 // Called when a method call is received from Flutter.
393 static void method_call_cb(FlMethodChannel* channel,
394  FlMethodCall* method_call,
395  gpointer user_data) {
396  FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(user_data);
397 
398  const gchar* method = fl_method_call_get_name(method_call);
399  FlValue* args = fl_method_call_get_args(method_call);
400 
401  g_autoptr(FlMethodResponse) response = nullptr;
402  if (strcmp(method, kSetClientMethod) == 0) {
403  response = set_client(self, args);
404  } else if (strcmp(method, kShowMethod) == 0) {
405  response = show(self);
406  } else if (strcmp(method, kSetEditingStateMethod) == 0) {
407  response = set_editing_state(self, args);
408  } else if (strcmp(method, kClearClientMethod) == 0) {
409  response = clear_client(self);
410  } else if (strcmp(method, kHideMethod) == 0) {
411  response = hide(self);
412  } else if (strcmp(method, kSetEditableSizeAndTransform) == 0) {
413  response = set_editable_size_and_transform(self, args);
414  } else if (strcmp(method, kSetMarkedTextRect) == 0) {
415  response = set_marked_text_rect(self, args);
416  } else {
417  response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
418  }
419 
420  g_autoptr(GError) error = nullptr;
421  if (!fl_method_call_respond(method_call, response, &error)) {
422  g_warning("Failed to send method call response: %s", error->message);
423  }
424 }
425 
426 static void view_weak_notify_cb(gpointer user_data, GObject* object) {
427  FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(object);
428  self->view = nullptr;
429 }
430 
431 static void fl_text_input_plugin_dispose(GObject* object) {
432  FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(object);
433 
434  g_clear_object(&self->channel);
435  g_clear_pointer(&self->input_action, g_free);
436  g_clear_object(&self->im_context);
437  if (self->text_model != nullptr) {
438  delete self->text_model;
439  self->text_model = nullptr;
440  }
441 
442  G_OBJECT_CLASS(fl_text_input_plugin_parent_class)->dispose(object);
443 }
444 
445 static void fl_text_input_plugin_class_init(FlTextInputPluginClass* klass) {
446  G_OBJECT_CLASS(klass)->dispose = fl_text_input_plugin_dispose;
447 }
448 
449 static void fl_text_input_plugin_init(FlTextInputPlugin* self) {
450  self->client_id = kClientIdUnset;
451  self->im_context = gtk_im_multicontext_new();
452  self->input_multiline = FALSE;
453  g_signal_connect_object(self->im_context, "preedit-start",
454  G_CALLBACK(im_preedit_start_cb), self,
455  G_CONNECT_SWAPPED);
456  g_signal_connect_object(self->im_context, "preedit-end",
457  G_CALLBACK(im_preedit_end_cb), self,
458  G_CONNECT_SWAPPED);
459  g_signal_connect_object(self->im_context, "preedit-changed",
460  G_CALLBACK(im_preedit_changed_cb), self,
461  G_CONNECT_SWAPPED);
462  g_signal_connect_object(self->im_context, "commit", G_CALLBACK(im_commit_cb),
463  self, G_CONNECT_SWAPPED);
464  g_signal_connect_object(self->im_context, "retrieve-surrounding",
465  G_CALLBACK(im_retrieve_surrounding_cb), self,
466  G_CONNECT_SWAPPED);
467  g_signal_connect_object(self->im_context, "delete-surrounding",
468  G_CALLBACK(im_delete_surrounding_cb), self,
469  G_CONNECT_SWAPPED);
470  self->text_model = new flutter::TextInputModel();
471 }
472 
473 FlTextInputPlugin* fl_text_input_plugin_new(FlBinaryMessenger* messenger,
474  FlView* view) {
475  g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr);
476 
477  FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(
478  g_object_new(fl_text_input_plugin_get_type(), nullptr));
479 
480  g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
481  self->channel =
482  fl_method_channel_new(messenger, kChannelName, FL_METHOD_CODEC(codec));
484  nullptr);
485  self->view = view;
486  g_object_weak_ref(G_OBJECT(view), view_weak_notify_cb, self);
487 
488  return self;
489 }
490 
491 gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin* self,
492  GdkEventKey* event) {
493  g_return_val_if_fail(FL_IS_TEXT_INPUT_PLUGIN(self), FALSE);
494 
495  if (self->client_id == kClientIdUnset) {
496  return FALSE;
497  }
498 
499  if (gtk_im_context_filter_keypress(self->im_context, event)) {
500  return TRUE;
501  }
502 
503  // Handle the enter/return key.
504  gboolean do_action = FALSE;
505  // Handle navigation keys.
506  gboolean changed = FALSE;
507  if (event->type == GDK_KEY_PRESS) {
508  switch (event->keyval) {
509  case GDK_KEY_BackSpace:
510  changed = self->text_model->Backspace();
511  break;
512  case GDK_KEY_Delete:
513  case GDK_KEY_KP_Delete:
514  // Already handled inside Flutter.
515  break;
516  case GDK_KEY_End:
517  case GDK_KEY_KP_End:
518  changed = self->text_model->MoveCursorToEnd();
519  break;
520  case GDK_KEY_Return:
521  case GDK_KEY_KP_Enter:
522  case GDK_KEY_ISO_Enter:
523  if (self->input_multiline == TRUE) {
524  self->text_model->AddCodePoint('\n');
525  changed = TRUE;
526  }
527  do_action = TRUE;
528  break;
529  case GDK_KEY_Home:
530  case GDK_KEY_KP_Home:
531  changed = self->text_model->MoveCursorToBeginning();
532  break;
533  case GDK_KEY_Left:
534  case GDK_KEY_KP_Left:
535  // Already handled inside Flutter.
536  break;
537  case GDK_KEY_Right:
538  case GDK_KEY_KP_Right:
539  // Already handled inside Flutter.
540  break;
541  }
542  }
543 
544  if (changed) {
545  update_editing_state(self);
546  }
547  if (do_action) {
548  perform_action(self);
549  }
550 
551  return FALSE;
552 }
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:310
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
flutter::TextInputModel * text_model
static constexpr char kSetMarkedTextRect[]
G_BEGIN_DECLS FlMethodCall * method_call
size_t base() const
Definition: text_range.h:25
G_MODULE_EXPORT FlMethodResponse * fl_method_channel_invoke_method_finish(FlMethodChannel *self, GAsyncResult *result, GError **error)
static void view_weak_notify_cb(gpointer user_data, GObject *object)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:395
static constexpr char kSetClientMethod[]
static gboolean im_delete_surrounding_cb(FlTextInputPlugin *self, gint offset, gint n_chars)
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
G_MODULE_EXPORT FlJsonMethodCodec * fl_json_method_codec_new()
FlMethodResponse GError ** error
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:327
static void im_preedit_end_cb(FlTextInputPlugin *self)
static constexpr char kShowMethod[]
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:582
static gboolean im_retrieve_surrounding_cb(FlTextInputPlugin *self)
static gboolean finish_method(GObject *object, GAsyncResult *result, GError **error)
static constexpr char kTextAffinityDownstream[]
double editabletext_transform[4][4]
static FlMethodResponse * set_editing_state(FlTextInputPlugin *self, FlValue *args)
static constexpr char kSetEditableSizeAndTransform[]
gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin *self, GdkEventKey *event)
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:226
static constexpr char kPerformActionMethod[]
G_MODULE_EXPORT FlValue * fl_method_call_get_args(FlMethodCall *self)
static constexpr char kComposingBaseKey[]
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition: fl_value.cc:506
static void fl_text_input_plugin_dispose(GObject *object)
static constexpr char kSelectionIsDirectionalKey[]
static constexpr char kMultilineInputType[]
static constexpr char kComposingExtentKey[]
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition: fl_value.cc:589
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:514
static void im_preedit_start_cb(FlTextInputPlugin *self)
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
Definition: fl_value.cc:712
G_MODULE_EXPORT gboolean fl_method_call_respond(FlMethodCall *self, FlMethodResponse *response, GError **error)
static constexpr char kInputActionKey[]
static void update_im_cursor_position(FlTextInputPlugin *self)
static void update_editing_state(FlTextInputPlugin *self)
static FlMethodResponse * set_editable_size_and_transform(FlTextInputPlugin *self, FlValue *args)
static FlMethodResponse * hide(FlTextInputPlugin *self)
static void im_commit_cb(FlTextInputPlugin *self, const gchar *text)
G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(FlMethodChannel *self, FlMethodChannelMethodCallHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
static constexpr char kSelectionAffinityKey[]
G_MODULE_EXPORT const gchar * fl_method_call_get_name(FlMethodCall *self)
G_MODULE_EXPORT FlMethodChannel * fl_method_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMethodCodec *codec)
static void perform_action(FlTextInputPlugin *self)
static void fl_text_input_plugin_class_init(FlTextInputPluginClass *klass)
FlTextInputPlugin * fl_text_input_plugin_new(FlBinaryMessenger *messenger, FlView *view)
static constexpr char kTextKey[]
static constexpr char kSetEditingStateMethod[]
static constexpr char kSelectionExtentKey[]
static constexpr int64_t kClientIdUnset
static FlMethodResponse * set_marked_text_rect(FlTextInputPlugin *self, FlValue *args)
G_BEGIN_DECLS FlMethodCall gpointer user_data
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition: fl_value.cc:677
static void update_editing_state_response_cb(GObject *object, GAsyncResult *result, gpointer user_data)
static constexpr char kClearClientMethod[]
GdkEventButton * event
Definition: fl_view.cc:62
static FlMethodResponse * clear_client(FlTextInputPlugin *self)
static constexpr char kSelectionBaseKey[]
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:233
static constexpr char kChannelName[]
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:247
size_t extent() const
Definition: text_range.h:31
G_MODULE_EXPORT void fl_method_channel_invoke_method(FlMethodChannel *self, const gchar *method, FlValue *args, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
return TRUE
Definition: fl_view.cc:107
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:596
static void perform_action_response_cb(GObject *object, GAsyncResult *result, gpointer user_data)
static void fl_text_input_plugin_init(FlTextInputPlugin *self)
FlMethodChannel * channel
static constexpr char kHideMethod[]
G_MODULE_EXPORT FlValue * fl_method_response_get_result(FlMethodResponse *self, GError **error)
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()
static void im_preedit_changed_cb(FlTextInputPlugin *self)
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:564
static constexpr char kUpdateEditingStateMethod[]
static constexpr char kBadArgumentsError[]
static void method_call_cb(FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data)
static constexpr char kTransform[]
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:631
static FlMethodResponse * set_client(FlTextInputPlugin *self, FlValue *args)
static constexpr char kTextInputTypeNameKey[]
static FlMethodResponse * show(FlTextInputPlugin *self)
static constexpr char kTextInputTypeKey[]
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)