| Flutter Linux Embedder |

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

Go to the source code of this file.

## Classes
struct | _FlView

## Enumerations
enum | { SIGNAL_FIRST_FRAME , LAST_SIGNAL }

## Functions
static void | fl_renderable_iface_init (FlRenderableInterface *iface)
static void | fl_view_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
| G_DEFINE_TYPE_WITH_CODE (FlView, fl_view, GTK_TYPE_BOX, G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_view_plugin_registry_iface_init)) static gboolean redraw_cb(gpointer user_data)
static gboolean | window_delete_event_cb (FlView *self)
static void | init_scrolling (FlView *self)
static void | init_touch (FlView *self)
static FlutterPointerDeviceKind | get_device_kind (GdkEvent *event)
static void | cursor_changed_cb (FlView *self)
static void | setup_cursor (FlView *self)
static void | handle_geometry_changed (FlView *self)
static void | view_added_cb (GObject *object, GAsyncResult *result, gpointer user_data)
static void | update_semantics_cb (FlView *self, const FlutterSemanticsUpdate2 *update)
static void | on_pre_engine_restart_cb (FlView *self)
static void | fl_view_present_layers (FlRenderable *renderable, const FlutterLayer **layers, size_t layers_count)
static FlPluginRegistrar * | fl_view_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
static void | sync_modifier_if_needed (FlView *self, GdkEvent *event)
static void | set_scrolling_position (FlView *self, gdouble x, gdouble y)
static gboolean | button_press_event_cb (FlView *self, GdkEventButton *button_event)
static gboolean | button_release_event_cb (FlView *self, GdkEventButton *button_event)
static gboolean | scroll_event_cb (FlView *self, GdkEventScroll *event)
static gboolean | touch_event_cb (FlView *self, GdkEventTouch *event)
static gboolean | motion_notify_event_cb (FlView *self, GdkEventMotion *motion_event)
static gboolean | enter_notify_event_cb (FlView *self, GdkEventCrossing *crossing_event)
static gboolean | leave_notify_event_cb (FlView *self, GdkEventCrossing *crossing_event)
static void | gesture_rotation_begin_cb (FlView *self)
static void | gesture_rotation_update_cb (FlView *self, gdouble rotation, gdouble delta)
static void | gesture_rotation_end_cb (FlView *self)
static void | gesture_zoom_begin_cb (FlView *self)
static void | gesture_zoom_update_cb (FlView *self, gdouble scale)
static void | gesture_zoom_end_cb (FlView *self)
static void | setup_opengl (FlView *self)
static void | setup_software (FlView *self)
static void | realize_cb (FlView *self)
static void | size_allocate_cb (FlView *self)
static void | paint_background (FlView *self, cairo_t *cr)
static gboolean | draw_cb (FlView *self, cairo_t *cr)
static void | fl_view_notify (GObject *object, GParamSpec *pspec)
static void | fl_view_dispose (GObject *object)
static void | fl_view_realize (GtkWidget *widget)
static gboolean | handle_key_event (FlView *self, GdkEventKey *key_event)
static gboolean | fl_view_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
static gboolean | fl_view_key_press_event (GtkWidget *widget, GdkEventKey *key_event)
static gboolean | fl_view_key_release_event (GtkWidget *widget, GdkEventKey *key_event)
static void | fl_view_class_init (FlViewClass *klass)
static void | setup_engine (FlView *self)
static void | fl_view_init (FlView *self)
G_MODULE_EXPORT FlView * | fl_view_new (FlDartProject *project)
G_MODULE_EXPORT FlView * | fl_view_new_for_engine (FlEngine *engine)
G_MODULE_EXPORT FlEngine * | fl_view_get_engine (FlView *self)
G_MODULE_EXPORT int64_t | fl_view_get_id (FlView *self)
G_MODULE_EXPORT void | fl_view_set_background_color (FlView *self, const GdkRGBA *color)
FlViewAccessible * | fl_view_get_accessible (FlView *self)

## Variables
static guint | fl_view_signals [LAST_SIGNAL]

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
SIGNAL_FIRST_FRAME |
LAST_SIGNAL |

Definition at line 85 of file fl_view.cc.

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

## Function Documentation

## ◆ button_press_event_cb()

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

Definition at line 294 of file fl_view.cc.

295 {
296 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
297
298 // Flutter doesn't handle double and triple click events.
299 GdkEventType event_type = gdk_event_get_event_type(event);
300 if (event_type == GDK_DOUBLE_BUTTON_PRESS ||
301 event_type == GDK_TRIPLE_BUTTON_PRESS) {
302 return FALSE;
303 }
304
305 guint button = 0;
306 gdk_event_get_button(event, &button);
307
308 gdouble x = 0.0, y = 0.0;
309 gdk_event_get_coords(event, &x, &y);
310
311 set_scrolling_position(self, x, y);
312 sync_modifier_if_needed(self, event);
313
314 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
315 return fl_pointer_manager_handle_button_press(
316 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
317 x * scale_factor, y * scale_factor, button);
318 }
self
g_cond_signal & self
Definition: fl_compositor_software.cc:67
fl_pointer_manager_handle_button_press
gboolean fl_pointer_manager_handle_button_press(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_button)
Definition: fl_pointer_manager.cc:105
set_scrolling_position
static void set_scrolling_position(FlView *self, gdouble x, gdouble y)
Definition: fl_view.cc:287
sync_modifier_if_needed
static void sync_modifier_if_needed(FlView *self, GdkEvent *event)
Definition: fl_view.cc:279
get_device_kind
static FlutterPointerDeviceKind get_device_kind(GdkEvent *event)
Definition: fl_view.cc:134

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

Referenced by fl_view_init().

## ◆ button_release_event_cb()

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

Definition at line 321 of file fl_view.cc.

