| Flutter Linux Embedder |

Classes | Enumerations | Functions | Variables
fl_view.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"`
`#include <atk/atk.h>`
`#include <gtk/gtk-a11y.h>`
`#include <cstring>`
`#include "flutter/common/constants.h"`
`#include "flutter/shell/platform/linux/fl_accessible_node.h"`
`#include "flutter/shell/platform/linux/fl_compositor_opengl.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include "flutter/shell/platform/linux/fl_key_event.h"`
`#include "flutter/shell/platform/linux/fl_opengl_manager.h"`
`#include "flutter/shell/platform/linux/fl_plugin_registrar_private.h"`
`#include "flutter/shell/platform/linux/fl_pointer_manager.h"`
`#include "flutter/shell/platform/linux/fl_scrolling_manager.h"`
`#include "flutter/shell/platform/linux/fl_socket_accessible.h"`
`#include "flutter/shell/platform/linux/fl_touch_manager.h"`
`#include "flutter/shell/platform/linux/fl_view_accessible.h"`
`#include "flutter/shell/platform/linux/fl_view_private.h"`
`#include "flutter/shell/platform/linux/fl_window_state_monitor.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_plugin_registry.h"`

Go to the source code of this file.

## Classes
struct | _FlView

## Enumerations
enum | { SIGNAL_FIRST_FRAME , LAST_SIGNAL }

## Functions
static void | fl_renderable_iface_init (FlRenderableInterface *iface)
static void | fl_view_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
| 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 first_frame_idle_cb(gpointer user_data)
static gboolean | window_delete_event_cb (FlView *self)
static void | init_scrolling (FlView *self)
static void | init_touch (FlView *self)
static FlutterPointerDeviceKind | get_device_kind (GdkEvent *event)
static void | cursor_changed_cb (FlView *self)
static void | setup_cursor (FlView *self)
static void | handle_geometry_changed (FlView *self)
static void | view_added_cb (GObject *object, GAsyncResult *result, gpointer user_data)
static void | update_semantics_cb (FlView *self, const FlutterSemanticsUpdate2 *update)
static void | on_pre_engine_restart_cb (FlView *self)
static void | fl_view_redraw (FlRenderable *renderable)
static void | fl_view_make_current (FlRenderable *renderable)
static FlPluginRegistrar * | fl_view_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
static void | sync_modifier_if_needed (FlView *self, GdkEvent *event)
static void | set_scrolling_position (FlView *self, gdouble x, gdouble y)
static gboolean | button_press_event_cb (FlView *self, GdkEventButton *button_event)
static gboolean | button_release_event_cb (FlView *self, GdkEventButton *button_event)
static gboolean | scroll_event_cb (FlView *self, GdkEventScroll *event)
static gboolean | touch_event_cb (FlView *self, GdkEventTouch *event)
static gboolean | motion_notify_event_cb (FlView *self, GdkEventMotion *motion_event)
static gboolean | enter_notify_event_cb (FlView *self, GdkEventCrossing *crossing_event)
static gboolean | leave_notify_event_cb (FlView *self, GdkEventCrossing *crossing_event)
static void | gesture_rotation_begin_cb (FlView *self)
static void | gesture_rotation_update_cb (FlView *self, gdouble rotation, gdouble delta)
static void | gesture_rotation_end_cb (FlView *self)
static void | gesture_zoom_begin_cb (FlView *self)
static void | gesture_zoom_update_cb (FlView *self, gdouble scale)
static void | gesture_zoom_end_cb (FlView *self)
static GdkGLContext * | create_context_cb (FlView *self)
static void | realize_cb (FlView *self)
static void | secondary_realize_cb (FlView *self)
static gboolean | render_cb (FlView *self, GdkGLContext *context)
static void | unrealize_cb (FlView *self)
static void | size_allocate_cb (FlView *self)
static void | fl_view_notify (GObject *object, GParamSpec *pspec)
static void | fl_view_dispose (GObject *object)
static void | fl_view_realize (GtkWidget *widget)
static gboolean | handle_key_event (FlView *self, GdkEventKey *key_event)
static gboolean | fl_view_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
static gboolean | fl_view_key_press_event (GtkWidget *widget, GdkEventKey *key_event)
static gboolean | fl_view_key_release_event (GtkWidget *widget, GdkEventKey *key_event)
static void | fl_view_class_init (FlViewClass *klass)
static void | setup_engine (FlView *self)
static void | fl_view_init (FlView *self)
G_MODULE_EXPORT FlView * | fl_view_new (FlDartProject *project)
G_MODULE_EXPORT FlView * | fl_view_new_for_engine (FlEngine *engine)
G_MODULE_EXPORT FlEngine * | fl_view_get_engine (FlView *self)
G_MODULE_EXPORT int64_t | fl_view_get_id (FlView *self)
G_MODULE_EXPORT void | fl_view_set_background_color (FlView *self, const GdkRGBA *color)
FlViewAccessible * | fl_view_get_accessible (FlView *self)

## Variables
static guint | fl_view_signals [LAST_SIGNAL]

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
SIGNAL_FIRST_FRAME |
LAST_SIGNAL |

Definition at line 74 of file fl_view.cc.

74 { SIGNAL_FIRST_FRAME, LAST_SIGNAL };
LAST_SIGNAL
@ LAST_SIGNAL
Definition: fl_view.cc:74
SIGNAL_FIRST_FRAME
@ SIGNAL_FIRST_FRAME
Definition: fl_view.cc:74

## Function Documentation

## ◆ button_press_event_cb()

static gboolean button_press_event_cb | ( | FlView * | self,
|  | GdkEventButton * | button_event
| ) |  |
| static

Definition at line 300 of file fl_view.cc.

301 {
302 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
303
304 // Flutter doesn't handle double and triple click events.
305 GdkEventType event_type = gdk_event_get_event_type(event);
306 if (event_type == GDK_DOUBLE_BUTTON_PRESS ||
307 event_type == GDK_TRIPLE_BUTTON_PRESS) {
308 return FALSE;
309 }
310
311 guint button = 0;
312 gdk_event_get_button(event, &button);
313
314 gdouble x = 0.0, y = 0.0;
315 gdk_event_get_coords(event, &x, &y);
316
317 set_scrolling_position(self, x, y);
318 sync_modifier_if_needed(self, event);
319
320 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
321 return fl_pointer_manager_handle_button_press(
322 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
323 x * scale_factor, y * scale_factor, button);
324 }
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
set_scrolling_position
static void set_scrolling_position(FlView *self, gdouble x, gdouble y)
Definition: fl_view.cc:293
sync_modifier_if_needed
static void sync_modifier_if_needed(FlView *self, GdkEvent *event)
Definition: fl_view.cc:285
get_device_kind
static FlutterPointerDeviceKind get_device_kind(GdkEvent *event)
Definition: fl_view.cc:118

References fl_pointer_manager_handle_button_press(), get_device_kind(), set_scrolling_position(), and sync_modifier_if_needed().

Referenced by fl_view_init().

## ◆ button_release_event_cb()

static gboolean button_release_event_cb | ( | FlView * | self,
|  | GdkEventButton * | button_event
| ) |  |
| static

