Flutter Engine
fl_view.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"
#include "flutter/shell/platform/linux/fl_view_private.h"
#include <cstring>
#include "flutter/shell/platform/linux/fl_accessibility_plugin.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_keyboard_manager.h"
#include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h"
#include "flutter/shell/platform/linux/fl_mouse_cursor_plugin.h"
#include "flutter/shell/platform/linux/fl_platform_plugin.h"
#include "flutter/shell/platform/linux/fl_plugin_registrar_private.h"
#include "flutter/shell/platform/linux/fl_renderer_gl.h"
#include "flutter/shell/platform/linux/fl_scrolling_manager.h"
#include "flutter/shell/platform/linux/fl_scrolling_view_delegate.h"
#include "flutter/shell/platform/linux/fl_text_input_plugin.h"
#include "flutter/shell/platform/linux/fl_view_accessible.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
 
struct  _FlViewChild
 
struct  _ReorderData
 

Typedefs

typedef struct _FlViewChild FlViewChild
 

Enumerations

enum  {
  kPropFlutterProject = 1,
  kPropLast
}
 

Functions

static void fl_view_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
 
static void fl_view_keyboard_delegate_iface_init (FlKeyboardViewDelegateInterface *iface)
 
static void fl_view_scrolling_delegate_iface_init (FlScrollingViewDelegateInterface *iface)
 
 G_DEFINE_TYPE_WITH_CODE (FlView, fl_view, GTK_TYPE_CONTAINER, G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_view_plugin_registry_iface_init) G_IMPLEMENT_INTERFACE(fl_keyboard_view_delegate_get_type(), fl_view_keyboard_delegate_iface_init) G_IMPLEMENT_INTERFACE(fl_scrolling_view_delegate_get_type(), fl_view_scrolling_delegate_iface_init)) static void init_keyboard(FlView *self)
 
static void init_scrolling (FlView *self)
 
static gboolean send_pointer_button_event (FlView *self, GdkEventButton *event)
 
static void check_pointer_inside (FlView *view, GdkEvent *event)
 
static void handle_geometry_changed (FlView *self)
 
static void add_pending_child (FlView *self, GtkWidget *widget, GdkRectangle *geometry)
 
static GList * find_child (GList *list, GtkWidget *widget)
 
static void update_semantics_node_cb (FlEngine *engine, const FlutterSemanticsNode *node, gpointer user_data)
 
static void on_pre_engine_restart_cb (FlEngine *engine, gpointer user_data)
 
static FlPluginRegistrar * fl_view_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
 
static gboolean button_press_event_cb (GtkWidget *widget, GdkEventButton *event, FlView *view)
 
static gboolean button_release_event_cb (GtkWidget *widget, GdkEventButton *event, FlView *view)
 
static gboolean scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, FlView *view)
 
static gboolean motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, FlView *view)
 
static gboolean enter_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, FlView *view)
 
static gboolean leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, FlView *view)
 
static void keymap_keys_changed_cb (GdkKeymap *self, FlView *view)
 
static void gesture_rotation_begin_cb (GtkGestureRotate *gesture, GdkEventSequence *sequence, FlView *view)
 
static void gesture_rotation_update_cb (GtkGestureRotate *widget, gdouble rotation, gdouble delta, FlView *view)
 
static void gesture_rotation_end_cb (GtkGestureRotate *gesture, GdkEventSequence *sequence, FlView *view)
 
static void gesture_zoom_begin_cb (GtkGestureZoom *gesture, GdkEventSequence *sequence, FlView *view)
 
static void gesture_zoom_update_cb (GtkGestureZoom *widget, gdouble scale, FlView *view)
 
static void gesture_zoom_end_cb (GtkGestureZoom *gesture, GdkEventSequence *sequence, FlView *view)
 
static void fl_view_constructed (GObject *object)
 
static void fl_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 
static void fl_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 
static void fl_view_notify (GObject *object, GParamSpec *pspec)
 
static void fl_view_dispose (GObject *object)
 
static void fl_view_realize (GtkWidget *widget)
 
static void fl_view_get_preferred_width (GtkWidget *widget, gint *minimum, gint *natural)
 
static void fl_view_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural)
 
static void fl_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 
static void fl_view_reorder_forall (GtkWidget *widget, gpointer user_data)
 
static gboolean fl_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
 
static gboolean fl_view_key_release_event (GtkWidget *widget, GdkEventKey *event)
 
static void put_widget (FlView *self, GtkWidget *widget, GdkRectangle *geometry)
 
static void fl_view_add (GtkContainer *container, GtkWidget *widget)
 
static void fl_view_remove (GtkContainer *container, GtkWidget *widget)
 
static void fl_view_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
 
static GType fl_view_child_type (GtkContainer *container)
 
static void fl_view_set_child_property (GtkContainer *container, GtkWidget *child, guint property_id, const GValue *value, GParamSpec *pspec)
 
static void fl_view_get_child_property (GtkContainer *container, GtkWidget *child, guint property_id, GValue *value, GParamSpec *pspec)
 
static void fl_view_class_init (FlViewClass *klass)
 
static void fl_view_init (FlView *self)
 
G_MODULE_EXPORT FlView * fl_view_new (FlDartProject *project)
 
G_MODULE_EXPORT FlEngine * fl_view_get_engine (FlView *view)
 
void fl_view_begin_frame (FlView *view)
 
void fl_view_add_gl_area (FlView *view, GdkGLContext *context, FlBackingStoreProvider *texture)
 
void fl_view_add_widget (FlView *view, GtkWidget *widget, GdkRectangle *geometry)
 
void fl_view_end_frame (FlView *view)
 

Variables

static constexpr int kMicrosecondsPerMillisecond = 1000
 

Typedef Documentation

◆ FlViewChild

typedef struct _FlViewChild FlViewChild

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kPropFlutterProject 
kPropLast 

Definition at line 73 of file fl_view.cc.

Function Documentation

◆ add_pending_child()

static void add_pending_child ( FlView *  self,
GtkWidget *  widget,
GdkRectangle *  geometry 
)
static

Definition at line 197 of file fl_view.cc.

References _FlViewChild::geometry, and _FlViewChild::widget.

Referenced by fl_view_add_gl_area(), and fl_view_add_widget().

199  {
200  FlViewChild* child = g_new(FlViewChild, 1);
201  child->widget = widget;
202  if (geometry) {
203  child->geometry = *geometry;
204  } else {
205  child->geometry = {0, 0, 0, 0};
206  }
207 
208  self->pending_children_list =
209  g_list_append(self->pending_children_list, child);
210 }
GtkWidget * widget
Definition: fl_view.cc:69
GdkRectangle geometry
Definition: fl_view.cc:70

◆ button_press_event_cb()

static gboolean button_press_event_cb ( GtkWidget *  widget,
GdkEventButton *  event,
FlView *  view 
)
static

Definition at line 335 of file fl_view.cc.

References FALSE, and send_pointer_button_event().

Referenced by fl_view_constructed().

337  {
338  // Flutter doesn't handle double and triple click events.
339  if (event->type == GDK_DOUBLE_BUTTON_PRESS ||
340  event->type == GDK_TRIPLE_BUTTON_PRESS) {
341  return FALSE;
342  }
343 
344  if (!gtk_widget_has_focus(GTK_WIDGET(view))) {
345  gtk_widget_grab_focus(GTK_WIDGET(view));
346  }
347 
348  return send_pointer_button_event(view, event);
349 }
FlKeyEvent * event
static gboolean send_pointer_button_event(FlView *self, GdkEventButton *event)
Definition: fl_view.cc:115
return FALSE