322 {
323 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
324
325 guint button = 0;
326 gdk_event_get_button(event, &button);
327
328 gdouble x = 0.0, y = 0.0;
329 gdk_event_get_coords(event, &x, &y);
330
331 set_scrolling_position(self, x, y);
332 sync_modifier_if_needed(self, event);
333
334 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
335 return fl_pointer_manager_handle_button_release(
336 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
337 x * scale_factor, y * scale_factor, button);
338 }
fl_pointer_manager_handle_button_release
gboolean fl_pointer_manager_handle_button_release(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y, guint gdk_button)
Definition: fl_pointer_manager.cc:143

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

Referenced by fl_view_init().

## ◆ cursor_changed_cb()

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

Definition at line 154 of file fl_view.cc.

154 {
155 FlMouseCursorHandler* handler =
156 fl_engine_get_mouse_cursor_handler(self->engine);
157 const gchar* cursor_name = fl_mouse_cursor_handler_get_cursor_name(handler);
158 GdkWindow* window =
159 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
160 g_autoptr(GdkCursor) cursor =
161 gdk_cursor_new_from_name(gdk_window_get_display(window), cursor_name);
162 gdk_window_set_cursor(window, cursor);
163 }
window
return window
Definition: fl_application.cc:41
g_autoptr
g_autoptr(GMutexLocker) locker
fl_engine_get_mouse_cursor_handler
FlMouseCursorHandler * fl_engine_get_mouse_cursor_handler(FlEngine *self)
Definition: fl_engine.cc:1467
fl_mouse_cursor_handler_get_cursor_name
const gchar * fl_mouse_cursor_handler_get_cursor_name(FlMouseCursorHandler *self)
Definition: fl_mouse_cursor_handler.cc:147

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

Referenced by setup_cursor().

## ◆ draw_cb()

static gboolean draw_cb | ( | FlView * | self,
|  | cairo_t * | cr
| ) |  |
| static

Definition at line 520 of file fl_view.cc.

520 {
521 paint_background(self, cr);
522
523 if (self->render_context) {
524 gdk_gl_context_make_current(self->render_context);
525 }
526
527 gboolean result = fl_compositor_render(
528 self->compositor, cr,
529 gtk_widget_get_window(GTK_WIDGET(self->render_area)));
530
531 if (self->render_context) {
532 gdk_gl_context_clear_current();
533 }
534
535 return result;
536 }
fl_compositor_render
gboolean fl_compositor_render(FlCompositor *self, cairo_t *cr, GdkWindow *window)
Definition: fl_compositor.cc:23
paint_background
static void paint_background(FlView *self, cairo_t *cr)
Definition: fl_view.cc:508

References fl_compositor_render(), paint_background(), and self.

Referenced by fl_view_init().

## ◆ enter_notify_event_cb()

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

Definition at line 380 of file fl_view.cc.

