31 FlTouchManager*
self = FL_TOUCH_MANAGER(
object);
33 g_weak_ref_clear(&
self->engine);
35 g_list_free(
self->added_touch_devices);
37 g_clear_pointer(&
self->number_to_id, g_hash_table_unref);
39 G_OBJECT_CLASS(fl_touch_manager_parent_class)->dispose(
object);
49 g_return_val_if_fail(FL_IS_ENGINE(
engine),
nullptr);
51 FlTouchManager*
self =
52 FL_TOUCH_MANAGER(g_object_new(fl_touch_manager_get_type(),
nullptr));
58 g_hash_table_new_full(g_direct_hash, g_direct_equal,
nullptr,
nullptr);
73 if (g_list_find(
self->added_touch_devices, GINT_TO_POINTER(touch_id)) !=
87 self->added_touch_devices =
88 g_list_append(
self->added_touch_devices, GINT_TO_POINTER(touch_id));
95 if (g_hash_table_lookup_extended(
self->number_to_id, GUINT_TO_POINTER(number),
98 if (
value ==
nullptr) {
101 id = GPOINTER_TO_UINT(
value);
105 auto values = g_hash_table_get_values(
self->number_to_id);
106 while (values !=
nullptr &&
107 g_list_find(values, GUINT_TO_POINTER(
self->min_touch_device_id)) !=
110 ++
self->min_touch_device_id;
117 GUINT_TO_POINTER(
self->min_touch_device_id));
118 return self->min_touch_device_id;
122 if (g_hash_table_contains(
self->number_to_id, GINT_TO_POINTER(number))) {
123 auto id = g_hash_table_lookup(
self->number_to_id, GINT_TO_POINTER(number));
124 if (GPOINTER_TO_UINT(
id) <
self->min_touch_device_id) {
125 self->min_touch_device_id = GPOINTER_TO_UINT(
id);
127 g_hash_table_remove(
self->number_to_id, GINT_TO_POINTER(number));
132 GdkEventTouch* touch_event,
134 g_return_if_fail(FL_IS_TOUCH_MANAGER(
self));
141 GdkEvent*
event =
reinterpret_cast<GdkEvent*
>(touch_event);
143 GdkEventSequence* seq = gdk_event_get_event_sequence(event);
145 uint32_t
id =
reinterpret_cast<uint64_t
>(seq);
152 gdouble event_x = 0.0, event_y = 0.0;
153 gdk_event_get_coords(event, &event_x, &event_y);
155 double x = event_x * scale_factor;
156 double y = event_y * scale_factor;
158 guint event_time = gdk_event_get_time(event);
162 GdkEventType touch_event_type = gdk_event_get_event_type(event);
164 switch (touch_event_type) {
165 case GDK_TOUCH_BEGIN:
170 case GDK_TOUCH_UPDATE:
184 self->added_touch_devices =
185 g_list_remove(
self->added_touch_devices, GINT_TO_POINTER(touch_id));
@ kFlutterPointerDeviceKindTouch
g_autoptr(GMutexLocker) locker
void fl_engine_send_touch_up_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void fl_engine_send_touch_move_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void fl_engine_send_touch_add_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void fl_engine_send_touch_remove_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void fl_engine_send_touch_down_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
g_hash_table_insert(self->handlers, g_strdup(channel), handler_new(handler, user_data, destroy_notify))
static void fl_touch_manager_class_init(FlTouchManagerClass *klass)
static void release_number(_FlTouchManager *self, uint32_t number)
static void fl_touch_manager_init(FlTouchManager *self)
static const int kMaxTouchDeviceId
G_DEFINE_TYPE(FlTouchManager, fl_touch_manager, G_TYPE_OBJECT)
static void ensure_touch_added(_FlTouchManager *self, guint event_time, gdouble x, gdouble y, int32_t touch_id, int32_t device_id)
void fl_touch_manager_handle_touch_event(FlTouchManager *self, GdkEventTouch *touch_event, gint scale_factor)
static const int kMinTouchDeviceId
static constexpr int kMicrosecondsPerMillisecond
static uint32_t get_generated_id(_FlTouchManager *self, uint32_t number)
static void fl_touch_manager_dispose(GObject *object)
FlTouchManager * fl_touch_manager_new(FlEngine *engine, FlutterViewId view_id)
G_BEGIN_DECLS FlutterViewId view_id
guint min_touch_device_id
GHashTable * number_to_id
GList * added_touch_devices