50 case GDK_BUTTON_PRIMARY:
51 *button = kFlutterPointerButtonMousePrimary;
53 case GDK_BUTTON_MIDDLE:
54 *button = kFlutterPointerButtonMouseMiddle;
56 case GDK_BUTTON_SECONDARY:
57 *button = kFlutterPointerButtonMouseSecondary;
60 *button = kFlutterPointerButtonMouseBack;
63 *button = kFlutterPointerButtonMouseForward;
70 static gboolean
get_button(FlutterPointerDeviceKind device_kind,
73 if (device_kind == kFlutterPointerDeviceKindStylus ||
74 device_kind == kFlutterPointerDeviceKindInvertedStylus) {
79 case GDK_BUTTON_PRIMARY:
80 *button = kFlutterPointerButtonStylusContact;
82 case GDK_BUTTON_SECONDARY:
83 *button = kFlutterPointerButtonStylusPrimary;
85 case GDK_BUTTON_MIDDLE:
86 *button = kFlutterPointerButtonStylusSecondary;
98 return (gdk_state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK |
99 GDK_BUTTON4_MASK | GDK_BUTTON5_MASK)) != 0;
105 FlutterPointerDeviceKind device_kind,
110 self->last_device_kind = device_kind;
113 self->last_rotation = rotation;
114 self->last_pressure = pressure;
120 FlutterPointerDeviceKind device_kind,
128 self->leave_pending = FALSE;
130 if (self->pointer_inside) {
133 self->pointer_inside =
TRUE;
135 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
136 if (engine ==
nullptr) {
142 y, device_kind, 0, 0, self->button_state, rotation, pressure);
146 FlPointerManager*
self = FL_POINTER_MANAGER(
object);
148 g_weak_ref_clear(&self->engine);
150 G_OBJECT_CLASS(fl_pointer_manager_parent_class)->dispose(
object);
158 self->last_device_kind = kFlutterPointerDeviceKindMouse;
163 FlPointerManager*
self =
164 FL_POINTER_MANAGER(g_object_new(fl_pointer_manager_get_type(),
nullptr));
167 g_weak_ref_init(&self->engine, engine);
173 FlPointerManager*
self,
175 FlutterPointerDeviceKind device_kind,
181 g_return_val_if_fail(FL_IS_POINTER_MANAGER(
self), FALSE);
184 if (!
get_button(device_kind, gdk_button, &button)) {
195 if ((self->button_state & button) != 0) {
199 int old_button_state =
self->button_state;
200 FlutterPointerPhase phase = kMove;
201 self->button_state ^= button;
202 phase = old_button_state == 0 ? kDown : kMove;
204 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
205 if (engine ==
nullptr) {
211 y, device_kind, 0, 0, self->button_state, rotation, pressure);
217 FlPointerManager*
self,
219 FlutterPointerDeviceKind device_kind,
225 g_return_val_if_fail(FL_IS_POINTER_MANAGER(
self), FALSE);
228 if (!
get_button(device_kind, gdk_button, &button)) {
235 if ((self->button_state & button) == 0) {
239 FlutterPointerPhase phase = kMove;
240 self->button_state ^= button;
242 phase =
self->button_state == 0 ? kUp : kMove;
244 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
245 if (engine ==
nullptr) {
251 y, device_kind, 0, 0, self->button_state, rotation, pressure);
258 FlutterPointerDeviceKind device_kind,
263 g_return_val_if_fail(FL_IS_POINTER_MANAGER(
self), FALSE);
265 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
266 if (engine ==
nullptr) {
273 engine, self->view_id, self->button_state != 0 ? kMove : kHover,
275 self->button_state, rotation, pressure);
282 FlutterPointerDeviceKind device_kind,
288 g_return_val_if_fail(FL_IS_POINTER_MANAGER(
self), FALSE);
290 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
291 if (engine ==
nullptr) {
309 FlutterPointerDeviceKind device_kind,
314 g_return_val_if_fail(FL_IS_POINTER_MANAGER(
self), FALSE);
316 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
317 if (engine ==
nullptr) {
321 if (!self->pointer_inside) {
330 if (self->button_state != 0) {
332 self->leave_pending =
TRUE;
338 x, y, device_kind, 0, 0, self->button_state, rotation, pressure);
339 self->pointer_inside = FALSE;
340 self->leave_pending = FALSE;
347 g_return_val_if_fail(FL_IS_POINTER_MANAGER(
self), FALSE);
350 if (self->button_state == 0) {
354 self->button_state = 0;
356 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
357 if (engine ==
nullptr) {
363 self->last_x, self->last_y, self->last_device_kind, 0, 0,
364 self->button_state, self->last_rotation, self->last_pressure);
369 if (self->leave_pending) {
371 engine, self->view_id, kRemove,
373 self->last_device_kind, 0, 0, self->button_state, self->last_rotation,
374 self->last_pressure);
375 self->pointer_inside = FALSE;
376 self->leave_pending = FALSE;
g_autoptr(FlEngine) engine
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterViewId view_id, FlutterPointerPhase phase, size_t timestamp, double x, double y, FlutterPointerDeviceKind device_kind, double scroll_delta_x, double scroll_delta_y, int64_t buttons, double rotation, double pressure)
static void record_pointer_state(FlPointerManager *self, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
static gboolean get_button(FlutterPointerDeviceKind device_kind, guint gdk_button, int64_t *button)
FlPointerManager * fl_pointer_manager_new(FlutterViewId view_id, FlEngine *engine)
G_DEFINE_TYPE(FlPointerManager, fl_pointer_manager, G_TYPE_OBJECT)
static void ensure_pointer_added(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
static gboolean get_mouse_button(guint gdk_button, int64_t *button)
static void fl_pointer_manager_dispose(GObject *object)
gboolean fl_pointer_manager_cancel_input(FlPointerManager *self, guint event_time)
static constexpr int kMicrosecondsPerMillisecond
static gboolean has_buttons_pressed(guint gdk_state)
gboolean fl_pointer_manager_handle_button_press(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_button, gdouble rotation, gdouble pressure)
static constexpr guint kMouseButtonForward
static constexpr guint kMouseButtonBack
static void fl_pointer_manager_class_init(FlPointerManagerClass *klass)
static void fl_pointer_manager_init(FlPointerManager *self)
gboolean fl_pointer_manager_handle_motion(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
gboolean fl_pointer_manager_handle_enter(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_state, gdouble rotation, gdouble pressure)
gboolean fl_pointer_manager_handle_button_release(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_button, gdouble rotation, gdouble pressure)
gboolean fl_pointer_manager_handle_leave(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
G_BEGIN_DECLS FlutterViewId view_id
FlutterPointerDeviceKind last_device_kind