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_channel_responder.h"
#include "flutter/shell/platform/linux/fl_key_embedder_responder.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_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_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  {
  PROP_FLUTTER_PROJECT = 1,
  PROP_LAST
}
 

Functions

static void fl_view_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
 
static gboolean text_input_im_filter_by_gtk (GtkIMContext *im_context, gpointer gdk_event)
 
static void redispatch_key_event_by_gtk (gpointer gdk_event)
 
 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)) static void fl_view_update_semantics_node_cb(FlEngine *engine
 
 fl_accessibility_plugin_handle_update_semantics_node (self->accessibility_plugin, node)
 
static void fl_view_init_keyboard (FlView *self)
 
static void fl_view_on_pre_engine_restart_cb (FlEngine *engine, gpointer user_data)
 
static gboolean fl_view_send_pointer_button_event (FlView *self, GdkEventButton *event)
 
static void fl_view_geometry_changed (FlView *self)
 
static FlPluginRegistrar * fl_view_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
 
static gboolean event_box_button_release_event (GtkWidget *widget, GdkEventButton *event, FlView *view)
 
static gboolean event_box_button_press_event (GtkWidget *widget, GdkEventButton *event, FlView *view)
 
static gboolean event_box_scroll_event (GtkWidget *widget, GdkEventScroll *event, FlView *view)
 
static gboolean event_box_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, FlView *view)
 
static gboolean event_box_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event, FlView *view)
 
static gboolean event_box_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event, 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 void check_pointer_inside (FlView *view, GdkEvent *event)
 
static gboolean fl_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
 
static gboolean fl_view_key_release_event (GtkWidget *widget, GdkEventKey *event)
 
static void fl_view_put (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)
 
static void fl_view_add_pending_child (FlView *self, GtkWidget *widget, GdkRectangle *geometry)
 
void fl_view_add_gl_area (FlView *view, GdkGLContext *context, FlBackingStoreProvider *texture)
 
void fl_view_add_widget (FlView *view, GtkWidget *widget, GdkRectangle *geometry)
 
GList * find_child (GList *list, GtkWidget *widget)
 
void fl_view_end_frame (FlView *view)
 

Variables

static constexpr int kMicrosecondsPerMillisecond = 1000
 
const FlutterSemanticsNodenode
 
const FlutterSemanticsNode gpointer user_data
 

Typedef Documentation

◆ FlViewChild

typedef struct _FlViewChild FlViewChild

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROP_FLUTTER_PROJECT 
PROP_LAST 

Definition at line 65 of file fl_view.cc.

Function Documentation

◆ check_pointer_inside()

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

Definition at line 537 of file fl_view.cc.

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

Referenced by event_box_enter_notify_event(), and event_box_motion_notify_event().

537  {
538  if (!view->pointer_inside) {
539  view->pointer_inside = TRUE;
540 
541  gdouble x, y;
542  if (gdk_event_get_coords(event, &x, &y)) {
543  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(view));
544 
546  view->engine, kAdd,
547  gdk_event_get_time(event) * kMicrosecondsPerMillisecond,
548  x * scale_factor, y * scale_factor, 0, 0, view->button_state);
549  }
550  }
551 }
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:25
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:684
Definition: embedder.h:612
FlView * view

◆ event_box_button_press_event()

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

Definition at line 479 of file fl_view.cc.

References FALSE, and fl_view_send_pointer_button_event().

Referenced by fl_view_constructed(), and fl_view_plugin_registry_iface_init().

481  {
482  // Flutter doesn't handle double and triple click events.
483  if (event->type == GDK_DOUBLE_BUTTON_PRESS ||
484  event->type == GDK_TRIPLE_BUTTON_PRESS) {
485  return FALSE;
486  }
487 
488  if (!gtk_widget_has_focus(GTK_WIDGET(view))) {
489  gtk_widget_grab_focus(GTK_WIDGET(view));
490  }
491 
493 }
FlKeyEvent * event
static gboolean fl_view_send_pointer_button_event(FlView *self, GdkEventButton *event)
Definition: fl_view.cc:119
FlView * view
return FALSE

◆ event_box_button_release_event()

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

Definition at line 495 of file fl_view.cc.

References fl_view_send_pointer_button_event().

Referenced by fl_view_constructed(), and fl_view_plugin_registry_iface_init().

497  {
499 }
FlKeyEvent * event
static gboolean fl_view_send_pointer_button_event(FlView *self, GdkEventButton *event)
Definition: fl_view.cc:119
FlView * view

◆ event_box_enter_notify_event()

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

Definition at line 571 of file fl_view.cc.

References check_pointer_inside(), FALSE, and TRUE.

Referenced by fl_view_constructed(), and fl_view_plugin_registry_iface_init().

573  {
574  if (view->engine == nullptr) {
575  return FALSE;
576  }
577 
578  check_pointer_inside(view, reinterpret_cast<GdkEvent*>(event));
579 
580  return TRUE;
581 }
FlKeyEvent * event
FlView * view
static void check_pointer_inside(FlView *view, GdkEvent *event)
Definition: fl_view.cc:537
return FALSE

◆ event_box_leave_notify_event()

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

Definition at line 583 of file fl_view.cc.

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

Referenced by fl_view_constructed(), and fl_view_plugin_registry_iface_init().