381 {
382 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
383 gdouble x = 0.0, y = 0.0;
384 gdk_event_get_coords(event, &x, &y);
385 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
386 return fl_pointer_manager_handle_enter(
387 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
388 x * scale_factor, y * scale_factor);
389 }
fl_pointer_manager_handle_enter
gboolean fl_pointer_manager_handle_enter(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:201

References fl_pointer_manager_handle_enter(), get_device_kind(), and self.

Referenced by fl_view_init().

## ◆ fl_renderable_iface_init()

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

Definition at line 270 of file fl_view.cc.

270 {
271 iface->present_layers = fl_view_present_layers;
272 }
fl_view_present_layers
static void fl_view_present_layers(FlRenderable *renderable, const FlutterLayer **layers, size_t layers_count)
Definition: fl_view.cc:248

References fl_view_present_layers().

## ◆ fl_view_class_init()

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

Definition at line 662 of file fl_view.cc.

662 {
663 GObjectClass* object_class = G_OBJECT_CLASS(klass);
664 object_class->notify = fl_view_notify;
665 object_class->dispose = fl_view_dispose;
666
667 GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
668 widget_class->realize = fl_view_realize;
669 widget_class->focus_in_event = fl_view_focus_in_event;
670 widget_class->key_press_event = fl_view_key_press_event;
671 widget_class->key_release_event = fl_view_key_release_event;
672
673 fl_view_signals[SIGNAL_FIRST_FRAME] =
674 g_signal_new("first-frame", fl_view_get_type(), G_SIGNAL_RUN_LAST, 0,
675 NULL, NULL, NULL, G_TYPE_NONE, 0);
676
677 gtk_widget_class_set_accessible_type(GTK_WIDGET_CLASS(klass),
678 fl_socket_accessible_get_type());
679 }
fl_view_realize
static void fl_view_realize(GtkWidget *widget)
Definition: fl_view.cc:594
fl_view_key_release_event
static gboolean fl_view_key_release_event(GtkWidget *widget, GdkEventKey *key_event)
Definition: fl_view.cc:656
fl_view_dispose
static void fl_view_dispose(GObject *object)
Definition: fl_view.cc:550
fl_view_key_press_event
static gboolean fl_view_key_press_event(GtkWidget *widget, GdkEventKey *key_event)
Definition: fl_view.cc:649
fl_view_notify
static void fl_view_notify(GObject *object, GParamSpec *pspec)
Definition: fl_view.cc:538
fl_view_signals
static guint fl_view_signals[LAST_SIGNAL]
Definition: fl_view.cc:87
fl_view_focus_in_event
static gboolean fl_view_focus_in_event(GtkWidget *widget, GdkEventFocus *event)
Definition: fl_view.cc:640

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

## ◆ fl_view_dispose()

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

Definition at line 550 of file fl_view.cc.

550 {
551 FlView* self = FL_VIEW(object);
552
553 g_cancellable_cancel(self->cancellable);
554
555 if (self->engine != nullptr) {
556 FlMouseCursorHandler* handler =
557 fl_engine_get_mouse_cursor_handler(self->engine);
558 if (self->cursor_changed_cb_id != 0) {
559 g_signal_handler_disconnect(handler, self->cursor_changed_cb_id);
560 self->cursor_changed_cb_id = 0;
561 }
562
563 // Release the view ID from the engine.
564 fl_engine_remove_view(self->engine, self->view_id, nullptr, nullptr,
565 nullptr);
566 }
567
568 if (self->on_pre_engine_restart_cb_id != 0) {
569 g_signal_handler_disconnect(self->engine,
570 self->on_pre_engine_restart_cb_id);
571 self->on_pre_engine_restart_cb_id = 0;
572 }
573
574 if (self->update_semantics_cb_id != 0) {
575 g_signal_handler_disconnect(self->engine, self->update_semantics_cb_id);
576 self->update_semantics_cb_id = 0;
577 }
578
579 g_clear_object(&self->render_context);
580 g_clear_object(&self->engine);
581 g_clear_object(&self->compositor);
582 g_clear_pointer(&self->background_color, gdk_rgba_free);
583 g_clear_object(&self->window_state_monitor);
584 g_clear_object(&self->scrolling_manager);
585 g_clear_object(&self->pointer_manager);
586 g_clear_object(&self->touch_manager);
587 g_clear_object(&self->view_accessible);
588 g_clear_object(&self->cancellable);
589
590 G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
591 }
fl_engine_remove_view
void fl_engine_remove_view(FlEngine *self, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:947

References fl_engine_get_mouse_cursor_handler(), fl_engine_remove_view(), and self.

Referenced by fl_view_class_init().

## ◆ fl_view_focus_in_event()

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

Definition at line 640 of file fl_view.cc.

641 {
642 FlView* self = FL_VIEW(widget);
643 fl_text_input_handler_set_widget(
644 fl_engine_get_text_input_handler(self->engine), widget);
645 return FALSE;
646 }
fl_engine_get_text_input_handler
FlTextInputHandler * fl_engine_get_text_input_handler(FlEngine *self)
Definition: fl_engine.cc:1462
fl_text_input_handler_set_widget
void fl_text_input_handler_set_widget(FlTextInputHandler *self, GtkWidget *widget)
Definition: fl_text_input_handler.cc:464

References fl_engine_get_text_input_handler(), fl_text_input_handler_set_widget(), and self.

Referenced by fl_view_class_init().

## ◆ fl_view_get_accessible()

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

fl_view_get_accessible: @view: an #FlView.

Get the accessible object for this view.

Returns: an #FlViewAccessible.

Definition at line 806 of file fl_view.cc.

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

Referenced by TEST().

## ◆ fl_view_get_engine()

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

fl_view_get_engine: @view: an #FlView.

Gets the engine being rendered in the view.

Returns: an #FlEngine.

Definition at line 788 of file fl_view.cc.

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

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_get_id()

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

fl_view_get_id: @view: an #FlView.

Gets the Flutter view ID used by this view.

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

Definition at line 794 of file fl_view.cc.

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

Referenced by create_regular(), and TEST().

## ◆ fl_view_get_registrar_for_plugin()

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

Definition at line 260 of file fl_view.cc.

262 {
263 FlView* self = FL_VIEW(registry);
264
265 return fl_plugin_registrar_new(self,
266 fl_engine_get_binary_messenger(self->engine),
267 fl_engine_get_texture_registrar(self->engine));
268 }
fl_engine_get_texture_registrar
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:1430
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:1414
fl_plugin_registrar_new
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
Definition: fl_plugin_registrar.cc:84

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

Referenced by fl_view_plugin_registry_iface_init().

## ◆ fl_view_init()

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

Definition at line 700 of file fl_view.cc.

700 {
701 self->cancellable = g_cancellable_new();
702
703 gtk_widget_set_can_focus(GTK_WIDGET(self), TRUE);
704
705 self->view_id = -1;
706
707 GdkRGBA default_background = {
708 .red = 0.0, .green = 0.0, .blue = 0.0, .alpha = 1.0};
709 self->background_color = gdk_rgba_copy(&default_background);
710
711 self->event_box = gtk_event_box_new();
712 gtk_widget_set_hexpand(self->event_box, TRUE);
713 gtk_widget_set_vexpand(self->event_box, TRUE);
714 gtk_container_add(GTK_CONTAINER(self), self->event_box);
715 gtk_widget_show(self->event_box);
716 gtk_widget_add_events(self->event_box,
717 GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
718 GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK |
719 GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK);
720
721 g_signal_connect_swapped(self->event_box, "button-press-event",
722 G_CALLBACK(button_press_event_cb), self);
723 g_signal_connect_swapped(self->event_box, "button-release-event",
724 G_CALLBACK(button_release_event_cb), self);
725 g_signal_connect_swapped(self->event_box, "scroll-event",
726 G_CALLBACK(scroll_event_cb), self);
727 g_signal_connect_swapped(self->event_box, "motion-notify-event",
728 G_CALLBACK(motion_notify_event_cb), self);
729 g_signal_connect_swapped(self->event_box, "enter-notify-event",
730 G_CALLBACK(enter_notify_event_cb), self);
731 g_signal_connect_swapped(self->event_box, "leave-notify-event",
732 G_CALLBACK(leave_notify_event_cb), self);
733 GtkGesture* zoom = gtk_gesture_zoom_new(self->event_box);
734 g_signal_connect_swapped(zoom, "begin", G_CALLBACK(gesture_zoom_begin_cb),
735 self);
736 g_signal_connect_swapped(zoom, "scale-changed",
737 G_CALLBACK(gesture_zoom_update_cb), self);
738 g_signal_connect_swapped(zoom, "end", G_CALLBACK(gesture_zoom_end_cb), self);
739 GtkGesture* rotate = gtk_gesture_rotate_new(self->event_box);
740 g_signal_connect_swapped(rotate, "begin",
741 G_CALLBACK(gesture_rotation_begin_cb), self);
742 g_signal_connect_swapped(rotate, "angle-changed",
743 G_CALLBACK(gesture_rotation_update_cb), self);
744 g_signal_connect_swapped(rotate, "end", G_CALLBACK(gesture_rotation_end_cb),
745 self);
746 g_signal_connect_swapped(self->event_box, "touch-event",
747 G_CALLBACK(touch_event_cb), self);
748
749 self->render_area = GTK_DRAWING_AREA(gtk_drawing_area_new());
750 gtk_widget_show(GTK_WIDGET(self->render_area));
751 gtk_container_add(GTK_CONTAINER(self->event_box),
752 GTK_WIDGET(self->render_area));
753 g_signal_connect_swapped(self->render_area, "realize", G_CALLBACK(realize_cb),
754 self);
755 g_signal_connect_swapped(self->render_area, "size-allocate",
756 G_CALLBACK(size_allocate_cb), self);
757 g_signal_connect_swapped(self->render_area, "draw", G_CALLBACK(draw_cb),
758 self);
759 }
TRUE
return TRUE
Definition: fl_compositor_software.cc:69
gesture_zoom_begin_cb
static void gesture_zoom_begin_cb(FlView *self)
Definition: fl_view.cc:422
button_release_event_cb
static gboolean button_release_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:321
gesture_rotation_end_cb
static void gesture_rotation_end_cb(FlView *self)
Definition: fl_view.cc:418
gesture_rotation_update_cb
static void gesture_rotation_update_cb(FlView *self, gdouble rotation, gdouble delta)
Definition: fl_view.cc:411
button_press_event_cb
static gboolean button_press_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:294
gesture_zoom_end_cb
static void gesture_zoom_end_cb(FlView *self)
Definition: fl_view.cc:430
size_allocate_cb
static void size_allocate_cb(FlView *self)
Definition: fl_view.cc:504
motion_notify_event_cb
static gboolean motion_notify_event_cb(FlView *self, GdkEventMotion *motion_event)
Definition: fl_view.cc:359
enter_notify_event_cb
static gboolean enter_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:380
gesture_rotation_begin_cb
static void gesture_rotation_begin_cb(FlView *self)
Definition: fl_view.cc:407
scroll_event_cb
static gboolean scroll_event_cb(FlView *self, GdkEventScroll *event)
Definition: fl_view.cc:341
gesture_zoom_update_cb
static void gesture_zoom_update_cb(FlView *self, gdouble scale)
Definition: fl_view.cc:426
realize_cb
static void realize_cb(FlView *self)
Definition: fl_view.cc:462
draw_cb
static gboolean draw_cb(FlView *self, cairo_t *cr)
Definition: fl_view.cc:520
leave_notify_event_cb
static gboolean leave_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:392
touch_event_cb
static gboolean touch_event_cb(FlView *self, GdkEventTouch *event)
Definition: fl_view.cc:351

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

## ◆ fl_view_key_press_event()

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

Definition at line 649 of file fl_view.cc.

650 {
651 FlView* self = FL_VIEW(widget);
652 return handle_key_event(self, key_event);
653 }
handle_key_event
static gboolean handle_key_event(FlView *self, GdkEventKey *key_event)
Definition: fl_view.cc:603

References handle_key_event().

Referenced by fl_view_class_init().

## ◆ fl_view_key_release_event()

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

Definition at line 656 of file fl_view.cc.

657 {
658 FlView* self = FL_VIEW(widget);
659 return handle_key_event(self, key_event);
660 }

References handle_key_event().

Referenced by fl_view_class_init().

## ◆ fl_view_new()

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

FlView:

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

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

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

Creates a widget to show a Flutter application.

Returns: a new #FlView.

Definition at line 761 of file fl_view.cc.

761 {
762 g_autoptr(FlEngine) engine = fl_engine_new(project);
763 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
764
765 self->view_id = flutter::kFlutterImplicitViewId;
766 self->engine = FL_ENGINE(g_object_ref(engine));
767
768 setup_engine(self);
769
770 fl_engine_set_implicit_view(engine, FL_RENDERABLE(self));
771
772 return self;
773 }
fl_engine_set_implicit_view
void fl_engine_set_implicit_view(FlEngine *self, FlRenderable *renderable)
Definition: fl_engine.cc:876
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:692
setup_engine
static void setup_engine(FlView *self)
Definition: fl_view.cc:682

References fl_engine_new(), fl_engine_set_implicit_view(), g_autoptr(), and setup_engine().

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_new_for_engine()

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

fl_view_new_for_engine: @engine: an #FlEngine.

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

Returns: a new #FlView.

Definition at line 775 of file fl_view.cc.

775 {
776 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
777
778 self->engine = FL_ENGINE(g_object_ref(engine));
779
780 self->view_id = fl_engine_add_view(engine, FL_RENDERABLE(self), 1, 1, 1.0,
781 self->cancellable, view_added_cb, self);
782
783 setup_engine(self);
784
785 return self;
786 }
fl_engine_add_view
FlutterViewId fl_engine_add_view(FlEngine *self, FlRenderable *renderable, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:883
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:207

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

Referenced by create_regular(), and TEST().

## ◆ fl_view_notify()

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

Definition at line 538 of file fl_view.cc.

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

References handle_geometry_changed(), and pspec.

Referenced by fl_view_class_init().

## ◆ fl_view_plugin_registry_iface_init()

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

Definition at line 274 of file fl_view.cc.

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

References fl_view_get_registrar_for_plugin().

## ◆ fl_view_present_layers()

static void fl_view_present_layers | ( | FlRenderable * | renderable,
|  | const FlutterLayer ** | layers,
|  | size_t | layers_count
| ) |  |
| static

Definition at line 248 of file fl_view.cc.

250 {
251 FlView* self = FL_VIEW(renderable);
252
253 fl_compositor_present_layers(self->compositor, layers, layers_count);
254
255 // Perform the redraw in the GTK thead.
256 g_idle_add(redraw_cb, self);
257 }
fl_compositor_present_layers
gboolean fl_compositor_present_layers(FlCompositor *self, const FlutterLayer **layers, size_t layers_count)
Definition: fl_compositor.cc:15
layers_count
const FlutterLayer size_t layers_count
Definition: fl_compositor_software.cc:33
layers
const FlutterLayer ** layers
Definition: fl_compositor_software.cc:32

References fl_compositor_present_layers(), layers, layers_count, and self.

Referenced by fl_renderable_iface_init().

## ◆ fl_view_realize()

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

Definition at line 594 of file fl_view.cc.

594 {
595 FlView* self = FL_VIEW(widget);
596
597 GTK_WIDGET_CLASS(fl_view_parent_class)->realize(widget);
598
599 // Realize the child widgets.
600 gtk_widget_realize(GTK_WIDGET(self->render_area));
601 }

References self.

Referenced by fl_view_class_init().

## ◆ fl_view_set_background_color()

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

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

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

Definition at line 799 of file fl_view.cc.

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

References self.

## ◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE | ( | FlView | ,
|  | fl_view | ,
|  | GTK_TYPE_BOX | ,
|  | G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_view_plugin_registry_iface_init) |
| ) |  |

Definition at line 94 of file fl_view.cc.

103 {
104 FlView* self = FL_VIEW(user_data);
105
106 gtk_widget_queue_draw(GTK_WIDGET(self->render_area));
107
108 if (!self->have_first_frame) {
109 self->have_first_frame = TRUE;
110 g_signal_emit(self, fl_view_signals[SIGNAL_FIRST_FRAME], 0);
111 }
112
113 return FALSE;
114 }
g_signal_emit
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view, &window)
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90

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