◆ button_release_event_cb()

static gboolean button_release_event_cb ( GtkWidget *  widget,
GdkEventButton *  event,
FlView *  view 
)
static

Definition at line 352 of file fl_view.cc.

References send_pointer_button_event().

Referenced by fl_view_constructed().

354  {
355  return send_pointer_button_event(view, event);
356 }
FlKeyEvent * event
static gboolean send_pointer_button_event(FlView *self, GdkEventButton *event)
Definition: fl_view.cc:115

◆ check_pointer_inside()

static void check_pointer_inside ( FlView *  view,
GdkEvent *  event 
)
static

Definition at line 167 of file fl_view.cc.

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

Referenced by enter_notify_event_cb(), and motion_notify_event_cb().

167  {
168  if (!view->pointer_inside) {
169  view->pointer_inside = TRUE;
170 
171  gdouble x, y;
172  if (gdk_event_get_coords(event, &x, &y)) {
173  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(view));
174 
176  view->engine, kAdd,
177  gdk_event_get_time(event) * kMicrosecondsPerMillisecond,
178  x * scale_factor, y * scale_factor, 0, 0, view->button_state);
179  }
180  }
181 }
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:27
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterPointerPhase phase, size_t timestamp, double x, double y, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:710
Definition: embedder.h:736

◆ enter_notify_event_cb()

static gboolean enter_notify_event_cb ( GtkWidget *  widget,
GdkEventCrossing *  event,
FlView *  view 
)
static

Definition at line 391 of file fl_view.cc.

References check_pointer_inside(), FALSE, and TRUE.

Referenced by fl_view_constructed().

393  {
394  if (view->engine == nullptr) {
395  return FALSE;
396  }
397 
398  check_pointer_inside(view, reinterpret_cast<GdkEvent*>(event));
399 
400  return TRUE;
401 }
FlKeyEvent * event
static void check_pointer_inside(FlView *view, GdkEvent *event)
Definition: fl_view.cc:167
return FALSE

◆ find_child()

static GList* find_child ( GList *  list,
GtkWidget *  widget 
)
static

Definition at line 213 of file fl_view.cc.

References _FlViewChild::widget.

Referenced by fl_view_end_frame().

213  {
214  for (GList* i = list; i; i = i->next) {
215  FlViewChild* child = reinterpret_cast<FlViewChild*>(i->data);
216  if (child && child->widget == widget)
217  return i;
218  }
219  return nullptr;
220 }
GtkWidget * widget
Definition: fl_view.cc:69

◆ fl_view_add()

static void fl_view_add ( GtkContainer *  container,
GtkWidget *  widget 
)
static

Definition at line 784 of file fl_view.cc.

References put_widget().

Referenced by fl_view_class_init().

784  {
785  GdkRectangle geometry = {
786  .x = 0,
787  .y = 0,
788  .width = 0,
789  .height = 0,
790  };
791  put_widget(FL_VIEW(container), widget, &geometry);
792 }
static void put_widget(FlView *self, GtkWidget *widget, GdkRectangle *geometry)
Definition: fl_view.cc:772

◆ fl_view_add_gl_area()

void fl_view_add_gl_area ( FlView *  view,
GdkGLContext *  context,
FlBackingStoreProvider *  texture 
)

fl_view_add_gl_area: : an #FlView. : (transfer full): a #GdkGLContext, for #FlGLArea to render. : (transfer full): texture for OpenGL area to render.

Append an #FlGLArea at top of stacked children of #FlView. This function must be called after fl_view_begin_frame, and before fl_view_end_frame.

Definition at line 913 of file fl_view.cc.

References add_pending_child(), fl_gl_area_new(), and fl_gl_area_queue_render().

Referenced by fl_renderer_gl_present_layers().

915  {
916  g_return_if_fail(FL_IS_VIEW(view));
917 
918  FlGLArea* area;
919  if (view->used_area_list) {
920  area = reinterpret_cast<FlGLArea*>(view->used_area_list->data);
921  view->used_area_list = view->used_area_list->next;
922  } else {
923  area = FL_GL_AREA(fl_gl_area_new(context));
924  view->gl_area_list = g_list_append(view->gl_area_list, area);
925  }
926 
927  gtk_widget_show(GTK_WIDGET(area));
928  add_pending_child(view, GTK_WIDGET(area), nullptr);
930 }
static void add_pending_child(FlView *self, GtkWidget *widget, GdkRectangle *geometry)
Definition: fl_view.cc:197
GtkWidget * fl_gl_area_new(GdkGLContext *context)
Definition: fl_gl_area.cc:119
void fl_gl_area_queue_render(FlGLArea *self, FlBackingStoreProvider *texture)
Definition: fl_gl_area.cc:127
FlTexture * texture

◆ fl_view_add_widget()

void fl_view_add_widget ( FlView *  view,
GtkWidget *  widget,
GdkRectangle *  geometry 
)

fl_view_add_widget: : an #FlView. : a #GtkWidget. : geometry of the widget.

Append a #GtkWidget at top of stacked children of #FlView.

Definition at line 932 of file fl_view.cc.

References add_pending_child().

934  {
935  gtk_widget_show(widget);
936  add_pending_child(view, widget, geometry);
937 }
static void add_pending_child(FlView *self, GtkWidget *widget, GdkRectangle *geometry)
Definition: fl_view.cc:197

◆ fl_view_begin_frame()

void fl_view_begin_frame ( FlView *  view)

fl_view_begin_frame: : an #FlView.

Reset children of #FlView a stacked #GtkContainer. This function is always paired with fl_view_end_frame.

Definition at line 904 of file fl_view.cc.

Referenced by fl_renderer_gl_present_layers().

904  {
905  g_return_if_fail(FL_IS_VIEW(view));
906  FlView* self = FL_VIEW(view);
907 
908  self->used_area_list = self->gl_area_list;
909  g_list_free_full(self->pending_children_list, g_free);
910  self->pending_children_list = nullptr;
911 }

◆ fl_view_child_type()

static GType fl_view_child_type ( GtkContainer *  container)
static

Definition at line 836 of file fl_view.cc.

Referenced by fl_view_class_init().

836  {
837  return GTK_TYPE_WIDGET;
838 }

◆ fl_view_class_init()

static void fl_view_class_init ( FlViewClass *  klass)
static

Definition at line 854 of file fl_view.cc.

References fl_view_add(), fl_view_child_type(), fl_view_constructed(), fl_view_dispose(), fl_view_forall(), fl_view_get_child_property(), fl_view_get_preferred_height(), fl_view_get_preferred_width(), fl_view_get_property(), fl_view_key_press_event(), fl_view_key_release_event(), fl_view_notify(), fl_view_realize(), fl_view_remove(), fl_view_set_child_property(), fl_view_set_property(), fl_view_size_allocate(), and kPropFlutterProject.

