| Flutter Linux Embedder |

fl_view.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"
6
7 #include <atk/atk.h>
8 #include <gtk/gtk-a11y.h>
9
10 #include <cstring>
11
12 #include "flutter/common/constants.h"
13 #include "flutter/shell/platform/linux/fl_accessible_node.h"
14 #include "flutter/shell/platform/linux/fl_engine_private.h"
15 #include "flutter/shell/platform/linux/fl_key_event.h"
16 #include "flutter/shell/platform/linux/fl_keyboard_handler.h"
17 #include "flutter/shell/platform/linux/fl_keyboard_manager.h"
18 #include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h"
19 #include "flutter/shell/platform/linux/fl_plugin_registrar_private.h"
20 #include "flutter/shell/platform/linux/fl_pointer_manager.h"
21 #include "flutter/shell/platform/linux/fl_renderer_gdk.h"
22 #include "flutter/shell/platform/linux/fl_scrolling_manager.h"
23 #include "flutter/shell/platform/linux/fl_socket_accessible.h"
24 #include "flutter/shell/platform/linux/fl_text_input_handler.h"
25 #include "flutter/shell/platform/linux/fl_text_input_view_delegate.h"
26 #include "flutter/shell/platform/linux/fl_touch_manager.h"
27 #include "flutter/shell/platform/linux/fl_view_accessible.h"
28 #include "flutter/shell/platform/linux/fl_window_state_monitor.h"
29 #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
30 #include "flutter/shell/platform/linux/public/flutter_linux/fl_plugin_registry.h"
31
32 struct _FlView {
33 GtkBox parent_instance;
34
35 // The widget rendering the Flutter view.
36 GtkGLArea* gl_area;
37
38 // Engine this view is showing.
39 FlEngine* engine;
40
41 // Signal subscription for engine restarts.
42 guint on_pre_engine_restart_cb_id;
43
44 // ID for this view.
45 FlutterViewId view_id;
46
47 // Object that performs the view rendering.
48 FlRendererGdk* renderer;
49
50 // Background color.
51 GdkRGBA* background_color;
52
53 // TRUE if have got the first frame to render.
54 gboolean have_first_frame;
55
56 // Monitor to track window state.
57 FlWindowStateMonitor* window_state_monitor;
58
59 // Manages scrolling events.
60 FlScrollingManager* scrolling_manager;
61
62 // Manages pointer events.
63 FlPointerManager* pointer_manager;
64
65 // Manages touch events.
66 FlTouchManager* touch_manager;
67
68 // Manages keyboard events.
69 FlKeyboardManager* keyboard_manager;
70
71 // Flutter system channel handlers.
72 FlKeyboardHandler* keyboard_handler;
73 FlTextInputHandler* text_input_handler;
74
75 // Accessible tree from Flutter, exposed as an AtkPlug.
76 FlViewAccessible* view_accessible;
77
78 // Signal subscripton for cursor changes.
79 guint cursor_changed_cb_id;
80
81 GCancellable* cancellable;
82 };
83
84 enum { SIGNAL_FIRST_FRAME, LAST_SIGNAL };
85
86 static guint fl_view_signals[LAST_SIGNAL];
87
88 static void fl_renderable_iface_init(FlRenderableInterface* iface);
89
90 static void fl_view_plugin_registry_iface_init(
91 FlPluginRegistryInterface* iface);
92
93 static void fl_view_keyboard_delegate_iface_init(
94 FlKeyboardViewDelegateInterface* iface);
95
96 static void fl_view_text_input_delegate_iface_init(
97 FlTextInputViewDelegateInterface* iface);
98
99 G_DEFINE_TYPE_WITH_CODE(
100 FlView,
101 fl_view,
102 GTK_TYPE_BOX,
103 G_IMPLEMENT_INTERFACE(fl_renderable_get_type(), fl_renderable_iface_init)
104 G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(),
105 fl_view_plugin_registry_iface_init)
106 G_IMPLEMENT_INTERFACE(fl_keyboard_view_delegate_get_type(),
107 fl_view_keyboard_delegate_iface_init)
108 G_IMPLEMENT_INTERFACE(fl_text_input_view_delegate_get_type(),
109 fl_view_text_input_delegate_iface_init))
110
111 // Emit the first frame signal in the main thread.
112 static gboolean first_frame_idle_cb(gpointer user_data) {
113 FlView* self = FL_VIEW(user_data);
114
115 g_signal_emit(self, fl_view_signals[SIGNAL_FIRST_FRAME], 0);
116
117 return FALSE;
118 }
119
120 // Signal handler for GtkWidget::delete-event
121 static gboolean window_delete_event_cb(FlView* self) {
122 fl_engine_request_app_exit(self->engine);
123 // Stop the event from propagating.
124 return TRUE;
125 }
126
127 // Initialize keyboard.
128 static void init_keyboard(FlView* self) {
129 FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
130
131 GdkWindow* window =
132 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
133 g_return_if_fail(GDK_IS_WINDOW(window));
134 g_autoptr(GtkIMContext) im_context = gtk_im_multicontext_new();
135 gtk_im_context_set_client_window(im_context, window);
136
137 g_clear_object(&self->text_input_handler);
138 self->text_input_handler = fl_text_input_handler_new(
139 messenger, im_context, FL_TEXT_INPUT_VIEW_DELEGATE(self));
140 g_clear_object(&self->keyboard_manager);
141 self->keyboard_manager =
142 fl_keyboard_manager_new(self->engine, FL_KEYBOARD_VIEW_DELEGATE(self));
143 g_clear_object(&self->keyboard_handler);
144 self->keyboard_handler =
145 fl_keyboard_handler_new(messenger, self->keyboard_manager);
146 }
147
148 static void init_scrolling(FlView* self) {
149 g_clear_object(&self->scrolling_manager);
150 self->scrolling_manager =
151 fl_scrolling_manager_new(self->engine, self->view_id);
152 }
153
154 static void init_touch(FlView* self) {
155 g_clear_object(&self->touch_manager);
156 self->touch_manager = fl_touch_manager_new(self->engine, self->view_id);
157 }
158
159 static FlutterPointerDeviceKind get_device_kind(GdkEvent* event) {
160 GdkDevice* device = gdk_event_get_source_device(event);
161 GdkInputSource source = gdk_device_get_source(device);
162 switch (source) {
163 case GDK_SOURCE_PEN:
164 case GDK_SOURCE_ERASER:
165 case GDK_SOURCE_CURSOR:
166 case GDK_SOURCE_TABLET_PAD:
167 return kFlutterPointerDeviceKindStylus;
168 case GDK_SOURCE_TOUCHSCREEN:
169 return kFlutterPointerDeviceKindTouch;
170 case GDK_SOURCE_TOUCHPAD: // trackpad device type is reserved for gestures
171 case GDK_SOURCE_TRACKPOINT:
172 case GDK_SOURCE_KEYBOARD:
173 case GDK_SOURCE_MOUSE:
174 return kFlutterPointerDeviceKindMouse;
175 }
176 }
177
178 static gboolean get_mouse_button(GdkEvent* event, int64_t* button) {
179 guint event_button = 0;
180 gdk_event_get_button(event, &event_button);
181
182 switch (event_button) {
183 case 1:
184 *button = kFlutterPointerButtonMousePrimary;
185 return TRUE;
186 case 2:
187 *button = kFlutterPointerButtonMouseMiddle;
188 return TRUE;
189 case 3:
190 *button = kFlutterPointerButtonMouseSecondary;
191 return TRUE;
192 default:
193 return FALSE;
194 }
195 }
196
197 // Called when the mouse cursor changes.
198 static void cursor_changed_cb(FlView* self) {
199 FlMouseCursorHandler* handler =
200 fl_engine_get_mouse_cursor_handler(self->engine);
201 const gchar* cursor_name = fl_mouse_cursor_handler_get_cursor_name(handler);
202 GdkWindow* window =
203 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
204 g_autoptr(GdkCursor) cursor =
205 gdk_cursor_new_from_name(gdk_window_get_display(window), cursor_name);
206 gdk_window_set_cursor(window, cursor);
207 }
208
209 // Set the mouse cursor.
210 static void setup_cursor(FlView* self) {
211 FlMouseCursorHandler* handler =
212 fl_engine_get_mouse_cursor_handler(self->engine);
213
214 self->cursor_changed_cb_id = g_signal_connect_swapped(
215 handler, "cursor-changed", G_CALLBACK(cursor_changed_cb), self);
216 cursor_changed_cb(self);
217 }
218
219 // Updates the engine with the current window metrics.
220 static void handle_geometry_changed(FlView* self) {
221 GtkAllocation allocation;
222 gtk_widget_get_allocation(GTK_WIDGET(self), &allocation);
223 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
224
225 // Note we can't detect if a window is moved between monitors - this
226 // information is provided by Wayland but GTK only notifies us if the scale
227 // has changed, so moving between two monitors of the same scale doesn't
228 // provide any information.
229
230 GdkWindow* window =
231 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
232 GdkMonitor* monitor = gdk_display_get_monitor_at_window(
233 gtk_widget_get_display(GTK_WIDGET(self)), window);
234 fl_engine_send_window_metrics_event(
235 self->engine,
236 fl_display_monitor_get_display_id(
237 fl_engine_get_display_monitor(self->engine), monitor),
238 self->view_id, allocation.width * scale_factor,
239 allocation.height * scale_factor, scale_factor);
240
241 // Make sure the view has been realized and its size has been allocated before
242 // waiting for a frame. `fl_view_realize()` and `fl_view_size_allocate()` may
243 // be called in either order depending on the order in which the window is
244 // shown and the view is added to a container in the app runner.
245 //
246 // Note: `gtk_widget_init()` initializes the size allocation to 1x1.
247 if (allocation.width > 1 && allocation.height > 1 &&
248 gtk_widget_get_realized(GTK_WIDGET(self))) {
249 fl_renderer_wait_for_frame(FL_RENDERER(self->renderer),
250 allocation.width * scale_factor,
251 allocation.height * scale_factor);
252 }
253 }
254
255 static void view_added_cb(GObject* object,
256 GAsyncResult* result,
257 gpointer user_data) {
258 FlView* self = FL_VIEW(user_data);
259
260 g_autoptr(GError) error = nullptr;
261 if (!fl_engine_add_view_finish(FL_ENGINE(object), result, &error)) {
262 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
263 return;
264 }
265
266 g_warning("Failed to add view: %s", error->message);
267 // FIXME: Show on the GLArea
268 return;
269 }
270
271 handle_geometry_changed(self);
272 }
273
274 // Called when the engine updates accessibility.
275 static void update_semantics_cb(FlEngine* engine,
276 const FlutterSemanticsUpdate2* update,
277 gpointer user_data) {
278 FlView* self = FL_VIEW(user_data);
279
280 fl_view_accessible_handle_update_semantics(self->view_accessible, update);
281 }
282
283 // Invoked by the engine right before the engine is restarted.
284 //
285 // This method should reset states to be as if the engine had just been started,
286 // which usually indicates the user has requested a hot restart (Shift-R in the
287 // Flutter CLI.)
288 static void on_pre_engine_restart_cb(FlView* self) {
289 init_keyboard(self);
290 init_scrolling(self);
291 init_touch(self);
292 }
293
294 // Implements FlRenderable::redraw
295 static void fl_view_redraw(FlRenderable* renderable) {
296 FlView* self = FL_VIEW(renderable);
297
298 gtk_widget_queue_draw(GTK_WIDGET(self->gl_area));
299
300 if (!self->have_first_frame) {
301 self->have_first_frame = TRUE;
302 // This is not the main thread, so the signal needs to be done via an idle
303 // callback.
304 g_idle_add(first_frame_idle_cb, self);
305 }
306 }
307
308 // Implements FlRenderable::make_current
309 static void fl_view_make_current(FlRenderable* renderable) {
310 FlView* self = FL_VIEW(renderable);
311 gtk_gl_area_make_current(self->gl_area);
312 }
313
314 // Implements FlPluginRegistry::get_registrar_for_plugin.
315 static FlPluginRegistrar* fl_view_get_registrar_for_plugin(
316 FlPluginRegistry* registry,
317 const gchar* name) {
318 FlView* self = FL_VIEW(registry);
319
320 return fl_plugin_registrar_new(self,
321 fl_engine_get_binary_messenger(self->engine),
322 fl_engine_get_texture_registrar(self->engine));
323 }
324
325 static void fl_renderable_iface_init(FlRenderableInterface* iface) {
326 iface->redraw = fl_view_redraw;
327 iface->make_current = fl_view_make_current;
328 }
329
330 static void fl_view_plugin_registry_iface_init(
331 FlPluginRegistryInterface* iface) {
332 iface->get_registrar_for_plugin = fl_view_get_registrar_for_plugin;
333 }
334
335 static void fl_view_keyboard_delegate_iface_init(
336 FlKeyboardViewDelegateInterface* iface) {
337 iface->text_filter_key_press = [](FlKeyboardViewDelegate* view_delegate,
338 FlKeyEvent* event) {
339 FlView* self = FL_VIEW(view_delegate);
340 return fl_text_input_handler_filter_keypress(self->text_input_handler,
341 event);
342 };
343 }
344
345 static void fl_view_text_input_delegate_iface_init(
346 FlTextInputViewDelegateInterface* iface) {
347 iface->translate_coordinates = [](FlTextInputViewDelegate* delegate,
348 gint view_x, gint view_y, gint* window_x,
349 gint* window_y) {
350 FlView* self = FL_VIEW(delegate);
351 gtk_widget_translate_coordinates(GTK_WIDGET(self),
352 gtk_widget_get_toplevel(GTK_WIDGET(self)),
353 view_x, view_y, window_x, window_y);
354 };
355 }
356
357 static void sync_modifier_if_needed(FlView* self, GdkEvent* event) {
358 guint event_time = gdk_event_get_time(event);
359 GdkModifierType event_state = static_cast<GdkModifierType>(0);
360 gdk_event_get_state(event, &event_state);
361 fl_keyboard_manager_sync_modifier_if_needed(self->keyboard_manager,
362 event_state, event_time);
363 }
364
365 static void set_scrolling_position(FlView* self, gdouble x, gdouble y) {
366 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
367 fl_scrolling_manager_set_last_mouse_position(
368 self->scrolling_manager, x * scale_factor, y * scale_factor);
369 }
370
371 // Signal handler for GtkWidget::button-press-event
372 static gboolean button_press_event_cb(FlView* self,
373 GdkEventButton* button_event) {
374 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
375
376 // Flutter doesn't handle double and triple click events.
377 GdkEventType event_type = gdk_event_get_event_type(event);
378 if (event_type == GDK_DOUBLE_BUTTON_PRESS ||
379 event_type == GDK_TRIPLE_BUTTON_PRESS) {
380 return FALSE;
381 }
382
383 int64_t button;
384 if (!get_mouse_button(event, &button)) {
385 return FALSE;
386 }
387
388 gdouble x = 0.0, y = 0.0;
389 gdk_event_get_coords(event, &x, &y);
390
391 set_scrolling_position(self, x, y);
392 sync_modifier_if_needed(self, event);
393
394 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
395 return fl_pointer_manager_handle_button_press(
396 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
397 x * scale_factor, y * scale_factor, button);
398 }
399
400 // Signal handler for GtkWidget::button-release-event
401 static gboolean button_release_event_cb(FlView* self,
402 GdkEventButton* button_event) {
403 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
404
405 int64_t button;
406 if (!get_mouse_button(event, &button)) {
407 return FALSE;
408 }
409
410 gdouble x = 0.0, y = 0.0;
411 gdk_event_get_coords(event, &x, &y);
412
413 set_scrolling_position(self, x, y);
414 sync_modifier_if_needed(self, event);
415
416 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
417 return fl_pointer_manager_handle_button_release(
418 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
419 x * scale_factor, y * scale_factor, button);
420 }
421
422 // Signal handler for GtkWidget::scroll-event
423 static gboolean scroll_event_cb(FlView* self, GdkEventScroll* event) {
424 // TODO(robert-ancell): Update to use GtkEventControllerScroll when we can
425 // depend on GTK 3.24.
426
427 fl_scrolling_manager_handle_scroll_event(
428 self->scrolling_manager, event,
429 gtk_widget_get_scale_factor(GTK_WIDGET(self)));
430 return TRUE;
431 }
432
433 static gboolean touch_event_cb(FlView* self, GdkEventTouch* event) {
434 fl_touch_manager_handle_touch_event(
435 self->touch_manager, event,
436 gtk_widget_get_scale_factor(GTK_WIDGET(self)));
437 return TRUE;
438 }
439
440 // Signal handler for GtkWidget::motion-notify-event
441 static gboolean motion_notify_event_cb(FlView* self,
442 GdkEventMotion* motion_event) {
443 GdkEvent* event = reinterpret_cast<GdkEvent*>(motion_event);
444 sync_modifier_if_needed(self, event);
445
446 // return if touch event
447 auto event_type = gdk_event_get_event_type(event);
448 if (event_type == GDK_TOUCH_BEGIN || event_type == GDK_TOUCH_UPDATE ||
449 event_type == GDK_TOUCH_END || event_type == GDK_TOUCH_CANCEL) {
450 return FALSE;
451 }
452
453 gdouble x = 0.0, y = 0.0;
454 gdk_event_get_coords(event, &x, &y);
455 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
456 return fl_pointer_manager_handle_motion(
457 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
458 x * scale_factor, y * scale_factor);
459 }
460
461 // Signal handler for GtkWidget::enter-notify-event
462 static gboolean enter_notify_event_cb(FlView* self,
463 GdkEventCrossing* crossing_event) {
464 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
465 gdouble x = 0.0, y = 0.0;
466 gdk_event_get_coords(event, &x, &y);
467 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
468 return fl_pointer_manager_handle_enter(
469 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
470 x * scale_factor, y * scale_factor);
471 }
472
473 // Signal handler for GtkWidget::leave-notify-event
474 static gboolean leave_notify_event_cb(FlView* self,
475 GdkEventCrossing* crossing_event) {
476 if (crossing_event->mode != GDK_CROSSING_NORMAL) {
477 return FALSE;
478 }
479
480 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
481 gdouble x = 0.0, y = 0.0;
482 gdk_event_get_coords(event, &x, &y);
483 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
484 return fl_pointer_manager_handle_leave(
485 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
486 x * scale_factor, y * scale_factor);
487 }
488
489 static void gesture_rotation_begin_cb(FlView* self) {
490 fl_scrolling_manager_handle_rotation_begin(self->scrolling_manager);
491 }
492
493 static void gesture_rotation_update_cb(FlView* self,
494 gdouble rotation,
495 gdouble delta) {
496 fl_scrolling_manager_handle_rotation_update(self->scrolling_manager,
497 rotation);
498 }
499
500 static void gesture_rotation_end_cb(FlView* self) {
501 fl_scrolling_manager_handle_rotation_end(self->scrolling_manager);
502 }
503
504 static void gesture_zoom_begin_cb(FlView* self) {
505 fl_scrolling_manager_handle_zoom_begin(self->scrolling_manager);
506 }
507
508 static void gesture_zoom_update_cb(FlView* self, gdouble scale) {
509 fl_scrolling_manager_handle_zoom_update(self->scrolling_manager, scale);
510 }
511
512 static void gesture_zoom_end_cb(FlView* self) {
513 fl_scrolling_manager_handle_zoom_end(self->scrolling_manager);
514 }
515
516 static GdkGLContext* create_context_cb(FlView* self) {
517 fl_renderer_gdk_set_window(self->renderer,
518 gtk_widget_get_parent_window(GTK_WIDGET(self)));
519
520 init_scrolling(self);
521 init_touch(self);
522
523 g_autoptr(GError) error = nullptr;
524 if (!fl_renderer_gdk_create_contexts(self->renderer, &error)) {
525 gtk_gl_area_set_error(self->gl_area, error);
526 return nullptr;
527 }
528
529 return GDK_GL_CONTEXT(
530 g_object_ref(fl_renderer_gdk_get_context(self->renderer)));
531 }
532
533 static void realize_cb(FlView* self) {
534 g_autoptr(GError) error = nullptr;
535
536 fl_renderer_make_current(FL_RENDERER(self->renderer));
537
538 GError* gl_error = gtk_gl_area_get_error(self->gl_area);
539 if (gl_error != NULL) {
540 g_warning("Failed to initialize GLArea: %s", gl_error->message);
541 return;
542 }
543
544 fl_renderer_setup(FL_RENDERER(self->renderer));
545
546 GtkWidget* toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(self));
547
548 self->window_state_monitor =
549 fl_window_state_monitor_new(fl_engine_get_binary_messenger(self->engine),
550 GTK_WINDOW(toplevel_window));
551
552 // Handle requests by the user to close the application.
553 g_signal_connect_swapped(toplevel_window, "delete-event",
554 G_CALLBACK(window_delete_event_cb), self);
555
556 init_keyboard(self);
557
558 fl_renderer_add_renderable(FL_RENDERER(self->renderer), self->view_id,
559 FL_RENDERABLE(self));
560
561 if (!fl_engine_start(self->engine, &error)) {
562 g_warning("Failed to start Flutter engine: %s", error->message);
563 return;
564 }
565
566 setup_cursor(self);
567
568 handle_geometry_changed(self);
569
570 self->view_accessible = fl_view_accessible_new(self->engine);
571 fl_socket_accessible_embed(
572 FL_SOCKET_ACCESSIBLE(gtk_widget_get_accessible(GTK_WIDGET(self))),
573 atk_plug_get_id(ATK_PLUG(self->view_accessible)));
574 }
575
576 static gboolean render_cb(FlView* self, GdkGLContext* context) {
577 if (gtk_gl_area_get_error(self->gl_area) != NULL) {
578 return FALSE;
579 }
580
581 int width = gtk_widget_get_allocated_width(GTK_WIDGET(self->gl_area));
582 int height = gtk_widget_get_allocated_height(GTK_WIDGET(self->gl_area));
583 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self->gl_area));
584 fl_renderer_render(FL_RENDERER(self->renderer), self->view_id,
585 width * scale_factor, height * scale_factor,
586 self->background_color);
587
588 return TRUE;
589 }
590
591 static void unrealize_cb(FlView* self) {
592 g_autoptr(GError) error = nullptr;
593
594 fl_renderer_make_current(FL_RENDERER(self->renderer));
595
596 GError* gl_error = gtk_gl_area_get_error(self->gl_area);
597 if (gl_error != NULL) {
598 g_warning("Failed to uninitialize GLArea: %s", gl_error->message);
599 return;
600 }
601
602 fl_renderer_cleanup(FL_RENDERER(self->renderer));
603 }
604
605 static void size_allocate_cb(FlView* self) {
606 handle_geometry_changed(self);
607 }
608
609 static void fl_view_notify(GObject* object, GParamSpec* pspec) {
610 FlView* self = FL_VIEW(object);
611
612 if (strcmp(pspec->name, "scale-factor") == 0) {
613 handle_geometry_changed(self);
614 }
615
616 if (G_OBJECT_CLASS(fl_view_parent_class)->notify != nullptr) {
617 G_OBJECT_CLASS(fl_view_parent_class)->notify(object, pspec);
618 }
619 }
620
621 static void fl_view_dispose(GObject* object) {
622 FlView* self = FL_VIEW(object);
623
624 g_cancellable_cancel(self->cancellable);
625
626 if (self->engine != nullptr) {
627 fl_engine_set_update_semantics_handler(self->engine, nullptr, nullptr,
628 nullptr);
629
630 FlMouseCursorHandler* handler =
631 fl_engine_get_mouse_cursor_handler(self->engine);
632 if (self->cursor_changed_cb_id != 0) {
633 g_signal_handler_disconnect(handler, self->cursor_changed_cb_id);
634 self->cursor_changed_cb_id = 0;
635 }
636
637 // Stop rendering.
638 fl_renderer_remove_view(FL_RENDERER(self->renderer), self->view_id);
639
640 // Release the view ID from the engine.
641 fl_engine_remove_view(self->engine, self->view_id, nullptr, nullptr,
642 nullptr);
643 }
644
645 if (self->on_pre_engine_restart_cb_id != 0) {
646 g_signal_handler_disconnect(self->engine,
647 self->on_pre_engine_restart_cb_id);
648 self->on_pre_engine_restart_cb_id = 0;
649 }
650
651 g_clear_object(&self->engine);
652 g_clear_object(&self->renderer);
653 g_clear_pointer(&self->background_color, gdk_rgba_free);
654 g_clear_object(&self->window_state_monitor);
655 g_clear_object(&self->scrolling_manager);
656 g_clear_object(&self->pointer_manager);
657 g_clear_object(&self->touch_manager);
658 g_clear_object(&self->keyboard_manager);
659 g_clear_object(&self->keyboard_handler);
660 g_clear_object(&self->view_accessible);
661 g_clear_object(&self->cancellable);
662
663 G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
664 }
665
666 // Implements GtkWidget::realize.
667 static void fl_view_realize(GtkWidget* widget) {
668 FlView* self = FL_VIEW(widget);
669
670 GTK_WIDGET_CLASS(fl_view_parent_class)->realize(widget);
671
672 // Realize the child widgets.
673 gtk_widget_realize(GTK_WIDGET(self->gl_area));
674 }
675
676 // Implements GtkWidget::key_press_event.
677 static gboolean fl_view_key_press_event(GtkWidget* widget,
678 GdkEventKey* key_event) {
679 FlView* self = FL_VIEW(widget);
680
681 GdkEvent* event = reinterpret_cast<GdkEvent*>(key_event);
682 return fl_keyboard_manager_handle_event(
683 self->keyboard_manager,
684 fl_key_event_new_from_gdk_event(gdk_event_copy(event)));
685 }
686
687 // Implements GtkWidget::key_release_event.
688 static gboolean fl_view_key_release_event(GtkWidget* widget,
689 GdkEventKey* key_event) {
690 FlView* self = FL_VIEW(widget);
691 GdkEvent* event = reinterpret_cast<GdkEvent*>(key_event);
692 return fl_keyboard_manager_handle_event(
693 self->keyboard_manager,
694 fl_key_event_new_from_gdk_event(gdk_event_copy(event)));
695 }
696
697 static void fl_view_class_init(FlViewClass* klass) {
698 GObjectClass* object_class = G_OBJECT_CLASS(klass);
699 object_class->notify = fl_view_notify;
700 object_class->dispose = fl_view_dispose;
701
702 GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
703 widget_class->realize = fl_view_realize;
704 widget_class->key_press_event = fl_view_key_press_event;
705 widget_class->key_release_event = fl_view_key_release_event;
706
707 fl_view_signals[SIGNAL_FIRST_FRAME] =
708 g_signal_new("first-frame", fl_view_get_type(), G_SIGNAL_RUN_LAST, 0,
709 NULL, NULL, NULL, G_TYPE_NONE, 0);
710
711 gtk_widget_class_set_accessible_type(GTK_WIDGET_CLASS(klass),
712 fl_socket_accessible_get_type());
713 }
714
715 static void fl_view_init(FlView* self) {
716 self->cancellable = g_cancellable_new();
717
718 gtk_widget_set_can_focus(GTK_WIDGET(self), TRUE);
719
720 self->view_id = -1;
721
722 GdkRGBA default_background = {
723 .red = 0.0, .green = 0.0, .blue = 0.0, .alpha = 1.0};
724 self->background_color = gdk_rgba_copy(&default_background);
725
726 GtkWidget* event_box = gtk_event_box_new();
727 gtk_widget_set_hexpand(event_box, TRUE);
728 gtk_widget_set_vexpand(event_box, TRUE);
729 gtk_container_add(GTK_CONTAINER(self), event_box);
730 gtk_widget_show(event_box);
731 gtk_widget_add_events(event_box,
732 GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
733 GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK |
734 GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK);
735
736 g_signal_connect_swapped(event_box, "button-press-event",
737 G_CALLBACK(button_press_event_cb), self);
738 g_signal_connect_swapped(event_box, "button-release-event",
739 G_CALLBACK(button_release_event_cb), self);
740 g_signal_connect_swapped(event_box, "scroll-event",
741 G_CALLBACK(scroll_event_cb), self);
742 g_signal_connect_swapped(event_box, "motion-notify-event",
743 G_CALLBACK(motion_notify_event_cb), self);
744 g_signal_connect_swapped(event_box, "enter-notify-event",
745 G_CALLBACK(enter_notify_event_cb), self);
746 g_signal_connect_swapped(event_box, "leave-notify-event",
747 G_CALLBACK(leave_notify_event_cb), self);
748 GtkGesture* zoom = gtk_gesture_zoom_new(event_box);
749 g_signal_connect_swapped(zoom, "begin", G_CALLBACK(gesture_zoom_begin_cb),
750 self);
751 g_signal_connect_swapped(zoom, "scale-changed",
752 G_CALLBACK(gesture_zoom_update_cb), self);
753 g_signal_connect_swapped(zoom, "end", G_CALLBACK(gesture_zoom_end_cb), self);
754 GtkGesture* rotate = gtk_gesture_rotate_new(event_box);
755 g_signal_connect_swapped(rotate, "begin",
756 G_CALLBACK(gesture_rotation_begin_cb), self);
757 g_signal_connect_swapped(rotate, "angle-changed",
758 G_CALLBACK(gesture_rotation_update_cb), self);
759 g_signal_connect_swapped(rotate, "end", G_CALLBACK(gesture_rotation_end_cb),
760 self);
761 g_signal_connect_swapped(event_box, "touch-event", G_CALLBACK(touch_event_cb),
762 self);
763
764 self->gl_area = GTK_GL_AREA(gtk_gl_area_new());
765 gtk_gl_area_set_has_alpha(self->gl_area, TRUE);
766 gtk_widget_show(GTK_WIDGET(self->gl_area));
767 gtk_container_add(GTK_CONTAINER(event_box), GTK_WIDGET(self->gl_area));
768 g_signal_connect_swapped(self->gl_area, "render", G_CALLBACK(render_cb),
769 self);
770
771 g_signal_connect_swapped(self, "size-allocate", G_CALLBACK(size_allocate_cb),
772 self);
773 }
774
775 G_MODULE_EXPORT FlView* fl_view_new(FlDartProject* project) {
776 g_autoptr(FlEngine) engine = fl_engine_new(project);
777 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
778
779 self->view_id = flutter::kFlutterImplicitViewId;
780 self->engine = FL_ENGINE(g_object_ref(engine));
781 FlRenderer* renderer = fl_engine_get_renderer(engine);
782 g_assert(FL_IS_RENDERER_GDK(renderer));
783 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
784
785 self->pointer_manager = fl_pointer_manager_new(self->view_id, engine);
786
787 fl_engine_set_update_semantics_handler(self->engine, update_semantics_cb,
788 self, nullptr);
789 self->on_pre_engine_restart_cb_id =
790 g_signal_connect_swapped(engine, "on-pre-engine-restart",
791 G_CALLBACK(on_pre_engine_restart_cb), self);
792
793 g_signal_connect_swapped(self->gl_area, "create-context",
794 G_CALLBACK(create_context_cb), self);
795 g_signal_connect_swapped(self->gl_area, "realize", G_CALLBACK(realize_cb),
796 self);
797 g_signal_connect_swapped(self->gl_area, "unrealize", G_CALLBACK(unrealize_cb),
798 self);
799
800 return self;
801 }
802
803 G_MODULE_EXPORT FlView* fl_view_new_for_engine(FlEngine* engine) {
804 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
805
806 self->engine = FL_ENGINE(g_object_ref(engine));
807 FlRenderer* renderer = fl_engine_get_renderer(engine);
808 g_assert(FL_IS_RENDERER_GDK(renderer));
809 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
810
811 self->on_pre_engine_restart_cb_id =
812 g_signal_connect_swapped(engine, "on-pre-engine-restart",
813 G_CALLBACK(on_pre_engine_restart_cb), self);
814
815 self->view_id = fl_engine_add_view(self->engine, 1, 1, 1.0, self->cancellable,
816 view_added_cb, self);
817 fl_renderer_add_renderable(FL_RENDERER(self->renderer), self->view_id,
818 FL_RENDERABLE(self));
819
820 self->pointer_manager = fl_pointer_manager_new(self->view_id, engine);
821
822 setup_cursor(self);
823
824 return self;
825 }
826
827 G_MODULE_EXPORT FlEngine* fl_view_get_engine(FlView* self) {
828 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
829 return self->engine;
830 }
831
832 G_MODULE_EXPORT
833 int64_t fl_view_get_id(FlView* self) {
834 g_return_val_if_fail(FL_IS_VIEW(self), -1);
835 return self->view_id;
836 }
837
838 G_MODULE_EXPORT void fl_view_set_background_color(FlView* self,
839 const GdkRGBA* color) {
840 g_return_if_fail(FL_IS_VIEW(self));
841 gdk_rgba_free(self->background_color);
842 self->background_color = gdk_rgba_copy(color);
843 }
fl_view_realize
static void fl_view_realize(GtkWidget *widget)
Definition: fl_view.cc:667
window_delete_event_cb
static gboolean window_delete_event_cb(FlView *self)
Definition: fl_view.cc:121
fl_renderer_remove_view
void fl_renderer_remove_view(FlRenderer *self, FlutterViewId view_id)
Definition: fl_renderer.cc:354
gesture_rotation_update_cb
static void gesture_rotation_update_cb(FlView *self, gdouble rotation, gdouble delta)
Definition: fl_view.cc:493
fl_renderer_wait_for_frame
void fl_renderer_wait_for_frame(FlRenderer *self, int target_width, int target_height)
Definition: fl_renderer.cc:433
_FlView::cursor_changed_cb_id
guint cursor_changed_cb_id
Definition: fl_view.cc:79
fl_renderer_gdk_set_window
void fl_renderer_gdk_set_window(FlRendererGdk *self, GdkWindow *window)
Definition: fl_renderer_gdk.cc:69
fl_view_text_input_delegate_iface_init
static void fl_view_text_input_delegate_iface_init(FlTextInputViewDelegateInterface *iface)
Definition: fl_view.cc:345
set_scrolling_position
static void set_scrolling_position(FlView *self, gdouble x, gdouble y)
Definition: fl_view.cc:365
SIGNAL_FIRST_FRAME
@ SIGNAL_FIRST_FRAME
Definition: fl_view.cc:84
enter_notify_event_cb
static gboolean enter_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:462
fl_view_redraw
static void fl_view_redraw(FlRenderable *renderable)
Definition: fl_view.cc:295
fl_view_accessible.h
leave_notify_event_cb
static gboolean leave_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:474
fl_scrolling_manager_handle_zoom_end
void fl_scrolling_manager_handle_zoom_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:235
_FlView::text_input_handler
FlTextInputHandler * text_input_handler
Definition: fl_view.cc:73
_FlView::window_state_monitor
FlWindowStateMonitor * window_state_monitor
Definition: fl_view.cc:57
fl_key_event_new_from_gdk_event
FlKeyEvent * fl_key_event_new_from_gdk_event(GdkEvent *event)
Definition: fl_key_event.cc:53
fl_view_set_background_color
G_MODULE_EXPORT void fl_view_set_background_color(FlView *self, const GdkRGBA *color)
Definition: fl_view.cc:838
fl_scrolling_manager_handle_scroll_event
void fl_scrolling_manager_handle_scroll_event(FlScrollingManager *self, GdkEventScroll *scroll_event, gint scale_factor)
Definition: fl_scrolling_manager.cc:71
fl_view_make_current
static void fl_view_make_current(FlRenderable *renderable)
Definition: fl_view.cc:309
_FlView::background_color
GdkRGBA * background_color
Definition: fl_view.cc:51
fl_view_accessible_handle_update_semantics
void fl_view_accessible_handle_update_semantics(FlViewAccessible *self, const FlutterSemanticsUpdate2 *update)
Definition: fl_view_accessible.cc:139
fl_text_input_view_delegate.h
_FlView::touch_manager
FlTouchManager * touch_manager
Definition: fl_view.cc:66
fl_view_class_init
static void fl_view_class_init(FlViewClass *klass)
Definition: fl_view.cc:697
_FlView::pointer_manager
FlPointerManager * pointer_manager
Definition: fl_view.cc:63
fl_plugin_registrar_private.h
fl_view_get_id
G_MODULE_EXPORT int64_t fl_view_get_id(FlView *self)
Definition: fl_view.cc:833
_FlView::parent_instance
GtkBox parent_instance
Definition: fl_view.cc:33
fl_touch_manager.h
G_DEFINE_TYPE_WITH_CODE
G_DEFINE_TYPE_WITH_CODE(FlView, fl_view, GTK_TYPE_BOX, G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_view_plugin_registry_iface_init) G_IMPLEMENT_INTERFACE(fl_keyboard_view_delegate_get_type(), fl_view_keyboard_delegate_iface_init) G_IMPLEMENT_INTERFACE(fl_text_input_view_delegate_get_type(), fl_view_text_input_delegate_iface_init)) static gboolean first_frame_idle_cb(gpointer user_data)
Definition: fl_view.cc:99
_FlView::have_first_frame
gboolean have_first_frame
Definition: fl_view.cc:54
_FlView::cancellable
GCancellable * cancellable
Definition: fl_view.cc:81
fl_keyboard_manager.h
init_scrolling
static void init_scrolling(FlView *self)
Definition: fl_view.cc:148
fl_renderer_gdk_get_context
GdkGLContext * fl_renderer_gdk_get_context(FlRendererGdk *self)
Definition: fl_renderer_gdk.cc:106
create_context_cb
static GdkGLContext * create_context_cb(FlView *self)
Definition: fl_view.cc:516
get_device_kind
static FlutterPointerDeviceKind get_device_kind(GdkEvent *event)
Definition: fl_view.cc:159
fl_view_get_registrar_for_plugin
static FlPluginRegistrar * fl_view_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_view.cc:315
on_pre_engine_restart_cb
static void on_pre_engine_restart_cb(FlView *self)
Definition: fl_view.cc:288
fl_engine_get_renderer
FlRenderer * fl_engine_get_renderer(FlEngine *self)
Definition: fl_engine.cc:534
fl_view_new_for_engine
G_MODULE_EXPORT FlView * fl_view_new_for_engine(FlEngine *engine)
Definition: fl_view.cc:803
size_allocate_cb
static void size_allocate_cb(FlView *self)
Definition: fl_view.cc:605
unrealize_cb
static void unrealize_cb(FlView *self)
Definition: fl_view.cc:591
fl_display_monitor_get_display_id
FlutterEngineDisplayId fl_display_monitor_get_display_id(FlDisplayMonitor *self, GdkMonitor *monitor)
Definition: fl_display_monitor.cc:115
init_touch
static void init_touch(FlView *self)
Definition: fl_view.cc:154
fl_text_input_handler.h
fl_engine_remove_view
void fl_engine_remove_view(FlEngine *self, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:728
fl_pointer_manager.h
_FlView
Definition: fl_view.cc:32
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
fl_text_input_handler_new
FlTextInputHandler * fl_text_input_handler_new(FlBinaryMessenger *messenger, GtkIMContext *im_context, FlTextInputViewDelegate *view_delegate)
Definition: fl_text_input_handler.cc:455
_FlView::on_pre_engine_restart_cb_id
guint on_pre_engine_restart_cb_id
Definition: fl_view.cc:42
realize_cb
static void realize_cb(FlView *self)
Definition: fl_view.cc:533
scroll_event_cb
static gboolean scroll_event_cb(FlView *self, GdkEventScroll *event)
Definition: fl_view.cc:423
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:1203
touch_event_cb
static gboolean touch_event_cb(FlView *self, GdkEventTouch *event)
Definition: fl_view.cc:433
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:255
_FlView::keyboard_handler
FlKeyboardHandler * keyboard_handler
Definition: fl_view.cc:72
update_semantics_cb
static void update_semantics_cb(FlEngine *engine, const FlutterSemanticsUpdate2 *update, gpointer user_data)
Definition: fl_view.cc:275
_FlView::scrolling_manager
FlScrollingManager * scrolling_manager
Definition: fl_view.cc:60
fl_keyboard_handler.h
fl_view_new
G_MODULE_EXPORT FlView * fl_view_new(FlDartProject *project)
Definition: fl_view.cc:775
fl_keyboard_manager_handle_event
gboolean fl_keyboard_manager_handle_event(FlKeyboardManager *self, FlKeyEvent *event)
Definition: fl_keyboard_manager.cc:522
render_cb
static gboolean render_cb(FlView *self, GdkGLContext *context)
Definition: fl_view.cc:576
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_touch_manager_handle_touch_event
void fl_touch_manager_handle_touch_event(FlTouchManager *self, GdkEventTouch *touch_event, gint scale_factor)
Definition: fl_touch_manager.cc:131
gesture_zoom_end_cb
static void gesture_zoom_end_cb(FlView *self)
Definition: fl_view.cc:512
button_release_event_cb
static gboolean button_release_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:401
fl_socket_accessible.h
_FlView::view_id
FlutterViewId view_id
Definition: fl_view.cc:45
fl_engine_add_view_finish
gboolean fl_engine_add_view_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:721
_FlView::engine
FlEngine * engine
Definition: fl_view.cc:39
LAST_SIGNAL
@ LAST_SIGNAL
Definition: fl_view.cc:84
fl_keyboard_handler_new
FlKeyboardHandler * fl_keyboard_handler_new(FlBinaryMessenger *messenger, FlKeyboardManager *keyboard_manager)
Definition: fl_keyboard_handler.cc:62
fl_text_input_handler_filter_keypress
gboolean fl_text_input_handler_filter_keypress(FlTextInputHandler *self, FlKeyEvent *event)
Definition: fl_text_input_handler.cc:476
fl_view_plugin_registry_iface_init
static void fl_view_plugin_registry_iface_init(FlPluginRegistryInterface *iface)
Definition: fl_view.cc:330
fl_scrolling_manager_set_last_mouse_position
void fl_scrolling_manager_set_last_mouse_position(FlScrollingManager *self, gdouble x, gdouble y)
Definition: fl_scrolling_manager.cc:63
fl_view_signals
static guint fl_view_signals[LAST_SIGNAL]
Definition: fl_view.cc:86
fl_view_dispose
static void fl_view_dispose(GObject *object)
Definition: fl_view.cc:621
fl_engine_private.h
fl_engine_request_app_exit
void fl_engine_request_app_exit(FlEngine *self)
Definition: fl_engine.cc:1236
fl_scrolling_manager.h
fl_renderer_gdk_create_contexts
gboolean fl_renderer_gdk_create_contexts(FlRendererGdk *self, GError **error)
Definition: fl_renderer_gdk.cc:76
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
fl_scrolling_manager_handle_zoom_update
void fl_scrolling_manager_handle_zoom_update(FlScrollingManager *self, gdouble scale)
Definition: fl_scrolling_manager.cc:220
fl_view_get_engine
G_MODULE_EXPORT FlEngine * fl_view_get_engine(FlView *self)
Definition: fl_view.cc:827
fl_renderable_iface_init
static void fl_renderable_iface_init(FlRenderableInterface *iface)
Definition: fl_view.cc:325
fl_window_state_monitor_new
FlWindowStateMonitor * fl_window_state_monitor_new(FlBinaryMessenger *messenger, GtkWindow *window)
Definition: fl_window_state_monitor.cc:104
fl_scrolling_manager_handle_rotation_update
void fl_scrolling_manager_handle_rotation_update(FlScrollingManager *self, gdouble rotation)
Definition: fl_scrolling_manager.cc:171
gesture_rotation_begin_cb
static void gesture_rotation_begin_cb(FlView *self)
Definition: fl_view.cc:489
fl_accessible_node.h
fl_engine_add_view
FlutterViewId fl_engine_add_view(FlEngine *self, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:678
fl_socket_accessible_embed
void fl_socket_accessible_embed(FlSocketAccessible *self, gchar *id)
Definition: fl_socket_accessible.cc:55
fl_engine_get_mouse_cursor_handler
FlMouseCursorHandler * fl_engine_get_mouse_cursor_handler(FlEngine *self)
Definition: fl_engine.cc:1241
fl_engine_get_display_monitor
FlDisplayMonitor * fl_engine_get_display_monitor(FlEngine *self)
Definition: fl_engine.cc:539
setup_cursor
static void setup_cursor(FlView *self)
Definition: fl_view.cc:210
fl_view.h
cursor_changed_cb
static void cursor_changed_cb(FlView *self)
Definition: fl_view.cc:198
fl_keyboard_manager_sync_modifier_if_needed
void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager *self, guint state, double event_time)
Definition: fl_keyboard_manager.cc:558
fl_renderer_gdk.h
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
fl_touch_manager_new
FlTouchManager * fl_touch_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_touch_manager.cc:48
handle_geometry_changed
static void handle_geometry_changed(FlView *self)
Definition: fl_view.cc:220
_FlView::renderer
FlRendererGdk * renderer
Definition: fl_view.cc:48
fl_renderer_cleanup
void fl_renderer_cleanup(FlRenderer *self)
Definition: fl_renderer.cc:608
fl_view_key_press_event
static gboolean fl_view_key_press_event(GtkWidget *widget, GdkEventKey *key_event)
Definition: fl_view.cc:677
sync_modifier_if_needed
static void sync_modifier_if_needed(FlView *self, GdkEvent *event)
Definition: fl_view.cc:357
gesture_rotation_end_cb
static void gesture_rotation_end_cb(FlView *self)
Definition: fl_view.cc:500
_FlView::gl_area
GtkGLArea * gl_area
Definition: fl_view.cc:36
fl_pointer_manager_handle_motion
gboolean fl_pointer_manager_handle_motion(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:140
gesture_zoom_update_cb
static void gesture_zoom_update_cb(FlView *self, gdouble scale)
Definition: fl_view.cc:508
fl_pointer_manager_handle_leave
gboolean fl_pointer_manager_handle_leave(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:179
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:524
fl_view_keyboard_delegate_iface_init
static void fl_view_keyboard_delegate_iface_init(FlKeyboardViewDelegateInterface *iface)
Definition: fl_view.cc:335
fl_key_event.h
gesture_zoom_begin_cb
static void gesture_zoom_begin_cb(FlView *self)
Definition: fl_view.cc:504
_FlView::view_accessible
FlViewAccessible * view_accessible
Definition: fl_view.cc:76
fl_engine.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_renderer_make_current
void fl_renderer_make_current(FlRenderer *self)
Definition: fl_renderer.cc:369
fl_engine_set_update_semantics_handler
void fl_engine_set_update_semantics_handler(FlEngine *self, FlEngineUpdateSemanticsHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:778
fl_pointer_manager_handle_enter
gboolean fl_pointer_manager_handle_enter(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:162
fl_view_init
static void fl_view_init(FlView *self)
Definition: fl_view.cc:715
fl_mouse_cursor_handler_get_cursor_name
const gchar * fl_mouse_cursor_handler_get_cursor_name(FlMouseCursorHandler *self)
Definition: fl_mouse_cursor_handler.cc:147
fl_view_notify
static void fl_view_notify(GObject *object, GParamSpec *pspec)
Definition: fl_view.cc:609
fl_renderer_render
void fl_renderer_render(FlRenderer *self, FlutterViewId view_id, int width, int height, const GdkRGBA *background_color)
Definition: fl_renderer.cc:585
fl_scrolling_manager_handle_rotation_end
void fl_scrolling_manager_handle_rotation_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:186
fl_window_state_monitor.h
fl_view_key_release_event
static gboolean fl_view_key_release_event(GtkWidget *widget, GdkEventKey *key_event)
Definition: fl_view.cc:688
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:544
fl_scrolling_manager_handle_rotation_begin
void fl_scrolling_manager_handle_rotation_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:153
_FlView::keyboard_manager
FlKeyboardManager * keyboard_manager
Definition: fl_view.cc:69
fl_scrolling_manager_new
FlScrollingManager * fl_scrolling_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_scrolling_manager.cc:47
fl_renderer_add_renderable
void fl_renderer_add_renderable(FlRenderer *self, FlutterViewId view_id, FlRenderable *renderable)
Definition: fl_renderer.cc:341
fl_plugin_registrar_new
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
Definition: fl_plugin_registrar.cc:84
get_mouse_button
static gboolean get_mouse_button(GdkEvent *event, int64_t *button)
Definition: fl_view.cc:178
fl_keyboard_view_delegate.h
fl_plugin_registry.h
motion_notify_event_cb
static gboolean motion_notify_event_cb(FlView *self, GdkEventMotion *motion_event)
Definition: fl_view.cc:441
fl_engine_send_window_metrics_event
void fl_engine_send_window_metrics_event(FlEngine *self, FlutterEngineDisplayId display_id, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
Definition: fl_engine.cc:896
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
fl_scrolling_manager_handle_zoom_begin
void fl_scrolling_manager_handle_zoom_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:202
fl_pointer_manager_handle_button_press
gboolean fl_pointer_manager_handle_button_press(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, int64_t button)
Definition: fl_pointer_manager.cc:76
fl_keyboard_manager_new
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine, FlKeyboardViewDelegate *view_delegate)
Definition: fl_keyboard_manager.cc:462
fl_view_accessible_new
FlViewAccessible * fl_view_accessible_new(FlEngine *engine)
Definition: fl_view_accessible.cc:132
init_keyboard
static void init_keyboard(FlView *self)
Definition: fl_view.cc:128
fl_engine_get_texture_registrar
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:1219
button_press_event_cb
static gboolean button_press_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:372
fl_pointer_manager_handle_button_release
gboolean fl_pointer_manager_handle_button_release(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, int64_t button)
Definition: fl_pointer_manager.cc:109
fl_pointer_manager_new
FlPointerManager * fl_pointer_manager_new(FlutterViewId view_id, FlEngine *engine)
Definition: fl_pointer_manager.cc:65
fl_renderer_setup
void fl_renderer_setup(FlRenderer *self)
Definition: fl_renderer.cc:567