## ◆ gesture_rotation_begin_cb()

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

Definition at line 407 of file fl_view.cc.

407 {
408 fl_scrolling_manager_handle_rotation_begin(self->scrolling_manager);
409 }
fl_scrolling_manager_handle_rotation_begin
void fl_scrolling_manager_handle_rotation_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:153

References fl_scrolling_manager_handle_rotation_begin(), and self.

Referenced by fl_view_init().

## ◆ gesture_rotation_end_cb()

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

Definition at line 418 of file fl_view.cc.

418 {
419 fl_scrolling_manager_handle_rotation_end(self->scrolling_manager);
420 }
fl_scrolling_manager_handle_rotation_end
void fl_scrolling_manager_handle_rotation_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:186

References fl_scrolling_manager_handle_rotation_end(), and self.

Referenced by fl_view_init().

## ◆ gesture_rotation_update_cb()

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

Definition at line 411 of file fl_view.cc.

413 {
414 fl_scrolling_manager_handle_rotation_update(self->scrolling_manager,
415 rotation);
416 }
fl_scrolling_manager_handle_rotation_update
void fl_scrolling_manager_handle_rotation_update(FlScrollingManager *self, gdouble rotation)
Definition: fl_scrolling_manager.cc:171

References fl_scrolling_manager_handle_rotation_update(), and self.

