Flutter Engine
The Flutter Engine
fl_key_embedder_responder.h
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#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
6#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
7
8#include <gdk/gdk.h>
9#include <functional>
10
11#include "flutter/shell/platform/linux/fl_key_responder.h"
12#include "flutter/shell/platform/linux/fl_keyboard_manager.h"
13#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
14#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"
15
16constexpr int kMaxConvertedKeyData = 3;
17
18// The signature of a function that FlKeyEmbedderResponder calls on every key
19// event.
20//
21// The `user_data` is opaque data managed by the object that creates
22// FlKeyEmbedderResponder, and is registered along with this callback
23// via `fl_key_embedder_responder_new`.
24//
25// The `callback_user_data` is opaque data managed by FlKeyEmbedderResponder.
26// Instances of the EmbedderSendKeyEvent callback are required to invoke
27// `callback` with the `callback_user_data` parameter after the `event` has been
28// processed.
31 void* callback_user_data,
32 void* send_key_event_user_data);
33
34G_BEGIN_DECLS
35
36#define FL_TYPE_KEY_EMBEDDER_RESPONDER fl_key_embedder_responder_get_type()
37G_DECLARE_FINAL_TYPE(FlKeyEmbedderResponder,
38 fl_key_embedder_responder,
39 FL,
40 KEY_EMBEDDER_RESPONDER,
41 GObject);
42
43/**
44 * FlKeyEmbedderResponder:
45 *
46 * A #FlKeyResponder that handles events by sending the converted events
47 * through the embedder API.
48 *
49 * This class communicates with the HardwareKeyboard API in the framework.
50 */
51
52/**
53 * fl_key_embedder_responder_new:
54 * @engine: The #FlEngine, whose the embedder API will be used to send
55 * the event.
56 *
57 * Creates a new #FlKeyEmbedderResponder.
58 * @send_key_event: a function that is called on every key event.
59 * @send_key_event_user_data: an opaque pointer that will be sent back as the
60 * last argument of send_key_event, created and managed by the object that holds
61 * FlKeyEmbedderResponder.
62 *
63 * Returns: a new #FlKeyEmbedderResponder.
64 */
65FlKeyEmbedderResponder* fl_key_embedder_responder_new(
67 void* send_key_event_user_data);
68
69/**
70 * fl_key_embedder_responder_sync_modifiers_if_needed:
71 * @responder: the #FlKeyEmbedderResponder self.
72 * @state: the state of the modifiers mask.
73 * @event_time: the time attribute of the incoming GDK event.
74 *
75 * If needed, synthesize modifier keys up and down event by comparing their
76 * current pressing states with the given modifiers mask.
77 */
79 FlKeyEmbedderResponder* responder,
80 guint state,
81 double event_time);
82
83/**
84 * fl_key_embedder_responder_get_pressed_state:
85 * @responder: the #FlKeyEmbedderResponder self.
86 *
87 * Returns the keyboard pressed state. The hash table contains one entry per
88 * pressed keys, mapping from the logical key to the physical key.
89 */
91 FlKeyEmbedderResponder* responder);
92
93G_END_DECLS
94
95#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
void(* FlutterKeyEventCallback)(bool, void *)
Definition: embedder.h:1155
AtkStateType state
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
FlKeyEvent * event
constexpr int kMaxConvertedKeyData
G_DECLARE_FINAL_TYPE(FlKeyEmbedderResponder, fl_key_embedder_responder, FL, KEY_EMBEDDER_RESPONDER, GObject)
FlKeyEmbedderResponder * fl_key_embedder_responder_new(EmbedderSendKeyEvent send_key_event, void *send_key_event_user_data)
void(* EmbedderSendKeyEvent)(const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *callback_user_data, void *send_key_event_user_data)
void fl_key_embedder_responder_sync_modifiers_if_needed(FlKeyEmbedderResponder *responder, guint state, double event_time)
GHashTable * fl_key_embedder_responder_get_pressed_state(FlKeyEmbedderResponder *responder)
static void send_key_event(FlTextInputPlugin *plugin, gint keyval, gint state=0)