| Flutter Linux Embedder |

Classes | Macros | Functions
fl_keyboard_manager.cc File Reference
`#include "flutter/shell/platform/linux/fl_keyboard_manager.h"`
`#include <array>`
`#include <cinttypes>`
`#include <memory>`
`#include <string>`
`#include "flutter/shell/platform/linux/fl_key_channel_responder.h"`
`#include "flutter/shell/platform/linux/fl_key_embedder_responder.h"`
`#include "flutter/shell/platform/linux/fl_keyboard_layout.h"`
`#include "flutter/shell/platform/linux/key_mapping.h"`

Go to the source code of this file.

## Classes
struct | HandleEventData
struct | _FlKeyboardManager

## Macros
#define | DEBUG_PRINT_LAYOUT

## Functions
static HandleEventData * | handle_event_data_new (FlKeyEvent *event)
static void | handle_event_data_free (HandleEventData *data)
| G_DEFINE_TYPE (FlKeyboardManager, fl_keyboard_manager, G_TYPE_OBJECT)
static gboolean | event_is_redispatched (FlKeyboardManager *self, FlKeyEvent *event)
static void | keymap_keys_changed_cb (FlKeyboardManager *self)
static void | complete_handle_event (FlKeyboardManager *self, GTask *task)
static void | responder_handle_embedder_event_cb (GObject *object, GAsyncResult *result, gpointer user_data)
static void | responder_handle_channel_event_cb (GObject *object, GAsyncResult *result, gpointer user_data)
static uint16_t | convert_key_to_char (FlKeyboardManager *self, guint keycode, gint group, gint level)
static void | guarantee_layout (FlKeyboardManager *self, FlKeyEvent *event)
static void | fl_keyboard_manager_dispose (GObject *object)
static void | fl_keyboard_manager_class_init (FlKeyboardManagerClass *klass)
static void | fl_keyboard_manager_init (FlKeyboardManager *self)
FlKeyboardManager * | fl_keyboard_manager_new (FlEngine *engine)
void | fl_keyboard_manager_add_redispatched_event (FlKeyboardManager *self, FlKeyEvent *event)
void | fl_keyboard_manager_handle_event (FlKeyboardManager *self, FlKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_keyboard_manager_handle_event_finish (FlKeyboardManager *self, GAsyncResult *result, FlKeyEvent **redispatched_event, GError **error)
void | fl_keyboard_manager_sync_modifier_if_needed (FlKeyboardManager *self, guint state, double event_time)
GHashTable * | fl_keyboard_manager_get_pressed_state (FlKeyboardManager *self)
void | fl_keyboard_manager_set_lookup_key_handler (FlKeyboardManager *self, FlKeyboardManagerLookupKeyHandler lookup_key_handler, gpointer user_data)

## Macro Definition Documentation

## ◆ DEBUG_PRINT_LAYOUT

#define DEBUG_PRINT_LAYOUT

Definition at line 19 of file fl_keyboard_manager.cc.

## Function Documentation

## ◆ complete_handle_event()

static void complete_handle_event | ( | FlKeyboardManager * | self,
|  | GTask * | task
| ) |  |
| static

Definition at line 147 of file fl_keyboard_manager.cc.

147 {
148 HandleEventData* data =
149 static_cast<HandleEventData*>(g_task_get_task_data(task));
150
151 // Waiting for responses.
152 if (!data->embedder_responded || !data->channel_responded) {
153 return;
154 }
155
156 data->redispatch = !data->handled;
157 g_task_return_boolean(task, TRUE);
158 }
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
HandleEventData
Definition: fl_keyboard_manager.cc:54
HandleEventData::embedder_responded
gboolean embedder_responded
Definition: fl_keyboard_manager.cc:59
HandleEventData::handled
gboolean handled
Definition: fl_keyboard_manager.cc:68
HandleEventData::channel_responded
gboolean channel_responded
Definition: fl_keyboard_manager.cc:62
HandleEventData::redispatch
gboolean redispatch
Definition: fl_keyboard_manager.cc:65

References HandleEventData::channel_responded, HandleEventData::embedder_responded, HandleEventData::handled, HandleEventData::redispatch, and TRUE.

Referenced by responder_handle_channel_event_cb(), and responder_handle_embedder_event_cb().

## ◆ convert_key_to_char()

static uint16_t convert_key_to_char | ( | FlKeyboardManager * | self,
|  | guint | keycode,
|  | gint | group,
|  | gint | level
| ) |  |
| static

Definition at line 212 of file fl_keyboard_manager.cc.

215 {
216 GdkKeymapKey key = {keycode, group, level};
217 constexpr int kBmpMax = 0xD7FF;
218 guint origin;
219 if (self->lookup_key_handler != nullptr) {
220 origin = self->lookup_key_handler(&key, self->lookup_key_handler_user_data);
221 } else {
222 origin = gdk_keymap_lookup_key(self->keymap, &key);
223 }
224 return origin < kBmpMax ? origin : 0xFFFF;
225 }

Referenced by guarantee_layout().

## ◆ event_is_redispatched()

static gboolean event_is_redispatched | ( | FlKeyboardManager * | self,
|  | FlKeyEvent * | event
| ) |  |
| static

Definition at line 123 of file fl_keyboard_manager.cc.

124 {
125 guint32 time = fl_key_event_get_time(event);
126 gboolean is_press = !!fl_key_event_get_is_press(event);
127 guint16 keycode = fl_key_event_get_keycode(event);
128 for (guint i = 0; i < self->redispatched_key_events->len; i++) {
129 FlKeyEvent* e =
130 FL_KEY_EVENT(g_ptr_array_index(self->redispatched_key_events, i));
131 if (fl_key_event_get_time(e) == time &&
132 !!fl_key_event_get_is_press(e) == is_press &&
133 fl_key_event_get_keycode(e) == keycode) {
134 g_ptr_array_remove_index(self->redispatched_key_events, i);
135 return TRUE;
136 }
137 }
138
139 return FALSE;
140 }
fl_key_event_get_keycode
guint16 fl_key_event_get_keycode(FlKeyEvent *self)
Definition: fl_key_event.cc:89
fl_key_event_get_is_press
gboolean fl_key_event_get_is_press(FlKeyEvent *self)
Definition: fl_key_event.cc:84
fl_key_event_get_time
guint32 fl_key_event_get_time(FlKeyEvent *self)
Definition: fl_key_event.cc:79
i
int i
Definition: fl_socket_accessible.cc:18

References fl_key_event_get_is_press(), fl_key_event_get_keycode(), fl_key_event_get_time(), i, and TRUE.

Referenced by fl_keyboard_manager_handle_event().

## ◆ 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_class_init()

static void fl_keyboard_manager_class_init | ( | FlKeyboardManagerClass * | klass | ) |
| static

Definition at line 330 of file fl_keyboard_manager.cc.

330 {
331 G_OBJECT_CLASS(klass)->dispose = fl_keyboard_manager_dispose;
332 }
fl_keyboard_manager_dispose
static void fl_keyboard_manager_dispose(GObject *object)
Definition: fl_keyboard_manager.cc:309

References fl_keyboard_manager_dispose().

## ◆ fl_keyboard_manager_dispose()

static void fl_keyboard_manager_dispose | ( | GObject * | object | ) |
| static

Definition at line 309 of file fl_keyboard_manager.cc.

309 {
310 FlKeyboardManager* self = FL_KEYBOARD_MANAGER(object);
311
312 g_cancellable_cancel(self->cancellable);
313
314 self->keycode_to_goals.reset();
315 self->logical_to_mandatory_goals.reset();
316
317 g_clear_pointer(&self->redispatched_key_events, g_ptr_array_unref);
318 g_clear_object(&self->key_embedder_responder);
319 g_clear_object(&self->key_channel_responder);
320 g_clear_object(&self->derived_layout);
321 if (self->keymap_keys_changed_cb_id != 0) {
322 g_signal_handler_disconnect(self->keymap, self->keymap_keys_changed_cb_id);
323 self->keymap_keys_changed_cb_id = 0;
324 }
325 g_clear_object(&self->cancellable);
326
327 G_OBJECT_CLASS(fl_keyboard_manager_parent_class)->dispose(object);
328 }

Referenced by fl_keyboard_manager_class_init().

## ◆ 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_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

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

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

Referenced by TEST().

## ◆ fl_keyboard_manager_init()

static void fl_keyboard_manager_init | ( | FlKeyboardManager * | self | ) |
| static

Definition at line 334 of file fl_keyboard_manager.cc.

334 {
335 self->redispatched_key_events =
336 g_ptr_array_new_with_free_func(g_object_unref);
337 self->derived_layout = fl_keyboard_layout_new();
338
339 self->keycode_to_goals =
340 std::make_unique<std::map<uint16_t, const LayoutGoal*>>();
341 self->logical_to_mandatory_goals =
342 std::make_unique<std::map<uint64_t, const LayoutGoal*>>();
343 for (const LayoutGoal& goal : layout_goals) {
344 (*self->keycode_to_goals)[goal.keycode] = &goal;
345 if (goal.mandatory) {
346 (*self->logical_to_mandatory_goals)[goal.logical_key] = &goal;
347 }
348 }
349
350 self->keymap = gdk_keymap_get_for_display(gdk_display_get_default());
351 self->keymap_keys_changed_cb_id = g_signal_connect_swapped(
352 self->keymap, "keys-changed", G_CALLBACK(keymap_keys_changed_cb), self);
353 self->cancellable = g_cancellable_new();
354 }
if
if(end==-1)
Definition: fl_accessible_text_field.cc:42
fl_keyboard_layout_new
FlKeyboardLayout * fl_keyboard_layout_new()
Definition: fl_keyboard_layout.cc:40
keymap_keys_changed_cb
static void keymap_keys_changed_cb(FlKeyboardManager *self)
Definition: fl_keyboard_manager.cc:142
layout_goals
const std::vector< LayoutGoal > layout_goals
Definition: key_mapping.g.cc:462
LayoutGoal
Definition: key_mapping.h:40

References fl_keyboard_layout_new(), if(), keymap_keys_changed_cb(), and layout_goals.

## ◆ 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_DEFINE_TYPE()

G_DEFINE_TYPE | ( | FlKeyboardManager | ,
|  | fl_keyboard_manager | ,
|  | G_TYPE_OBJECT |
| ) |  |

## ◆ guarantee_layout()

static void guarantee_layout | ( | FlKeyboardManager * | self,
|  | FlKeyEvent * | event
| ) |  |
| static

Definition at line 229 of file fl_keyboard_manager.cc.

229 {
230 guint8 group = fl_key_event_get_group(event);
231 if (fl_keyboard_layout_has_group(self->derived_layout, group)) {
232 return;
233 }
234 if (self->keycode_to_goals->find(fl_key_event_get_keycode(event)) ==
235 self->keycode_to_goals->end()) {
236 return;
237 }
238
239 // Clone all mandatory goals. Each goal is removed from this cloned map when
240 // fulfilled, and the remaining ones will be assigned to a default position.
241 std::map<uint64_t, const LayoutGoal*> remaining_mandatory_goals =
242 *self->logical_to_mandatory_goals;
243
244 #ifdef DEBUG_PRINT_LAYOUT
245 std::string debug_layout_data;
246 for (uint16_t keycode = 0; keycode < 128; keycode += 1) {
247 std::vector<uint16_t> this_key_clues = {
248 convert_key_to_char(self, keycode, group, 0),
249 convert_key_to_char(self, keycode, group, 1), // Shift
250 };
251 debug_format_layout_data(debug_layout_data, keycode, this_key_clues[0],
252 this_key_clues[1]);
253 }
254 #endif
255
256 // It's important to only traverse layout goals instead of all keycodes.
257 // Some key codes outside of the standard keyboard also gives alpha-numeric
258 // letters, and will therefore take over mandatory goals from standard
259 // keyboard keys if they come first. Example: French keyboard digit 1.
260 for (const LayoutGoal& keycode_goal : layout_goals) {
261 uint16_t keycode = keycode_goal.keycode;
262 std::vector<uint16_t> this_key_clues = {
263 convert_key_to_char(self, keycode, group, 0),
264 convert_key_to_char(self, keycode, group, 1), // Shift
265 };
266
267 // The logical key should be the first available clue from below:
268 //
269 // - Mandatory goal, if it matches any clue. This ensures that all alnum
270 // keys can be found somewhere.
271 // - US layout, if neither clue of the key is EASCII. This ensures that
272 // there are no non-latin logical keys.
273 // - A value derived on the fly from keycode & keyval.
274 for (uint16_t clue : this_key_clues) {
275 auto matching_goal = remaining_mandatory_goals.find(clue);
276 if (matching_goal != remaining_mandatory_goals.end()) {
277 // Found a key that produces a mandatory char. Use it.
278 g_return_if_fail(fl_keyboard_layout_get_logical_key(
279 self->derived_layout, group, keycode) == 0);
280 fl_keyboard_layout_set_logical_key(self->derived_layout, group, keycode,
281 clue);
282 remaining_mandatory_goals.erase(matching_goal);
283 break;
284 }
285 }
286 bool has_any_eascii =
287 is_eascii(this_key_clues[0]) || is_eascii(this_key_clues[1]);
288 // See if any produced char meets the requirement as a logical key.
289 if (fl_keyboard_layout_get_logical_key(self->derived_layout, group,
290 keycode) == 0 &&
291 !has_any_eascii) {
292 auto found_us_layout = self->keycode_to_goals->find(keycode);
293 if (found_us_layout != self->keycode_to_goals->end()) {
294 fl_keyboard_layout_set_logical_key(
295 self->derived_layout, group, keycode,
296 found_us_layout->second->logical_key);
297 }
298 }
299 }
300
301 // Ensure all mandatory goals are assigned.
302 for (const auto mandatory_goal_iter : remaining_mandatory_goals) {
303 const LayoutGoal* goal = mandatory_goal_iter.second;
304 fl_keyboard_layout_set_logical_key(self->derived_layout, group,
305 goal->keycode, goal->logical_key);
306 }
307 }
fl_keyboard_layout_set_logical_key
void fl_keyboard_layout_set_logical_key(FlKeyboardLayout *self, uint8_t group, uint16_t keycode, uint64_t logical_key)
Definition: fl_keyboard_layout.cc:49
fl_keyboard_layout_has_group
gboolean fl_keyboard_layout_has_group(FlKeyboardLayout *self, uint8_t group)
Definition: fl_keyboard_layout.cc:45
convert_key_to_char
static uint16_t convert_key_to_char(FlKeyboardManager *self, guint keycode, gint group, gint level)
Definition: fl_keyboard_manager.cc:212
LayoutGoal::keycode
uint16_t keycode
Definition: key_mapping.h:42
LayoutGoal::logical_key
uint64_t logical_key
Definition: key_mapping.h:45

References convert_key_to_char(), fl_key_event_get_group(), fl_key_event_get_keycode(), fl_keyboard_layout_get_logical_key(), fl_keyboard_layout_has_group(), fl_keyboard_layout_set_logical_key(), LayoutGoal::keycode, layout_goals, and LayoutGoal::logical_key.

Referenced by fl_keyboard_manager_handle_event().

## ◆ handle_event_data_free()

static void handle_event_data_free | ( | HandleEventData * | data | ) |
| static

Definition at line 78 of file fl_keyboard_manager.cc.

78 {
79 g_object_unref(data->event);
80 g_free(data);
81 }

References HandleEventData::event.

Referenced by fl_keyboard_manager_handle_event().

## ◆ handle_event_data_new()

static HandleEventData* handle_event_data_new | ( | FlKeyEvent * | event | ) |
| static

Definition at line 71 of file fl_keyboard_manager.cc.

71 {
72 HandleEventData* data =
73 static_cast<HandleEventData*>(g_new0(HandleEventData, 1));
74 data->event = FL_KEY_EVENT(g_object_ref(event));
75 return data;
76 }

References HandleEventData::event.

Referenced by fl_keyboard_manager_handle_event().

## ◆ keymap_keys_changed_cb()

static void keymap_keys_changed_cb | ( | FlKeyboardManager * | self | ) |
| static

Definition at line 142 of file fl_keyboard_manager.cc.

142 {
143 g_clear_object(&self->derived_layout);
144 self->derived_layout = fl_keyboard_layout_new();
145 }

References fl_keyboard_layout_new().

Referenced by fl_keyboard_manager_init().

## ◆ responder_handle_channel_event_cb()

static void responder_handle_channel_event_cb | ( | GObject * | object,
|  | GAsyncResult * | result,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 186 of file fl_keyboard_manager.cc.

188 {
189 g_autoptr(GTask) task = G_TASK(user_data);
190 FlKeyboardManager* self = FL_KEYBOARD_MANAGER(g_task_get_source_object(task));
191
192 HandleEventData* data =
193 static_cast<HandleEventData*>(g_task_get_task_data(G_TASK(task)));
194 data->channel_responded = TRUE;
195
196 g_autoptr(GError) error = nullptr;
197 gboolean handled;
198 if (!fl_key_channel_responder_handle_event_finish(
199 FL_KEY_CHANNEL_RESPONDER(object), result, &handled, &error)) {
200 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
201 g_warning("Failed to handle key event in platform: %s", error->message);
202 }
203 handled = FALSE;
204 }
205 if (handled) {
206 data->handled = TRUE;
207 }
208
209 complete_handle_event(self, task);
210 }
fl_key_channel_responder_handle_event_finish
gboolean fl_key_channel_responder_handle_event_finish(FlKeyChannelResponder *self, GAsyncResult *result, gboolean *handled, GError **error)
Definition: fl_key_channel_responder.cc:139
complete_handle_event
static void complete_handle_event(FlKeyboardManager *self, GTask *task)
Definition: fl_keyboard_manager.cc:147

References HandleEventData::channel_responded, complete_handle_event(), error, fl_key_channel_responder_handle_event_finish(), HandleEventData::handled, TRUE, and user_data.

Referenced by fl_keyboard_manager_handle_event().

## ◆ responder_handle_embedder_event_cb()

static void responder_handle_embedder_event_cb | ( | GObject * | object,
|  | GAsyncResult * | result,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 160 of file fl_keyboard_manager.cc.

162 {
163 g_autoptr(GTask) task = G_TASK(user_data);
164 FlKeyboardManager* self = FL_KEYBOARD_MANAGER(g_task_get_source_object(task));
165
166 HandleEventData* data =
167 static_cast<HandleEventData*>(g_task_get_task_data(G_TASK(task)));
168 data->embedder_responded = TRUE;
169
170 g_autoptr(GError) error = nullptr;
171 gboolean handled;
172 if (!fl_key_embedder_responder_handle_event_finish(
173 FL_KEY_EMBEDDER_RESPONDER(object), result, &handled, &error)) {
174 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
175 g_warning("Failed to handle key event in embedder: %s", error->message);
176 }
177 handled = FALSE;
178 }
179 if (handled) {
180 data->handled = TRUE;
181 }
182
183 complete_handle_event(self, task);
184 }
fl_key_embedder_responder_handle_event_finish
gboolean fl_key_embedder_responder_handle_event_finish(FlKeyEmbedderResponder *self, GAsyncResult *result, gboolean *handled, GError **error)
Definition: fl_key_embedder_responder.cc:757

References complete_handle_event(), HandleEventData::embedder_responded, error, fl_key_embedder_responder_handle_event_finish(), HandleEventData::handled, TRUE, and user_data.

Referenced by fl_keyboard_manager_handle_event().