Referenced by fl_view_init().

## ◆ gesture_zoom_begin_cb()

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

Definition at line 422 of file fl_view.cc.

422 {
423 fl_scrolling_manager_handle_zoom_begin(self->scrolling_manager);
424 }
fl_scrolling_manager_handle_zoom_begin
void fl_scrolling_manager_handle_zoom_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:202

References fl_scrolling_manager_handle_zoom_begin(), and self.

Referenced by fl_view_init().

## ◆ gesture_zoom_end_cb()

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

Definition at line 430 of file fl_view.cc.

430 {
431 fl_scrolling_manager_handle_zoom_end(self->scrolling_manager);
432 }
fl_scrolling_manager_handle_zoom_end
void fl_scrolling_manager_handle_zoom_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:235

References fl_scrolling_manager_handle_zoom_end(), and self.

Referenced by fl_view_init().

## ◆ gesture_zoom_update_cb()

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

Definition at line 426 of file fl_view.cc.

426 {
427 fl_scrolling_manager_handle_zoom_update(self->scrolling_manager, scale);
428 }
fl_scrolling_manager_handle_zoom_update
void fl_scrolling_manager_handle_zoom_update(FlScrollingManager *self, gdouble scale)
Definition: fl_scrolling_manager.cc:220

References fl_scrolling_manager_handle_zoom_update(), and self.

Referenced by fl_view_init().

## ◆ get_device_kind()

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

Definition at line 134 of file fl_view.cc.

134 {
135 GdkDevice* device = gdk_event_get_source_device(event);
136 GdkInputSource source = gdk_device_get_source(device);
137 switch (source) {
138 case GDK_SOURCE_PEN:
139 case GDK_SOURCE_ERASER:
140 case GDK_SOURCE_CURSOR:
141 case GDK_SOURCE_TABLET_PAD:
142 return kFlutterPointerDeviceKindStylus;
143 case GDK_SOURCE_TOUCHSCREEN:
144 return kFlutterPointerDeviceKindTouch;
145 case GDK_SOURCE_TOUCHPAD: // trackpad device type is reserved for gestures
146 case GDK_SOURCE_TRACKPOINT:
147 case GDK_SOURCE_KEYBOARD:
148 case GDK_SOURCE_MOUSE:
149 return kFlutterPointerDeviceKindMouse;
150 }
151 }

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

