| Flutter Linux Embedder |

fl_keyboard_pending_event.cc
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 #include "flutter/shell/platform/linux/fl_keyboard_pending_event.h"
6
7 /**
8 * FlKeyboardPendingEvent:
9 * A record for events that have been received by the handler, but
10 * dispatched to other objects, whose results have yet to return.
11 *
12 * This object is used by both the "pending_responds" list and the
13 * "pending_redispatches" list.
14 */
15
16 struct _FlKeyboardPendingEvent {
17 GObject parent_instance;
18
19 // The target event.
20 FlKeyEvent* event;
21
22 // True if the embedder responder has replied.
23 bool embedder_replied;
24
25 // True if the channel responder has replied.
26 bool channel_replied;
27
28 // True if this event was handled by the embedder responder.
29 bool embedder_handled;
30
31 // True if this event was handled by the channel responder.
32 bool channel_handled;
33
34 // A value calculated out of critical event information that can be used
35 // to identify redispatched events.
36 uint64_t hash;
37 };
38
39 G_DEFINE_TYPE(FlKeyboardPendingEvent, fl_keyboard_pending_event, G_TYPE_OBJECT)
40
41 static void fl_keyboard_pending_event_dispose(GObject* object) {
42 FlKeyboardPendingEvent* self = FL_KEYBOARD_PENDING_EVENT(object);
43
44 g_clear_object(&self->event);
45
46 G_OBJECT_CLASS(fl_keyboard_pending_event_parent_class)->dispose(object);
47 }
48
49 static void fl_keyboard_pending_event_class_init(
50 FlKeyboardPendingEventClass* klass) {
51 G_OBJECT_CLASS(klass)->dispose = fl_keyboard_pending_event_dispose;
52 }
53
54 static void fl_keyboard_pending_event_init(FlKeyboardPendingEvent* self) {}
55
56 // Creates a new FlKeyboardPendingEvent by providing the target event,
57 // the sequence ID, and the number of responders that will reply.
58 FlKeyboardPendingEvent* fl_keyboard_pending_event_new(FlKeyEvent* event) {
59 FlKeyboardPendingEvent* self = FL_KEYBOARD_PENDING_EVENT(
60 g_object_new(fl_keyboard_pending_event_get_type(), nullptr));
61
62 self->event = FL_KEY_EVENT(g_object_ref(event));
63 self->hash = fl_key_event_hash(self->event);
64
65 return self;
66 }
67
68 FlKeyEvent* fl_keyboard_pending_event_get_event(FlKeyboardPendingEvent* self) {
69 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), nullptr);
70 return self->event;
71 }
72
73 uint64_t fl_keyboard_pending_event_get_hash(FlKeyboardPendingEvent* self) {
74 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), 0);
75 return self->hash;
76 }
77
78 void fl_keyboard_pending_event_mark_embedder_replied(
79 FlKeyboardPendingEvent* self,
80 gboolean handled) {
81 g_return_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self));
82 self->embedder_replied = true;
83 self->embedder_handled = handled;
84 }
85
86 void fl_keyboard_pending_event_mark_channel_replied(
87 FlKeyboardPendingEvent* self,
88 gboolean handled) {
89 g_return_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self));
90 self->channel_replied = true;
91 self->channel_handled = handled;
92 }
93
94 gboolean fl_keyboard_pending_event_get_any_handled(
95 FlKeyboardPendingEvent* self) {
96 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), FALSE);
97 return self->embedder_handled || self->channel_handled;
98 }
99
100 gboolean fl_keyboard_pending_event_is_complete(FlKeyboardPendingEvent* self) {
101 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), FALSE);
102 return self->embedder_replied && self->channel_replied;
103 }
G_DEFINE_TYPE
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
Definition: fl_basic_message_channel.cc:37
fl_key_event_hash
uint64_t fl_key_event_hash(FlKeyEvent *self)
Definition: fl_key_event.cc:114
fl_keyboard_pending_event_get_any_handled
gboolean fl_keyboard_pending_event_get_any_handled(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:94
fl_keyboard_pending_event_mark_embedder_replied
void fl_keyboard_pending_event_mark_embedder_replied(FlKeyboardPendingEvent *self, gboolean handled)
Definition: fl_keyboard_pending_event.cc:78
fl_keyboard_pending_event_get_hash
uint64_t fl_keyboard_pending_event_get_hash(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:73
fl_keyboard_pending_event_class_init
static void fl_keyboard_pending_event_class_init(FlKeyboardPendingEventClass *klass)
Definition: fl_keyboard_pending_event.cc:49
fl_keyboard_pending_event_new
FlKeyboardPendingEvent * fl_keyboard_pending_event_new(FlKeyEvent *event)
Definition: fl_keyboard_pending_event.cc:58
fl_keyboard_pending_event_get_event
FlKeyEvent * fl_keyboard_pending_event_get_event(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:68
fl_keyboard_pending_event_dispose
static void fl_keyboard_pending_event_dispose(GObject *object)
Definition: fl_keyboard_pending_event.cc:41
fl_keyboard_pending_event_is_complete
gboolean fl_keyboard_pending_event_is_complete(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:100
fl_keyboard_pending_event_init
static void fl_keyboard_pending_event_init(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:54
fl_keyboard_pending_event_mark_channel_replied
void fl_keyboard_pending_event_mark_channel_replied(FlKeyboardPendingEvent *self, gboolean handled)
Definition: fl_keyboard_pending_event.cc:86
fl_keyboard_pending_event.h
_FlKeyboardPendingEvent
Definition: fl_keyboard_pending_event.cc:16
_FlKeyboardPendingEvent::embedder_replied
bool embedder_replied
Definition: fl_keyboard_pending_event.cc:23
_FlKeyboardPendingEvent::parent_instance
GObject parent_instance
Definition: fl_keyboard_pending_event.cc:17
_FlKeyboardPendingEvent::channel_handled
bool channel_handled
Definition: fl_keyboard_pending_event.cc:32
_FlKeyboardPendingEvent::embedder_handled
bool embedder_handled
Definition: fl_keyboard_pending_event.cc:29
_FlKeyboardPendingEvent::hash
uint64_t hash
Definition: fl_keyboard_pending_event.cc:36
_FlKeyboardPendingEvent::channel_replied
bool channel_replied
Definition: fl_keyboard_pending_event.cc:26
_FlKeyboardPendingEvent::event
FlKeyEvent * event
Definition: fl_keyboard_pending_event.cc:20