854  {
855  GObjectClass* object_class = G_OBJECT_CLASS(klass);
856  object_class->constructed = fl_view_constructed;
857  object_class->set_property = fl_view_set_property;
858  object_class->get_property = fl_view_get_property;
859  object_class->notify = fl_view_notify;
860  object_class->dispose = fl_view_dispose;
861 
862  GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
863  widget_class->realize = fl_view_realize;
864  widget_class->get_preferred_width = fl_view_get_preferred_width;
865  widget_class->get_preferred_height = fl_view_get_preferred_height;
866  widget_class->size_allocate = fl_view_size_allocate;
867  widget_class->key_press_event = fl_view_key_press_event;
868  widget_class->key_release_event = fl_view_key_release_event;
869 
870  GtkContainerClass* container_class = GTK_CONTAINER_CLASS(klass);
871  container_class->add = fl_view_add;
872  container_class->remove = fl_view_remove;
873  container_class->forall = fl_view_forall;
874  container_class->child_type = fl_view_child_type;
875  container_class->set_child_property = fl_view_set_child_property;
876  container_class->get_child_property = fl_view_get_child_property;
877 
878  g_object_class_install_property(
879  G_OBJECT_CLASS(klass), kPropFlutterProject,
880  g_param_spec_object(
881  "flutter-project", "flutter-project", "Flutter project in use",
882  fl_dart_project_get_type(),
883  static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
884  G_PARAM_STATIC_STRINGS)));
885 
886  gtk_widget_class_set_accessible_type(GTK_WIDGET_CLASS(klass),
887  fl_view_accessible_get_type());
888 }
static void fl_view_get_child_property(GtkContainer *container, GtkWidget *child, guint property_id, GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:848
static void fl_view_dispose(GObject *object)
Definition: fl_view.cc:572
static void fl_view_constructed(GObject *object)
Definition: fl_view.cc:472
static void fl_view_notify(GObject *object, GParamSpec *pspec)
Definition: fl_view.cc:560
static void fl_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:527
static void fl_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:544
static void fl_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
Definition: fl_view.cc:685
static void fl_view_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
Definition: fl_view.cc:819
static void fl_view_realize(GtkWidget *widget)
Definition: fl_view.cc:596
static void fl_view_get_preferred_height(GtkWidget *widget, gint *minimum, gint *natural)
Definition: fl_view.cc:660
static gboolean fl_view_key_release_event(GtkWidget *widget, GdkEventKey *event)
Definition: fl_view.cc:764
static GType fl_view_child_type(GtkContainer *container)
Definition: fl_view.cc:836
static void fl_view_set_child_property(GtkContainer *container, GtkWidget *child, guint property_id, const GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:841
static void fl_view_add(GtkContainer *container, GtkWidget *widget)
Definition: fl_view.cc:784
static void fl_view_remove(GtkContainer *container, GtkWidget *widget)
Definition: fl_view.cc:795
static void fl_view_get_preferred_width(GtkWidget *widget, gint *minimum, gint *natural)
Definition: fl_view.cc:635
static gboolean fl_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
Definition: fl_view.cc:755

◆ fl_view_constructed()

static void fl_view_constructed ( GObject *  object)
static

Definition at line 472 of file fl_view.cc.

References button_press_event_cb(), button_release_event_cb(), enter_notify_event_cb(), fl_accessibility_plugin_new(), fl_engine_get_binary_messenger(), fl_engine_new(), fl_engine_set_on_pre_engine_restart_handler(), fl_engine_set_update_semantics_node_handler(), fl_mouse_cursor_plugin_new(), fl_platform_plugin_new(), fl_renderer_gl_new(), gesture_rotation_begin_cb(), gesture_rotation_end_cb(), gesture_rotation_update_cb(), gesture_zoom_begin_cb(), gesture_zoom_end_cb(), gesture_zoom_update_cb(), init_scrolling(), keymap_keys_changed_cb(), leave_notify_event_cb(), motion_notify_event_cb(), on_pre_engine_restart_cb(), scroll_event_cb(), and update_semantics_node_cb().

Referenced by fl_view_class_init().

472  {
473  FlView* self = FL_VIEW(object);
474 
475  self->renderer = FL_RENDERER(fl_renderer_gl_new());
476  self->engine = fl_engine_new(self->project, self->renderer);
478  self->engine, update_semantics_node_cb, self, nullptr);
480  self->engine, on_pre_engine_restart_cb, self, nullptr);
481 
482  // Must initialize the keymap before the keyboard.
483  self->keymap = gdk_keymap_get_for_display(gdk_display_get_default());
484 
485  // Create system channel handlers.
486  FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
487  self->accessibility_plugin = fl_accessibility_plugin_new(self);
488  init_scrolling(self);
489  self->mouse_cursor_plugin = fl_mouse_cursor_plugin_new(messenger, self);
490  self->platform_plugin = fl_platform_plugin_new(messenger);
491 
492  self->event_box = gtk_event_box_new();
493  gtk_widget_set_parent(self->event_box, GTK_WIDGET(self));
494  gtk_widget_show(self->event_box);
495  gtk_widget_add_events(self->event_box,
496  GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
497  GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK |
498  GDK_SMOOTH_SCROLL_MASK);
499 
500  g_signal_connect(self->event_box, "button-press-event",
501  G_CALLBACK(button_press_event_cb), self);
502  g_signal_connect(self->event_box, "button-release-event",
503  G_CALLBACK(button_release_event_cb), self);
504  g_signal_connect(self->event_box, "scroll-event", G_CALLBACK(scroll_event_cb),
505  self);
506  g_signal_connect(self->event_box, "motion-notify-event",
507  G_CALLBACK(motion_notify_event_cb), self);
508  g_signal_connect(self->event_box, "enter-notify-event",
509  G_CALLBACK(enter_notify_event_cb), self);
510  g_signal_connect(self->event_box, "leave-notify-event",
511  G_CALLBACK(leave_notify_event_cb), self);
512  g_signal_connect(self->keymap, "keys-changed",
513  G_CALLBACK(keymap_keys_changed_cb), self);
514  GtkGesture* zoom = gtk_gesture_zoom_new(self->event_box);
515  g_signal_connect(zoom, "begin", G_CALLBACK(gesture_zoom_begin_cb), self);
516  g_signal_connect(zoom, "scale-changed", G_CALLBACK(gesture_zoom_update_cb),
517  self);
518  g_signal_connect(zoom, "end", G_CALLBACK(gesture_zoom_end_cb), self);
519  GtkGesture* rotate = gtk_gesture_rotate_new(self->event_box);
520  g_signal_connect(rotate, "begin", G_CALLBACK(gesture_rotation_begin_cb),
521  self);
522  g_signal_connect(rotate, "angle-changed",
523  G_CALLBACK(gesture_rotation_update_cb), self);
524  g_signal_connect(rotate, "end", G_CALLBACK(gesture_rotation_end_cb), self);
525 }
static gboolean leave_notify_event_cb(GtkWidget *widget, GdkEventCrossing *event, FlView *view)
Definition: fl_view.cc:404
static void gesture_rotation_update_cb(GtkGestureRotate *widget, gdouble rotation, gdouble delta, FlView *view)
Definition: fl_view.cc:440
static gboolean motion_notify_event_cb(GtkWidget *widget, GdkEventMotion *event, FlView *view)
Definition: fl_view.cc:372
FlMouseCursorPlugin * fl_mouse_cursor_plugin_new(FlBinaryMessenger *messenger, FlView *view)
static void init_scrolling(FlView *self)
Definition: fl_view.cc:109
static void gesture_zoom_end_cb(GtkGestureZoom *gesture, GdkEventSequence *sequence, FlView *view)
Definition: fl_view.cc:466
FlRendererGL * fl_renderer_gl_new()
static void gesture_zoom_begin_cb(GtkGestureZoom *gesture, GdkEventSequence *sequence, FlView *view)
Definition: fl_view.cc:454
static gboolean enter_notify_event_cb(GtkWidget *widget, GdkEventCrossing *event, FlView *view)
Definition: fl_view.cc:391
void fl_engine_set_on_pre_engine_restart_handler(FlEngine *self, FlEngineOnPreEngineRestartHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:575
static void gesture_rotation_begin_cb(GtkGestureRotate *gesture, GdkEventSequence *sequence, FlView *view)
Definition: fl_view.cc:434
static gboolean button_press_event_cb(GtkWidget *widget, GdkEventButton *event, FlView *view)
Definition: fl_view.cc:335
static void gesture_rotation_end_cb(GtkGestureRotate *gesture, GdkEventSequence *sequence, FlView *view)
Definition: fl_view.cc:448
static void update_semantics_node_cb(FlEngine *engine, const FlutterSemanticsNode *node, gpointer user_data)
Definition: fl_view.cc:223
static void keymap_keys_changed_cb(GdkKeymap *self, FlView *view)
Definition: fl_view.cc:426
FlEngine * fl_engine_new(FlDartProject *project, FlRenderer *renderer)
Definition: fl_engine.cc:412
FlPlatformPlugin * fl_platform_plugin_new(FlBinaryMessenger *messenger)
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:826
static void on_pre_engine_restart_cb(FlEngine *engine, gpointer user_data)
Definition: fl_view.cc:237
void fl_engine_set_update_semantics_node_handler(FlEngine *self, FlEngineUpdateSemanticsNodeHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:558
static void gesture_zoom_update_cb(GtkGestureZoom *widget, gdouble scale, FlView *view)
Definition: fl_view.cc:460
FlAccessibilityPlugin * fl_accessibility_plugin_new(FlView *view)
static gboolean scroll_event_cb(GtkWidget *widget, GdkEventScroll *event, FlView *view)
Definition: fl_view.cc:359
static gboolean button_release_event_cb(GtkWidget *widget, GdkEventButton *event, FlView *view)
Definition: fl_view.cc:352

◆ fl_view_dispose()

static void fl_view_dispose ( GObject *  object)
static

Definition at line 572 of file fl_view.cc.

References fl_engine_set_on_pre_engine_restart_handler(), and fl_engine_set_update_semantics_node_handler().

Referenced by fl_view_class_init().

572  {
573  FlView* self = FL_VIEW(object);
574 
575  if (self->engine != nullptr) {
576  fl_engine_set_update_semantics_node_handler(self->engine, nullptr, nullptr,
577  nullptr);
578  fl_engine_set_on_pre_engine_restart_handler(self->engine, nullptr, nullptr,
579  nullptr);
580  }
581 
582  g_clear_object(&self->project);
583  g_clear_object(&self->renderer);
584  g_clear_object(&self->engine);
585  g_clear_object(&self->accessibility_plugin);
586  g_clear_object(&self->keyboard_manager);
587  g_clear_object(&self->mouse_cursor_plugin);
588  g_clear_object(&self->platform_plugin);
589  g_list_free_full(self->gl_area_list, g_object_unref);
590  self->gl_area_list = nullptr;
591 
592  G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
593 }
void fl_engine_set_on_pre_engine_restart_handler(FlEngine *self, FlEngineOnPreEngineRestartHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:575
void fl_engine_set_update_semantics_node_handler(FlEngine *self, FlEngineUpdateSemanticsNodeHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:558

◆ fl_view_end_frame()

void fl_view_end_frame ( FlView *  view)

fl_view_end_frame: : an #FlView.

Apply changes made by fl_view_add_gl_area and fl_view_add_widget.

Definition at line 939 of file fl_view.cc.

References find_child(), fl_view_reorder_forall(), _ReorderData::parent_window, and _FlViewChild::widget.

Referenced by fl_renderer_gl_present_layers().

939  {
940  for (GList* pending_child = view->pending_children_list; pending_child;
941  pending_child = pending_child->next) {
942  FlViewChild* pending_view_child =
943  reinterpret_cast<FlViewChild*>(pending_child->data);
944  GList* child = find_child(view->children_list, pending_view_child->widget);
945 
946  if (child) {
947  // existing child
948  g_free(child->data);
949  child->data = nullptr;
950  } else {
951  // newly added child
952  gtk_widget_set_parent(pending_view_child->widget, GTK_WIDGET(view));
953  }
954  }
955 
956  for (GList* child = view->children_list; child; child = child->next) {
957  FlViewChild* view_child = reinterpret_cast<FlViewChild*>(child->data);
958  if (view_child) {
959  // removed child
960  g_object_ref(view_child->widget);
961  gtk_widget_unparent(view_child->widget);
962  g_free(view_child);
963  child->data = nullptr;
964  }
965  }
966 
967  g_list_free(view->children_list);
968  view->children_list = view->pending_children_list;
969  view->pending_children_list = nullptr;
970 
971  struct _ReorderData data = {
972  .parent_window = gtk_widget_get_window(GTK_WIDGET(view)),
973  .last_window = nullptr,
974  };
975 
976  gtk_container_forall(GTK_CONTAINER(view), fl_view_reorder_forall, &data);
977 
978  gtk_widget_queue_draw(GTK_WIDGET(view));
979 }
static void fl_view_reorder_forall(GtkWidget *widget, gpointer user_data)
Definition: fl_view.cc:743
static GList * find_child(GList *list, GtkWidget *widget)
Definition: fl_view.cc:213
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
GtkWidget * widget
Definition: fl_view.cc:69

◆ fl_view_forall()

static void fl_view_forall ( GtkContainer *  container,
gboolean  include_internals,
GtkCallback  callback,
gpointer  callback_data 
)
static

Definition at line 819 of file fl_view.cc.

References _FlViewChild::widget.

Referenced by fl_view_class_init().

822  {
823  FlView* self = FL_VIEW(container);
824  for (GList* iterator = self->children_list; iterator;
825  iterator = iterator->next) {
826  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
827  (*callback)(child->widget, callback_data);
828  }
829 
830  if (include_internals) {
831  (*callback)(self->event_box, callback_data);
832  }
833 }
GtkWidget * widget
Definition: fl_view.cc:69

◆ fl_view_get_child_property()

static void fl_view_get_child_property ( GtkContainer *  container,
GtkWidget *  child,
guint  property_id,
GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 848 of file fl_view.cc.

Referenced by fl_view_class_init().

852  {}

◆ fl_view_get_engine()

G_MODULE_EXPORT FlEngine* fl_view_get_engine ( FlView *  view)

fl_view_get_engine: : an #FlView.

Gets the engine being rendered in the view.

Returns: an #FlEngine.

Definition at line 899 of file fl_view.cc.

Referenced by fl_renderer_unblock_main_thread(), fl_renderer_wait_for_frame(), and get_engine().

899  {
900  g_return_val_if_fail(FL_IS_VIEW(view), nullptr);
901  return view->engine;
902 }

◆ fl_view_get_preferred_height()

static void fl_view_get_preferred_height ( GtkWidget *  widget,
gint *  minimum,
gint *  natural 
)
static

Definition at line 660 of file fl_view.cc.

References _FlViewChild::geometry, and _FlViewChild::widget.

Referenced by fl_view_class_init().

662  {
663  FlView* self = FL_VIEW(widget);
664  gint child_min, child_nat;
665 
666  *minimum = 0;
667  *natural = 0;
668 
669  for (GList* iterator = self->children_list; iterator;
670  iterator = iterator->next) {
671  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
672 
673  if (!gtk_widget_get_visible(child->widget)) {
674  continue;
675  }
676 
677  gtk_widget_get_preferred_height(child->widget, &child_min, &child_nat);
678 
679  *minimum = MAX(*minimum, child->geometry.y + child_min);
680  *natural = MAX(*natural, child->geometry.y + child_nat);
681  }
682 }
GtkWidget * widget
Definition: fl_view.cc:69
GdkRectangle geometry
Definition: fl_view.cc:70

◆ fl_view_get_preferred_width()

static void fl_view_get_preferred_width ( GtkWidget *  widget,
gint *  minimum,
gint *  natural 
)
static

Definition at line 635 of file fl_view.cc.

References _FlViewChild::geometry, and _FlViewChild::widget.

Referenced by fl_view_class_init().

637  {
638  FlView* self = FL_VIEW(widget);
639  gint child_min, child_nat;
640 
641  *minimum = 0;
642  *natural = 0;
643 
644  for (GList* iterator = self->children_list; iterator;
645  iterator = iterator->next) {
646  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
647 
648  if (!gtk_widget_get_visible(child->widget)) {
649  continue;
650  }
651 
652  gtk_widget_get_preferred_width(child->widget, &child_min, &child_nat);
653 
654  *minimum = MAX(*minimum, child->geometry.x + child_min);
655  *natural = MAX(*natural, child->geometry.x + child_nat);
656  }
657 }
GtkWidget * widget
Definition: fl_view.cc:69
GdkRectangle geometry
Definition: fl_view.cc:70

◆ fl_view_get_property()

static void fl_view_get_property ( GObject *  object,
guint  prop_id,
GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 544 of file fl_view.cc.

References kPropFlutterProject.

Referenced by fl_view_class_init().

547  {
548  FlView* self = FL_VIEW(object);
549 
550  switch (prop_id) {
551  case kPropFlutterProject:
552  g_value_set_object(value, self->project);
553  break;
554  default:
555  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
556  break;
557  }
558 }
uint8_t value

◆ fl_view_get_registrar_for_plugin()

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

Definition at line 248 of file fl_view.cc.

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

Referenced by fl_view_plugin_registry_iface_init().

250  {
251  FlView* self = FL_VIEW(registry);
252 
253  return fl_plugin_registrar_new(self,
254  fl_engine_get_binary_messenger(self->engine),
255  fl_engine_get_texture_registrar(self->engine));
256 }
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:826
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:842

◆ fl_view_init()

static void fl_view_init ( FlView *  self)
static

Definition at line 890 of file fl_view.cc.

References TRUE.

890  {
891  gtk_widget_set_can_focus(GTK_WIDGET(self), TRUE);
892 }

◆ fl_view_key_press_event()

static gboolean fl_view_key_press_event ( GtkWidget *  widget,
GdkEventKey *  event 
)
static

Definition at line 755 of file fl_view.cc.

References fl_key_event_new_from_gdk_event(), and fl_keyboard_manager_handle_event().

Referenced by fl_view_class_init().

755  {
756  FlView* self = FL_VIEW(widget);
757 
759  self->keyboard_manager, fl_key_event_new_from_gdk_event(gdk_event_copy(
760  reinterpret_cast<GdkEvent*>(event))));
761 }
gboolean fl_keyboard_manager_handle_event(FlKeyboardManager *self, FlKeyEvent *event)
FlKeyEvent * event
FlKeyEvent * fl_key_event_new_from_gdk_event(GdkEvent *raw_event)
Definition: fl_key_event.cc:22

◆ fl_view_key_release_event()

static gboolean fl_view_key_release_event ( GtkWidget *  widget,
GdkEventKey *  event 
)
static

Definition at line 764 of file fl_view.cc.

References fl_key_event_new_from_gdk_event(), and fl_keyboard_manager_handle_event().

Referenced by fl_view_class_init().

765  {
766  FlView* self = FL_VIEW(widget);
768  self->keyboard_manager, fl_key_event_new_from_gdk_event(gdk_event_copy(
769  reinterpret_cast<GdkEvent*>(event))));
770 }
gboolean fl_keyboard_manager_handle_event(FlKeyboardManager *self, FlKeyEvent *event)
FlKeyEvent * event
FlKeyEvent * fl_key_event_new_from_gdk_event(GdkEvent *raw_event)
Definition: fl_key_event.cc:22

◆ fl_view_keyboard_delegate_iface_init()

static void fl_view_keyboard_delegate_iface_init ( FlKeyboardViewDelegateInterface *  iface)
static

Definition at line 263 of file fl_view.cc.

References callback, event, fl_engine_get_binary_messenger(), fl_engine_send_key_event(), fl_key_event_dispose(), fl_text_input_plugin_filter_keypress(), key, type, and user_data.

264  {
265  iface->send_key_event =
266  [](FlKeyboardViewDelegate* view_delegate, const FlutterKeyEvent* event,
268  FlView* self = FL_VIEW(view_delegate);
269  if (self->engine != nullptr) {
270  fl_engine_send_key_event(self->engine, event, callback, user_data);
271  };
272  };
273 
274  iface->text_filter_key_press = [](FlKeyboardViewDelegate* view_delegate,
275  FlKeyEvent* event) {
276  FlView* self = FL_VIEW(view_delegate);
277  return fl_text_input_plugin_filter_keypress(self->text_input_plugin, event);
278  };
279 
280  iface->get_messenger = [](FlKeyboardViewDelegate* view_delegate) {
281  FlView* self = FL_VIEW(view_delegate);
282  return fl_engine_get_binary_messenger(self->engine);
283  };
284 
285  iface->redispatch_event = [](FlKeyboardViewDelegate* view_delegate,
286  std::unique_ptr<FlKeyEvent> in_event) {
287  FlKeyEvent* event = in_event.release();
288  GdkEvent* gdk_event = reinterpret_cast<GdkEvent*>(event->origin);
289  GdkEventType type = gdk_event->type;
290  g_return_if_fail(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE);
291  gdk_event_put(gdk_event);
292  fl_key_event_dispose(event);
293  };
294 
295  iface->subscribe_to_layout_change = [](FlKeyboardViewDelegate* view_delegate,
296  KeyboardLayoutNotifier notifier) {
297  FlView* self = FL_VIEW(view_delegate);
298  self->keyboard_layout_notifier = std::move(notifier);
299  };
300 
301  iface->lookup_key = [](FlKeyboardViewDelegate* view_delegate,
302  const GdkKeymapKey* key) -> guint {
303  FlView* self = FL_VIEW(view_delegate);
304  return gdk_keymap_lookup_key(self->keymap, key);
305  };
306 }
void fl_key_event_dispose(FlKeyEvent *event)
Definition: fl_key_event.cc:43
enum flutter::testing::@1969::KeyboardChange::Type type
void * user_data
void fl_engine_send_key_event(FlEngine *self, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Definition: fl_engine.cc:771
FlKeyEvent * event
gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin *self, FlKeyEvent *event)
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:826
void(* FlutterKeyEventCallback)(bool, void *)
Definition: embedder.h:887
std::function< void()> KeyboardLayoutNotifier
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ 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: : The project to show.

Creates a widget to show Flutter application.

Returns: a new #FlView.

Definition at line 894 of file fl_view.cc.

894  {
895  return static_cast<FlView*>(
896  g_object_new(fl_view_get_type(), "flutter-project", project, nullptr));
897 }

◆ fl_view_notify()

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

Definition at line 560 of file fl_view.cc.

References handle_geometry_changed().

Referenced by fl_view_class_init().

560  {
561  FlView* self = FL_VIEW(object);
562 
563  if (strcmp(pspec->name, "scale-factor") == 0) {
565  }
566 
567  if (G_OBJECT_CLASS(fl_view_parent_class)->notify != nullptr) {
568  G_OBJECT_CLASS(fl_view_parent_class)->notify(object, pspec);
569  }
570 }
static void handle_geometry_changed(FlView *self)
Definition: fl_view.cc:184

◆ fl_view_plugin_registry_iface_init()

static void fl_view_plugin_registry_iface_init ( FlPluginRegistryInterface *  iface)
static

Definition at line 258 of file fl_view.cc.

References fl_view_get_registrar_for_plugin().

259  {
260  iface->get_registrar_for_plugin = fl_view_get_registrar_for_plugin;
261 }
static FlPluginRegistrar * fl_view_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_view.cc:248

◆ fl_view_realize()

static void fl_view_realize ( GtkWidget *  widget)
static

Definition at line 596 of file fl_view.cc.

References error, fl_engine_start(), fl_renderer_start(), TRUE, and window.

Referenced by fl_view_class_init().

596  {
597  FlView* self = FL_VIEW(widget);
598  g_autoptr(GError) error = nullptr;
599 
600  GtkAllocation allocation;
601  gtk_widget_get_allocation(widget, &allocation);
602 
603  gtk_widget_set_realized(widget, TRUE);
604 
605  GdkWindowAttr attributes;
606  attributes.window_type = GDK_WINDOW_CHILD;
607  attributes.x = allocation.x;
608  attributes.y = allocation.y;
609  attributes.width = allocation.width;
610  attributes.height = allocation.height;
611  attributes.wclass = GDK_INPUT_OUTPUT;
612  attributes.visual = gtk_widget_get_visual(widget);
613  attributes.event_mask =
614  gtk_widget_get_events(widget) | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK;
615  gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
616  GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget),
617  &attributes, attributes_mask);
618  gtk_widget_set_window(widget, window);
619  gtk_widget_register_window(widget, window);
620 
621  init_keyboard(self);
622 
623  if (!fl_renderer_start(self->renderer, self, &error)) {
624  g_warning("Failed to start Flutter renderer: %s", error->message);
625  return;
626  }
627 
628  if (!fl_engine_start(self->engine, &error)) {
629  g_warning("Failed to start Flutter engine: %s", error->message);
630  return;
631  }
632 }
const uint8_t uint32_t uint32_t GError ** error
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:427
gboolean fl_renderer_start(FlRenderer *self, FlView *view, GError **error)
Definition: fl_renderer.cc:59
GLFWwindow * window
Definition: main.cc:43

◆ fl_view_remove()

static void fl_view_remove ( GtkContainer *  container,
GtkWidget *  widget 
)
static

Definition at line 795 of file fl_view.cc.

References _FlViewChild::widget.

Referenced by fl_view_class_init().

795  {
796  FlView* self = FL_VIEW(container);
797  for (GList* iterator = self->children_list; iterator;
798  iterator = iterator->next) {
799  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
800  if (child->widget == widget) {
801  g_object_ref(widget);
802  gtk_widget_unparent(widget);
803  self->children_list = g_list_remove_link(self->children_list, iterator);
804  g_list_free(iterator);
805  g_free(child);
806 
807  break;
808  }
809  }
810 
811  if (widget == GTK_WIDGET(self->event_box)) {
812  g_clear_object(&self->event_box);
813  }
814 
815  g_clear_object(&self->keymap);
816 }
GtkWidget * widget
Definition: fl_view.cc:69

◆ fl_view_reorder_forall()

static void fl_view_reorder_forall ( GtkWidget *  widget,
gpointer  user_data 
)
static

Definition at line 743 of file fl_view.cc.

References flutter::data, _ReorderData::last_window, _ReorderData::parent_window, TRUE, user_data, and window.

Referenced by fl_view_end_frame().

743  {
744  _ReorderData* data = reinterpret_cast<_ReorderData*>(user_data);
745  GdkWindow* window = gtk_widget_get_window(widget);
746  if (window && window != data->parent_window) {
747  if (data->last_window) {
748  gdk_window_restack(window, data->last_window, TRUE);
749  }
750  data->last_window = window;
751  }
752 }
GdkWindow * parent_window
Definition: fl_view.cc:739
void * user_data
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
GdkWindow * last_window
Definition: fl_view.cc:740
GLFWwindow * window
Definition: main.cc:43

◆ fl_view_scrolling_delegate_iface_init()

static void fl_view_scrolling_delegate_iface_init ( FlScrollingViewDelegateInterface *  iface)
static

Definition at line 308 of file fl_view.cc.

References fl_engine_send_mouse_pointer_event(), and fl_engine_send_pointer_pan_zoom_event().

309  {
310  iface->send_mouse_pointer_event =
311  [](FlScrollingViewDelegate* view_delegate, FlutterPointerPhase phase,
312  size_t timestamp, double x, double y, double scroll_delta_x,
313  double scroll_delta_y, int64_t buttons) {
314  FlView* self = FL_VIEW(view_delegate);
315  if (self->engine != nullptr) {
316  fl_engine_send_mouse_pointer_event(self->engine, phase, timestamp, x,
317  y, scroll_delta_x, scroll_delta_y,
318  buttons);
319  }
320  };
321  iface->send_pointer_pan_zoom_event =
322  [](FlScrollingViewDelegate* view_delegate, size_t timestamp, double x,
323  double y, FlutterPointerPhase phase, double pan_x, double pan_y,
324  double scale, double rotation) {
325  FlView* self = FL_VIEW(view_delegate);
326  if (self->engine != nullptr) {
327  fl_engine_send_pointer_pan_zoom_event(self->engine, timestamp, x, y,
328  phase, pan_x, pan_y, scale,
329  rotation);
330  };
331  };
332 }
FlutterPointerPhase
The phase of the pointer event.
Definition: embedder.h:711
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterPointerPhase phase, size_t timestamp, double x, double y, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:710
void fl_engine_send_pointer_pan_zoom_event(FlEngine *self, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
Definition: fl_engine.cc:741

◆ fl_view_set_child_property()

static void fl_view_set_child_property ( GtkContainer *  container,
GtkWidget *  child,
guint  property_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 841 of file fl_view.cc.

Referenced by fl_view_class_init().

845  {}

◆ fl_view_set_property()

static void fl_view_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 527 of file fl_view.cc.

References kPropFlutterProject.

Referenced by fl_view_class_init().

530  {
531  FlView* self = FL_VIEW(object);
532 
533  switch (prop_id) {
534  case kPropFlutterProject:
535  g_set_object(&self->project,
536  static_cast<FlDartProject*>(g_value_get_object(value)));
537  break;
538  default:
539  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
540  break;
541  }
542 }
uint8_t value

◆ fl_view_size_allocate()

static void fl_view_size_allocate ( GtkWidget *  widget,
GtkAllocation *  allocation 
)
static

Definition at line 685 of file fl_view.cc.

References _FlViewChild::geometry, handle_geometry_changed(), and _FlViewChild::widget.

Referenced by fl_view_class_init().

686  {
687  FlView* self = FL_VIEW(widget);
688 
689  gtk_widget_set_allocation(widget, allocation);
690 
691  if (gtk_widget_get_has_window(widget)) {
692  if (gtk_widget_get_realized(widget)) {
693  gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x,
694  allocation->y, allocation->width,
695  allocation->height);
696  }
697  }
698 
699  for (GList* iterator = self->children_list; iterator;
700  iterator = iterator->next) {
701  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
702  if (!gtk_widget_get_visible(child->widget)) {
703  continue;
704  }
705 
706  GtkAllocation child_allocation = child->geometry;
707  GtkRequisition child_requisition;
708  gtk_widget_get_preferred_size(child->widget, &child_requisition, NULL);
709 
710  if (!gtk_widget_get_has_window(widget)) {
711  child_allocation.x += allocation->x;
712  child_allocation.y += allocation->y;
713  }
714 
715  if (child_allocation.width == 0 && child_allocation.height == 0) {
716  child_allocation.width = allocation->width;
717  child_allocation.height = allocation->height;
718  }
719 
720  gtk_widget_size_allocate(child->widget, &child_allocation);
721  }
722 
723  GtkAllocation event_box_allocation = {
724  .x = 0,
725  .y = 0,
726  .width = allocation->width,
727  .height = allocation->height,
728  };
729  if (!gtk_widget_get_has_window(self->event_box)) {
730  event_box_allocation.x += allocation->x;
731  event_box_allocation.y += allocation->y;
732  }
733  gtk_widget_size_allocate(self->event_box, &event_box_allocation);
734 
736 }
static void handle_geometry_changed(FlView *self)
Definition: fl_view.cc:184
GtkWidget * widget
Definition: fl_view.cc:69
GdkRectangle geometry
Definition: fl_view.cc:70

◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE ( FlView  ,
fl_view  ,
GTK_TYPE_CONTAINER  ,
G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_view_plugin_registry_iface_init) G_IMPLEMENT_INTERFACE(fl_keyboard_view_delegate_get_type(), fl_view_keyboard_delegate_iface_init) G_IMPLEMENT_INTERFACE(fl_scrolling_view_delegate_get_type(), fl_view_scrolling_delegate_iface_init  
)

Definition at line 84 of file fl_view.cc.

References fl_engine_get_binary_messenger(), fl_keyboard_manager_new(), fl_text_input_plugin_new(), and window.

96  {
97  FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
98 
99  GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(self));
100  g_return_if_fail(GDK_IS_WINDOW(window));
101  g_autoptr(GtkIMContext) im_context = gtk_im_multicontext_new();
102  gtk_im_context_set_client_window(im_context, window);
103 
104  self->text_input_plugin = fl_text_input_plugin_new(messenger, im_context);
105  self->keyboard_manager =
106  fl_keyboard_manager_new(FL_KEYBOARD_VIEW_DELEGATE(self));
107 }
FlKeyboardManager * fl_keyboard_manager_new(FlKeyboardViewDelegate *view_delegate)
FlTextInputPlugin * fl_text_input_plugin_new(FlBinaryMessenger *messenger, GtkIMContext *im_context)
GLFWwindow * window
Definition: main.cc:43
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:826

◆ gesture_rotation_begin_cb()

static void gesture_rotation_begin_cb ( GtkGestureRotate *  gesture,
GdkEventSequence *  sequence,
FlView *  view 
)
static

Definition at line 434 of file fl_view.cc.

References fl_scrolling_manager_handle_rotation_begin().

Referenced by fl_view_constructed().

436  {
437  fl_scrolling_manager_handle_rotation_begin(view->scrolling_manager);
438 }
void fl_scrolling_manager_handle_rotation_begin(FlScrollingManager *self)

◆ gesture_rotation_end_cb()

static void gesture_rotation_end_cb ( GtkGestureRotate *  gesture,
GdkEventSequence *  sequence,
FlView *  view 
)
static

Definition at line 448 of file fl_view.cc.

References fl_scrolling_manager_handle_rotation_end().

Referenced by fl_view_constructed().

450  {
451  fl_scrolling_manager_handle_rotation_end(view->scrolling_manager);
452 }
void fl_scrolling_manager_handle_rotation_end(FlScrollingManager *self)

◆ gesture_rotation_update_cb()

static void gesture_rotation_update_cb ( GtkGestureRotate *  widget,
gdouble  rotation,
gdouble  delta,
FlView *  view 
)
static

Definition at line 440 of file fl_view.cc.

References fl_scrolling_manager_handle_rotation_update().

Referenced by fl_view_constructed().

443  {
444  fl_scrolling_manager_handle_rotation_update(view->scrolling_manager,
445  rotation);
446 }
void fl_scrolling_manager_handle_rotation_update(FlScrollingManager *self, gdouble rotation)

◆ gesture_zoom_begin_cb()

static void gesture_zoom_begin_cb ( GtkGestureZoom *  gesture,
GdkEventSequence *  sequence,
FlView *  view 
)
static

Definition at line 454 of file fl_view.cc.

References fl_scrolling_manager_handle_zoom_begin().

Referenced by fl_view_constructed().

456  {
457  fl_scrolling_manager_handle_zoom_begin(view->scrolling_manager);
458 }
void fl_scrolling_manager_handle_zoom_begin(FlScrollingManager *self)

◆ gesture_zoom_end_cb()

static void gesture_zoom_end_cb ( GtkGestureZoom *  gesture,
GdkEventSequence *  sequence,
FlView *  view 
)
static

Definition at line 466 of file fl_view.cc.

References fl_scrolling_manager_handle_zoom_end().

Referenced by fl_view_constructed().

468  {
469  fl_scrolling_manager_handle_zoom_end(view->scrolling_manager);
470 }
void fl_scrolling_manager_handle_zoom_end(FlScrollingManager *self)

◆ gesture_zoom_update_cb()

static void gesture_zoom_update_cb ( GtkGestureZoom *  widget,
gdouble  scale,
FlView *  view 
)
static

Definition at line 460 of file fl_view.cc.

References fl_scrolling_manager_handle_zoom_update().

Referenced by fl_view_constructed().

462  {
463  fl_scrolling_manager_handle_zoom_update(view->scrolling_manager, scale);
464 }
void fl_scrolling_manager_handle_zoom_update(FlScrollingManager *self, gdouble scale)

◆ handle_geometry_changed()

static void handle_geometry_changed ( FlView *  self)
static

Definition at line 184 of file fl_view.cc.

References fl_engine_send_window_metrics_event(), and fl_renderer_wait_for_frame().

Referenced by fl_view_notify(), and fl_view_size_allocate().

184  {
185  GtkAllocation allocation;
186  gtk_widget_get_allocation(GTK_WIDGET(self), &allocation);
187  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
189  self->engine, allocation.width * scale_factor,
190  allocation.height * scale_factor, scale_factor);
191 
192  fl_renderer_wait_for_frame(self->renderer, allocation.width * scale_factor,
193  allocation.height * scale_factor);
194 }
void fl_engine_send_window_metrics_event(FlEngine *self, size_t width, size_t height, double pixel_ratio)
Definition: fl_engine.cc:692
void fl_renderer_wait_for_frame(FlRenderer *self, int target_width, int target_height)
Definition: fl_renderer.cc:140

◆ init_scrolling()

static void init_scrolling ( FlView *  self)
static

Definition at line 109 of file fl_view.cc.

References fl_scrolling_manager_new().

Referenced by fl_view_constructed(), and on_pre_engine_restart_cb().

109  {
110  self->scrolling_manager =
111  fl_scrolling_manager_new(FL_SCROLLING_VIEW_DELEGATE(self));
112 }
FlScrollingManager * fl_scrolling_manager_new(FlScrollingViewDelegate *view_delegate)

◆ keymap_keys_changed_cb()

static void keymap_keys_changed_cb ( GdkKeymap *  self,
FlView *  view 
)
static

Definition at line 426 of file fl_view.cc.

Referenced by fl_view_constructed().

426  {
427  if (view->keyboard_layout_notifier == nullptr) {
428  return;
429  }
430 
431  view->keyboard_layout_notifier();
432 }

◆ leave_notify_event_cb()

static gboolean leave_notify_event_cb ( GtkWidget *  widget,
GdkEventCrossing *  event,
FlView *  view 
)
static

Definition at line 404 of file fl_view.cc.

References FALSE, fl_engine_send_mouse_pointer_event(), kMicrosecondsPerMillisecond, kRemove, and TRUE.

Referenced by fl_view_constructed().

406  {
407  if (view->engine == nullptr) {
408  return FALSE;
409  }
410 
411  // Don't remove pointer while button is down; In case of dragging outside of
412  // window with mouse grab active Gtk will send another leave notify on
413  // release.
414  if (view->pointer_inside && view->button_state == 0) {
415  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(view));
417  view->engine, kRemove, event->time * kMicrosecondsPerMillisecond,
418  event->x * scale_factor, event->y * scale_factor, 0, 0,
419  view->button_state);
420  view->pointer_inside = FALSE;
421  }
422 
423  return TRUE;
424 }
guint32 time
Definition: fl_key_event.h:33
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:27
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterPointerPhase phase, size_t timestamp, double x, double y, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:710
return FALSE