Definition at line 327 of file fl_view.cc.

328 {
329 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
330
331 guint button = 0;
332 gdk_event_get_button(event, &button);
333
334 gdouble x = 0.0, y = 0.0;
335 gdk_event_get_coords(event, &x, &y);
336
337 set_scrolling_position(self, x, y);
338 sync_modifier_if_needed(self, event);
339
340 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
341 return fl_pointer_manager_handle_button_release(
342 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
343 x * scale_factor, y * scale_factor, button);
344 }
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

References fl_pointer_manager_handle_button_release(), get_device_kind(), set_scrolling_position(), and sync_modifier_if_needed().

Referenced by fl_view_init().

## ◆ create_context_cb()

static GdkGLContext* create_context_cb | ( | FlView * | self | ) |
| static

Definition at line 440 of file fl_view.cc.

440 {
441 init_scrolling(self);
442 init_touch(self);
443
444 FlOpenGLManager* opengl_manager = fl_engine_get_opengl_manager(self->engine);
445 g_autoptr(GError) error = nullptr;
446 if (!fl_opengl_manager_create_contexts(
447 opengl_manager, gtk_widget_get_parent_window(GTK_WIDGET(self)),
448 &error)) {
449 gtk_gl_area_set_error(self->gl_area, error);
450 return nullptr;
451 }
452
453 return GDK_GL_CONTEXT(
454 g_object_ref(fl_opengl_manager_get_context(opengl_manager)));
455 }
fl_engine_get_opengl_manager
FlOpenGLManager * fl_engine_get_opengl_manager(FlEngine *self)
Definition: fl_engine.cc:603
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_get_context
GdkGLContext * fl_opengl_manager_get_context(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:77
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
init_scrolling
static void init_scrolling(FlView *self)
Definition: fl_view.cc:107
init_touch
static void init_touch(FlView *self)
Definition: fl_view.cc:113

References error, fl_engine_get_opengl_manager(), fl_opengl_manager_create_contexts(), fl_opengl_manager_get_context(), init_scrolling(), and init_touch().

Referenced by fl_view_new().

## ◆ cursor_changed_cb()

static void cursor_changed_cb | ( | FlView * | self | ) |
| static

Definition at line 138 of file fl_view.cc.

138 {
139 FlMouseCursorHandler* handler =
140 fl_engine_get_mouse_cursor_handler(self->engine);
141 const gchar* cursor_name = fl_mouse_cursor_handler_get_cursor_name(handler);
142 GdkWindow* window =
143 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
144 g_autoptr(GdkCursor) cursor =
145 gdk_cursor_new_from_name(gdk_window_get_display(window), cursor_name);
146 gdk_window_set_cursor(window, cursor);
147 }
window
return window
Definition: fl_application.cc:41
fl_engine_get_mouse_cursor_handler
FlMouseCursorHandler * fl_engine_get_mouse_cursor_handler(FlEngine *self)
Definition: fl_engine.cc:1334
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

References fl_engine_get_mouse_cursor_handler(), fl_mouse_cursor_handler_get_cursor_name(), and window.

Referenced by setup_cursor().

## ◆ enter_notify_event_cb()

static gboolean enter_notify_event_cb | ( | FlView * | self,
|  | GdkEventCrossing * | crossing_event
| ) |  |
| static

Definition at line 386 of file fl_view.cc.

387 {
388 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
389 gdouble x = 0.0, y = 0.0;
390 gdk_event_get_coords(event, &x, &y);
391 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
392 return fl_pointer_manager_handle_enter(
393 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
394 x * scale_factor, y * scale_factor);
395 }
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

References fl_pointer_manager_handle_enter(), and get_device_kind().

Referenced by fl_view_init().

## ◆ fl_renderable_iface_init()

static void fl_renderable_iface_init | ( | FlRenderableInterface * | iface | ) |
| static

Definition at line 275 of file fl_view.cc.

275 {
276 iface->redraw = fl_view_redraw;
277 iface->make_current = fl_view_make_current;
278 }
fl_view_make_current
static void fl_view_make_current(FlRenderable *renderable)
Definition: fl_view.cc:259
fl_view_redraw
static void fl_view_redraw(FlRenderable *renderable)
Definition: fl_view.cc:245

References fl_view_make_current(), and fl_view_redraw().

## ◆ fl_view_class_init()

static void fl_view_class_init | ( | FlViewClass * | klass | ) |
| static

Definition at line 656 of file fl_view.cc.

656 {
657 GObjectClass* object_class = G_OBJECT_CLASS(klass);
658 object_class->notify = fl_view_notify;
659 object_class->dispose = fl_view_dispose;
660
661 GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
662 widget_class->realize = fl_view_realize;
663 widget_class->focus_in_event = fl_view_focus_in_event;
664 widget_class->key_press_event = fl_view_key_press_event;
665 widget_class->key_release_event = fl_view_key_release_event;
666
667 fl_view_signals[SIGNAL_FIRST_FRAME] =
668 g_signal_new("first-frame", fl_view_get_type(), G_SIGNAL_RUN_LAST, 0,
669 NULL, NULL, NULL, G_TYPE_NONE, 0);
670
671 gtk_widget_class_set_accessible_type(GTK_WIDGET_CLASS(klass),
672 fl_socket_accessible_get_type());
673 }
fl_view_realize
static void fl_view_realize(GtkWidget *widget)
Definition: fl_view.cc:588
fl_view_key_release_event
static gboolean fl_view_key_release_event(GtkWidget *widget, GdkEventKey *key_event)
Definition: fl_view.cc:650
fl_view_dispose
static void fl_view_dispose(GObject *object)
Definition: fl_view.cc:546
fl_view_key_press_event
static gboolean fl_view_key_press_event(GtkWidget *widget, GdkEventKey *key_event)
Definition: fl_view.cc:643
fl_view_notify
static void fl_view_notify(GObject *object, GParamSpec *pspec)
Definition: fl_view.cc:534
fl_view_signals
static guint fl_view_signals[LAST_SIGNAL]
Definition: fl_view.cc:76
fl_view_focus_in_event
static gboolean fl_view_focus_in_event(GtkWidget *widget, GdkEventFocus *event)
Definition: fl_view.cc:634

References fl_view_dispose(), fl_view_focus_in_event(), fl_view_key_press_event(), fl_view_key_release_event(), fl_view_notify(), fl_view_realize(), fl_view_signals, and SIGNAL_FIRST_FRAME.

## ◆ fl_view_dispose()

static void fl_view_dispose | ( | GObject * | object | ) |
| static

Definition at line 546 of file fl_view.cc.

546 {
547 FlView* self = FL_VIEW(object);
548
549 g_cancellable_cancel(self->cancellable);
550
551 if (self->engine != nullptr) {
552 FlMouseCursorHandler* handler =
553 fl_engine_get_mouse_cursor_handler(self->engine);
554 if (self->cursor_changed_cb_id != 0) {
555 g_signal_handler_disconnect(handler, self->cursor_changed_cb_id);
556 self->cursor_changed_cb_id = 0;
557 }
558
559 // Release the view ID from the engine.
560 fl_engine_remove_view(self->engine, self->view_id, nullptr, nullptr,
561 nullptr);
562 }
563
564 if (self->on_pre_engine_restart_cb_id != 0) {
565 g_signal_handler_disconnect(self->engine,
566 self->on_pre_engine_restart_cb_id);
567 self->on_pre_engine_restart_cb_id = 0;
568 }
569
570 if (self->update_semantics_cb_id != 0) {
571 g_signal_handler_disconnect(self->engine, self->update_semantics_cb_id);
572 self->update_semantics_cb_id = 0;
573 }
574
575 g_clear_object(&self->engine);
576 g_clear_pointer(&self->background_color, gdk_rgba_free);
577 g_clear_object(&self->window_state_monitor);
578 g_clear_object(&self->scrolling_manager);
579 g_clear_object(&self->pointer_manager);
580 g_clear_object(&self->touch_manager);
581 g_clear_object(&self->view_accessible);
582 g_clear_object(&self->cancellable);
583
584 G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
585 }
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:814

References fl_engine_get_mouse_cursor_handler(), and fl_engine_remove_view().

Referenced by fl_view_class_init().

## ◆ fl_view_focus_in_event()

static gboolean fl_view_focus_in_event | ( | GtkWidget * | widget,
|  | GdkEventFocus * | event
| ) |  |
| static

Definition at line 634 of file fl_view.cc.

635 {
636 FlView* self = FL_VIEW(widget);
637 fl_text_input_handler_set_widget(
638 fl_engine_get_text_input_handler(self->engine), widget);
639 return FALSE;
640 }
fl_engine_get_text_input_handler
FlTextInputHandler * fl_engine_get_text_input_handler(FlEngine *self)
Definition: fl_engine.cc:1329
fl_text_input_handler_set_widget
void fl_text_input_handler_set_widget(FlTextInputHandler *self, GtkWidget *widget)
Definition: fl_text_input_handler.cc:464

References fl_engine_get_text_input_handler(), and fl_text_input_handler_set_widget().

Referenced by fl_view_class_init().

## ◆ fl_view_get_accessible()

FlViewAccessible* fl_view_get_accessible | ( | FlView * | view | ) |

fl_view_get_accessible: @view: an #FlView.

Get the accessible object for this view.

Returns: an #FlViewAccessible.

Definition at line 805 of file fl_view.cc.

805 {
806 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
807 return self->view_accessible;
808 }

Referenced by TEST().

## ◆ fl_view_get_engine()

G_MODULE_EXPORT FlEngine* fl_view_get_engine | ( | FlView * | view | ) |

fl_view_get_engine: @view: an #FlView.

Gets the engine being rendered in the view.

Returns: an #FlEngine.

Definition at line 787 of file fl_view.cc.

787 {
788 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
789 return self->engine;
790 }

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_get_id()

G_MODULE_EXPORT int64_t fl_view_get_id | ( | FlView * | view | ) |

fl_view_get_id: @view: an #FlView.

Gets the Flutter view ID used by this view.

Returns: a view ID or -1 if now ID assigned.

Definition at line 793 of file fl_view.cc.

793 {
794 g_return_val_if_fail(FL_IS_VIEW(self), -1);
795 return self->view_id;
796 }

Referenced by create_regular(), and TEST().

## ◆ fl_view_get_registrar_for_plugin()

static FlPluginRegistrar* fl_view_get_registrar_for_plugin | ( | FlPluginRegistry * | registry,
|  | const gchar * | name
| ) |  |
| static

Definition at line 265 of file fl_view.cc.

267 {
268 FlView* self = FL_VIEW(registry);
269
270 return fl_plugin_registrar_new(self,
271 fl_engine_get_binary_messenger(self->engine),
272 fl_engine_get_texture_registrar(self->engine));
273 }
fl_engine_get_texture_registrar
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:1297
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:1281
fl_plugin_registrar_new
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
Definition: fl_plugin_registrar.cc:84

References fl_engine_get_binary_messenger(), fl_engine_get_texture_registrar(), and fl_plugin_registrar_new().

Referenced by fl_view_plugin_registry_iface_init().

## ◆ fl_view_init()

static void fl_view_init | ( | FlView * | self | ) |
| static

Definition at line 691 of file fl_view.cc.

691 {
692 self->cancellable = g_cancellable_new();
693
694 gtk_widget_set_can_focus(GTK_WIDGET(self), TRUE);
695
696 self->view_id = -1;
697
698 GdkRGBA default_background = {
699 .red = 0.0, .green = 0.0, .blue = 0.0, .alpha = 1.0};
700 self->background_color = gdk_rgba_copy(&default_background);
701
702 GtkWidget* event_box = gtk_event_box_new();
703 gtk_widget_set_hexpand(event_box, TRUE);
704 gtk_widget_set_vexpand(event_box, TRUE);
705 gtk_container_add(GTK_CONTAINER(self), event_box);
706 gtk_widget_show(event_box);
707 gtk_widget_add_events(event_box,
708 GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
709 GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK |
710 GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK);
711
712 g_signal_connect_swapped(event_box, "button-press-event",
713 G_CALLBACK(button_press_event_cb), self);
714 g_signal_connect_swapped(event_box, "button-release-event",
715 G_CALLBACK(button_release_event_cb), self);
716 g_signal_connect_swapped(event_box, "scroll-event",
717 G_CALLBACK(scroll_event_cb), self);
718 g_signal_connect_swapped(event_box, "motion-notify-event",
719 G_CALLBACK(motion_notify_event_cb), self);
720 g_signal_connect_swapped(event_box, "enter-notify-event",
721 G_CALLBACK(enter_notify_event_cb), self);
722 g_signal_connect_swapped(event_box, "leave-notify-event",
723 G_CALLBACK(leave_notify_event_cb), self);
724 GtkGesture* zoom = gtk_gesture_zoom_new(event_box);
725 g_signal_connect_swapped(zoom, "begin", G_CALLBACK(gesture_zoom_begin_cb),
726 self);
727 g_signal_connect_swapped(zoom, "scale-changed",
728 G_CALLBACK(gesture_zoom_update_cb), self);
729 g_signal_connect_swapped(zoom, "end", G_CALLBACK(gesture_zoom_end_cb), self);
730 GtkGesture* rotate = gtk_gesture_rotate_new(event_box);
731 g_signal_connect_swapped(rotate, "begin",
732 G_CALLBACK(gesture_rotation_begin_cb), self);
733 g_signal_connect_swapped(rotate, "angle-changed",
734 G_CALLBACK(gesture_rotation_update_cb), self);
735 g_signal_connect_swapped(rotate, "end", G_CALLBACK(gesture_rotation_end_cb),
736 self);
737 g_signal_connect_swapped(event_box, "touch-event", G_CALLBACK(touch_event_cb),
738 self);
739
740 self->gl_area = GTK_GL_AREA(gtk_gl_area_new());
741 gtk_gl_area_set_has_alpha(self->gl_area, TRUE);
742 gtk_widget_show(GTK_WIDGET(self->gl_area));
743 gtk_container_add(GTK_CONTAINER(event_box), GTK_WIDGET(self->gl_area));
744 g_signal_connect_swapped(self->gl_area, "render", G_CALLBACK(render_cb),
745 self);
746
747 g_signal_connect_swapped(self, "size-allocate", G_CALLBACK(size_allocate_cb),
748 self);
749 }
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
gesture_zoom_begin_cb
static void gesture_zoom_begin_cb(FlView *self)
Definition: fl_view.cc:428
button_release_event_cb
static gboolean button_release_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:327
gesture_rotation_end_cb
static void gesture_rotation_end_cb(FlView *self)
Definition: fl_view.cc:424
gesture_rotation_update_cb
static void gesture_rotation_update_cb(FlView *self, gdouble rotation, gdouble delta)
Definition: fl_view.cc:417
button_press_event_cb
static gboolean button_press_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:300
gesture_zoom_end_cb
static void gesture_zoom_end_cb(FlView *self)
Definition: fl_view.cc:436
render_cb
static gboolean render_cb(FlView *self, GdkGLContext *context)
Definition: fl_view.cc:499
size_allocate_cb
static void size_allocate_cb(FlView *self)
Definition: fl_view.cc:530
motion_notify_event_cb
static gboolean motion_notify_event_cb(FlView *self, GdkEventMotion *motion_event)
Definition: fl_view.cc:365
enter_notify_event_cb
static gboolean enter_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:386
gesture_rotation_begin_cb
static void gesture_rotation_begin_cb(FlView *self)
Definition: fl_view.cc:413
scroll_event_cb
static gboolean scroll_event_cb(FlView *self, GdkEventScroll *event)
Definition: fl_view.cc:347
gesture_zoom_update_cb
static void gesture_zoom_update_cb(FlView *self, gdouble scale)
Definition: fl_view.cc:432
leave_notify_event_cb
static gboolean leave_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:398
touch_event_cb
static gboolean touch_event_cb(FlView *self, GdkEventTouch *event)
Definition: fl_view.cc:357

References button_press_event_cb(), button_release_event_cb(), enter_notify_event_cb(), gesture_rotation_begin_cb(), gesture_rotation_end_cb(), gesture_rotation_update_cb(), gesture_zoom_begin_cb(), gesture_zoom_end_cb(), gesture_zoom_update_cb(), leave_notify_event_cb(), motion_notify_event_cb(), render_cb(), scroll_event_cb(), size_allocate_cb(), touch_event_cb(), and TRUE.

## ◆ fl_view_key_press_event()

static gboolean fl_view_key_press_event | ( | GtkWidget * | widget,
|  | GdkEventKey * | key_event
| ) |  |
| static

Definition at line 643 of file fl_view.cc.

644 {
645 FlView* self = FL_VIEW(widget);
646 return handle_key_event(self, key_event);
647 }
handle_key_event
static gboolean handle_key_event(FlView *self, GdkEventKey *key_event)
Definition: fl_view.cc:597

References handle_key_event().

Referenced by fl_view_class_init().

## ◆ fl_view_key_release_event()

static gboolean fl_view_key_release_event | ( | GtkWidget * | widget,
|  | GdkEventKey * | key_event
| ) |  |
| static

Definition at line 650 of file fl_view.cc.

651 {
652 FlView* self = FL_VIEW(widget);
653 return handle_key_event(self, key_event);
654 }

References handle_key_event().

Referenced by fl_view_class_init().

## ◆ fl_view_make_current()

static void fl_view_make_current | ( | FlRenderable * | renderable | ) |
| static

Definition at line 259 of file fl_view.cc.

259 {
260 FlView* self = FL_VIEW(renderable);
261 gtk_gl_area_make_current(self->gl_area);
262 }

Referenced by fl_renderable_iface_init().

## ◆ fl_view_new()

G_MODULE_EXPORT FlView* fl_view_new | ( | FlDartProject * | project | ) |

FlView:

#FlView is a GTK widget that is capable of displaying a Flutter application.

The following example shows how to set up a view in a GTK application: |[ FlDartProject *project = fl_dart_project_new (); FlView *view = fl_view_new (project); gtk_widget_show (GTK_WIDGET (view)); gtk_container_add (GTK_CONTAINER (parent), view);

FlBinaryMessenger *messenger = fl_engine_get_binary_messenger (fl_view_get_engine (view)); setup_channels_or_plugins (messenger); ]| fl_view_new: @project: The project to show.

Creates a widget to show a Flutter application.

Returns: a new #FlView.

Definition at line 751 of file fl_view.cc.

751 {
752 g_autoptr(FlEngine) engine = fl_engine_new(project);
753 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
754
755 self->view_id = flutter::kFlutterImplicitViewId;
756 self->engine = FL_ENGINE(g_object_ref(engine));
757
758 setup_engine(self);
759
760 g_signal_connect_swapped(self->gl_area, "create-context",
761 G_CALLBACK(create_context_cb), self);
762 g_signal_connect_swapped(self->gl_area, "realize", G_CALLBACK(realize_cb),
763 self);
764 g_signal_connect_swapped(self->gl_area, "unrealize", G_CALLBACK(unrealize_cb),
765 self);
766
767 fl_engine_set_implicit_view(engine, FL_RENDERABLE(self));
768
769 return self;
770 }
fl_engine_set_implicit_view
void fl_engine_set_implicit_view(FlEngine *self, FlRenderable *renderable)
Definition: fl_engine.cc:743
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:584
setup_engine
static void setup_engine(FlView *self)
Definition: fl_view.cc:676
create_context_cb
static GdkGLContext * create_context_cb(FlView *self)
Definition: fl_view.cc:440
realize_cb
static void realize_cb(FlView *self)
Definition: fl_view.cc:457
unrealize_cb
static void unrealize_cb(FlView *self)
Definition: fl_view.cc:515

References create_context_cb(), fl_engine_new(), fl_engine_set_implicit_view(), realize_cb(), setup_engine(), and unrealize_cb().

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_new_for_engine()

G_MODULE_EXPORT FlView* fl_view_new_for_engine | ( | FlEngine * | engine | ) |

fl_view_new_for_engine: @engine: an #FlEngine.

Creates a widget to show a window in a Flutter application. The engine must be not be headless.

Returns: a new #FlView.

Definition at line 772 of file fl_view.cc.

772 {
773 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
774
775 self->engine = FL_ENGINE(g_object_ref(engine));
776
777 self->view_id = fl_engine_add_view(engine, FL_RENDERABLE(self), 1, 1, 1.0,
778 self->cancellable, view_added_cb, self);
779
780 setup_engine(self);
781
782 g_signal_connect_swapped(self->gl_area, "realize",
783 G_CALLBACK(secondary_realize_cb), self);
784 return self;
785 }
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:750
secondary_realize_cb
static void secondary_realize_cb(FlView *self)
Definition: fl_view.cc:495
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:204

References fl_engine_add_view(), secondary_realize_cb(), setup_engine(), and view_added_cb().

Referenced by create_regular(), and TEST().

## ◆ fl_view_notify()

static void fl_view_notify | ( | GObject * | object,
|  | GParamSpec * | pspec
| ) |  |
| static

Definition at line 534 of file fl_view.cc.

534 {
535 FlView* self = FL_VIEW(object);
536
537 if (strcmp(pspec->name, "scale-factor") == 0) {
538 handle_geometry_changed(self);
539 }
540
541 if (G_OBJECT_CLASS(fl_view_parent_class)->notify != nullptr) {
542 G_OBJECT_CLASS(fl_view_parent_class)->notify(object, pspec);
543 }
544 }
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
handle_geometry_changed
static void handle_geometry_changed(FlView *self)
Definition: fl_view.cc:160

References handle_geometry_changed(), and pspec.

Referenced by fl_view_class_init().

## ◆ fl_view_plugin_registry_iface_init()

static void fl_view_plugin_registry_iface_init | ( | FlPluginRegistryInterface * | iface | ) |
| static

Definition at line 280 of file fl_view.cc.

281 {
282 iface->get_registrar_for_plugin = fl_view_get_registrar_for_plugin;
283 }
fl_view_get_registrar_for_plugin
static FlPluginRegistrar * fl_view_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_view.cc:265

References fl_view_get_registrar_for_plugin().

## ◆ fl_view_realize()

static void fl_view_realize | ( | GtkWidget * | widget | ) |
| static

Definition at line 588 of file fl_view.cc.

588 {
589 FlView* self = FL_VIEW(widget);
590
591 GTK_WIDGET_CLASS(fl_view_parent_class)->realize(widget);
592
593 // Realize the child widgets.
594 gtk_widget_realize(GTK_WIDGET(self->gl_area));
595 }

Referenced by fl_view_class_init().

## ◆ fl_view_redraw()

static void fl_view_redraw | ( | FlRenderable * | renderable | ) |
| static

Definition at line 245 of file fl_view.cc.

245 {
246 FlView* self = FL_VIEW(renderable);
247
248 gtk_widget_queue_draw(GTK_WIDGET(self->gl_area));
249
250 if (!self->have_first_frame) {
251 self->have_first_frame = TRUE;
252 // This is not the main thread, so the signal needs to be done via an idle
253 // callback.
254 g_idle_add(first_frame_idle_cb, self);
255 }
256 }

References TRUE.

Referenced by fl_renderable_iface_init().

## ◆ fl_view_set_background_color()

G_MODULE_EXPORT void fl_view_set_background_color | ( | FlView * | view,
|  | const GdkRGBA * | color
| ) |  |

fl_view_set_background_color: @view: an #FlView. @color: a background color.

Set the background color for Flutter (defaults to black).

Definition at line 798 of file fl_view.cc.

799 {
800 g_return_if_fail(FL_IS_VIEW(self));
801 gdk_rgba_free(self->background_color);
802 self->background_color = gdk_rgba_copy(color);
803 }

## ◆ 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) |
| ) |  |