## ◆ handle_geometry_changed()

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

Definition at line 176 of file fl_view.cc.

176 {
177 GtkAllocation allocation;
178 gtk_widget_get_allocation(GTK_WIDGET(self), &allocation);
179 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
180
181 // Note we can't detect if a window is moved between monitors - this
182 // information is provided by Wayland but GTK only notifies us if the scale
183 // has changed, so moving between two monitors of the same scale doesn't
184 // provide any information.
185
186 GdkWindow* window =
187 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
188 // NOTE(robert-ancell) If we haven't got a window we default to display 0.
189 // This is probably indicating a problem with this code in that we
190 // shouldn't be generating anything until the window is created.
191 // Another event with the correct display ID is generated soon after.
192 // I haven't changed this code in case there are side-effects but we
193 // probably shouldn't call handle_geometry_changed after the view is
194 // added but only when the window is realized.
195 FlutterEngineDisplayId display_id = 0;
196 if (window != nullptr) {
197 GdkMonitor* monitor = gdk_display_get_monitor_at_window(
198 gtk_widget_get_display(GTK_WIDGET(self)), window);
199 display_id = fl_display_monitor_get_display_id(
200 fl_engine_get_display_monitor(self->engine), monitor);
201 }
202 fl_engine_send_window_metrics_event(
203 self->engine, display_id, self->view_id, allocation.width * scale_factor,
204 allocation.height * scale_factor, scale_factor);
205 }
fl_display_monitor_get_display_id
FlutterEngineDisplayId fl_display_monitor_get_display_id(FlDisplayMonitor *self, GdkMonitor *monitor)
Definition: fl_display_monitor.cc:115
fl_engine_send_window_metrics_event
void fl_engine_send_window_metrics_event(FlEngine *self, FlutterEngineDisplayId display_id, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
Definition: fl_engine.cc:1100
fl_engine_get_display_monitor
FlDisplayMonitor * fl_engine_get_display_monitor(FlEngine *self)
Definition: fl_engine.cc:716

References fl_display_monitor_get_display_id(), fl_engine_get_display_monitor(), fl_engine_send_window_metrics_event(), self, and window.

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

## ◆ handle_key_event()

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

Definition at line 603 of file fl_view.cc.

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

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

Referenced by fl_view_key_press_event(), and fl_view_key_release_event().

## ◆ init_scrolling()

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

Definition at line 123 of file fl_view.cc.

123 {
124 g_clear_object(&self->scrolling_manager);
125 self->scrolling_manager =
126 fl_scrolling_manager_new(self->engine, self->view_id);
127 }
fl_scrolling_manager_new
FlScrollingManager * fl_scrolling_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_scrolling_manager.cc:47

References fl_scrolling_manager_new(), and self.

Referenced by on_pre_engine_restart_cb(), and setup_engine().

## ◆ init_touch()

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

Definition at line 129 of file fl_view.cc.

129 {
130 g_clear_object(&self->touch_manager);
131 self->touch_manager = fl_touch_manager_new(self->engine, self->view_id);
132 }
fl_touch_manager_new
FlTouchManager * fl_touch_manager_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_touch_manager.cc:48

References fl_touch_manager_new(), and self.

Referenced by on_pre_engine_restart_cb(), and setup_engine().

## ◆ leave_notify_event_cb()

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

Definition at line 392 of file fl_view.cc.

393 {
394 if (crossing_event->mode != GDK_CROSSING_NORMAL) {
395 return FALSE;
396 }
397
398 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
399 gdouble x = 0.0, y = 0.0;
400 gdk_event_get_coords(event, &x, &y);
401 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
402 return fl_pointer_manager_handle_leave(
403 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
404 x * scale_factor, y * scale_factor);
405 }
fl_pointer_manager_handle_leave
gboolean fl_pointer_manager_handle_leave(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:218

References fl_pointer_manager_handle_leave(), get_device_kind(), and self.

Referenced by fl_view_init().

## ◆ motion_notify_event_cb()

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

Definition at line 359 of file fl_view.cc.

360 {
361 GdkEvent* event = reinterpret_cast<GdkEvent*>(motion_event);
362 sync_modifier_if_needed(self, event);
363
364 // return if touch event
365 auto event_type = gdk_event_get_event_type(event);
366 if (event_type == GDK_TOUCH_BEGIN || event_type == GDK_TOUCH_UPDATE ||
367 event_type == GDK_TOUCH_END || event_type == GDK_TOUCH_CANCEL) {
368 return FALSE;
369 }
370
371 gdouble x = 0.0, y = 0.0;
372 gdk_event_get_coords(event, &x, &y);
373 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
374 return fl_pointer_manager_handle_motion(
375 self->pointer_manager, gdk_event_get_time(event), get_device_kind(event),
376 x * scale_factor, y * scale_factor);
377 }
fl_pointer_manager_handle_motion
gboolean fl_pointer_manager_handle_motion(FlPointerManager *self, guint event_time, FlutterPointerDeviceKind device_kind, gdouble x, gdouble y)
Definition: fl_pointer_manager.cc:179

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

Referenced by fl_view_init().

## ◆ on_pre_engine_restart_cb()

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

Definition at line 242 of file fl_view.cc.

242 {
243 init_scrolling(self);
244 init_touch(self);
245 }
init_scrolling
static void init_scrolling(FlView *self)
Definition: fl_view.cc:123
init_touch
static void init_touch(FlView *self)
Definition: fl_view.cc:129

References init_scrolling(), and init_touch().

Referenced by setup_engine().

## ◆ paint_background()

static void paint_background | ( | FlView * | self,
|  | cairo_t * | cr
| ) |  |
| static

Definition at line 508 of file fl_view.cc.

508 {
509 // Don't bother drawing if fully transparent - the widget above this will
510 // already be drawn by GTK.
511 if (self->background_color->red == 0 && self->background_color->green == 0 &&
512 self->background_color->blue == 0 && self->background_color->alpha == 0) {
513 return;
514 }
515
516 gdk_cairo_set_source_rgba(cr, self->background_color);
517 cairo_paint(cr);
518 }

References self.

Referenced by draw_cb().

## ◆ realize_cb()

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

Definition at line 462 of file fl_view.cc.

462 {
463 switch (fl_engine_get_renderer_type(self->engine)) {
464 case kOpenGL:
465 setup_opengl(self);
466 break;
467 case kSoftware:
468 setup_software(self);
469 break;
470 default:
471 break;
472 }
473
474 if (self->view_id != flutter::kFlutterImplicitViewId) {
475 setup_cursor(self);
476 return;
477 }
478
479 GtkWidget* toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(self));
480
481 self->window_state_monitor =
482 fl_window_state_monitor_new(fl_engine_get_binary_messenger(self->engine),
483 GTK_WINDOW(toplevel_window));
484
485 // Handle requests by the user to close the application.
486 g_signal_connect_swapped(toplevel_window, "delete-event",
487 G_CALLBACK(window_delete_event_cb), self);
488
489 // Flutter engine will need to make the context current from raster thread
490 // during initialization.
491 fl_opengl_manager_clear_current(fl_engine_get_opengl_manager(self->engine));
492
493 g_autoptr(GError) error = nullptr;
494 if (!fl_engine_start(self->engine, &error)) {
495 g_warning("Failed to start Flutter engine: %s", error->message);
496 return;
497 }
498
499 setup_cursor(self);
500
501 handle_geometry_changed(self);
502 }
fl_engine_get_opengl_manager
FlOpenGLManager * fl_engine_get_opengl_manager(FlEngine *self)
Definition: fl_engine.cc:711
fl_engine_get_renderer_type
FlutterRendererType fl_engine_get_renderer_type(FlEngine *self)
Definition: fl_engine.cc:706
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:721
fl_opengl_manager_clear_current
void fl_opengl_manager_clear_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:86
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
setup_opengl
static void setup_opengl(FlView *self)
Definition: fl_view.cc:434
setup_software
static void setup_software(FlView *self)
Definition: fl_view.cc:458
setup_cursor
static void setup_cursor(FlView *self)
Definition: fl_view.cc:166
window_delete_event_cb
static gboolean window_delete_event_cb(FlView *self)
Definition: fl_view.cc:117
fl_window_state_monitor_new
FlWindowStateMonitor * fl_window_state_monitor_new(FlBinaryMessenger *messenger, GtkWindow *window)
Definition: fl_window_state_monitor.cc:104

References error, fl_engine_get_binary_messenger(), fl_engine_get_opengl_manager(), fl_engine_get_renderer_type(), fl_engine_start(), fl_opengl_manager_clear_current(), fl_window_state_monitor_new(), g_autoptr(), handle_geometry_changed(), self, setup_cursor(), setup_opengl(), setup_software(), and window_delete_event_cb().

Referenced by fl_view_init().

## ◆ scroll_event_cb()

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

Definition at line 341 of file fl_view.cc.

341 {
342 // TODO(robert-ancell): Update to use GtkEventControllerScroll when we can
343 // depend on GTK 3.24.
344
345 fl_scrolling_manager_handle_scroll_event(
346 self->scrolling_manager, event,
347 gtk_widget_get_scale_factor(GTK_WIDGET(self)));
348 return TRUE;
349 }
fl_scrolling_manager_handle_scroll_event
void fl_scrolling_manager_handle_scroll_event(FlScrollingManager *self, GdkEventScroll *scroll_event, gint scale_factor)
Definition: fl_scrolling_manager.cc:71

References fl_scrolling_manager_handle_scroll_event(), self, and TRUE.

Referenced by fl_view_init().

## ◆ set_scrolling_position()

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

Definition at line 287 of file fl_view.cc.

287 {
288 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
289 fl_scrolling_manager_set_last_mouse_position(
290 self->scrolling_manager, x * scale_factor, y * scale_factor);
291 }
fl_scrolling_manager_set_last_mouse_position
void fl_scrolling_manager_set_last_mouse_position(FlScrollingManager *self, gdouble x, gdouble y)
Definition: fl_scrolling_manager.cc:63

References fl_scrolling_manager_set_last_mouse_position(), and self.

Referenced by button_press_event_cb(), and button_release_event_cb().

## ◆ setup_cursor()

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

Definition at line 166 of file fl_view.cc.

166 {
167 FlMouseCursorHandler* handler =
168 fl_engine_get_mouse_cursor_handler(self->engine);
169
170 self->cursor_changed_cb_id = g_signal_connect_swapped(
171 handler, "cursor-changed", G_CALLBACK(cursor_changed_cb), self);
172 cursor_changed_cb(self);
173 }
cursor_changed_cb
static void cursor_changed_cb(FlView *self)
Definition: fl_view.cc:154

References cursor_changed_cb(), fl_engine_get_mouse_cursor_handler(), and self.

Referenced by realize_cb().

## ◆ setup_engine()

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

Definition at line 682 of file fl_view.cc.

682 {
683 self->view_accessible = fl_view_accessible_new(self->engine, self->view_id);
684 fl_socket_accessible_embed(
685 FL_SOCKET_ACCESSIBLE(gtk_widget_get_accessible(GTK_WIDGET(self))),
686 atk_plug_get_id(ATK_PLUG(self->view_accessible)));
687
688 self->pointer_manager = fl_pointer_manager_new(self->view_id, self->engine);
689
690 init_scrolling(self);
691 init_touch(self);
692
693 self->on_pre_engine_restart_cb_id =
694 g_signal_connect_swapped(self->engine, "on-pre-engine-restart",
695 G_CALLBACK(on_pre_engine_restart_cb), self);
696 self->update_semantics_cb_id = g_signal_connect_swapped(
697 self->engine, "update-semantics", G_CALLBACK(update_semantics_cb), self);
698 }
fl_pointer_manager_new
FlPointerManager * fl_pointer_manager_new(FlutterViewId view_id, FlEngine *engine)
Definition: fl_pointer_manager.cc:94
fl_socket_accessible_embed
void fl_socket_accessible_embed(FlSocketAccessible *self, gchar *id)
Definition: fl_socket_accessible.cc:55
on_pre_engine_restart_cb
static void on_pre_engine_restart_cb(FlView *self)
Definition: fl_view.cc:242
update_semantics_cb
static void update_semantics_cb(FlView *self, const FlutterSemanticsUpdate2 *update)
Definition: fl_view.cc:227
fl_view_accessible_new
FlViewAccessible * fl_view_accessible_new(FlEngine *engine, FlutterViewId view_id)
Definition: fl_view_accessible.cc:134

References fl_pointer_manager_new(), fl_socket_accessible_embed(), fl_view_accessible_new(), init_scrolling(), init_touch(), on_pre_engine_restart_cb(), self, and update_semantics_cb().

Referenced by fl_view_new(), and fl_view_new_for_engine().

## ◆ setup_opengl()

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

Definition at line 434 of file fl_view.cc.

434 {
435 g_autoptr(GError) error = nullptr;
436
437 self->render_context = gdk_window_create_gl_context(
438 gtk_widget_get_window(GTK_WIDGET(self->render_area)), &error);
439 if (self->render_context == nullptr) {
440 g_warning("Failed to create OpenGL context: %s", error->message);
441 return;
442 }
443
444 if (!gdk_gl_context_realize(self->render_context, &error)) {
445 g_warning("Failed to realize OpenGL context: %s", error->message);
446 return;
447 }
448
449 // If using Wayland, then EGL is in use and we can access the frame
450 // from the Flutter context using EGLImage. If not (i.e. X11 using GLX)
451 // then we have to copy the texture via the CPU.
452 gboolean shareable =
453 GDK_IS_WAYLAND_DISPLAY(gtk_widget_get_display(GTK_WIDGET(self)));
454 self->compositor =
455 FL_COMPOSITOR(fl_compositor_opengl_new(self->engine, shareable));
456 }
fl_compositor_opengl_new
FlCompositorOpenGL * fl_compositor_opengl_new(FlEngine *engine, gboolean shareable)
Definition: fl_compositor_opengl.cc:402
shareable
G_BEGIN_DECLS gboolean shareable
Definition: fl_compositor_opengl.h:40

References error, fl_compositor_opengl_new(), g_autoptr(), self, and shareable.

Referenced by realize_cb().

## ◆ setup_software()

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

Definition at line 458 of file fl_view.cc.

458 {
459 self->compositor = FL_COMPOSITOR(fl_compositor_software_new());
460 }
fl_compositor_software_new
FlCompositorSoftware * fl_compositor_software_new()
Definition: fl_compositor_software.cc:125

References fl_compositor_software_new().

Referenced by realize_cb().

## ◆ size_allocate_cb()

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

Definition at line 504 of file fl_view.cc.

504 {
505 handle_geometry_changed(self);
506 }

References handle_geometry_changed().

Referenced by fl_view_init().

## ◆ sync_modifier_if_needed()

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

Definition at line 279 of file fl_view.cc.

279 {
280 guint event_time = gdk_event_get_time(event);
281 GdkModifierType event_state = static_cast<GdkModifierType>(0);
282 gdk_event_get_state(event, &event_state);
283 fl_keyboard_manager_sync_modifier_if_needed(
284 fl_engine_get_keyboard_manager(self->engine), event_state, event_time);
285 }
fl_keyboard_manager_sync_modifier_if_needed
void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager *self, guint state, double event_time)
Definition: fl_keyboard_manager.cc:427

