Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_pointer_manager.h File Reference

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, gdouble rotation, gdouble pressure)
 
gboolean fl_pointer_manager_handle_button_release (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_button, gdouble rotation, gdouble pressure)
 
gboolean fl_pointer_manager_handle_motion (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
 
gboolean fl_pointer_manager_handle_enter (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
 
gboolean fl_pointer_manager_handle_leave (FlPointerManager *manager, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
 

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,
gdouble  rotation,
gdouble  pressure 
)

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. @rotation: rotation of the pointer device in degrees. @pressure: pressure of the pointer device.

Returns TRUE if this event was handled.

Definition at line 133 of file fl_pointer_manager.cc.

141 {
142 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
143
144 int64_t button;
145 if (!get_button(device_kind, gdk_button, &button)) {
146 return FALSE;
147 }
148
149 ensure_pointer_added(self, event_time, device_kind, x, y, rotation, pressure);
150
151 // Drop the event if Flutter already thinks the button is down.
152 if ((self->button_state & button) != 0) {
153 return FALSE;
154 }
155
156 int old_button_state = self->button_state;
158 self->button_state ^= button;
159 phase = old_button_state == 0 ? kDown : kMove;
160
161 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
162 if (engine == nullptr) {
163 return FALSE;
164 }
165
167 engine, self->view_id, phase, event_time * kMicrosecondsPerMillisecond, x,
168 y, device_kind, 0, 0, self->button_state, rotation, pressure);
169
170 return TRUE;
171}
int32_t x
FlutterPointerPhase
The phase of the pointer event.
Definition embedder.h:1267
@ kDown
Definition embedder.h:1282
@ kMove
Definition embedder.h:1287
FlutterEngine engine
Definition main.cc:84
g_autoptr(FlEngine) engine
return TRUE
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 gboolean get_button(FlutterPointerDeviceKind device_kind, guint gdk_button, int64_t *button)
static void ensure_pointer_added(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, gdouble rotation, gdouble pressure)
static constexpr int kMicrosecondsPerMillisecond
double y

References engine, ensure_pointer_added(), fl_engine_send_mouse_pointer_event(), g_autoptr(), get_button(), kDown, kMicrosecondsPerMillisecond, kMove, self, TRUE, x, and y.

Referenced by button_press_event_cb(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ 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,
gdouble  rotation,
gdouble  pressure 
)

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. @rotation: rotation of the pointer device in degrees. @pressure: pressure of the pointer device.

Returns TRUE if this event was handled.

Definition at line 173 of file fl_pointer_manager.cc.

181 {
182 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
183
184 int64_t button;
185 if (!get_button(device_kind, gdk_button, &button)) {
186 return FALSE;
187 }
188
189 // Drop the event if Flutter already thinks the button is up.
190 if ((self->button_state & button) == 0) {
191 return FALSE;
192 }
193
195 self->button_state ^= button;
196
197 phase = self->button_state == 0 ? kUp : kMove;
198
199 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
200 if (engine == nullptr) {
201 return FALSE;
202 }
203
205 engine, self->view_id, phase, event_time * kMicrosecondsPerMillisecond, x,
206 y, device_kind, 0, 0, self->button_state, rotation, pressure);
207
208 return TRUE;
209}
@ kUp
Definition embedder.h:1275

References engine, fl_engine_send_mouse_pointer_event(), g_autoptr(), get_button(), kMicrosecondsPerMillisecond, kMove, kUp, self, TRUE, x, and y.

Referenced by button_release_event_cb(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_pointer_manager_handle_enter()

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

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. @rotation: rotation of the pointer device in degrees. @pressure: pressure of the pointer device.

Returns TRUE if this event was handled.

Definition at line 235 of file fl_pointer_manager.cc.

241 {
242 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
243
244 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
245 if (engine == nullptr) {
246 return FALSE;
247 }
248
249 ensure_pointer_added(self, event_time, device_kind, x, y, rotation, pressure);
250
251 return TRUE;
252}

References engine, ensure_pointer_added(), g_autoptr(), self, TRUE, x, and y.

Referenced by enter_notify_event_cb(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_pointer_manager_handle_leave()

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

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. @rotation: rotation of the pointer device in degrees. @pressure: pressure of the pointer device.

Returns TRUE if this event was handled.

Definition at line 254 of file fl_pointer_manager.cc.

260 {
261 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
262
263 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
264 if (engine == nullptr) {
265 return FALSE;
266 }
267
268 // Don't remove pointer while button is down; In case of dragging outside of
269 // window with mouse grab active Gtk will send another leave notify on
270 // release.
271 if (self->pointer_inside && self->button_state == 0) {
273 event_time * kMicrosecondsPerMillisecond,
274 x, y, device_kind, 0, 0,
275 self->button_state, rotation, pressure);
276 self->pointer_inside = FALSE;
277 }
278
279 return TRUE;
280}
@ kRemove
Definition embedder.h:1297

References engine, fl_engine_send_mouse_pointer_event(), g_autoptr(), kMicrosecondsPerMillisecond, kRemove, self, TRUE, x, and y.

Referenced by leave_notify_event_cb(), TEST_F(), TEST_F(), and TEST_F().

◆ fl_pointer_manager_handle_motion()

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

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. @rotation: rotation of the pointer device in degrees. @pressure: pressure of the pointer device.

Returns TRUE if this event was handled.

Definition at line 211 of file fl_pointer_manager.cc.

217 {
218 g_return_val_if_fail(FL_IS_POINTER_MANAGER(self), FALSE);
219
220 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
221 if (engine == nullptr) {
222 return FALSE;
223 }
224
225 ensure_pointer_added(self, event_time, device_kind, x, y, rotation, pressure);
226
228 engine, self->view_id, self->button_state != 0 ? kMove : kHover,
229 event_time * kMicrosecondsPerMillisecond, x, y, device_kind, 0, 0,
230 self->button_state, rotation, pressure);
231
232 return TRUE;
233}
@ kHover
The pointer moved while up.
Definition embedder.h:1299

References engine, ensure_pointer_added(), fl_engine_send_mouse_pointer_event(), g_autoptr(), kHover, kMicrosecondsPerMillisecond, kMove, self, TRUE, x, and y.

Referenced by motion_notify_event_cb(), TEST_F(), TEST_F(), and TEST_F().

◆ 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 122 of file fl_pointer_manager.cc.

123 {
124 FlPointerManager* self =
125 FL_POINTER_MANAGER(g_object_new(fl_pointer_manager_get_type(), nullptr));
126
127 self->view_id = view_id;
128 g_weak_ref_init(&self->engine, engine);
129
130 return self;
131}
G_BEGIN_DECLS FlutterViewId view_id

References engine, self, and view_id.

Referenced by setup_engine(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ G_DECLARE_FINAL_TYPE()

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