| 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 // Unique ID to identify pending responds.
23 uint64_t sequence_id;
24
25 // The number of responders that haven't replied.
26 size_t unreplied;
27
28 // Whether any replied responders reported true (handled).
29 bool any_handled;
30
31 // A value calculated out of critical event information that can be used
32 // to identify redispatched events.
33 uint64_t hash;
34 };
35
36 G_DEFINE_TYPE(FlKeyboardPendingEvent, fl_keyboard_pending_event, G_TYPE_OBJECT)
37
38 static void fl_keyboard_pending_event_dispose(GObject* object) {
39 FlKeyboardPendingEvent* self = FL_KEYBOARD_PENDING_EVENT(object);
40
41 g_clear_object(&self->event);
42
43 G_OBJECT_CLASS(fl_keyboard_pending_event_parent_class)->dispose(object);
44 }
45
46 static void fl_keyboard_pending_event_class_init(
47 FlKeyboardPendingEventClass* klass) {
48 G_OBJECT_CLASS(klass)->dispose = fl_keyboard_pending_event_dispose;
49 }
50
51 static void fl_keyboard_pending_event_init(FlKeyboardPendingEvent* self) {}
52
53 // Creates a new FlKeyboardPendingEvent by providing the target event,
54 // the sequence ID, and the number of responders that will reply.
55 FlKeyboardPendingEvent* fl_keyboard_pending_event_new(FlKeyEvent* event,
56 uint64_t sequence_id,
57 size_t to_reply) {
58 FlKeyboardPendingEvent* self = FL_KEYBOARD_PENDING_EVENT(
59 g_object_new(fl_keyboard_pending_event_get_type(), nullptr));
60
61 self->event = FL_KEY_EVENT(g_object_ref(event));
62 self->sequence_id = sequence_id;
63 self->unreplied = to_reply;
64 self->any_handled = false;
65 self->hash = fl_key_event_hash(self->event);
66
67 return self;
68 }
69
70 FlKeyEvent* fl_keyboard_pending_event_get_event(FlKeyboardPendingEvent* self) {
71 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), nullptr);
72 return self->event;
73 }
74
75 uint64_t fl_keyboard_pending_event_get_sequence_id(
76 FlKeyboardPendingEvent* self) {
77 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), 0);
78 return self->sequence_id;
79 }
80
81 uint64_t fl_keyboard_pending_event_get_hash(FlKeyboardPendingEvent* self) {
82 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), 0);
83 return self->hash;
84 }
85
86 void fl_keyboard_pending_event_mark_replied(FlKeyboardPendingEvent* self,
87 gboolean handled) {
88 g_return_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self));
89 g_return_if_fail(self->unreplied > 0);
90 self->unreplied -= 1;
91 if (handled) {
92 self->any_handled = TRUE;
93 }
94 }
95
96 gboolean fl_keyboard_pending_event_get_any_handled(
97 FlKeyboardPendingEvent* self) {
98 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), FALSE);
99 return self->any_handled;
100 }
101
102 gboolean fl_keyboard_pending_event_is_complete(FlKeyboardPendingEvent* self) {
103 g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), FALSE);
104 return self->unreplied == 0;
105 }
fl_keyboard_pending_event_get_hash
uint64_t fl_keyboard_pending_event_get_hash(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:81
_FlKeyboardPendingEvent::any_handled
bool any_handled
Definition: fl_keyboard_pending_event.cc:29
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
fl_keyboard_pending_event_get_event
FlKeyEvent * fl_keyboard_pending_event_get_event(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:70
_FlKeyboardPendingEvent::hash
uint64_t hash
Definition: fl_keyboard_pending_event.cc:33
_FlKeyboardPendingEvent::sequence_id
uint64_t sequence_id
Definition: fl_keyboard_pending_event.cc:23
fl_keyboard_pending_event_get_sequence_id
uint64_t fl_keyboard_pending_event_get_sequence_id(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:75
fl_keyboard_pending_event_is_complete
gboolean fl_keyboard_pending_event_is_complete(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:102
_FlKeyboardPendingEvent::parent_instance
GObject parent_instance
Definition: fl_keyboard_pending_event.cc:17
fl_keyboard_pending_event_get_any_handled
gboolean fl_keyboard_pending_event_get_any_handled(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:96
fl_keyboard_pending_event_init
static void fl_keyboard_pending_event_init(FlKeyboardPendingEvent *self)
Definition: fl_keyboard_pending_event.cc:51
fl_keyboard_pending_event_mark_replied
void fl_keyboard_pending_event_mark_replied(FlKeyboardPendingEvent *self, gboolean handled)
Definition: fl_keyboard_pending_event.cc:86
_FlKeyboardPendingEvent::event
FlKeyEvent * event
Definition: fl_keyboard_pending_event.cc:20
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
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
fl_key_event_hash
uint64_t fl_key_event_hash(FlKeyEvent *self)
Definition: fl_key_event.cc:114
fl_keyboard_pending_event_new
FlKeyboardPendingEvent * fl_keyboard_pending_event_new(FlKeyEvent *event, uint64_t sequence_id, size_t to_reply)
Definition: fl_keyboard_pending_event.cc:55
fl_keyboard_pending_event.h
_FlKeyboardPendingEvent
Definition: fl_keyboard_pending_event.cc:16
fl_keyboard_pending_event_class_init
static void fl_keyboard_pending_event_class_init(FlKeyboardPendingEventClass *klass)
Definition: fl_keyboard_pending_event.cc:46
_FlKeyboardPendingEvent::unreplied
size_t unreplied
Definition: fl_keyboard_pending_event.cc:26
fl_keyboard_pending_event_dispose
static void fl_keyboard_pending_event_dispose(GObject *object)
Definition: fl_keyboard_pending_event.cc:38