585  {
586  if (view->engine == nullptr) {
587  return FALSE;
588  }
589 
590  // Don't remove pointer while button is down; In case of dragging outside of
591  // window with mouse grab active Gtk will send another leave notify on
592  // release.
593  if (view->pointer_inside && view->button_state == 0) {
594  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(view));
597  event->x * scale_factor, event->y * scale_factor, 0, 0,
598  view->button_state);
599  view->pointer_inside = FALSE;
600  }
601 
602  return TRUE;
603 }
guint32 time
Definition: fl_key_event.h:33
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:25
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:684
FlView * view
return FALSE

◆ event_box_motion_notify_event()

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

Definition at line 553 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(), and fl_view_plugin_registry_iface_init().

555  {
556  if (view->engine == nullptr) {
557  return FALSE;
558  }
559 
560  check_pointer_inside(view, reinterpret_cast<GdkEvent*>(event));
561 
562  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(view));
564  view->engine, view->button_state != 0 ? kMove : kHover,
565  event->time * kMicrosecondsPerMillisecond, event->x * scale_factor,
566  event->y * scale_factor, 0, 0, view->button_state);
567 
568  return TRUE;
569 }
guint32 time
Definition: fl_key_event.h:33
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:25
The pointer moved while up.
Definition: embedder.h:619
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:684
FlView * view
static void check_pointer_inside(FlView *view, GdkEvent *event)
Definition: fl_view.cc:537
return FALSE

◆ event_box_scroll_event()

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

Definition at line 501 of file fl_view.cc.

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

Referenced by fl_view_constructed(), and fl_view_plugin_registry_iface_init().

503  {
504  // TODO(robert-ancell): Update to use GtkEventControllerScroll when we can
505  // depend on GTK 3.24.
506 
507  gdouble scroll_delta_x = 0.0, scroll_delta_y = 0.0;
508  if (event->direction == GDK_SCROLL_SMOOTH) {
509  scroll_delta_x = event->delta_x;
510  scroll_delta_y = event->delta_y;
511  } else if (event->direction == GDK_SCROLL_UP) {
512  scroll_delta_y = -1;
513  } else if (event->direction == GDK_SCROLL_DOWN) {
514  scroll_delta_y = 1;
515  } else if (event->direction == GDK_SCROLL_LEFT) {
516  scroll_delta_x = -1;
517  } else if (event->direction == GDK_SCROLL_RIGHT) {
518  scroll_delta_x = 1;
519  }
520 
521  // The multiplier is taken from the Chromium source
522  // (ui/events/x/events_x_utils.cc).
523  const int kScrollOffsetMultiplier = 53;
524  scroll_delta_x *= kScrollOffsetMultiplier;
525  scroll_delta_y *= kScrollOffsetMultiplier;
526 
527  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(view));
529  view->engine, view->button_state != 0 ? kMove : kHover,
530  event->time * kMicrosecondsPerMillisecond, event->x * scale_factor,
531  event->y * scale_factor, scroll_delta_x, scroll_delta_y,
532  view->button_state);
533 
534  return TRUE;
535 }
guint32 time
Definition: fl_key_event.h:33
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:25
The pointer moved while up.
Definition: embedder.h:619
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:684
FlView * view

◆ find_child()

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

Definition at line 796 of file fl_view.cc.

References _FlViewChild::widget.

Referenced by fl_view_end_frame().

796  {
797  for (GList* i = list; i; i = i->next) {
798  FlViewChild* child = reinterpret_cast<FlViewChild*>(i->data);
799  if (child && child->widget == widget)
800  return i;
801  }
802  return nullptr;
803 }
GtkWidget * widget
Definition: fl_view.cc:61

◆ fl_accessibility_plugin_handle_update_semantics_node()

fl_accessibility_plugin_handle_update_semantics_node ( self->  accessibility_plugin,
node   
)

◆ fl_view_add()

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

Definition at line 634 of file fl_view.cc.

References fl_view_put().

Referenced by fl_view_class_init().

634  {
635  GdkRectangle geometry = {
636  .x = 0,
637  .y = 0,
638  .width = 0,
639  .height = 0,
640  };
641  fl_view_put(FL_VIEW(container), widget, &geometry);
642 }
static void fl_view_put(FlView *self, GtkWidget *widget, GdkRectangle *geometry)
Definition: fl_view.cc:623

◆ 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 770 of file fl_view.cc.

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

Referenced by fl_renderer_gl_present_layers().

772  {
773  g_return_if_fail(FL_IS_VIEW(view));
774 
775  FlGLArea* area;
776  if (view->used_area_list) {
777  area = reinterpret_cast<FlGLArea*>(view->used_area_list->data);
778  view->used_area_list = view->used_area_list->next;
779  } else {
780  area = FL_GL_AREA(fl_gl_area_new(context));
781  view->gl_area_list = g_list_append(view->gl_area_list, area);
782  }
783 
784  gtk_widget_show(GTK_WIDGET(area));
785  fl_view_add_pending_child(view, GTK_WIDGET(area), nullptr);
787 }
G_BEGIN_DECLS FlTexture * texture
GtkWidget * fl_gl_area_new(GdkGLContext *context)
Definition: fl_gl_area.cc:117
void fl_gl_area_queue_render(FlGLArea *self, FlBackingStoreProvider *texture)
Definition: fl_gl_area.cc:125
FlView * view
static void fl_view_add_pending_child(FlView *self, GtkWidget *widget, GdkRectangle *geometry)
Definition: fl_view.cc:756

◆ fl_view_add_pending_child()

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

Definition at line 756 of file fl_view.cc.

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

