| Flutter Linux Embedder |

Functions
fl_pointer_manager.h File Reference
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"`

Go to the source code of this file.

## Functions
G_BEGIN_DECLS | G_DECLARE_FINAL_TYPE (FlPointerManager, fl_pointer_manager, FL, POINTER_MANAGER, GObject)
FlPointerManager * | fl_pointer_manager_new (FlutterViewId view_id, FlEngine *engine)
gboolean | fl_pointer_manager_handle_button_press (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_button)
gboolean | fl_pointer_manager_handle_button_release (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_button)
gboolean | fl_pointer_manager_handle_motion (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
gboolean | fl_pointer_manager_handle_enter (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
gboolean | fl_pointer_manager_handle_leave (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)

## Function Documentation

## ◆ fl_pointer_manager_handle_button_press()

gboolean fl_pointer_manager_handle_button_press | ( | FlPointerManager * | manager,
|  | guint | event_time,
|  | FlutterPointerDeviceKind | device_kind,
|  | gdouble | x,
|  | gdouble | y,
|  | guint | gdk_button
| ) |  |

fl_pointer_manager_handle_button_press: @manager: an #FlPointerManager. @event_time: event time in milliseconds. @device_kind: kind of device generating the event. @x: x co-ordinate of event. @y: y co-ordinate of event. @gdk_button: button being pressed.

Returns TRUE if this event was handled.

Definition at line 105 of file fl_pointer_manager.cc.

111 {
112 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
113
114 int64_t button;
115 if (!get_mouse_button(gdk_button, &button)) {
116 return FALSE;
117 }
118
119 ensure_pointer_added(self, event_time, device_kind, x, y);
120
121 // Drop the event if Flutter already thinks the button is down.
122 if ((self->button_state & button) != 0) {
123 return FALSE;
124 }
125
126 int old_button_state = self->button_state;
127 FlutterPointerPhase phase = kMove;
128 self->button_state ^= button;
129 phase = old_button_state == 0 ? kDown : kMove;
130
131 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
132 if (engine == nullptr) {
133 return FALSE;
134 }
135
136 fl_engine_send_mouse_pointer_event(
137 engine, self->view_id, phase, event_time * kMicrosecondsPerMillisecond, x,
138 y, device_kind, 0, 0, self->button_state);
139
140 return TRUE;
141 }
g_autoptr
g_autoptr(FlEngine) engine
TRUE
return TRUE
Definition: fl_compositor_software.cc:68
fl_engine_send_mouse_pointer_event
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)
Definition: fl_engine.cc:1136
get_mouse_button
static gboolean get_mouse_button(guint gdk_button, int64_t *button)
Definition: fl_pointer_manager.cc:37
ensure_pointer_added
static void ensure_pointer_added(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:60
kMicrosecondsPerMillisecond
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_pointer_manager.cc:9

References ensure_pointer_added(), fl_engine_send_mouse_pointer_event(), g_autoptr(), get_mouse_button(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by button_press_event_cb(), and TEST().

## ◆ fl_pointer_manager_handle_button_release()

gboolean fl_pointer_manager_handle_button_release | ( | FlPointerManager * | manager,
|  | guint | event_time,
|  | FlutterPointerDeviceKind | device_kind,
|  | gdouble | x,
|  | gdouble | y,
|  | guint | gdk_button
| ) |  |

fl_pointer_manager_handle_button_release: @manager: an #FlPointerManager. @event_time: event time in milliseconds. @device_kind: kind of device generating the event. @x: x co-ordinate of event. @y: y co-ordinate of event. @gdk_button: button being released.

Returns TRUE if this event was handled.

Definition at line 143 of file fl_pointer_manager.cc.

149 {
150 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
151
152 int64_t button;
153 if (!get_mouse_button(gdk_button, &button)) {
154 return FALSE;
155 }
156
157 // Drop the event if Flutter already thinks the button is up.
158 if ((self->button_state & button) == 0) {
159 return FALSE;
160 }
161
162 FlutterPointerPhase phase = kMove;
163 self->button_state ^= button;
164
165 phase = self->button_state == 0 ? kUp : kMove;
166
167 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
168 if (engine == nullptr) {
169 return FALSE;
170 }
171
172 fl_engine_send_mouse_pointer_event(
173 engine, self->view_id, phase, event_time * kMicrosecondsPerMillisecond, x,
174 y, device_kind, 0, 0, self->button_state);
175
176 return TRUE;
177 }

References fl_engine_send_mouse_pointer_event(), g_autoptr(), get_mouse_button(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by button_release_event_cb(), and TEST().

## ◆ fl_pointer_manager_handle_enter()

gboolean fl_pointer_manager_handle_enter | ( | FlPointerManager * | manager,
|  | guint | event_time,
|  | FlutterPointerDeviceKind | device_kind,
|  | gdouble | x,
|  | gdouble | y
| ) |  |

fl_pointer_manager_handle_enter: @manager: an #FlPointerManager. @event_time: event time in milliseconds. @device_kind: kind of device generating the event. @x: x co-ordinate of event. @y: y co-ordinate of event.

Returns TRUE if this event was handled.

Definition at line 201 of file fl_pointer_manager.cc.

205 {
206 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
207
208 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
209 if (engine == nullptr) {
210 return FALSE;
211 }
212
213 ensure_pointer_added(self, event_time, device_kind, x, y);
214
215 return TRUE;
216 }

References ensure_pointer_added(), g_autoptr(), and TRUE.

Referenced by enter_notify_event_cb(), and TEST().

## ◆ fl_pointer_manager_handle_leave()

gboolean fl_pointer_manager_handle_leave | ( | FlPointerManager * | manager,
|  | guint | event_time,
|  | FlutterPointerDeviceKind | device_kind,
|  | gdouble | x,
|  | gdouble | y
| ) |  |

fl_pointer_manager_handle_leave: @manager: an #FlPointerManager. @event_time: event time in milliseconds. @device_kind: kind of device generating the event. @x: x co-ordinate of event. @y: y co-ordinate of event.

Returns TRUE if this event was handled.

Definition at line 218 of file fl_pointer_manager.cc.

222 {
223 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
224
225 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
226 if (engine == nullptr) {
227 return FALSE;
228 }
229
230 // Don't remove pointer while button is down; In case of dragging outside of
231 // window with mouse grab active Gtk will send another leave notify on
232 // release.
233 if (self->pointer_inside && self->button_state == 0) {
234 fl_engine_send_mouse_pointer_event(engine, self->view_id, kRemove,
235 event_time * kMicrosecondsPerMillisecond,
236 x, y, device_kind, 0, 0,
237 self->button_state);
238 self->pointer_inside = FALSE;
239 }
240
241 return TRUE;
242 }

References fl_engine_send_mouse_pointer_event(), g_autoptr(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by leave_notify_event_cb(), and TEST().

## ◆ fl_pointer_manager_handle_motion()

gboolean fl_pointer_manager_handle_motion | ( | FlPointerManager * | manager,
|  | guint | event_time,
|  | FlutterPointerDeviceKind | device_kind,
|  | gdouble | x,
|  | gdouble | y
| ) |  |

fl_pointer_manager_handle_motion: @manager: an #FlPointerManager. @event_time: event time in milliseconds. @device_kind: kind of device generating the event. @x: x co-ordinate of event. @y: y co-ordinate of event.

Returns TRUE if this event was handled.

Definition at line 179 of file fl_pointer_manager.cc.

183 {
184 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
185
186 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
187 if (engine == nullptr) {
188 return FALSE;
189 }
190
191 ensure_pointer_added(self, event_time, device_kind, x, y);
192
193 fl_engine_send_mouse_pointer_event(
194 engine, self->view_id, self->button_state != 0 ? kMove : kHover,
195 event_time * kMicrosecondsPerMillisecond, x, y, device_kind, 0, 0,
196 self->button_state);
197
198 return TRUE;
199 }

References ensure_pointer_added(), fl_engine_send_mouse_pointer_event(), g_autoptr(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by motion_notify_event_cb(), and TEST().

## ◆ fl_pointer_manager_new()

FlPointerManager* fl_pointer_manager_new | ( | FlutterViewId | view_id,
|  | FlEngine * | engine
| ) |  |

fl_pointer_manager_new: @view_id: view ID to report events for. @engine: an #FlEngine.

Create a new #FlPointerManager.

Returns: a new #FlPointerManager.

Definition at line 94 of file fl_pointer_manager.cc.

95 {
96 FlPointerManager* self =
97 FL_POINTER_MANAGER(g_object_new(fl_pointer_manager_get_type(), nullptr));
98
99 self->view_id = view_id;
100 g_weak_ref_init(&self->engine, engine);
101
102 return self;
103 }
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References view_id.

Referenced by setup_engine(), and TEST().

## ◆ G_DECLARE_FINAL_TYPE()

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE | ( | FlPointerManager | ,
|  | fl_pointer_manager | ,
|  | FL | ,
|  | POINTER_MANAGER | ,
|  | GObject |
| ) |  |