Definition at line 83 of file fl_view.cc.

92 {
93 FlView* self = FL_VIEW(user_data);
94
95 g_signal_emit(self, fl_view_signals[SIGNAL_FIRST_FRAME], 0);
96
97 return FALSE;
98 }
g_signal_emit
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view, &window)
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90

References fl_view_signals, g_signal_emit(), SIGNAL_FIRST_FRAME, and user_data.

## ◆ gesture_rotation_begin_cb()

static void gesture_rotation_begin_cb | ( | FlView * | self | ) |
| static

Definition at line 413 of file fl_view.cc.

413 {
414 fl_scrolling_manager_handle_rotation_begin(self->scrolling_manager);
415 }
fl_scrolling_manager_handle_rotation_begin
void fl_scrolling_manager_handle_rotation_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:153

References fl_scrolling_manager_handle_rotation_begin().

Referenced by fl_view_init().

## ◆ gesture_rotation_end_cb()

static void gesture_rotation_end_cb | ( | FlView * | self | ) |
| static

Definition at line 424 of file fl_view.cc.

424 {
425 fl_scrolling_manager_handle_rotation_end(self->scrolling_manager);
426 }
fl_scrolling_manager_handle_rotation_end
void fl_scrolling_manager_handle_rotation_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:186

References fl_scrolling_manager_handle_rotation_end().