Referenced by fl_view_add_gl_area(), and fl_view_add_widget().

758  {
759  FlViewChild* child = g_new(FlViewChild, 1);
760  child->widget = widget;
761  if (geometry)
762  child->geometry = *geometry;
763  else
764  child->geometry = {0, 0, 0, 0};
765 
766  self->pending_children_list =
767  g_list_append(self->pending_children_list, child);
768 }
GtkWidget * widget
Definition: fl_view.cc:61
GdkRectangle geometry
Definition: fl_view.cc:62

◆ 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 789 of file fl_view.cc.

References fl_view_add_pending_child().

791  {
792  gtk_widget_show(widget);
793  fl_view_add_pending_child(view, widget, geometry);
794 }
FlView * view
static void fl_view_add_pending_child(FlView *self, GtkWidget *widget, GdkRectangle *geometry)
Definition: fl_view.cc:756

◆ 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 747 of file fl_view.cc.

Referenced by fl_renderer_gl_present_layers().

747  {
748  g_return_if_fail(FL_IS_VIEW(view));
749  FlView* self = FL_VIEW(view);
750 
751  self->used_area_list = self->gl_area_list;
752  g_list_free_full(self->pending_children_list, g_free);
753  self->pending_children_list = nullptr;
754 }
FlView * view

◆ fl_view_child_type()

static GType fl_view_child_type ( GtkContainer *  container)
static

Definition at line 681 of file fl_view.cc.

Referenced by fl_view_class_init().

681  {
682  return GTK_TYPE_WIDGET;
683 }

◆ fl_view_class_init()

static void fl_view_class_init ( FlViewClass *  klass)
static

Definition at line 697 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 PROP_FLUTTER_PROJECT.