◆ motion_notify_event_cb()

static gboolean motion_notify_event_cb ( GtkWidget *  widget,
GdkEventMotion *  event,
FlView *  view 
)
static

Definition at line 372 of file fl_view.cc.

References check_pointer_inside(), FALSE, fl_engine_send_mouse_pointer_event(), kHover, kMicrosecondsPerMillisecond, kMove, and TRUE.

Referenced by fl_view_constructed().

374  {
375  if (view->engine == nullptr) {
376  return FALSE;
377  }
378 
379  check_pointer_inside(view, reinterpret_cast<GdkEvent*>(event));
380 
381  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(view));
383  view->engine, view->button_state != 0 ? kMove : kHover,
384  event->time * kMicrosecondsPerMillisecond, event->x * scale_factor,
385  event->y * scale_factor, 0, 0, view->button_state);
386 
387  return TRUE;
388 }
guint32 time
Definition: fl_key_event.h:33
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:27
The pointer moved while up.
Definition: embedder.h:743
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterPointerPhase phase, size_t timestamp, double x, double y, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:710
static void check_pointer_inside(FlView *view, GdkEvent *event)
Definition: fl_view.cc:167
return FALSE

◆ on_pre_engine_restart_cb()

static void on_pre_engine_restart_cb ( FlEngine *  engine,
gpointer  user_data 
)
static

