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 `FlKeyboardHandler` 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, FlKeyEvent* event);
50 
51  void (*subscribe_to_layout_change)(FlKeyboardViewDelegate* delegate,
52  KeyboardLayoutNotifier notifier);
53 
54  guint (*lookup_key)(FlKeyboardViewDelegate* view_delegate,
55  const GdkKeymapKey* key);
56 
57  GHashTable* (*get_keyboard_state)(FlKeyboardViewDelegate* delegate);
58 };
59 
60 /**
61  * fl_keyboard_view_delegate_send_key_event:
62  *
63  * Handles `FlKeyboardHandler`'s request to send a `FlutterKeyEvent` through the
64  * embedder API to the framework.
65  *
66  * The ownership of the `event` is kept by the keyboard handler, and the `event`
67  * might be immediately destroyed after this function returns.
68  *
69  * The `callback` must eventually be called exactly once with the event result
70  * and the `user_data`.
71  */
72 void fl_keyboard_view_delegate_send_key_event(FlKeyboardViewDelegate* delegate,
73  const FlutterKeyEvent* event,
74  FlutterKeyEventCallback callback,
75  void* user_data);
76 
77 /**
78  * fl_keyboard_view_delegate_text_filter_key_press:
79  *
80  * Handles `FlKeyboardHandler`'s request to check if the GTK text input IM
81  * filter would like to handle a GDK event.
82  *
83  * The ownership of the `event` is kept by the keyboard handler.
84  */
86  FlKeyboardViewDelegate* delegate,
87  FlKeyEvent* event);
88 
89 /**
90  * fl_keyboard_view_delegate_get_messenger:
91  *
92  * Returns a binary messenger that can be used to send messages to the
93  * framework.
94  *
95  * The ownership of messenger is kept by the view delegate.
96  */
98  FlKeyboardViewDelegate* delegate);
99 
100 /**
101  * fl_keyboard_view_delegate_redispatch_event:
102  *
103  * Handles `FlKeyboardHandler`'s request to insert a GDK event to the system for
104  * redispatching.
105  */
107  FlKeyboardViewDelegate* delegate,
108  FlKeyEvent* event);
109 
111  FlKeyboardViewDelegate* delegate,
112  KeyboardLayoutNotifier notifier);
113 
114 guint fl_keyboard_view_delegate_lookup_key(FlKeyboardViewDelegate* delegate,
115  const GdkKeymapKey* key);
116 
117 /**
118  * fl_keyboard_view_delegate_get_keyboard_state:
119  *
120  * Returns the keyboard pressed state. The hash table contains one entry per
121  * pressed keys, mapping from the logical key to the physical key.*
122  *
123  */
125  FlKeyboardViewDelegate* delegate);
126 
127 G_END_DECLS
128 
129 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_VIEW_DELEGATE_H_
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
_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:54
_FlKeyboardViewDelegateInterface::g_iface
GTypeInterface g_iface
Definition: fl_keyboard_view_delegate.h:37
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:51
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:60
_FlKeyboardViewDelegateInterface::subscribe_to_layout_change
void(* subscribe_to_layout_change)(FlKeyboardViewDelegate *delegate, KeyboardLayoutNotifier notifier)
Definition: fl_keyboard_view_delegate.h:51
fl_keyboard_view_delegate_get_keyboard_state
GHashTable * fl_keyboard_view_delegate_get_keyboard_state(FlKeyboardViewDelegate *delegate)
Definition: fl_keyboard_view_delegate.cc:67
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
fl_keyboard_view_delegate_redispatch_event
void fl_keyboard_view_delegate_redispatch_event(FlKeyboardViewDelegate *delegate, FlKeyEvent *event)
Definition: fl_keyboard_view_delegate.cc:42
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
_FlKeyboardViewDelegateInterface::redispatch_event
void(* redispatch_event)(FlKeyboardViewDelegate *delegate, FlKeyEvent *event)
Definition: fl_keyboard_view_delegate.h:49