Referenced by fl_view_init().

## ◆ gesture_rotation_update_cb()

static void gesture_rotation_update_cb | ( | FlView * | self,
|  | gdouble | rotation,
|  | gdouble | delta
| ) |  |
| static

Definition at line 417 of file fl_view.cc.

419 {
420 fl_scrolling_manager_handle_rotation_update(self->scrolling_manager,
421 rotation);
422 }
fl_scrolling_manager_handle_rotation_update
void fl_scrolling_manager_handle_rotation_update(FlScrollingManager *self, gdouble rotation)
Definition: fl_scrolling_manager.cc:171

References fl_scrolling_manager_handle_rotation_update().

Referenced by fl_view_init().

## ◆ gesture_zoom_begin_cb()

static void gesture_zoom_begin_cb | ( | FlView * | self | ) |
| static

Definition at line 428 of file fl_view.cc.

428 {
429 fl_scrolling_manager_handle_zoom_begin(self->scrolling_manager);
430 }
fl_scrolling_manager_handle_zoom_begin
void fl_scrolling_manager_handle_zoom_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:202

References fl_scrolling_manager_handle_zoom_begin().

Referenced by fl_view_init().

## ◆ gesture_zoom_end_cb()

static void gesture_zoom_end_cb | ( | FlView * | self | ) |
| static

