 |
Flutter Linux Embedder
|
|
Go to the source code of this file.
|
static void | update_editing_state_response_cb (GObject *object, GAsyncResult *result, gpointer user_data) |
|
static void | update_editing_state_with_deltas_response_cb (GObject *object, GAsyncResult *result, gpointer user_data) |
|
static void | update_editing_state (FlTextInputHandler *self) |
|
static void | update_editing_state_with_delta (FlTextInputHandler *self, flutter::TextEditingDelta *delta) |
|
static void | perform_action_response_cb (GObject *object, GAsyncResult *result, gpointer user_data) |
|
static void | perform_action (FlTextInputHandler *self) |
|
static void | im_preedit_start_cb (FlTextInputHandler *self) |
|
static void | im_preedit_changed_cb (FlTextInputHandler *self) |
|
static void | im_commit_cb (FlTextInputHandler *self, const gchar *text) |
|
static void | im_preedit_end_cb (FlTextInputHandler *self) |
|
static gboolean | im_retrieve_surrounding_cb (FlTextInputHandler *self) |
|
static gboolean | im_delete_surrounding_cb (FlTextInputHandler *self, gint offset, gint n_chars) |
|
static void | set_client (int64_t client_id, const gchar *input_action, gboolean enable_delta_model, FlTextInputType input_type, gpointer user_data) |
|
static void | hide (gpointer user_data) |
|
static void | show (gpointer user_data) |
|
static void | set_editing_state (const gchar *text, int64_t selection_base, int64_t selection_extent, int64_t composing_base, int64_t composing_extent, gpointer user_data) |
|
static void | clear_client (gpointer user_data) |
|
static void | update_im_cursor_position (FlTextInputHandler *self) |
|
static void | set_editable_size_and_transform (double *transform, gpointer user_data) |
|
static void | set_marked_text_rect (double x, double y, double width, double height, gpointer user_data) |
|
static void | fl_text_input_handler_dispose (GObject *object) |
|
static void | fl_text_input_handler_class_init (FlTextInputHandlerClass *klass) |
|
static void | fl_text_input_handler_init (FlTextInputHandler *self) |
|
static void | init_im_context (FlTextInputHandler *self, GtkIMContext *im_context) |
|
FlTextInputHandler * | fl_text_input_handler_new (FlBinaryMessenger *messenger, GtkIMContext *im_context, FlTextInputViewDelegate *view_delegate) |
|
gboolean | fl_text_input_handler_filter_keypress (FlTextInputHandler *self, FlKeyEvent *event) |
|
◆ clear_client()
static void clear_client |
( |
gpointer |
user_data | ) |
|
|
static |
◆ fl_text_input_handler_class_init()
static void fl_text_input_handler_class_init |
( |
FlTextInputHandlerClass * |
klass | ) |
|
|
static |
◆ fl_text_input_handler_dispose()
static void fl_text_input_handler_dispose |
( |
GObject * |
object | ) |
|
|
static |
Definition at line 386 of file fl_text_input_handler.cc.
387 FlTextInputHandler*
self = FL_TEXT_INPUT_HANDLER(
object);
389 g_cancellable_cancel(self->cancellable);
391 g_clear_object(&self->channel);
392 g_clear_pointer(&self->input_action, g_free);
393 g_clear_object(&self->im_context);
394 if (self->text_model !=
nullptr) {
395 delete self->text_model;
396 self->text_model =
nullptr;
398 g_weak_ref_clear(&self->view_delegate);
399 g_clear_object(&self->cancellable);
401 G_OBJECT_CLASS(fl_text_input_handler_parent_class)->dispose(
object);
Referenced by fl_text_input_handler_class_init().
◆ fl_text_input_handler_filter_keypress()
gboolean fl_text_input_handler_filter_keypress |
( |
FlTextInputHandler * |
handler, |
|
|
FlKeyEvent * |
event |
|
) |
| |
fl_text_input_handler_filter_keypress @handler: an #FlTextInputHandler. @event: a #FlKeyEvent
Process a Gdk key event.
Returns: TRUE if the event was used.
Definition at line 476 of file fl_text_input_handler.cc.
478 g_return_val_if_fail(FL_IS_TEXT_INPUT_HANDLER(
self), FALSE);
484 if (gtk_im_context_filter_keypress(
490 std::string text_before_change =
self->text_model->GetText();
492 std::string text =
self->text_model->GetText();
495 gboolean do_action = FALSE;
497 gboolean changed = FALSE;
503 changed =
self->text_model->SelectToEnd();
505 changed =
self->text_model->MoveCursorToEnd();
509 case GDK_KEY_KP_Enter:
510 case GDK_KEY_ISO_Enter:
513 self->text_model->AddCodePoint(
'\n');
520 case GDK_KEY_KP_Home:
522 changed =
self->text_model->SelectToBeginning();
524 changed =
self->text_model->MoveCursorToBeginning();
527 case GDK_KEY_BackSpace:
529 case GDK_KEY_KP_Delete:
531 case GDK_KEY_KP_Left:
533 case GDK_KEY_KP_Right:
540 if (self->enable_delta_model) {
542 text_before_change, selection_before_change, text);
References fl_key_event_get_is_press(), fl_key_event_get_keyval(), fl_key_event_get_origin(), fl_key_event_get_state(), FL_TEXT_INPUT_TYPE_MULTILINE, kClientIdUnset, kNewlineInputAction, perform_action(), TRUE, update_editing_state(), and update_editing_state_with_delta().
Referenced by fl_view_keyboard_delegate_iface_init(), and send_key_event().
◆ fl_text_input_handler_init()
static void fl_text_input_handler_init |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
◆ fl_text_input_handler_new()
FlTextInputHandler* fl_text_input_handler_new |
( |
FlBinaryMessenger * |
messenger, |
|
|
GtkIMContext * |
im_context, |
|
|
FlTextInputViewDelegate * |
view_delegate |
|
) |
| |
FlTextInputHandler:
#FlTextInputHandler is a handler that implements the shell side of SystemChannels.textInput from the Flutter services library. fl_text_input_handler_new: @messenger: an #FlBinaryMessenger. @im_context: (allow-none): a #GtkIMContext. @view_delegate: an #FlTextInputViewDelegate.
Creates a new handler that implements SystemChannels.textInput from the Flutter services library.
Returns: a new #FlTextInputHandler.
Definition at line 455 of file fl_text_input_handler.cc.
459 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger),
nullptr);
460 g_return_val_if_fail(GTK_IS_IM_CONTEXT(im_context),
nullptr);
461 g_return_val_if_fail(FL_IS_TEXT_INPUT_VIEW_DELEGATE(view_delegate),
nullptr);
463 FlTextInputHandler*
self = FL_TEXT_INPUT_HANDLER(
464 g_object_new(fl_text_input_handler_get_type(),
nullptr));
471 g_weak_ref_init(&self->view_delegate, view_delegate);
References fl_text_input_channel_new(), init_im_context(), and text_input_vtable.
Referenced by init_keyboard(), and TEST().
◆ hide()
static void hide |
( |
gpointer |
user_data | ) |
|
|
static |
◆ im_commit_cb()
static void im_commit_cb |
( |
FlTextInputHandler * |
self, |
|
|
const gchar * |
text |
|
) |
| |
|
static |
Definition at line 177 of file fl_text_input_handler.cc.
178 std::string text_before_change =
self->text_model->GetText();
180 self->text_model->composing_range();
182 gboolean was_composing =
self->text_model->composing();
184 self->text_model->AddText(text);
185 if (self->text_model->composing()) {
186 self->text_model->CommitComposing();
189 if (self->enable_delta_model) {
191 was_composing ? composing_before_change : selection_before_change;
192 std::unique_ptr<flutter::TextEditingDelta> delta =
193 std::make_unique<flutter::TextEditingDelta>(text_before_change,
194 replace_range, text);
References update_editing_state(), and update_editing_state_with_delta().
Referenced by init_im_context().
◆ im_delete_surrounding_cb()
static gboolean im_delete_surrounding_cb |
( |
FlTextInputHandler * |
self, |
|
|
gint |
offset, |
|
|
gint |
n_chars |
|
) |
| |
|
static |
◆ im_preedit_changed_cb()
static void im_preedit_changed_cb |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
Definition at line 150 of file fl_text_input_handler.cc.
151 std::string text_before_change =
self->text_model->GetText();
153 self->text_model->composing_range();
154 g_autofree gchar* buf =
nullptr;
155 gint cursor_offset = 0;
156 gtk_im_context_get_preedit_string(self->im_context, &buf,
nullptr,
158 if (self->text_model->composing()) {
159 cursor_offset +=
self->text_model->composing_range().start();
161 cursor_offset +=
self->text_model->selection().start();
163 self->text_model->UpdateComposingText(buf);
166 if (self->enable_delta_model) {
167 std::string text(buf);
169 text_before_change, composing_before_change, text);
References update_editing_state(), and update_editing_state_with_delta().
Referenced by init_im_context().
◆ im_preedit_end_cb()
static void im_preedit_end_cb |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
◆ im_preedit_start_cb()
static void im_preedit_start_cb |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
◆ im_retrieve_surrounding_cb()
static gboolean im_retrieve_surrounding_cb |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
Definition at line 214 of file fl_text_input_handler.cc.
215 auto text =
self->text_model->GetText();
216 size_t cursor_offset =
self->text_model->GetCursorOffset();
217 gtk_im_context_set_surrounding(self->im_context, text.c_str(), -1,
References TRUE.
Referenced by init_im_context().
◆ init_im_context()
static void init_im_context |
( |
FlTextInputHandler * |
self, |
|
|
GtkIMContext * |
im_context |
|
) |
| |
|
static |
Definition at line 417 of file fl_text_input_handler.cc.
419 self->im_context = GTK_IM_CONTEXT(g_object_ref(im_context));
424 gtk_im_context_focus_out(self->im_context);
426 g_signal_connect_object(self->im_context,
"preedit-start",
429 g_signal_connect_object(self->im_context,
"preedit-end",
432 g_signal_connect_object(self->im_context,
"preedit-changed",
435 g_signal_connect_object(self->im_context,
"commit", G_CALLBACK(
im_commit_cb),
436 self, G_CONNECT_SWAPPED);
437 g_signal_connect_object(self->im_context,
"retrieve-surrounding",
440 g_signal_connect_object(self->im_context,
"delete-surrounding",
References im_commit_cb(), im_delete_surrounding_cb(), im_preedit_changed_cb(), im_preedit_end_cb(), im_preedit_start_cb(), and im_retrieve_surrounding_cb().
Referenced by fl_text_input_handler_new().
◆ perform_action()
static void perform_action |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
◆ perform_action_response_cb()
static void perform_action_response_cb |
( |
GObject * |
object, |
|
|
GAsyncResult * |
result, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
◆ set_client()
static void set_client |
( |
int64_t |
client_id, |
|
|
const gchar * |
input_action, |
|
|
gboolean |
enable_delta_model, |
|
|
FlTextInputType |
input_type, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
Definition at line 241 of file fl_text_input_handler.cc.
246 FlTextInputHandler*
self = FL_TEXT_INPUT_HANDLER(
user_data);
248 self->client_id = client_id;
249 g_free(self->input_action);
250 self->input_action = g_strdup(input_action);
251 self->enable_delta_model = enable_delta_model;
252 self->input_type = input_type;
References user_data.
◆ set_editable_size_and_transform()
static void set_editable_size_and_transform |
( |
double * |
transform, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
◆ set_editing_state()
static void set_editing_state |
( |
const gchar * |
text, |
|
|
int64_t |
selection_base, |
|
|
int64_t |
selection_extent, |
|
|
int64_t |
composing_base, |
|
|
int64_t |
composing_extent, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
Definition at line 275 of file fl_text_input_handler.cc.
281 FlTextInputHandler*
self = FL_TEXT_INPUT_HANDLER(
user_data);
283 self->text_model->SetText(text);
286 if (selection_base == -1 && selection_extent == -1) {
287 selection_base = selection_extent = 0;
290 self->text_model->SetText(text);
291 self->text_model->SetSelection(
294 if (composing_base == -1 && composing_extent == -1) {
295 self->text_model->EndComposing();
297 size_t composing_start = std::min(composing_base, composing_extent);
298 size_t cursor_offset = selection_base - composing_start;
299 self->text_model->SetComposingRange(
References user_data.
◆ set_marked_text_rect()
static void set_marked_text_rect |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
width, |
|
|
double |
height, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
◆ show()
static void show |
( |
gpointer |
user_data | ) |
|
|
static |
◆ update_editing_state()
static void update_editing_state |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
Definition at line 88 of file fl_text_input_handler.cc.
89 int composing_base = -1;
90 int composing_extent = -1;
91 if (!self->text_model->composing_range().collapsed()) {
92 composing_base =
self->text_model->composing_range().base();
93 composing_extent =
self->text_model->composing_range().extent();
97 self->channel, self->client_id, self->text_model->GetText().c_str(),
99 composing_base, composing_extent, self->cancellable,
References flutter::TextRange::base(), flutter::TextRange::extent(), FL_TEXT_AFFINITY_DOWNSTREAM, fl_text_input_channel_update_editing_state(), and update_editing_state_response_cb().
Referenced by fl_text_input_handler_filter_keypress(), im_commit_cb(), im_delete_surrounding_cb(), im_preedit_changed_cb(), and im_preedit_end_cb().
◆ update_editing_state_response_cb()
static void update_editing_state_response_cb |
( |
GObject * |
object, |
|
|
GAsyncResult * |
result, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
◆ update_editing_state_with_delta()
Definition at line 104 of file fl_text_input_handler.cc.
107 int composing_base = -1;
108 int composing_extent = -1;
109 if (!self->text_model->composing_range().collapsed()) {
110 composing_base =
self->text_model->composing_range().
base();
111 composing_extent =
self->text_model->composing_range().extent();
114 self->channel, self->client_id, delta->
old_text().c_str(),
117 composing_base, composing_extent, self->cancellable,
References flutter::TextRange::base(), flutter::TextEditingDelta::delta_end(), flutter::TextEditingDelta::delta_start(), flutter::TextEditingDelta::delta_text(), flutter::TextRange::extent(), FL_TEXT_AFFINITY_DOWNSTREAM, fl_text_input_channel_update_editing_state_with_deltas(), flutter::TextEditingDelta::old_text(), and update_editing_state_with_deltas_response_cb().
Referenced by fl_text_input_handler_filter_keypress(), im_commit_cb(), im_delete_surrounding_cb(), im_preedit_changed_cb(), and im_preedit_end_cb().
◆ update_editing_state_with_deltas_response_cb()
static void update_editing_state_with_deltas_response_cb |
( |
GObject * |
object, |
|
|
GAsyncResult * |
result, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
◆ update_im_cursor_position()
static void update_im_cursor_position |
( |
FlTextInputHandler * |
self | ) |
|
|
static |
Definition at line 318 of file fl_text_input_handler.cc.
319 g_autoptr(FlTextInputViewDelegate) view_delegate =
320 FL_TEXT_INPUT_VIEW_DELEGATE(g_weak_ref_get(&self->view_delegate));
321 if (view_delegate ==
nullptr) {
326 if (!self->text_model->composing()) {
332 gint x =
self->composing_rect.x *
self->editabletext_transform[0][0] +
333 self->composing_rect.y *
self->editabletext_transform[1][0] +
334 self->editabletext_transform[3][0] +
self->composing_rect.width;
335 gint y =
self->composing_rect.x *
self->editabletext_transform[0][1] +
336 self->composing_rect.y *
self->editabletext_transform[1][1] +
337 self->editabletext_transform[3][1] +
self->composing_rect.height;
340 GdkRectangle preedit_rect = {};
342 view_delegate, x, y, &preedit_rect.x, &preedit_rect.y);
346 gtk_im_context_set_cursor_location(self->im_context, &preedit_rect);
References fl_text_input_view_delegate_translate_coordinates().
Referenced by set_editable_size_and_transform(), and set_marked_text_rect().
◆ kClientIdUnset
constexpr int64_t kClientIdUnset = -1 |
|
staticconstexpr |
◆ kNewlineInputAction
constexpr char kNewlineInputAction[] = "TextInputAction.newline" |
|
staticconstexpr |
◆ text_input_vtable
static void show(gpointer user_data)
static gboolean im_delete_surrounding_cb(FlTextInputHandler *self, gint offset, gint n_chars)
void fl_text_input_view_delegate_translate_coordinates(FlTextInputViewDelegate *self, gint view_x, gint view_y, gint *window_x, gint *window_y)
static void set_editable_size_and_transform(double *transform, gpointer user_data)
static void set_editing_state(const gchar *text, int64_t selection_base, int64_t selection_extent, int64_t composing_base, int64_t composing_extent, gpointer user_data)
FlTextInputChannel * fl_text_input_channel_new(FlBinaryMessenger *messenger, FlTextInputChannelVTable *vtable, gpointer user_data)
static void update_editing_state_with_deltas_response_cb(GObject *object, GAsyncResult *result, gpointer user_data)
int delta_start() const
Get the delta_start_ value.
@ FL_TEXT_AFFINITY_DOWNSTREAM
static void perform_action_response_cb(GObject *object, GAsyncResult *result, gpointer user_data)
void fl_text_input_channel_update_editing_state_with_deltas(FlTextInputChannel *self, int64_t client_id, const gchar *old_text, const gchar *delta_text, int64_t delta_start, int64_t delta_end, int64_t selection_base, int64_t selection_extent, FlTextAffinity selection_affinity, gboolean selection_is_directional, int64_t composing_base, int64_t composing_extent, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
static void init_im_context(FlTextInputHandler *self, GtkIMContext *im_context)
static void im_preedit_end_cb(FlTextInputHandler *self)
GdkEvent * fl_key_event_get_origin(FlKeyEvent *self)
@ FL_TEXT_INPUT_TYPE_TEXT
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
static void im_preedit_changed_cb(FlTextInputHandler *self)
std::string delta_text() const
static constexpr int64_t kClientIdUnset
guint fl_key_event_get_keyval(FlKeyEvent *self)
static void update_editing_state(FlTextInputHandler *self)
void fl_text_input_channel_update_editing_state(FlTextInputChannel *self, int64_t client_id, const gchar *text, int64_t selection_base, int64_t selection_extent, FlTextAffinity selection_affinity, gboolean selection_is_directional, int64_t composing_base, int64_t composing_extent, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
std::string old_text() const
static void im_preedit_start_cb(FlTextInputHandler *self)
@ FL_TEXT_INPUT_TYPE_MULTILINE
gboolean fl_text_input_channel_perform_action_finish(GObject *object, GAsyncResult *result, GError **error)
static void update_im_cursor_position(FlTextInputHandler *self)
static void fl_text_input_handler_dispose(GObject *object)
static FlTextInputChannelVTable text_input_vtable
gboolean fl_text_input_channel_update_editing_state_finish(GObject *object, GAsyncResult *result, GError **error)
static constexpr char kNewlineInputAction[]
const uint8_t uint32_t uint32_t * height
static void set_client(int64_t client_id, const gchar *input_action, gboolean enable_delta_model, FlTextInputType input_type, gpointer user_data)
static void hide(gpointer user_data)
GdkModifierType fl_key_event_get_state(FlKeyEvent *self)
const uint8_t uint32_t uint32_t GError ** error
static void set_marked_text_rect(double x, double y, double width, double height, gpointer user_data)
@ FL_TEXT_INPUT_TYPE_NONE
gboolean fl_key_event_get_is_press(FlKeyEvent *self)
static void clear_client(gpointer user_data)
A change in the state of an input field.
static void perform_action(FlTextInputHandler *self)
const uint8_t uint32_t * width
static void update_editing_state_response_cb(GObject *object, GAsyncResult *result, gpointer user_data)
static gboolean im_retrieve_surrounding_cb(FlTextInputHandler *self)
static void im_commit_cb(FlTextInputHandler *self, const gchar *text)
gboolean fl_text_input_channel_update_editing_state_with_deltas_finish(GObject *object, GAsyncResult *result, GError **error)
int delta_end() const
Get the delta_end_ value.
void fl_text_input_channel_perform_action(FlTextInputChannel *self, int64_t client_id, const gchar *input_action, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
static void update_editing_state_with_delta(FlTextInputHandler *self, flutter::TextEditingDelta *delta)