References fl_engine_get_keyboard_manager(), fl_keyboard_manager_sync_modifier_if_needed(), and self.

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

## ◆ touch_event_cb()

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

Definition at line 351 of file fl_view.cc.

351 {
352 fl_touch_manager_handle_touch_event(
353 self->touch_manager, event,
354 gtk_widget_get_scale_factor(GTK_WIDGET(self)));
355 return TRUE;
356 }
fl_touch_manager_handle_touch_event
void fl_touch_manager_handle_touch_event(FlTouchManager *self, GdkEventTouch *touch_event, gint scale_factor)
Definition: fl_touch_manager.cc:131

References fl_touch_manager_handle_touch_event(), self, and TRUE.

Referenced by fl_view_init().

## ◆ update_semantics_cb()

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

Definition at line 227 of file fl_view.cc.

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

References fl_view_accessible_handle_update_semantics(), and self.

Referenced by setup_engine().

## ◆ view_added_cb()

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

Definition at line 207 of file fl_view.cc.

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

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

Referenced by fl_view_new_for_engine().

## ◆ window_delete_event_cb()

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

Definition at line 117 of file fl_view.cc.

117 {
118 fl_engine_request_app_exit(self->engine);
119 // Stop the event from propagating.
120 return TRUE;
121 }
fl_engine_request_app_exit
void fl_engine_request_app_exit(FlEngine *self)
Definition: fl_engine.cc:1447

References fl_engine_request_app_exit(), self, and TRUE.

Referenced by realize_cb().

## Variable Documentation

## ◆ fl_view_signals

guint fl_view_signals[LAST_SIGNAL]
| static

Definition at line 87 of file fl_view.cc.

Referenced by fl_view_class_init(), and G_DEFINE_TYPE_WITH_CODE().