697  {
698  GObjectClass* object_class = G_OBJECT_CLASS(klass);
699  object_class->constructed = fl_view_constructed;
700  object_class->set_property = fl_view_set_property;
701  object_class->get_property = fl_view_get_property;
702  object_class->notify = fl_view_notify;
703  object_class->dispose = fl_view_dispose;
704 
705  GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
706  widget_class->realize = fl_view_realize;
707  widget_class->get_preferred_width = fl_view_get_preferred_width;
708  widget_class->get_preferred_height = fl_view_get_preferred_height;
709  widget_class->size_allocate = fl_view_size_allocate;
710  widget_class->key_press_event = fl_view_key_press_event;
711  widget_class->key_release_event = fl_view_key_release_event;
712 
713  GtkContainerClass* container_class = GTK_CONTAINER_CLASS(klass);
714  container_class->add = fl_view_add;
715  container_class->remove = fl_view_remove;
716  container_class->forall = fl_view_forall;
717  container_class->child_type = fl_view_child_type;
718  container_class->set_child_property = fl_view_set_child_property;
719  container_class->get_child_property = fl_view_get_child_property;
720 
721  g_object_class_install_property(
722  G_OBJECT_CLASS(klass), PROP_FLUTTER_PROJECT,
723  g_param_spec_object(
724  "flutter-project", "flutter-project", "Flutter project in use",
725  fl_dart_project_get_type(),
726  static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
727  G_PARAM_STATIC_STRINGS)));
728 
729  gtk_widget_class_set_accessible_type(GTK_WIDGET_CLASS(klass),
730  fl_view_accessible_get_type());
731 }
static void fl_view_get_child_property(GtkContainer *container, GtkWidget *child, guint property_id, GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:691
static void fl_view_dispose(GObject *object)
Definition: fl_view.cc:305
static void fl_view_constructed(GObject *object)
Definition: fl_view.cc:221
static void fl_view_notify(GObject *object, GParamSpec *pspec)
Definition: fl_view.cc:293
static void fl_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:260
static void fl_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:277
static void fl_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
Definition: fl_view.cc:412
static void fl_view_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
Definition: fl_view.cc:665
static void fl_view_realize(GtkWidget *widget)
Definition: fl_view.cc:329
static void fl_view_get_preferred_height(GtkWidget *widget, gint *minimum, gint *natural)
Definition: fl_view.cc:388
static gboolean fl_view_key_release_event(GtkWidget *widget, GdkEventKey *event)
Definition: fl_view.cc:615
static GType fl_view_child_type(GtkContainer *container)
Definition: fl_view.cc:681
static void fl_view_set_child_property(GtkContainer *container, GtkWidget *child, guint property_id, const GValue *value, GParamSpec *pspec)
Definition: fl_view.cc:685
static void fl_view_add(GtkContainer *container, GtkWidget *widget)
Definition: fl_view.cc:634
static void fl_view_remove(GtkContainer *container, GtkWidget *widget)
Definition: fl_view.cc:644
static void fl_view_get_preferred_width(GtkWidget *widget, gint *minimum, gint *natural)
Definition: fl_view.cc:365
static gboolean fl_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
Definition: fl_view.cc:606

◆ fl_view_constructed()

static void fl_view_constructed ( GObject *  object)
static

Definition at line 221 of file fl_view.cc.

References event_box_button_press_event(), event_box_button_release_event(), event_box_enter_notify_event(), event_box_leave_notify_event(), event_box_motion_notify_event(), event_box_scroll_event(), 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(), fl_view_init_keyboard(), and fl_view_on_pre_engine_restart_cb().

Referenced by fl_view_class_init().

221  {
222  FlView* self = FL_VIEW(object);
223 
224  self->renderer = FL_RENDERER(fl_renderer_gl_new());
225  self->engine = fl_engine_new(self->project, self->renderer);
227  self->engine, fl_view_update_semantics_node_cb, self, nullptr);
229  self->engine, fl_view_on_pre_engine_restart_cb, self, nullptr);
230 
231  // Create system channel handlers.
232  FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
233  self->accessibility_plugin = fl_accessibility_plugin_new(self);
234  fl_view_init_keyboard(self);
235  self->mouse_cursor_plugin = fl_mouse_cursor_plugin_new(messenger, self);
236  self->platform_plugin = fl_platform_plugin_new(messenger);
237 
238  self->event_box = gtk_event_box_new();
239  gtk_widget_set_parent(self->event_box, GTK_WIDGET(self));
240  gtk_widget_show(self->event_box);
241  gtk_widget_add_events(self->event_box,
242  GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
243  GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK |
244  GDK_SMOOTH_SCROLL_MASK);
245 
246  g_signal_connect(self->event_box, "button-press-event",
247  G_CALLBACK(event_box_button_press_event), self);
248  g_signal_connect(self->event_box, "button-release-event",
249  G_CALLBACK(event_box_button_release_event), self);
250  g_signal_connect(self->event_box, "scroll-event",
251  G_CALLBACK(event_box_scroll_event), self);
252  g_signal_connect(self->event_box, "motion-notify-event",
253  G_CALLBACK(event_box_motion_notify_event), self);
254  g_signal_connect(self->event_box, "enter-notify-event",
255  G_CALLBACK(event_box_enter_notify_event), self);
256  g_signal_connect(self->event_box, "leave-notify-event",
257  G_CALLBACK(event_box_leave_notify_event), self);
258 }
static void fl_view_on_pre_engine_restart_cb(FlEngine *engine, gpointer user_data)
Definition: fl_view.cc:110
static gboolean event_box_leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, FlView *view)
Definition: fl_view.cc:583
FlMouseCursorPlugin * fl_mouse_cursor_plugin_new(FlBinaryMessenger *messenger, FlView *view)
static gboolean event_box_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, FlView *view)
Definition: fl_view.cc:553
FlRendererGL * fl_renderer_gl_new()
static gboolean event_box_scroll_event(GtkWidget *widget, GdkEventScroll *event, FlView *view)
Definition: fl_view.cc:501
static gboolean event_box_button_release_event(GtkWidget *widget, GdkEventButton *event, FlView *view)
Definition: fl_view.cc:495
void fl_engine_set_on_pre_engine_restart_handler(FlEngine *self, FlEngineOnPreEngineRestartHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:549
static void fl_view_init_keyboard(FlView *self)
Definition: fl_view.cc:91
FlEngine * fl_engine_new(FlDartProject *project, FlRenderer *renderer)
Definition: fl_engine.cc:388
FlPlatformPlugin * fl_platform_plugin_new(FlBinaryMessenger *messenger)
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:769
void fl_engine_set_update_semantics_node_handler(FlEngine *self, FlEngineUpdateSemanticsNodeHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:532
static gboolean event_box_button_press_event(GtkWidget *widget, GdkEventButton *event, FlView *view)
Definition: fl_view.cc:479
FlAccessibilityPlugin * fl_accessibility_plugin_new(FlView *view)
static gboolean event_box_enter_notify_event(GtkWidget *widget, GdkEventCrossing *event, FlView *view)
Definition: fl_view.cc:571

◆ fl_view_dispose()

static void fl_view_dispose ( GObject *  object)
static

Definition at line 305 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().

305  {
306  FlView* self = FL_VIEW(object);
307 
308  if (self->engine != nullptr) {
309  fl_engine_set_update_semantics_node_handler(self->engine, nullptr, nullptr,
310  nullptr);
311  fl_engine_set_on_pre_engine_restart_handler(self->engine, nullptr, nullptr,
312  nullptr);
313  }
314 
315  g_clear_object(&self->project);
316  g_clear_object(&self->renderer);
317  g_clear_object(&self->engine);
318  g_clear_object(&self->accessibility_plugin);
319  g_clear_object(&self->keyboard_manager);
320  g_clear_object(&self->mouse_cursor_plugin);
321  g_clear_object(&self->platform_plugin);
322  g_list_free_full(self->gl_area_list, g_object_unref);
323  self->gl_area_list = nullptr;
324 
325  G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
326 }
void fl_engine_set_on_pre_engine_restart_handler(FlEngine *self, FlEngineOnPreEngineRestartHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:549
void fl_engine_set_update_semantics_node_handler(FlEngine *self, FlEngineUpdateSemanticsNodeHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:532

◆ 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 805 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().

805  {
806  for (GList* pending_child = view->pending_children_list; pending_child;
807  pending_child = pending_child->next) {
808  FlViewChild* pending_view_child =
809  reinterpret_cast<FlViewChild*>(pending_child->data);
810  GList* child = find_child(view->children_list, pending_view_child->widget);
811 
812  if (child) {
813  // existing child
814  g_free(child->data);
815  child->data = nullptr;
816  } else {
817  // newly added child
818  gtk_widget_set_parent(pending_view_child->widget, GTK_WIDGET(view));
819  }
820  }
821 
822  for (GList* child = view->children_list; child; child = child->next) {
823  FlViewChild* view_child = reinterpret_cast<FlViewChild*>(child->data);
824  if (view_child) {
825  // removed child
826  g_object_ref(view_child->widget);
827  gtk_widget_unparent(view_child->widget);
828  g_free(view_child);
829  child->data = nullptr;
830  }
831  }
832 
833  g_list_free(view->children_list);
834  view->children_list = view->pending_children_list;
835  view->pending_children_list = nullptr;
836 
837  struct _ReorderData data = {
838  .parent_window = gtk_widget_get_window(GTK_WIDGET(view)),
839  .last_window = nullptr,
840  };
841 
842  gtk_container_forall(GTK_CONTAINER(view), fl_view_reorder_forall, &data);
843 
844  gtk_widget_queue_draw(GTK_WIDGET(view));
845 }
static void fl_view_reorder_forall(GtkWidget *widget, gpointer user_data)
Definition: fl_view.cc:468
GdkWindow * parent_window
Definition: fl_view.cc:464
GList * find_child(GList *list, GtkWidget *widget)
Definition: fl_view.cc:796
GtkWidget * widget
Definition: fl_view.cc:61
FlView * view

◆ fl_view_forall()

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

Definition at line 665 of file fl_view.cc.

References _FlViewChild::widget.

Referenced by fl_view_class_init().

668  {
669  FlView* self = FL_VIEW(container);
670  for (GList* iterator = self->children_list; iterator;
671  iterator = iterator->next) {
672  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
673  (*callback)(child->widget, callback_data);
674  }
675 
676  if (include_internals) {
677  (*callback)(self->event_box, callback_data);
678  }
679 }
GtkWidget * widget
Definition: fl_view.cc:61

◆ fl_view_geometry_changed()

static void fl_view_geometry_changed ( FlView *  self)
static

Definition at line 169 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().

169  {
170  GtkAllocation allocation;
171  gtk_widget_get_allocation(GTK_WIDGET(self), &allocation);
172  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
174  self->engine, allocation.width * scale_factor,
175  allocation.height * scale_factor, scale_factor);
176 
177  fl_renderer_wait_for_frame(self->renderer, allocation.width * scale_factor,
178  allocation.height * scale_factor);
179 }
void fl_engine_send_window_metrics_event(FlEngine *self, size_t width, size_t height, double pixel_ratio)
Definition: fl_engine.cc:666
void fl_renderer_wait_for_frame(FlRenderer *self, int target_width, int target_height)
Definition: fl_renderer.cc:143

◆ 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 691 of file fl_view.cc.

Referenced by fl_view_class_init().

695  {}

◆ 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 742 of file fl_view.cc.

Referenced by fl_renderer_unblock_main_thread(), and fl_renderer_wait_for_frame().

742  {
743  g_return_val_if_fail(FL_IS_VIEW(view), nullptr);
744  return view->engine;
745 }
FlView * view

◆ fl_view_get_preferred_height()

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

Definition at line 388 of file fl_view.cc.

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

Referenced by fl_view_class_init().

390  {
391  FlView* self = FL_VIEW(widget);
392  gint child_min, child_nat;
393 
394  *minimum = 0;
395  *natural = 0;
396 
397  for (GList* iterator = self->children_list; iterator;
398  iterator = iterator->next) {
399  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
400 
401  if (!gtk_widget_get_visible(child->widget))
402  continue;
403 
404  gtk_widget_get_preferred_height(child->widget, &child_min, &child_nat);
405 
406  *minimum = MAX(*minimum, child->geometry.y + child_min);
407  *natural = MAX(*natural, child->geometry.y + child_nat);
408  }
409 }
GtkWidget * widget
Definition: fl_view.cc:61
GdkRectangle geometry
Definition: fl_view.cc:62

◆ fl_view_get_preferred_width()

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

Definition at line 365 of file fl_view.cc.

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

Referenced by fl_view_class_init().

367  {
368  FlView* self = FL_VIEW(widget);
369  gint child_min, child_nat;
370 
371  *minimum = 0;
372  *natural = 0;
373 
374  for (GList* iterator = self->children_list; iterator;
375  iterator = iterator->next) {
376  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
377 
378  if (!gtk_widget_get_visible(child->widget))
379  continue;
380 
381  gtk_widget_get_preferred_width(child->widget, &child_min, &child_nat);
382 
383  *minimum = MAX(*minimum, child->geometry.x + child_min);
384  *natural = MAX(*natural, child->geometry.x + child_nat);
385  }
386 }
GtkWidget * widget
Definition: fl_view.cc:61
GdkRectangle geometry
Definition: fl_view.cc:62

◆ fl_view_get_property()

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

Definition at line 277 of file fl_view.cc.

References PROP_FLUTTER_PROJECT.

Referenced by fl_view_class_init().

280  {
281  FlView* self = FL_VIEW(object);
282 
283  switch (prop_id) {
285  g_value_set_object(value, self->project);
286  break;
287  default:
288  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
289  break;
290  }
291 }
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 182 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().

184  {
185  FlView* self = FL_VIEW(registry);
186 
187  return fl_plugin_registrar_new(self,
188  fl_engine_get_binary_messenger(self->engine),
189  fl_engine_get_texture_registrar(self->engine));
190 }
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:769
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:785

◆ fl_view_init()

static void fl_view_init ( FlView *  self)
static

Definition at line 733 of file fl_view.cc.

References TRUE.

733  {
734  gtk_widget_set_can_focus(GTK_WIDGET(self), TRUE);
735 }

◆ fl_view_init_keyboard()

static void fl_view_init_keyboard ( FlView *  self)
static

Definition at line 91 of file fl_view.cc.

References fl_engine_get_binary_messenger(), fl_key_channel_responder_new(), fl_key_embedder_responder_new(), fl_keyboard_manager_add_responder(), fl_keyboard_manager_new(), fl_text_input_plugin_new(), redispatch_key_event_by_gtk(), and text_input_im_filter_by_gtk().

Referenced by fl_view_constructed(), and fl_view_on_pre_engine_restart_cb().

91  {
92  FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
93  self->keyboard_manager = fl_keyboard_manager_new(
96  // The embedder responder must be added before the channel responder.
98  self->keyboard_manager,
99  FL_KEY_RESPONDER(fl_key_embedder_responder_new(self->engine)));
101  self->keyboard_manager,
102  FL_KEY_RESPONDER(fl_key_channel_responder_new(messenger)));
103 }
static gboolean text_input_im_filter_by_gtk(GtkIMContext *im_context, gpointer gdk_event)
Definition: fl_view.cc:854
void fl_keyboard_manager_add_responder(FlKeyboardManager *self, FlKeyResponder *responder)
FlKeyboardManager * fl_keyboard_manager_new(FlTextInputPlugin *text_input_plugin, FlKeyboardManagerRedispatcher redispatch_callback)
FlKeyChannelResponder * fl_key_channel_responder_new(FlBinaryMessenger *messenger, FlKeyChannelResponderMock *mock)
static void redispatch_key_event_by_gtk(gpointer gdk_event)
Definition: fl_view.cc:847
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:769
FlTextInputPlugin * fl_text_input_plugin_new(FlBinaryMessenger *messenger, FlView *view, FlTextInputPluginImFilter im_filter)
FlKeyEmbedderResponder * fl_key_embedder_responder_new(FlEngine *engine)

◆ fl_view_key_press_event()

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

Definition at line 606 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().

606  {
607  FlView* self = FL_VIEW(widget);
608 
610  self->keyboard_manager, fl_key_event_new_from_gdk_event(gdk_event_copy(
611  reinterpret_cast<GdkEvent*>(event))));
612 }
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 615 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().

616  {
617  FlView* self = FL_VIEW(widget);
619  self->keyboard_manager, fl_key_event_new_from_gdk_event(gdk_event_copy(
620  reinterpret_cast<GdkEvent*>(event))));
621 }
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_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 737 of file fl_view.cc.