Definition at line 436 of file fl_view.cc.

436 {
437 fl_scrolling_manager_handle_zoom_end(self->scrolling_manager);
438 }
fl_scrolling_manager_handle_zoom_end
void fl_scrolling_manager_handle_zoom_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:235

References fl_scrolling_manager_handle_zoom_end().

Referenced by fl_view_init().

## ◆ gesture_zoom_update_cb()

static void gesture_zoom_update_cb | ( | FlView * | self,
|  | gdouble | scale
| ) |  |
| static

Definition at line 432 of file fl_view.cc.

432 {
433 fl_scrolling_manager_handle_zoom_update(self->scrolling_manager, scale);
434 }
fl_scrolling_manager_handle_zoom_update
void fl_scrolling_manager_handle_zoom_update(FlScrollingManager *self, gdouble scale)
Definition: fl_scrolling_manager.cc:220

References fl_scrolling_manager_handle_zoom_update().

Referenced by fl_view_init().

## ◆ get_device_kind()

static FlutterPointerDeviceKind get_device_kind | ( | GdkEvent * | event | ) |
| static

Definition at line 118 of file fl_view.cc.

118 {
119 GdkDevice* device = gdk_event_get_source_device(event);
120 GdkInputSource source = gdk_device_get_source(device);
121 switch (source) {
122 case GDK_SOURCE_PEN:
123 case GDK_SOURCE_ERASER:
124 case GDK_SOURCE_CURSOR:
125 case GDK_SOURCE_TABLET_PAD:
126 return kFlutterPointerDeviceKindStylus;
127 case GDK_SOURCE_TOUCHSCREEN:
128 return kFlutterPointerDeviceKindTouch;
129 case GDK_SOURCE_TOUCHPAD: // trackpad device type is reserved for gestures
130 case GDK_SOURCE_TRACKPOINT:
131 case GDK_SOURCE_KEYBOARD:
132 case GDK_SOURCE_MOUSE:
133 return kFlutterPointerDeviceKindMouse;
134 }
135 }

