| Flutter Linux Embedder |

Typedefs | Functions
fl_keyboard_manager.h File Reference
`#include <gdk/gdk.h>`
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/linux/fl_key_event.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"`

Go to the source code of this file.

## Typedefs
typedef guint(* | FlKeyboardManagerLookupKeyHandler) (const GdkKeymapKey *key, gpointer user_data)

## Functions
G_BEGIN_DECLS | G_DECLARE_FINAL_TYPE (FlKeyboardManager, fl_keyboard_manager, FL, KEYBOARD_MANAGER, GObject)
FlKeyboardManager * | fl_keyboard_manager_new (FlEngine *engine)
void | fl_keyboard_manager_add_redispatched_event (FlKeyboardManager *manager, FlKeyEvent *event)
void | fl_keyboard_manager_handle_event (FlKeyboardManager *manager, FlKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_keyboard_manager_handle_event_finish (FlKeyboardManager *manager, GAsyncResult *result, FlKeyEvent **redispatched_event, GError **error)
void | fl_keyboard_manager_sync_modifier_if_needed (FlKeyboardManager *manager, guint state, double event_time)
GHashTable * | fl_keyboard_manager_get_pressed_state (FlKeyboardManager *manager)
void | fl_keyboard_manager_set_lookup_key_handler (FlKeyboardManager *manager, FlKeyboardManagerLookupKeyHandler lookup_key_handler, gpointer user_data)

## Typedef Documentation

## ◆ FlKeyboardManagerLookupKeyHandler

typedef guint(* FlKeyboardManagerLookupKeyHandler) (const GdkKeymapKey *key, gpointer user_data)

Definition at line 118 of file fl_keyboard_manager.h.

## Function Documentation

## ◆ fl_keyboard_manager_add_redispatched_event()

void fl_keyboard_manager_add_redispatched_event | ( | FlKeyboardManager * | manager,
|  | FlKeyEvent * | event
| ) |  |

fl_keyboard_manager_add_redispatched_event: @manager: an #FlKeyboardManager. @event: an event that will be handled by the manager in the future.

Add an event that will be redispatched and handled by the manager in the future. When that event is received it will be ignored.

Definition at line 367 of file fl_keyboard_manager.cc.

368 {
369 g_return_if_fail(FL_IS_KEYBOARD_MANAGER(self));
370
371 g_ptr_array_add(self->redispatched_key_events, g_object_ref(event));
372 }

## ◆ fl_keyboard_manager_get_pressed_state()

GHashTable* fl_keyboard_manager_get_pressed_state | ( | FlKeyboardManager * | manager | ) |

fl_keyboard_manager_get_pressed_state: @manager: the #FlKeyboardManager self.

Returns the keyboard pressed state. The hash table contains one entry per pressed keys, mapping from the logical key to the physical key.*

Definition at line 435 of file fl_keyboard_manager.cc.

435 {
436 g_return_val_if_fail(FL_IS_KEYBOARD_MANAGER(self), nullptr);
437 return fl_key_embedder_responder_get_pressed_state(
438 self->key_embedder_responder);
439 }
fl_key_embedder_responder_get_pressed_state
GHashTable * fl_key_embedder_responder_get_pressed_state(FlKeyEmbedderResponder *self)
Definition: fl_key_embedder_responder.cc:783

References fl_key_embedder_responder_get_pressed_state().

Referenced by get_keyboard_state().

## ◆ fl_keyboard_manager_handle_event()

void fl_keyboard_manager_handle_event | ( | FlKeyboardManager * | manager,
|  | FlKeyEvent * | event,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_keyboard_manager_handle_event: @manager: an #FlKeyboardManager. @event: the event to be dispatched. It is usually a wrap of a GdkEventKey. This event will be managed and released by #FlKeyboardManager. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the view is added. @user_data: (closure): user data to pass to @callback.

Make the manager process a system key event. This might eventually send messages to the framework, trigger text input effects, or redispatch the event back to the system.

Definition at line 374 of file fl_keyboard_manager.cc.

378 {
379 g_return_if_fail(FL_IS_KEYBOARD_MANAGER(self));
380 g_return_if_fail(event != nullptr);
381
382 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
383
384 guarantee_layout(self, event);
385
386 g_task_set_task_data(
387 task, handle_event_data_new(event),
388 reinterpret_cast<GDestroyNotify>(handle_event_data_free));
389
390 if (event_is_redispatched(self, event)) {
391 HandleEventData* data =
392 static_cast<HandleEventData*>(g_task_get_task_data(task));
393 data->handled = TRUE;
394 g_task_return_boolean(task, TRUE);
395 return;
396 }
397
398 uint64_t specified_logical_key = fl_keyboard_layout_get_logical_key(
399 self->derived_layout, fl_key_event_get_group(event),
400 fl_key_event_get_keycode(event));
401 fl_key_embedder_responder_handle_event(
402 self->key_embedder_responder, event, specified_logical_key,
403 self->cancellable, responder_handle_embedder_event_cb,
404 g_object_ref(task));
405 fl_key_channel_responder_handle_event(
406 self->key_channel_responder, event, specified_logical_key,
407 self->cancellable, responder_handle_channel_event_cb, g_object_ref(task));
408 }
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_key_channel_responder_handle_event
void fl_key_channel_responder_handle_event(FlKeyChannelResponder *self, FlKeyEvent *event, uint64_t specified_logical_key, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_key_channel_responder.cc:71
fl_key_embedder_responder_handle_event
void fl_key_embedder_responder_handle_event(FlKeyEmbedderResponder *self, FlKeyEvent *event, uint64_t specified_logical_key, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_key_embedder_responder.cc:737
fl_key_event_get_keycode
guint16 fl_key_event_get_keycode(FlKeyEvent *self)
Definition: fl_key_event.cc:89
fl_key_event_get_group
guint8 fl_key_event_get_group(FlKeyEvent *self)
Definition: fl_key_event.cc:104
fl_keyboard_layout_get_logical_key
uint64_t fl_keyboard_layout_get_logical_key(FlKeyboardLayout *self, uint8_t group, uint16_t keycode)
Definition: fl_keyboard_layout.cc:65
guarantee_layout
static void guarantee_layout(FlKeyboardManager *self, FlKeyEvent *event)
Definition: fl_keyboard_manager.cc:229
responder_handle_channel_event_cb
static void responder_handle_channel_event_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_keyboard_manager.cc:186
handle_event_data_new
static HandleEventData * handle_event_data_new(FlKeyEvent *event)
Definition: fl_keyboard_manager.cc:71
handle_event_data_free
static void handle_event_data_free(HandleEventData *data)
Definition: fl_keyboard_manager.cc:78
responder_handle_embedder_event_cb
static void responder_handle_embedder_event_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_keyboard_manager.cc:160
event_is_redispatched
static gboolean event_is_redispatched(FlKeyboardManager *self, FlKeyEvent *event)
Definition: fl_keyboard_manager.cc:123
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
HandleEventData
Definition: fl_keyboard_manager.cc:54
HandleEventData::handled
gboolean handled
Definition: fl_keyboard_manager.cc:68

References event_is_redispatched(), fl_key_channel_responder_handle_event(), fl_key_embedder_responder_handle_event(), fl_key_event_get_group(), fl_key_event_get_keycode(), fl_keyboard_layout_get_logical_key(), guarantee_layout(), handle_event_data_free(), handle_event_data_new(), HandleEventData::handled, responder_handle_channel_event_cb(), responder_handle_embedder_event_cb(), TRUE, and user_data.

Referenced by handle_key_event(), and TEST().

## ◆ fl_keyboard_manager_handle_event_finish()

gboolean fl_keyboard_manager_handle_event_finish | ( | FlKeyboardManager * | manager,
|  | GAsyncResult * | result,
|  | FlKeyEvent ** | redispatched_event,
|  | GError ** | error
| ) |  |

fl_keyboard_manager_handle_event_finish: @manager: an #FlKeyboardManager.

Returns
  : a #GAsyncResult. @redispatched_event: FIXME @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_keyboard_manager_handle_event().

Returns: TRUE on success.

Definition at line 410 of file fl_keyboard_manager.cc.

414 {
415 g_return_val_if_fail(FL_IS_KEYBOARD_MANAGER(self), FALSE);
416 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
417
418 HandleEventData* data =
419 static_cast<HandleEventData*>(g_task_get_task_data(G_TASK(result)));
420 if (redispatched_event != nullptr && data->redispatch) {
421 *redispatched_event = FL_KEY_EVENT(g_object_ref(data->event));
422 }
423
424 return g_task_propagate_boolean(G_TASK(result), error);
425 }
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
HandleEventData::event
FlKeyEvent * event
Definition: fl_keyboard_manager.cc:56
HandleEventData::redispatch
gboolean redispatch
Definition: fl_keyboard_manager.cc:65

References error, HandleEventData::event, and HandleEventData::redispatch.

Referenced by TEST().

## ◆ fl_keyboard_manager_new()

FlKeyboardManager* fl_keyboard_manager_new | ( | FlEngine * | engine | ) |

FlKeyboardManager:

Processes keyboard events and cooperate with `TextInputManager`.

A keyboard event goes through a few sections, each can choose to handle the event, and only unhandled events can move to the next section:

- Keyboard: Dispatch to the embedder responder and the channel responder simultaneously. After both responders have responded (asynchronously), the event is considered handled if either responder handles it.
- Text input: Events are sent to IM filter (usually owned by `TextInputManager`) and are handled synchronously.
- Redispatching: Events are inserted back to the system for redispatching. fl_keyboard_manager_new: @engine: an #FlEngine.

Create a new #FlKeyboardManager.

Returns: a new #FlKeyboardManager.

Definition at line 356 of file fl_keyboard_manager.cc.

356 {
357 FlKeyboardManager* self = FL_KEYBOARD_MANAGER(
358 g_object_new(fl_keyboard_manager_get_type(), nullptr));
359
360 self->key_embedder_responder = fl_key_embedder_responder_new(engine);
361 self->key_channel_responder =
362 fl_key_channel_responder_new(fl_engine_get_binary_messenger(engine));
363
364 return self;
365 }
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:1281
fl_key_channel_responder_new
FlKeyChannelResponder * fl_key_channel_responder_new(FlBinaryMessenger *messenger)
Definition: fl_key_channel_responder.cc:59
fl_key_embedder_responder_new
FlKeyEmbedderResponder * fl_key_embedder_responder_new(FlEngine *engine)
Definition: fl_key_embedder_responder.cc:181

References fl_engine_get_binary_messenger(), fl_key_channel_responder_new(), and fl_key_embedder_responder_new().

Referenced by fl_engine_new_full(), setup_keyboard(), and TEST().

## ◆ fl_keyboard_manager_set_lookup_key_handler()

void fl_keyboard_manager_set_lookup_key_handler | ( | FlKeyboardManager * | manager,
|  | FlKeyboardManagerLookupKeyHandler | lookup_key_handler,
|  | gpointer | user_data
| ) |  |

fl_keyboard_manager_set_lookup_key_handler: @manager: the #FlKeyboardManager self.

Set the handler for key lookup, for testing purposes only.

Definition at line 441 of file fl_keyboard_manager.cc.

444 {
445 g_return_if_fail(FL_IS_KEYBOARD_MANAGER(self));
446 self->lookup_key_handler = lookup_key_handler;
447 self->lookup_key_handler_user_data = user_data;
448 }

References user_data.

## ◆ fl_keyboard_manager_sync_modifier_if_needed()

void fl_keyboard_manager_sync_modifier_if_needed | ( | FlKeyboardManager * | manager,
|  | guint | state,
|  | double | event_time
| ) |  |

fl_keyboard_manager_sync_modifier_if_needed: @manager: the #FlKeyboardManager self. @state: the state of the modifiers mask. @event_time: the time attribute of the incoming GDK event.

If needed, synthesize modifier keys up and down event by comparing their current pressing states with the given modifiers mask.

Definition at line 427 of file fl_keyboard_manager.cc.

429 {
430 g_return_if_fail(FL_IS_KEYBOARD_MANAGER(self));
431 fl_key_embedder_responder_sync_modifiers_if_needed(
432 self->key_embedder_responder, state, event_time);
433 }
state
AtkStateType state
Definition: fl_accessible_node.cc:10
fl_key_embedder_responder_sync_modifiers_if_needed
void fl_key_embedder_responder_sync_modifiers_if_needed(FlKeyEmbedderResponder *self, guint state, double event_time)
Definition: fl_key_embedder_responder.cc:774

References fl_key_embedder_responder_sync_modifiers_if_needed(), and state.

Referenced by sync_modifier_if_needed().

## ◆ G_DECLARE_FINAL_TYPE()

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE | ( | FlKeyboardManager | ,
|  | fl_keyboard_manager | ,
|  | FL | ,
|  | KEYBOARD_MANAGER | ,
|  | GObject |
| ) |  |