737  {
738  return static_cast<FlView*>(
739  g_object_new(fl_view_get_type(), "flutter-project", project, nullptr));
740 }

◆ fl_view_notify()

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

Definition at line 293 of file fl_view.cc.

References fl_view_geometry_changed().

Referenced by fl_view_class_init().

293  {
294  FlView* self = FL_VIEW(object);
295 
296  if (strcmp(pspec->name, "scale-factor") == 0) {
298  }
299 
300  if (G_OBJECT_CLASS(fl_view_parent_class)->notify != nullptr) {
301  G_OBJECT_CLASS(fl_view_parent_class)->notify(object, pspec);
302  }
303 }
static void fl_view_geometry_changed(FlView *self)
Definition: fl_view.cc:169

◆ fl_view_on_pre_engine_restart_cb()

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

Definition at line 110 of file fl_view.cc.

References fl_view_init_keyboard().

Referenced by fl_view_constructed().

111  {
112  FlView* self = FL_VIEW(user_data);
113 
114  g_clear_object(&self->keyboard_manager);
115  fl_view_init_keyboard(self);
116 }
static void fl_view_init_keyboard(FlView *self)
Definition: fl_view.cc:91
const FlutterSemanticsNode gpointer user_data
Definition: fl_view.cc:84

◆ fl_view_plugin_registry_iface_init()

