This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Expand file tree
/
Copy pathfl_keyboard_pending_event.cc
More file actions
103 lines (79 loc) · 3.25 KB
/
fl_keyboard_pending_event.cc
File metadata and controls
103 lines (79 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/linux/fl_keyboard_pending_event.h"
/**
* FlKeyboardPendingEvent:
* A record for events that have been received by the handler, but
* dispatched to other objects, whose results have yet to return.
*
* This object is used by both the "pending_responds" list and the
* "pending_redispatches" list.
*/
struct _FlKeyboardPendingEvent {
GObject parent_instance;
// The target event.
FlKeyEvent* event;
// True if the embedder responder has replied.
bool embedder_replied;
// True if the channel responder has replied.
bool channel_replied;
// True if this event was handled by the embedder responder.
bool embedder_handled;
// True if this event was handled by the channel responder.
bool channel_handled;
// A value calculated out of critical event information that can be used
// to identify redispatched events.
uint64_t hash;
};
G_DEFINE_TYPE(FlKeyboardPendingEvent, fl_keyboard_pending_event, G_TYPE_OBJECT)
static void fl_keyboard_pending_event_dispose(GObject* object) {
FlKeyboardPendingEvent* self = FL_KEYBOARD_PENDING_EVENT(object);
g_clear_object(&self->event);
G_OBJECT_CLASS(fl_keyboard_pending_event_parent_class)->dispose(object);
}
static void fl_keyboard_pending_event_class_init(
FlKeyboardPendingEventClass* klass) {
G_OBJECT_CLASS(klass)->dispose = fl_keyboard_pending_event_dispose;
}
static void fl_keyboard_pending_event_init(FlKeyboardPendingEvent* self) {}
// Creates a new FlKeyboardPendingEvent by providing the target event,
// the sequence ID, and the number of responders that will reply.
FlKeyboardPendingEvent* fl_keyboard_pending_event_new(FlKeyEvent* event) {
FlKeyboardPendingEvent* self = FL_KEYBOARD_PENDING_EVENT(
g_object_new(fl_keyboard_pending_event_get_type(), nullptr));
self->event = FL_KEY_EVENT(g_object_ref(event));
self->hash = fl_key_event_hash(self->event);
return self;
}
FlKeyEvent* fl_keyboard_pending_event_get_event(FlKeyboardPendingEvent* self) {
g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), nullptr);
return self->event;
}
uint64_t fl_keyboard_pending_event_get_hash(FlKeyboardPendingEvent* self) {
g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), 0);
return self->hash;
}
void fl_keyboard_pending_event_mark_embedder_replied(
FlKeyboardPendingEvent* self,
gboolean handled) {
g_return_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self));
self->embedder_replied = true;
self->embedder_handled = handled;
}
void fl_keyboard_pending_event_mark_channel_replied(
FlKeyboardPendingEvent* self,
gboolean handled) {
g_return_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self));
self->channel_replied = true;
self->channel_handled = handled;
}
gboolean fl_keyboard_pending_event_get_any_handled(
FlKeyboardPendingEvent* self) {
g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), FALSE);
return self->embedder_handled || self->channel_handled;
}
gboolean fl_keyboard_pending_event_is_complete(FlKeyboardPendingEvent* self) {
g_return_val_if_fail(FL_IS_KEYBOARD_PENDING_EVENT(self), FALSE);
return self->embedder_replied && self->channel_replied;
}