Referenced by button_press_event_cb(), button_release_event_cb(), enter_notify_event_cb(), leave_notify_event_cb(), and motion_notify_event_cb().

## ◆ handle_geometry_changed()

static void handle_geometry_changed | ( | FlView * | self | ) |
| static

Definition at line 160 of file fl_view.cc.

160 {
161 GtkAllocation allocation;
162 gtk_widget_get_allocation(GTK_WIDGET(self), &allocation);
163 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
164
165 // Note we can't detect if a window is moved between monitors - this
166 // information is provided by Wayland but GTK only notifies us if the scale
167 // has changed, so moving between two monitors of the same scale doesn't
168 // provide any information.
169
170 GdkWindow* window =
171 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
172 // NOTE(robert-ancell) If we haven't got a window we default to display 0.
173 // This is probably indicating a problem with this code in that we
174 // shouldn't be generating anything until the window is created.
175 // Another event with the correct display ID is generated soon after.
176 // I haven't changed this code in case there are side-effects but we
177 // probably shouldn't call handle_geometry_changed after the view is
178 // added but only when the window is realized.
179 FlutterEngineDisplayId display_id = 0;
180 if (window != nullptr) {
181 GdkMonitor* monitor = gdk_display_get_monitor_at_window(
182 gtk_widget_get_display(GTK_WIDGET(self)), window);
183 display_id = fl_display_monitor_get_display_id(
184 fl_engine_get_display_monitor(self->engine), monitor);
185 }
186 fl_engine_send_window_metrics_event(
187 self->engine, display_id, self->view_id, allocation.width * scale_factor,
188 allocation.height * scale_factor, scale_factor);
189
190 // Make sure the view has been realized and its size has been allocated before
191 // waiting for a frame. `fl_view_realize()` and `fl_view_size_allocate()` may
192 // be called in either order depending on the order in which the window is
193 // shown and the view is added to a container in the app runner.
194 //
195 // Note: `gtk_widget_init()` initializes the size allocation to 1x1.
196 if (allocation.width > 1 && allocation.height > 1 &&
197 gtk_widget_get_realized(GTK_WIDGET(self))) {
198 fl_compositor_wait_for_frame(fl_engine_get_compositor(self->engine),
199 allocation.width * scale_factor,
200 allocation.height * scale_factor);
201 }
202 }
fl_compositor_wait_for_frame
void fl_compositor_wait_for_frame(FlCompositor *self, int target_width, int target_height)
Definition: fl_compositor.cc:32
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_compositor
FlCompositor * fl_engine_get_compositor(FlEngine *self)
Definition: fl_engine.cc:598
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:967
fl_engine_get_display_monitor
FlDisplayMonitor * fl_engine_get_display_monitor(FlEngine *self)
Definition: fl_engine.cc:608

References fl_compositor_wait_for_frame(), fl_display_monitor_get_display_id(), fl_engine_get_compositor(), fl_engine_get_display_monitor(), fl_engine_send_window_metrics_event(), and window.

Referenced by fl_view_notify(), realize_cb(), size_allocate_cb(), and view_added_cb().

## ◆ handle_key_event()

static gboolean handle_key_event | ( | FlView * | self,
|  | GdkEventKey * | key_event
| ) |  |
| static

Definition at line 597 of file fl_view.cc.

597 {
598 g_autoptr(FlKeyEvent) event = fl_key_event_new_from_gdk_event(
599 gdk_event_copy(reinterpret_cast<GdkEvent*>(key_event)));
600
601 fl_keyboard_manager_handle_event(
602 fl_engine_get_keyboard_manager(self->engine), event, self->cancellable,
603 [](GObject* object, GAsyncResult* result, gpointer user_data) {
604 FlView* self = FL_VIEW(user_data);
605
606 g_autoptr(FlKeyEvent) redispatch_event = nullptr;
607 g_autoptr(GError) error = nullptr;
608 if (!fl_keyboard_manager_handle_event_finish(
609 FL_KEYBOARD_MANAGER(object), result, &redispatch_event,
610 &error)) {
611 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
612 return;
613 }
614
615 g_warning("Failed to handle key event: %s", error->message);
616 }
617
618 if (redispatch_event != nullptr) {
619 if (!fl_text_input_handler_filter_keypress(
620 fl_engine_get_text_input_handler(self->engine),
621 redispatch_event)) {
622 fl_keyboard_manager_add_redispatched_event(
623 fl_engine_get_keyboard_manager(self->engine), redispatch_event);
624 gdk_event_put(fl_key_event_get_origin(redispatch_event));
625 }
626 }
627 },
628 self);
629
630 return TRUE;
631 }
if
if(end==-1)
Definition: fl_accessible_text_field.cc:42
fl_engine_get_keyboard_manager
FlKeyboardManager * fl_engine_get_keyboard_manager(FlEngine *self)
Definition: fl_engine.cc:1324
fl_key_event_new_from_gdk_event
FlKeyEvent * fl_key_event_new_from_gdk_event(GdkEvent *event)
Definition: fl_key_event.cc:53
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_text_input_handler_filter_keypress
gboolean fl_text_input_handler_filter_keypress(FlTextInputHandler *self, FlKeyEvent *event)
Definition: fl_text_input_handler.cc:477

References fl_engine_get_keyboard_manager(), fl_engine_get_text_input_handler(), fl_key_event_new_from_gdk_event(), fl_keyboard_manager_handle_event(), fl_text_input_handler_filter_keypress(), if(), and user_data.

Referenced by fl_view_key_press_event(), and fl_view_key_release_event().

## ◆ init_scrolling()

static void init_scrolling | ( | FlView * | self | ) |
| static

Definition at line 107 of file fl_view.cc.

107 {
108 g_clear_object(&self->scrolling_manager);
109 self->scrolling_manager =
110 fl_scrolling_manager_new(self->engine, self->view_id);
111 }
fl_scrolling_manager_new
FlScrollingManager * fl_scrolling_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_scrolling_manager.cc:47

References fl_scrolling_manager_new().

Referenced by create_context_cb(), and on_pre_engine_restart_cb().

## ◆ init_touch()

static void init_touch | ( | FlView * | self | ) |
| static

Definition at line 113 of file fl_view.cc.

113 {
114 g_clear_object(&self->touch_manager);
115 self->touch_manager = fl_touch_manager_new(self->engine, self->view_id);
116 }
fl_touch_manager_new
FlTouchManager * fl_touch_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_touch_manager.cc:48

References fl_touch_manager_new().

Referenced by create_context_cb(), and on_pre_engine_restart_cb().

## ◆ leave_notify_event_cb()

static gboolean leave_notify_event_cb | ( | FlView * | self,
|  | GdkEventCrossing * | crossing_event
| ) |  |
| static

Definition at line 398 of file fl_view.cc.

399 {
400 if (crossing_event->mode != GDK_CROSSING_NORMAL) {
401 return FALSE;
402 }
403
404 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
405 gdouble x = 0.0, y = 0.0;
406 gdk_event_get_coords(event, &x, &y);
407 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
408 return fl_pointer_manager_handle_leave(
409 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
410 x * scale_factor, y * scale_factor);
411 }
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