static void fl_view_plugin_registry_iface_init ( FlPluginRegistryInterface *  iface)
static

Definition at line 192 of file fl_view.cc.

References event, event_box_button_press_event(), event_box_button_release_event(), event_box_enter_notify_event(), event_box_leave_notify_event(), event_box_motion_notify_event(), event_box_scroll_event(), fl_view_get_registrar_for_plugin(), and view.

193  {
194  iface->get_registrar_for_plugin = fl_view_get_registrar_for_plugin;
195 }
static FlPluginRegistrar * fl_view_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_view.cc:182

◆ fl_view_put()

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

Definition at line 623 of file fl_view.cc.

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

Referenced by fl_view_add().

625  {
626  FlViewChild* child = g_new(FlViewChild, 1);
627  child->widget = widget;
628  child->geometry = *geometry;
629 
630  gtk_widget_set_parent(widget, GTK_WIDGET(self));
631  self->children_list = g_list_append(self->children_list, child);
632 }
GtkWidget * widget
Definition: fl_view.cc:61
GdkRectangle geometry
Definition: fl_view.cc:62

◆ fl_view_realize()

static void fl_view_realize ( GtkWidget *  widget)
static

Definition at line 329 of file fl_view.cc.

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

Referenced by fl_view_class_init().

329  {
330  FlView* self = FL_VIEW(widget);
331  g_autoptr(GError) error = nullptr;
332 
333  GtkAllocation allocation;
334  gtk_widget_get_allocation(widget, &allocation);
335 
336  gtk_widget_set_realized(widget, TRUE);
337 
338  GdkWindowAttr attributes;
339  attributes.window_type = GDK_WINDOW_CHILD;
340  attributes.x = allocation.x;
341  attributes.y = allocation.y;
342  attributes.width = allocation.width;
343  attributes.height = allocation.height;
344  attributes.wclass = GDK_INPUT_OUTPUT;
345  attributes.visual = gtk_widget_get_visual(widget);
346  attributes.event_mask =
347  gtk_widget_get_events(widget) | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK;
348  gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
349  GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget),
350  &attributes, attributes_mask);
351  gtk_widget_set_window(widget, window);
352  gtk_widget_register_window(widget, window);
353 
354  if (!fl_renderer_start(self->renderer, self, &error)) {
355  g_warning("Failed to start Flutter renderer: %s", error->message);
356  return;
357  }
358 
359  if (!fl_engine_start(self->engine, &error)) {
360  g_warning("Failed to start Flutter engine: %s", error->message);
361  return;
362  }
363 }
const uint8_t uint32_t uint32_t GError ** error
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:403
gboolean fl_renderer_start(FlRenderer *self, FlView *view, GError **error)
Definition: fl_renderer.cc:59

