Flutter Linux Embedder
fl_keyboard_view_delegate.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_KEYBOARD_VIEW_DELEGATE_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_VIEW_DELEGATE_H_
7 
8 #include <gdk/gdk.h>
9 #include <cinttypes>
10 #include <functional>
11 #include <memory>
12 
13 #include "flutter/shell/platform/embedder/embedder.h"
16 
17 typedef std::function<void()> KeyboardLayoutNotifier;
18 
19 G_BEGIN_DECLS
20 
21 G_DECLARE_INTERFACE(FlKeyboardViewDelegate,
22  fl_keyboard_view_delegate,
23  FL,
24  KEYBOARD_VIEW_DELEGATE,
25  GObject);
26 
27 /**
28  * FlKeyboardViewDelegate:
29  *
30  * An interface for a class that provides `FlKeyboardManager` with
31  * platform-related features.
32  *
33  * This interface is typically implemented by `FlView`.
34  */
35 
37  GTypeInterface g_iface;
38 
39  void (*send_key_event)(FlKeyboardViewDelegate* delegate,
40  const FlutterKeyEvent* event,
41  FlutterKeyEventCallback callback,
42  void* user_data);
43 
44  gboolean (*text_filter_key_press)(FlKeyboardViewDelegate* delegate,
45  FlKeyEvent* event);
46 
47  FlBinaryMessenger* (*get_messenger)(FlKeyboardViewDelegate* delegate);
48 
49  void (*redispatch_event)(FlKeyboardViewDelegate* delegate,
50  std::unique_ptr<FlKeyEvent> event);
51 
52  void (*subscribe_to_layout_change)(FlKeyboardViewDelegate* delegate,
53  KeyboardLayoutNotifier notifier);
54 
55  guint (*lookup_key)(FlKeyboardViewDelegate* view_delegate,
56  const GdkKeymapKey* key);
57 
58  GHashTable* (*get_keyboard_state)(FlKeyboardViewDelegate* delegate);
59 };
60 
61 /**
62  * fl_keyboard_view_delegate_send_key_event:
63  *
64  * Handles `FlKeyboardManager`'s request to send a `FlutterKeyEvent` through the
65  * embedder API to the framework.
66  *
67  * The ownership of the `event` is kept by the keyboard manager, and the `event`
68  * might be immediately destroyed after this function returns.
69  *
70  * The `callback` must eventually be called exactly once with the event result
71  * and the `user_data`.
72  */
73 void fl_keyboard_view_delegate_send_key_event(FlKeyboardViewDelegate* delegate,
74  const FlutterKeyEvent* event,
75  FlutterKeyEventCallback callback,
76  void* user_data);
77 
78 /**
79  * fl_keyboard_view_delegate_text_filter_key_press:
80  *
81  * Handles `FlKeyboardManager`'s request to check if the GTK text input IM
82  * filter would like to handle a GDK event.
83  *
84  * The ownership of the `event` is kept by the keyboard manager.
85  */
87  FlKeyboardViewDelegate* delegate,
88  FlKeyEvent* event);
89 
90 /**
91  * fl_keyboard_view_delegate_get_messenger:
92  *
93  * Returns a binary messenger that can be used to send messages to the
94  * framework.
95  *
96  * The ownership of messenger is kept by the view delegate.
97  */
99  FlKeyboardViewDelegate* delegate);
100 
101 /**
102  * fl_keyboard_view_delegate_redispatch_event:
103  *
104  * Handles `FlKeyboardManager`'s request to insert a GDK event to the system for
105  * redispatching.
106  *
107  * The ownership of event will be transferred to the view delegate. The view
108  * delegate is responsible to call fl_key_event_dispose.
109  */
111  FlKeyboardViewDelegate* delegate,
112  std::unique_ptr<FlKeyEvent> event);
113 
115  FlKeyboardViewDelegate* delegate,
116  KeyboardLayoutNotifier notifier);
117 
118 guint fl_keyboard_view_delegate_lookup_key(FlKeyboardViewDelegate* delegate,
119  const GdkKeymapKey* key);
120 
121 /**
122  * fl_keyboard_view_delegate_get_keyboard_state:
123  *
124  * Returns the keyboard pressed state. The hash table contains one entry per
125  * pressed keys, mapping from the logical key to the physical key.*
126  *
127  */
129  FlKeyboardViewDelegate* delegate);
130 
131 G_END_DECLS
132 
133 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_VIEW_DELEGATE_H_
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
_FlKeyboardViewDelegateInterface::redispatch_event
void(* redispatch_event)(FlKeyboardViewDelegate *delegate, std::unique_ptr< FlKeyEvent > event)
Definition: fl_keyboard_view_delegate.h:49
_FlKeyboardViewDelegateInterface::text_filter_key_press
gboolean(* text_filter_key_press)(FlKeyboardViewDelegate *delegate, FlKeyEvent *event)
Definition: fl_keyboard_view_delegate.h:44
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
G_DECLARE_INTERFACE
G_BEGIN_DECLS G_DECLARE_INTERFACE(FlKeyboardViewDelegate, fl_keyboard_view_delegate, FL, KEYBOARD_VIEW_DELEGATE, GObject)
_FlKeyboardViewDelegateInterface::lookup_key
guint(* lookup_key)(FlKeyboardViewDelegate *view_delegate, const GdkKeymapKey *key)
Definition: fl_keyboard_view_delegate.h:55
_FlKeyboardViewDelegateInterface::g_iface
GTypeInterface g_iface
Definition: fl_keyboard_view_delegate.h:37
_FlKeyEvent
Definition: fl_key_event.h:22
fl_keyboard_view_delegate_redispatch_event
void fl_keyboard_view_delegate_redispatch_event(FlKeyboardViewDelegate *delegate, std::unique_ptr< FlKeyEvent > event)
Definition: fl_keyboard_view_delegate.cc:42
fl_keyboard_view_delegate_subscribe_to_layout_change
void fl_keyboard_view_delegate_subscribe_to_layout_change(FlKeyboardViewDelegate *delegate, KeyboardLayoutNotifier notifier)
Definition: fl_keyboard_view_delegate.cc:52
fl_keyboard_view_delegate_send_key_event
void fl_keyboard_view_delegate_send_key_event(FlKeyboardViewDelegate *delegate, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Definition: fl_keyboard_view_delegate.cc:14
KeyboardLayoutNotifier
std::function< void()> KeyboardLayoutNotifier
Definition: fl_keyboard_view_delegate.h:17
fl_binary_messenger.h
fl_keyboard_view_delegate_lookup_key
guint fl_keyboard_view_delegate_lookup_key(FlKeyboardViewDelegate *delegate, const GdkKeymapKey *key)
Definition: fl_keyboard_view_delegate.cc:61
_FlKeyboardViewDelegateInterface::subscribe_to_layout_change
void(* subscribe_to_layout_change)(FlKeyboardViewDelegate *delegate, KeyboardLayoutNotifier notifier)
Definition: fl_keyboard_view_delegate.h:52
fl_keyboard_view_delegate_get_keyboard_state
GHashTable * fl_keyboard_view_delegate_get_keyboard_state(FlKeyboardViewDelegate *delegate)
Definition: fl_keyboard_view_delegate.cc:68
FL
FL
Definition: fl_binary_messenger.cc:27
_FlKeyboardViewDelegateInterface
Definition: fl_keyboard_view_delegate.h:36
fl_keyboard_view_delegate_text_filter_key_press
gboolean fl_keyboard_view_delegate_text_filter_key_press(FlKeyboardViewDelegate *delegate, FlKeyEvent *event)
Definition: fl_keyboard_view_delegate.cc:25
fl_key_event.h
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_channel_responder.cc:120
_FlKeyboardViewDelegateInterface::send_key_event
void(* send_key_event)(FlKeyboardViewDelegate *delegate, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Definition: fl_keyboard_view_delegate.h:39
fl_keyboard_view_delegate_get_messenger
FlBinaryMessenger * fl_keyboard_view_delegate_get_messenger(FlKeyboardViewDelegate *delegate)
Definition: fl_keyboard_view_delegate.cc:35