References fl_pointer_manager_handle_leave(), and get_device_kind().

Referenced by fl_view_init().

## ◆ motion_notify_event_cb()

static gboolean motion_notify_event_cb | ( | FlView * | self,
|  | GdkEventMotion * | motion_event
| ) |  |
| static

Definition at line 365 of file fl_view.cc.

366 {
367 GdkEvent* event = reinterpret_cast<GdkEvent*>(motion_event);
368 sync_modifier_if_needed(self, event);
369
370 // return if touch event
371 auto event_type = gdk_event_get_event_type(event);
372 if (event_type == GDK_TOUCH_BEGIN || event_type == GDK_TOUCH_UPDATE ||
373 event_type == GDK_TOUCH_END || event_type == GDK_TOUCH_CANCEL) {
374 return FALSE;
375 }
376
377 gdouble x = 0.0, y = 0.0;
378 gdk_event_get_coords(event, &x, &y);
379 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
380 return fl_pointer_manager_handle_motion(
381 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
382 x * scale_factor, y * scale_factor);
383 }
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

References fl_pointer_manager_handle_motion(), get_device_kind(), and sync_modifier_if_needed().

Referenced by fl_view_init().

## ◆ on_pre_engine_restart_cb()

static void on_pre_engine_restart_cb | ( | FlView * | self | ) |
| static

Definition at line 239 of file fl_view.cc.

239 {
240 init_scrolling(self);
241 init_touch(self);
242 }

References init_scrolling(), and init_touch().

Referenced by setup_engine().

## ◆ realize_cb()

static void realize_cb | ( | FlView * | self | ) |
| static

Definition at line 457 of file fl_view.cc.

457 {
458 g_autoptr(GError) error = nullptr;
459
460 fl_opengl_manager_make_current(fl_engine_get_opengl_manager(self->engine));
461
462 GError* gl_error = gtk_gl_area_get_error(self->gl_area);
463 if (gl_error != NULL) {
464 g_warning("Failed to initialize GLArea: %s", gl_error->message);
465 return;
466 }
467
468 fl_compositor_opengl_setup(
469 FL_COMPOSITOR_OPENGL(fl_engine_get_compositor(self->engine)));
470
471 GtkWidget* toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(self));
472
473 self->window_state_monitor =
474 fl_window_state_monitor_new(fl_engine_get_binary_messenger(self->engine),
475 GTK_WINDOW(toplevel_window));
476
477 // Handle requests by the user to close the application.
478 g_signal_connect_swapped(toplevel_window, "delete-event",
479 G_CALLBACK(window_delete_event_cb), self);
480
481 // Flutter engine will need to make the context current from raster thread
482 // during initialization.
483 fl_opengl_manager_clear_current(fl_engine_get_opengl_manager(self->engine));
484
485 if (!fl_engine_start(self->engine, &error)) {
486 g_warning("Failed to start Flutter engine: %s", error->message);
487 return;
488 }
489
490 setup_cursor(self);
491
492 handle_geometry_changed(self);
493 }
fl_compositor_opengl_setup
void fl_compositor_opengl_setup(FlCompositorOpenGL *self)
Definition: fl_compositor_opengl.cc:582
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:613
fl_opengl_manager_clear_current
void fl_opengl_manager_clear_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:90
fl_opengl_manager_make_current
void fl_opengl_manager_make_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:82
setup_cursor
static void setup_cursor(FlView *self)
Definition: fl_view.cc:150
window_delete_event_cb
static gboolean window_delete_event_cb(FlView *self)
Definition: fl_view.cc:101
fl_window_state_monitor_new
FlWindowStateMonitor * fl_window_state_monitor_new(FlBinaryMessenger *messenger, GtkWindow *window)
Definition: fl_window_state_monitor.cc:104

References error, fl_compositor_opengl_setup(), fl_engine_get_binary_messenger(), fl_engine_get_compositor(), fl_engine_get_opengl_manager(), fl_engine_start(), fl_opengl_manager_clear_current(), fl_opengl_manager_make_current(), fl_window_state_monitor_new(), handle_geometry_changed(), setup_cursor(), and window_delete_event_cb().

Referenced by fl_view_new().

## ◆ render_cb()

static gboolean render_cb | ( | FlView * | self,
|  | GdkGLContext * | context
| ) |  |
| static

Definition at line 499 of file fl_view.cc.

499 {
500 if (gtk_gl_area_get_error(self->gl_area) != NULL) {
501 return FALSE;
502 }
503
504 int width = gtk_widget_get_allocated_width(GTK_WIDGET(self->gl_area));
505 int height = gtk_widget_get_allocated_height(GTK_WIDGET(self->gl_area));
506 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self->gl_area));
507 fl_compositor_opengl_render(
508 FL_COMPOSITOR_OPENGL(fl_engine_get_compositor(self->engine)),
509 self->view_id, width * scale_factor, height * scale_factor,
510 self->background_color);
511
512 return TRUE;
513 }
fl_compositor_opengl_render
void fl_compositor_opengl_render(FlCompositorOpenGL *self, FlutterViewId view_id, int width, int height, const GdkRGBA *background_color)
Definition: fl_compositor_opengl.cc:597
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

References fl_compositor_opengl_render(), fl_engine_get_compositor(), height, TRUE, and width.

Referenced by fl_view_init().

## ◆ scroll_event_cb()

static gboolean scroll_event_cb | ( | FlView * | self,
|  | GdkEventScroll * | event
| ) |  |
| static

Definition at line 347 of file fl_view.cc.

347 {
348 // TODO(robert-ancell): Update to use GtkEventControllerScroll when we can
349 // depend on GTK 3.24.
350
351 fl_scrolling_manager_handle_scroll_event(
352 self->scrolling_manager, event,
353 gtk_widget_get_scale_factor(GTK_WIDGET(self)));
354 return TRUE;
355 }
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

References fl_scrolling_manager_handle_scroll_event(), and TRUE.

Referenced by fl_view_init().

## ◆ secondary_realize_cb()

static void secondary_realize_cb | ( | FlView * | self | ) |
| static

Definition at line 495 of file fl_view.cc.

495 {
496 setup_cursor(self);
497 }

References setup_cursor().

Referenced by fl_view_new_for_engine().

## ◆ set_scrolling_position()

static void set_scrolling_position | ( | FlView * | self,
|  | gdouble | x,
|  | gdouble | y
| ) |  |
| static

Definition at line 293 of file fl_view.cc.

293 {
294 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
295 fl_scrolling_manager_set_last_mouse_position(
296 self->scrolling_manager, x * scale_factor, y * scale_factor);
297 }
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

References fl_scrolling_manager_set_last_mouse_position().

Referenced by button_press_event_cb(), and button_release_event_cb().

## ◆ setup_cursor()

static void setup_cursor | ( | FlView * | self | ) |
| static

Definition at line 150 of file fl_view.cc.