◆ fl_view_remove()

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

Definition at line 644 of file fl_view.cc.

References _FlViewChild::widget.

Referenced by fl_view_class_init().

644  {
645  FlView* self = FL_VIEW(container);
646  for (GList* iterator = self->children_list; iterator;
647  iterator = iterator->next) {
648  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
649  if (child->widget == widget) {
650  g_object_ref(widget);
651  gtk_widget_unparent(widget);
652  self->children_list = g_list_remove_link(self->children_list, iterator);
653  g_list_free(iterator);
654  g_free(child);
655 
656  break;
657  }
658  }
659 
660  if (widget == GTK_WIDGET(self->event_box)) {
661  g_clear_object(&self->event_box);
662  }
663 }
GtkWidget * widget
Definition: fl_view.cc:61

◆ fl_view_reorder_forall()

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

Definition at line 468 of file fl_view.cc.

References _ReorderData::last_window, _ReorderData::parent_window, TRUE, and user_data.

Referenced by fl_view_end_frame().

468  {
469  _ReorderData* data = reinterpret_cast<_ReorderData*>(user_data);
470  GdkWindow* window = gtk_widget_get_window(widget);
471  if (window && window != data->parent_window) {
472  if (data->last_window) {
473  gdk_window_restack(window, data->last_window, TRUE);
474  }
475  data->last_window = window;
476  }
477 }
GdkWindow * parent_window
Definition: fl_view.cc:464
GdkWindow * last_window
Definition: fl_view.cc:465
const FlutterSemanticsNode gpointer user_data
Definition: fl_view.cc:84

◆ fl_view_send_pointer_button_event()

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

Definition at line 119 of file fl_view.cc.

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

Referenced by event_box_button_press_event(), and event_box_button_release_event().

120  {
121  int64_t button;
122  switch (event->button) {
123  case 1:
125  break;
126  case 2:
128  break;
129  case 3:
131  break;
132  default:
133  return FALSE;
134  }
135  int old_button_state = self->button_state;
136  FlutterPointerPhase phase = kMove;
137  if (event->type == GDK_BUTTON_PRESS) {
138  // Drop the event if Flutter already thinks the button is down.
139  if ((self->button_state & button) != 0) {
140  return FALSE;
141  }
142  self->button_state ^= button;
143 
144  phase = old_button_state == 0 ? kDown : kMove;
145  } else if (event->type == GDK_BUTTON_RELEASE) {
146  // Drop the event if Flutter already thinks the button is up.
147  if ((self->button_state & button) == 0) {
148  return FALSE;
149  }
150  self->button_state ^= button;
151 
152  phase = self->button_state == 0 ? kUp : kMove;
153  }
154 
155  if (self->engine == nullptr) {
156  return FALSE;
157  }
158 
159  gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
161  self->engine, phase, event->time * kMicrosecondsPerMillisecond,
162  event->x * scale_factor, event->y * scale_factor, 0, 0,
163  self->button_state);
164 
165  return TRUE;
166 }
Definition: embedder.h:595
FlutterPointerPhase
The phase of the pointer event.
Definition: embedder.h:587
guint32 time
Definition: fl_key_event.h:33
FlKeyEvent * event
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:25
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:684
return FALSE

◆ 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 685 of file fl_view.cc.

Referenced by fl_view_class_init().

689  {}

◆ fl_view_set_property()

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

Definition at line 260 of file fl_view.cc.

References PROP_FLUTTER_PROJECT.

Referenced by fl_view_class_init().

263  {
264  FlView* self = FL_VIEW(object);
265 
266  switch (prop_id) {
268  g_set_object(&self->project,
269  static_cast<FlDartProject*>(g_value_get_object(value)));
270  break;
271  default:
272  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
273  break;
274  }
275 }
uint8_t value

◆ fl_view_size_allocate()

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

Definition at line 412 of file fl_view.cc.

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

Referenced by fl_view_class_init().