Definition at line 237 of file fl_view.cc.

References init_scrolling().

Referenced by fl_view_constructed().

237  {
238  FlView* self = FL_VIEW(user_data);
239 
240  g_clear_object(&self->keyboard_manager);
241  g_clear_object(&self->text_input_plugin);
242  g_clear_object(&self->scrolling_manager);
243  init_keyboard(self);
244  init_scrolling(self);
245 }
void * user_data
static void init_scrolling(FlView *self)
Definition: fl_view.cc:109

◆ put_widget()

static void put_widget ( FlView *  self,
GtkWidget *  widget,
GdkRectangle *  geometry 
)
static

Definition at line 772 of file fl_view.cc.

References _FlViewChild::geometry, and _FlViewChild::widget.

Referenced by fl_view_add().

774  {
775  FlViewChild* child = g_new(FlViewChild, 1);
776  child->widget = widget;
777  child->geometry = *geometry;
778 
779  gtk_widget_set_parent(widget, GTK_WIDGET(self));
780  self->children_list = g_list_append(self->children_list, child);
781 }
GtkWidget * widget
Definition: fl_view.cc:69
GdkRectangle geometry
Definition: fl_view.cc:70

◆ scroll_event_cb()

static gboolean scroll_event_cb ( GtkWidget *  widget,
GdkEventScroll *  event,
FlView *  view 
)
static

