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