413  {
414  FlView* self = FL_VIEW(widget);
415 
416  gtk_widget_set_allocation(widget, allocation);
417 
418  if (gtk_widget_get_has_window(widget)) {
419  if (gtk_widget_get_realized(widget))
420  gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x,
421  allocation->y, allocation->width,
422  allocation->height);
423  }
424 
425  for (GList* iterator = self->children_list; iterator;
426  iterator = iterator->next) {
427  FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
428  if (!gtk_widget_get_visible(child->widget))
429  continue;
430 
431  GtkAllocation child_allocation = child->geometry;
432  GtkRequisition child_requisition;
433  gtk_widget_get_preferred_size(child->widget, &child_requisition, NULL);
434 
435  if (!gtk_widget_get_has_window(widget)) {
436  child_allocation.x += allocation->x;
437  child_allocation.y += allocation->y;
438  }
439 
440  if (child_allocation.width == 0 && child_allocation.height == 0) {
441  child_allocation.width = allocation->width;
442  child_allocation.height = allocation->height;
443  }
444 
445  gtk_widget_size_allocate(child->widget, &child_allocation);
446  }
447 
448  GtkAllocation event_box_allocation = {
449  .x = 0,
450  .y = 0,
451  .width = allocation->width,
452  .height = allocation->height,
453  };
454  if (!gtk_widget_get_has_window(self->event_box)) {
455  event_box_allocation.x += allocation->x;
456  event_box_allocation.y += allocation->y;
457  }
458  gtk_widget_size_allocate(self->event_box, &event_box_allocation);
459 
461 }
static void fl_view_geometry_changed(FlView *self)
Definition: fl_view.cc:169
GtkWidget * widget
Definition: fl_view.cc:61
GdkRectangle geometry
Definition: fl_view.cc:62

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

◆ redispatch_key_event_by_gtk()

static void redispatch_key_event_by_gtk ( gpointer  gdk_event)
static

Definition at line 847 of file fl_view.cc.

References type.

Referenced by fl_view_init_keyboard().

847  {
848  GdkEvent* gdk_event = reinterpret_cast<GdkEvent*>(raw_event);
849  GdkEventType type = gdk_event->type;
850  g_return_if_fail(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE);
851  gdk_event_put(gdk_event);
852 }
KeyCallType type

◆ text_input_im_filter_by_gtk()

static gboolean text_input_im_filter_by_gtk ( GtkIMContext *  im_context,
gpointer  gdk_event 
)
static

Definition at line 854 of file fl_view.cc.

References event, and type.

Referenced by fl_view_init_keyboard().

855  {
856  GdkEventKey* event = reinterpret_cast<GdkEventKey*>(gdk_event);
857  GdkEventType type = event->type;
858  g_return_val_if_fail(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE, false);
859  return gtk_im_context_filter_keypress(im_context, event);
860 }
KeyCallType type
FlKeyEvent * event

Variable Documentation

◆ kMicrosecondsPerMillisecond

constexpr int kMicrosecondsPerMillisecond = 1000
static

◆ node

return node

Definition at line 83 of file fl_view.cc.

Referenced by ui::AXEventGenerator::AddEvent(), ui::AXTreeObserver::Change::Change(), SemanticsObject::collectRoutes:, flutter::AccessibilityBridge::CommitUpdates(), flutter::DidFlagChange(), ui::AXEventGenerator::end(), FlutterEngineInitialize(), ui::AXPlatformNode::GetAccessibilityMode(), ui::AXNode::GetCollapsedMenuListPopUpButtonAncestor(), ui::TestAXNodeWrapper::GetIndexInParent(), ui::AXTree::GetNextNegativeInternalNodeId(), ui::AXNodePosition::GetNextOnLineID(), ui::AXNode::GetNextUnignoredInTreeOrder(), ui::AXPlatformNodeDelegateBase::GetNodesForNodeIds(), ui::TestAXNodeHelper::GetOrCreate(), ui::AXNodePosition::GetPreviousOnLineID(), ui::AXTree::GetSetSize(), ui::AXNode::GetTableRowNodeIds(), ui::AXPlatformNodeDelegateBase::GetTargetNodesForRelation(), ui::TestAXNodeWrapper::GetUniqueId(), ui::AXPlatformNodeWinTest::IAccessibleFromNode(), flutter::FlutterPlatformNodeDelegate::Init(), ui::AXPosition< AXNodePosition, AXNode >::Initialize(), FlutterTextField::initWithPlatformNode:fieldEditor:, ui::AXTableInfo::Invalidate(), ui::AXNode::IsCellOrHeaderOfARIAGrid(), ui::AXNode::IsCellOrHeaderOfARIATable(), ui::AXNode::IsCollapsedMenuListPopUpButton(), ui::AXEventGenerator::OnAtomicUpdateFinished(), ui::AXEventGenerator::OnBoolAttributeChanged(), SemanticsObject::onCustomAccessibilityAction:, ui::AXEventGenerator::OnNodeDataChanged(), ui::AXEventGenerator::OnStateChanged(), SemanticsObject::routeName, ui::TestAXNodeWrapper::SetNodeFromLastDefaultAction(), flutter_runner::AccessibilityBridge::SetSemanticsEnabled(), SemanticsObject::setSemanticsNode:, FlutterEngine::shutDownEngine, TEST(), ui::TEST(), flutter::testing::TEST_F(), dart_utils::TEST_F(), flutter_runner_test::TEST_F(), flutter_runner::testing::TEST_F(), flutter::AccessibilityBridge::UpdateDelegate(), flutter::SemanticsUpdateBuilder::updateNode(), flutter_runner_test::MockSemanticsManager::UpdateSemanticNodes(), flutter::PlatformViewAndroidDelegate::UpdateSemantics(), and flutter::AccessibilityBridge::UpdateSemantics().

◆ user_data

const FlutterSemanticsNode gpointer user_data
Initial value:
{
FlView* self = FL_VIEW(user_data)
const FlutterSemanticsNode gpointer user_data
Definition: fl_view.cc:84

Definition at line 84 of file fl_view.cc.

Referenced by fl_view_reorder_forall().