150 {
151 FlMouseCursorHandler* handler =
152 fl_engine_get_mouse_cursor_handler(self->engine);
153
154 self->cursor_changed_cb_id = g_signal_connect_swapped(
155 handler, "cursor-changed", G_CALLBACK(cursor_changed_cb), self);
156 cursor_changed_cb(self);
157 }
cursor_changed_cb
static void cursor_changed_cb(FlView *self)
Definition: fl_view.cc:138

References cursor_changed_cb(), and fl_engine_get_mouse_cursor_handler().

Referenced by realize_cb(), and secondary_realize_cb().

## ◆ setup_engine()

static void setup_engine | ( | FlView * | self | ) |
| static

Definition at line 676 of file fl_view.cc.

676 {
677 self->view_accessible = fl_view_accessible_new(self->engine, self->view_id);
678 fl_socket_accessible_embed(
679 FL_SOCKET_ACCESSIBLE(gtk_widget_get_accessible(GTK_WIDGET(self))),
680 atk_plug_get_id(ATK_PLUG(self->view_accessible)));
681
682 self->pointer_manager = fl_pointer_manager_new(self->view_id, self->engine);
683
684 self->on_pre_engine_restart_cb_id =
685 g_signal_connect_swapped(self->engine, "on-pre-engine-restart",
686 G_CALLBACK(on_pre_engine_restart_cb), self);
687 self->update_semantics_cb_id = g_signal_connect_swapped(
688 self->engine, "update-semantics", G_CALLBACK(update_semantics_cb), self);
689 }
fl_pointer_manager_new
FlPointerManager * fl_pointer_manager_new(FlutterViewId view_id, FlEngine *engine)
Definition: fl_pointer_manager.cc:94
fl_socket_accessible_embed
void fl_socket_accessible_embed(FlSocketAccessible *self, gchar *id)
Definition: fl_socket_accessible.cc:55
on_pre_engine_restart_cb
static void on_pre_engine_restart_cb(FlView *self)
Definition: fl_view.cc:239
update_semantics_cb
static void update_semantics_cb(FlView *self, const FlutterSemanticsUpdate2 *update)
Definition: fl_view.cc:224
fl_view_accessible_new
FlViewAccessible * fl_view_accessible_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_view_accessible.cc:134

References fl_pointer_manager_new(), fl_socket_accessible_embed(), fl_view_accessible_new(), on_pre_engine_restart_cb(), and update_semantics_cb().

Referenced by fl_view_new(), and fl_view_new_for_engine().

## ◆ size_allocate_cb()

static void size_allocate_cb | ( | FlView * | self | ) |
| static

Definition at line 530 of file fl_view.cc.

530 {
531 handle_geometry_changed(self);
532 }

References handle_geometry_changed().

Referenced by fl_view_init().

## ◆ sync_modifier_if_needed()

static void sync_modifier_if_needed | ( | FlView * | self,
|  | GdkEvent * | event
| ) |  |
| static

Definition at line 285 of file fl_view.cc.

285 {
286 guint event_time = gdk_event_get_time(event);
287 GdkModifierType event_state = static_cast<GdkModifierType>(0);
288 gdk_event_get_state(event, &event_state);
289 fl_keyboard_manager_sync_modifier_if_needed(
290 fl_engine_get_keyboard_manager(self->engine), event_state, event_time);
291 }
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

References fl_engine_get_keyboard_manager(), and fl_keyboard_manager_sync_modifier_if_needed().

Referenced by button_press_event_cb(), button_release_event_cb(), and motion_notify_event_cb().

## ◆ touch_event_cb()

static gboolean touch_event_cb | ( | FlView * | self,
|  | GdkEventTouch * | event
| ) |  |
| static

Definition at line 357 of file fl_view.cc.

357 {
358 fl_touch_manager_handle_touch_event(
359 self->touch_manager, event,
360 gtk_widget_get_scale_factor(GTK_WIDGET(self)));
361 return TRUE;
362 }
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

References fl_touch_manager_handle_touch_event(), and TRUE.

Referenced by fl_view_init().

## ◆ unrealize_cb()

static void unrealize_cb | ( | FlView * | self | ) |
| static

Definition at line 515 of file fl_view.cc.

515 {
516 g_autoptr(GError) error = nullptr;
517
518 fl_opengl_manager_make_current(fl_engine_get_opengl_manager(self->engine));
519
520 GError* gl_error = gtk_gl_area_get_error(self->gl_area);
521 if (gl_error != NULL) {
522 g_warning("Failed to uninitialize GLArea: %s", gl_error->message);
523 return;
524 }
525
526 fl_compositor_opengl_cleanup(
527 FL_COMPOSITOR_OPENGL(fl_engine_get_compositor(self->engine)));
528 }
fl_compositor_opengl_cleanup
void fl_compositor_opengl_cleanup(FlCompositorOpenGL *self)
Definition: fl_compositor_opengl.cc:617

References error, fl_compositor_opengl_cleanup(), fl_engine_get_compositor(), fl_engine_get_opengl_manager(), and fl_opengl_manager_make_current().

Referenced by fl_view_new().

## ◆ update_semantics_cb()

static void update_semantics_cb | ( | FlView * | self,
|  | const FlutterSemanticsUpdate2 * | update
| ) |  |
| static

Definition at line 224 of file fl_view.cc.

225 {
226 // A semantics update is routed to a particular view.
227 if (update->view_id != self->view_id) {
228 return;
229 }
230
231 fl_view_accessible_handle_update_semantics(self->view_accessible, update);
232 }
fl_view_accessible_handle_update_semantics
void fl_view_accessible_handle_update_semantics(FlViewAccessible *self, const FlutterSemanticsUpdate2 *update)
Definition: fl_view_accessible.cc:143

References fl_view_accessible_handle_update_semantics().

Referenced by setup_engine().

## ◆ view_added_cb()

static void view_added_cb | ( | GObject * | object,
|  | GAsyncResult * | result,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 204 of file fl_view.cc.

206 {
207 FlView* self = FL_VIEW(user_data);
208
209 g_autoptr(GError) error = nullptr;
210 if (!fl_engine_add_view_finish(FL_ENGINE(object), result, &error)) {
211 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
212 return;
213 }
214
215 g_warning("Failed to add view: %s", error->message);
216 // FIXME: Show on the GLArea
217 return;
218 }
219
220 handle_geometry_changed(self);
221 }
fl_engine_add_view_finish
gboolean fl_engine_add_view_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:799

References error, fl_engine_add_view_finish(), handle_geometry_changed(), and user_data.

Referenced by fl_view_new_for_engine().

## ◆ window_delete_event_cb()

static gboolean window_delete_event_cb | ( | FlView * | self | ) |
| static

Definition at line 101 of file fl_view.cc.

101 {
102 fl_engine_request_app_exit(self->engine);
103 // Stop the event from propagating.
104 return TRUE;
105 }
fl_engine_request_app_exit
void fl_engine_request_app_exit(FlEngine *self)
Definition: fl_engine.cc:1314

References fl_engine_request_app_exit(), and TRUE.

Referenced by realize_cb().

## Variable Documentation

## ◆ fl_view_signals

guint fl_view_signals[LAST_SIGNAL]
| static

Definition at line 76 of file fl_view.cc.

Referenced by fl_view_class_init(), and G_DEFINE_TYPE_WITH_CODE().