Definition at line 359 of file fl_view.cc.

References fl_scrolling_manager_handle_scroll_event(), and TRUE.

Referenced by fl_view_constructed().

361  {
362  // TODO(robert-ancell): Update to use GtkEventControllerScroll when we can
363  // depend on GTK 3.24.
364 
366  view->scrolling_manager, event,
367  gtk_widget_get_scale_factor(GTK_WIDGET(view)));
368  return TRUE;
369 }
FlKeyEvent * event
void fl_scrolling_manager_handle_scroll_event(FlScrollingManager *self, GdkEventScroll *event, gint scale_factor)

◆ send_pointer_button_event()

static gboolean send_pointer_button_event ( FlView *  self,
GdkEventButton *  event 
)
static

Definition at line 115 of file fl_view.cc.

References FALSE, fl_engine_send_mouse_pointer_event(), fl_scrolling_manager_set_last_mouse_position(), kDown, kFlutterPointerButtonMouseMiddle, kFlutterPointerButtonMousePrimary, kFlutterPointerButtonMouseSecondary, kMicrosecondsPerMillisecond, kMove, kUp, and TRUE.

Referenced by button_press_event_cb(), and button_release_event_cb().

115  {
116  int64_t button;
117  switch (event->button) {
118  case 1:
120  break;
121  case 2:
123  break;
124  case 3:
126  break;
127  default:
128  return FALSE;
129  }
130  int old_button_state = self->button_state;
131  FlutterPointerPhase phase = kMove;
132  if (event->type == GDK_BUTTON_PRESS) {
133  // Drop the event if Flutter already thinks the button is down.
134  if ((self->button_state & button) != 0) {
135  return FALSE;
136  }
137  self->button_state ^= button;
138 
139  phase = old_button_state == 0 ? kDown : kMove;
140  } else if (event->type == GDK_BUTTON_RELEASE) {
141  // Drop the event if Flutter already thinks the button is up.
142  if ((self->button_state & button) == 0) {
143  return FALSE;
144  }
145  self->button_state ^= button;
146 
147  phase = self->button_state == 0 ? kUp : kMove;
148  }
149 
150  if (self->engine == nullptr) {
151  return FALSE;
152  }
153 
154  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
155  fl_scrolling_manager_set_last_mouse_position(self->scrolling_manager,
156  event->x * scale_factor,
157  event->y * scale_factor);
159  self->engine, phase, event->time * kMicrosecondsPerMillisecond,
160  event->x * scale_factor, event->y * scale_factor, 0, 0,
161  self->button_state);
162 
163  return TRUE;
164 }
Definition: embedder.h:719
FlutterPointerPhase
The phase of the pointer event.
Definition: embedder.h:711
guint32 time
Definition: fl_key_event.h:33
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:27
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterPointerPhase phase, size_t timestamp, double x, double y, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:710
return FALSE
void fl_scrolling_manager_set_last_mouse_position(FlScrollingManager *self, gdouble x, gdouble y)

◆ update_semantics_node_cb()

static void update_semantics_node_cb ( FlEngine *  engine,
const FlutterSemanticsNode node,
gpointer  user_data 
)
static

Definition at line 223 of file fl_view.cc.

References fl_accessibility_plugin_handle_update_semantics_node().

Referenced by fl_view_constructed().

225  {
226  FlView* self = FL_VIEW(user_data);
227 
229  self->accessibility_plugin, node);
230 }
void * user_data
void fl_accessibility_plugin_handle_update_semantics_node(FlAccessibilityPlugin *self, const FlutterSemanticsNode *node)

Variable Documentation

◆ kMicrosecondsPerMillisecond

constexpr int kMicrosecondsPerMillisecond = 1000
static