| Flutter Linux Embedder |

Classes | Enumerations | Functions | Variables
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 <atk/atk.h>`
`#include <gtk/gtk-a11y.h>`
`#include <cstring>`
`#include "flutter/common/constants.h"`
`#include "flutter/shell/platform/linux/fl_accessible_node.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include "flutter/shell/platform/linux/fl_framebuffer.h"`
`#include "flutter/shell/platform/linux/fl_key_event.h"`
`#include "flutter/shell/platform/linux/fl_keyboard_handler.h"`
`#include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h"`
`#include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h"`
`#include "flutter/shell/platform/linux/fl_platform_handler.h"`
`#include "flutter/shell/platform/linux/fl_plugin_registrar_private.h"`
`#include "flutter/shell/platform/linux/fl_renderer_gdk.h"`
`#include "flutter/shell/platform/linux/fl_scrolling_manager.h"`
`#include "flutter/shell/platform/linux/fl_scrolling_view_delegate.h"`
`#include "flutter/shell/platform/linux/fl_socket_accessible.h"`
`#include "flutter/shell/platform/linux/fl_text_input_handler.h"`
`#include "flutter/shell/platform/linux/fl_text_input_view_delegate.h"`
`#include "flutter/shell/platform/linux/fl_view_accessible.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 | { kSignalFirstFrame, kSignalLastSignal }

## Functions
static void | fl_view_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
static void | fl_view_keyboard_delegate_iface_init (FlKeyboardViewDelegateInterface *iface)
static void | fl_view_scrolling_delegate_iface_init (FlScrollingViewDelegateInterface *iface)
static void | fl_view_text_input_delegate_iface_init (FlTextInputViewDelegateInterface *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) G_IMPLEMENT_INTERFACE(fl_keyboard_view_delegate_get_type(), fl_view_keyboard_delegate_iface_init) G_IMPLEMENT_INTERFACE(fl_scrolling_view_delegate_get_type(), fl_view_scrolling_delegate_iface_init) G_IMPLEMENT_INTERFACE(fl_text_input_view_delegate_get_type(), fl_view_text_input_delegate_iface_init)) static gboolean first_frame_idle_cb(gpointer user_data)
static gboolean | window_delete_event_cb (FlView *self)
static void | init_keyboard (FlView *self)
static void | init_scrolling (FlView *self)
static FlutterPointerDeviceKind | get_device_kind (GdkEvent *event)
static gboolean | send_pointer_button_event (FlView *self, GdkEvent *event)
static void | check_pointer_inside (FlView *self, GdkEvent *event)
static void | handle_geometry_changed (FlView *self)
static void | view_added_cb (GObject *object, GAsyncResult *result, gpointer user_data)
static void | update_semantics_cb (FlEngine *engine, const FlutterSemanticsUpdate2 *update, gpointer user_data)
static void | on_pre_engine_restart_cb (FlView *self)
static FlPluginRegistrar * | fl_view_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
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 | 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 | keymap_keys_changed_cb (FlView *self)
static void | gesture_rotation_begin_cb (FlView *self)
static void | gesture_rotation_update_cb (FlView *self, gdouble rotation, gdouble delta)
static void | gesture_rotation_end_cb (FlView *self)
static void | gesture_zoom_begin_cb (FlView *self)
static void | gesture_zoom_update_cb (FlView *self, gdouble scale)
static void | gesture_zoom_end_cb (FlView *self)
static GdkGLContext * | create_context_cb (FlView *self)
static void | realize_cb (FlView *self)
static gboolean | render_cb (FlView *self, GdkGLContext *context)
static void | unrealize_cb (FlView *self)
static void | size_allocate_cb (FlView *self)
static void | fl_view_notify (GObject *object, GParamSpec *pspec)
static void | fl_view_dispose (GObject *object)
static void | fl_view_realize (GtkWidget *widget)
static gboolean | fl_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
static gboolean | fl_view_key_release_event (GtkWidget *widget, GdkEventKey *event)
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 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)
void | fl_view_redraw (FlView *self)
GHashTable * | fl_view_get_keyboard_state (FlView *self)

## Variables
static constexpr int | kMicrosecondsPerMillisecond = 1000
static guint | fl_view_signals [kSignalLastSignal]

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
kSignalFirstFrame |
kSignalLastSignal |

Definition at line 90 of file fl_view.cc.

90 { kSignalFirstFrame, kSignalLastSignal };

## Function Documentation

## ◆ button_press_event_cb()

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

Definition at line 428 of file fl_view.cc.

429 {
430 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
431
432 // Flutter doesn't handle double and triple click events.
433 GdkEventType event_type = gdk_event_get_event_type(event);
434 if (event_type == GDK_DOUBLE_BUTTON_PRESS ||
435 event_type == GDK_TRIPLE_BUTTON_PRESS) {
436 return FALSE;
437 }
438
439 check_pointer_inside(self, event);
440
441 return send_pointer_button_event(self, event);
442 }

References check_pointer_inside(), event, and send_pointer_button_event().

Referenced by fl_view_init().

## ◆ button_release_event_cb()

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

Definition at line 445 of file fl_view.cc.

446 {
447 GdkEvent* event = reinterpret_cast<GdkEvent*>(button_event);
448 return send_pointer_button_event(self, event);
449 }

References event, and send_pointer_button_event().

Referenced by fl_view_init().

## ◆ check_pointer_inside()

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

Definition at line 242 of file fl_view.cc.

242 {
243 if (!self->pointer_inside) {
244 self->pointer_inside = TRUE;
245
246 gdouble x, y;
247 if (gdk_event_get_coords(event, &x, &y)) {
248 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
249
250 fl_engine_send_mouse_pointer_event(
251 self->engine, self->view_id, kAdd,
252 gdk_event_get_time(event) * kMicrosecondsPerMillisecond,
253 x * scale_factor, y * scale_factor, get_device_kind(event), 0, 0,
254 self->button_state);
255 }
256 }
257 }

References event, fl_engine_send_mouse_pointer_event(), get_device_kind(), kMicrosecondsPerMillisecond, and TRUE.

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

## ◆ create_context_cb()

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

Definition at line 574 of file fl_view.cc.

574 {
575 fl_renderer_gdk_set_window(self->renderer,
576 gtk_widget_get_parent_window(GTK_WIDGET(self)));
577
578 // Must initialize the keymap before the keyboard.
579 self->keymap = gdk_keymap_get_for_display(gdk_display_get_default());
580 self->keymap_keys_changed_cb_id = g_signal_connect_swapped(
581 self->keymap, "keys-changed", G_CALLBACK(keymap_keys_changed_cb), self);
582
583 // Create system channel handlers.
584 FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
585 init_scrolling(self);
586 self->mouse_cursor_handler = fl_mouse_cursor_handler_new(messenger, self);
587 self->platform_handler = fl_platform_handler_new(messenger);
588
589 g_autoptr(GError) error = nullptr;
590 if (!fl_renderer_gdk_create_contexts(self->renderer, &error)) {
591 gtk_gl_area_set_error(self->gl_area, error);
592 return nullptr;
593 }
594
595 return GDK_GL_CONTEXT(
596 g_object_ref(fl_renderer_gdk_get_context(self->renderer)));
597 }

References error, fl_engine_get_binary_messenger(), fl_mouse_cursor_handler_new(), fl_platform_handler_new(), fl_renderer_gdk_create_contexts(), fl_renderer_gdk_get_context(), fl_renderer_gdk_set_window(), init_scrolling(), and keymap_keys_changed_cb().

Referenced by fl_view_new().

## ◆ enter_notify_event_cb()

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

Definition at line 493 of file fl_view.cc.

494 {
495 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
496
497 if (self->engine == nullptr) {
498 return FALSE;
499 }
500
501 check_pointer_inside(self, event);
502
503 return TRUE;
504 }

References check_pointer_inside(), event, and TRUE.

Referenced by fl_view_init().

## ◆ fl_view_class_init()

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

Definition at line 753 of file fl_view.cc.

753 {
754 GObjectClass* object_class = G_OBJECT_CLASS(klass);
755 object_class->notify = fl_view_notify;
756 object_class->dispose = fl_view_dispose;
757
758 GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
759 widget_class->realize = fl_view_realize;
760 widget_class->key_press_event = fl_view_key_press_event;
761 widget_class->key_release_event = fl_view_key_release_event;
762
763 fl_view_signals[kSignalFirstFrame] =
764 g_signal_new("first-frame", fl_view_get_type(), G_SIGNAL_RUN_LAST, 0,
765 NULL, NULL, NULL, G_TYPE_NONE, 0);
766
767 gtk_widget_class_set_accessible_type(GTK_WIDGET_CLASS(klass),
768 fl_socket_accessible_get_type());
769 }

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

## ◆ fl_view_dispose()

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

Definition at line 684 of file fl_view.cc.

684 {
685 FlView* self = FL_VIEW(object);
686
687 g_cancellable_cancel(self->cancellable);
688
689 if (self->engine != nullptr) {
690 fl_engine_set_update_semantics_handler(self->engine, nullptr, nullptr,
691 nullptr);
692
693 // Stop rendering.
694 fl_renderer_remove_view(FL_RENDERER(self->renderer), self->view_id);
695
696 // Release the view ID from the engine.
697 fl_engine_remove_view(self->engine, self->view_id, nullptr, nullptr,
698 nullptr);
699 }
700
701 if (self->on_pre_engine_restart_handler != 0) {
702 g_signal_handler_disconnect(self->engine,
703 self->on_pre_engine_restart_handler);
704 self->on_pre_engine_restart_handler = 0;
705 }
706
707 g_clear_object(&self->engine);
708 g_clear_object(&self->renderer);
709 g_clear_pointer(&self->background_color, gdk_rgba_free);
710 g_clear_object(&self->window_state_monitor);
711 g_clear_object(&self->scrolling_manager);
712 g_clear_object(&self->keyboard_handler);
713 if (self->keymap_keys_changed_cb_id != 0) {
714 g_signal_handler_disconnect(self->keymap, self->keymap_keys_changed_cb_id);
715 self->keymap_keys_changed_cb_id = 0;
716 }
717 g_clear_object(&self->mouse_cursor_handler);
718 g_clear_object(&self->platform_handler);
719 g_clear_object(&self->view_accessible);
720 g_clear_object(&self->cancellable);
721
722 G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
723 }

References fl_engine_remove_view(), fl_engine_set_update_semantics_handler(), and fl_renderer_remove_view().

Referenced by fl_view_class_init().

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

874 {
875 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
876 return self->engine;
877 }

Referenced by 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 880 of file fl_view.cc.

880 {
881 g_return_val_if_fail(FL_IS_VIEW(self), -1);
882 return self->view_id;
883 }

Referenced by TEST().

## ◆ fl_view_get_keyboard_state()

GHashTable* fl_view_get_keyboard_state | ( | FlView * | view | ) |

fl_view_get_keyboard_state: @view: an #FlView.

Returns the keyboard pressed state. The hash table contains one entry per pressed keys, mapping from the logical key to the physical key.*

Definition at line 905 of file fl_view.cc.

905 {
906 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
907 return fl_keyboard_handler_get_pressed_state(self->keyboard_handler);
908 }

References fl_keyboard_handler_get_pressed_state().

Referenced by fl_view_keyboard_delegate_iface_init().

## ◆ fl_view_get_registrar_for_plugin()

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

Definition at line 321 of file fl_view.cc.

323 {
324 FlView* self = FL_VIEW(registry);
325
326 return fl_plugin_registrar_new(self,
327 fl_engine_get_binary_messenger(self->engine),
328 fl_engine_get_texture_registrar(self->engine));
329 }

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

Referenced by fl_view_plugin_registry_iface_init().

## ◆ fl_view_init()

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

Definition at line 771 of file fl_view.cc.

771 {
772 self->cancellable = g_cancellable_new();
773
774 gtk_widget_set_can_focus(GTK_WIDGET(self), TRUE);
775
776 self->view_id = -1;
777
778 GdkRGBA default_background = {
779 .red = 0.0, .green = 0.0, .blue = 0.0, .alpha = 1.0};
780 self->background_color = gdk_rgba_copy(&default_background);
781
782 self->event_box = gtk_event_box_new();
783 gtk_widget_set_hexpand(self->event_box, TRUE);
784 gtk_widget_set_vexpand(self->event_box, TRUE);
785 gtk_container_add(GTK_CONTAINER(self), self->event_box);
786 gtk_widget_show(self->event_box);
787 gtk_widget_add_events(self->event_box,
788 GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
789 GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK |
790 GDK_SMOOTH_SCROLL_MASK);
791
792 g_signal_connect_swapped(self->event_box, "button-press-event",
793 G_CALLBACK(button_press_event_cb), self);
794 g_signal_connect_swapped(self->event_box, "button-release-event",
795 G_CALLBACK(button_release_event_cb), self);
796 g_signal_connect_swapped(self->event_box, "scroll-event",
797 G_CALLBACK(scroll_event_cb), self);
798 g_signal_connect_swapped(self->event_box, "motion-notify-event",
799 G_CALLBACK(motion_notify_event_cb), self);
800 g_signal_connect_swapped(self->event_box, "enter-notify-event",
801 G_CALLBACK(enter_notify_event_cb), self);
802 g_signal_connect_swapped(self->event_box, "leave-notify-event",
803 G_CALLBACK(leave_notify_event_cb), self);
804 GtkGesture* zoom = gtk_gesture_zoom_new(self->event_box);
805 g_signal_connect_swapped(zoom, "begin", G_CALLBACK(gesture_zoom_begin_cb),
806 self);
807 g_signal_connect_swapped(zoom, "scale-changed",
808 G_CALLBACK(gesture_zoom_update_cb), self);
809 g_signal_connect_swapped(zoom, "end", G_CALLBACK(gesture_zoom_end_cb), self);
810 GtkGesture* rotate = gtk_gesture_rotate_new(self->event_box);
811 g_signal_connect_swapped(rotate, "begin",
812 G_CALLBACK(gesture_rotation_begin_cb), self);
813 g_signal_connect_swapped(rotate, "angle-changed",
814 G_CALLBACK(gesture_rotation_update_cb), self);
815 g_signal_connect_swapped(rotate, "end", G_CALLBACK(gesture_rotation_end_cb),
816 self);
817
818 self->gl_area = GTK_GL_AREA(gtk_gl_area_new());
819 gtk_gl_area_set_has_alpha(self->gl_area, TRUE);
820 gtk_widget_show(GTK_WIDGET(self->gl_area));
821 gtk_container_add(GTK_CONTAINER(self->event_box), GTK_WIDGET(self->gl_area));
822 g_signal_connect_swapped(self->gl_area, "render", G_CALLBACK(render_cb),
823 self);
824
825 g_signal_connect_swapped(self, "size-allocate", G_CALLBACK(size_allocate_cb),
826 self);
827 }

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

## ◆ fl_view_key_press_event()

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

Definition at line 736 of file fl_view.cc.

736 {
737 FlView* self = FL_VIEW(widget);
738
739 return fl_keyboard_handler_handle_event(
740 self->keyboard_handler, fl_key_event_new_from_gdk_event(gdk_event_copy(
741 reinterpret_cast<GdkEvent*>(event))));
742 }

References event, fl_key_event_new_from_gdk_event(), and fl_keyboard_handler_handle_event().

Referenced by fl_view_class_init().

## ◆ fl_view_key_release_event()

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

Definition at line 745 of file fl_view.cc.

746 {
747 FlView* self = FL_VIEW(widget);
748 return fl_keyboard_handler_handle_event(
749 self->keyboard_handler, fl_key_event_new_from_gdk_event(gdk_event_copy(
750 reinterpret_cast<GdkEvent*>(event))));
751 }

References event, fl_key_event_new_from_gdk_event(), and fl_keyboard_handler_handle_event().

Referenced by fl_view_class_init().

## ◆ fl_view_keyboard_delegate_iface_init()

static void fl_view_keyboard_delegate_iface_init | ( | FlKeyboardViewDelegateInterface * | iface | ) |
| static

Definition at line 336 of file fl_view.cc.

337 {
338 iface->send_key_event =
339 [](FlKeyboardViewDelegate* view_delegate, const FlutterKeyEvent* event,
340 FlutterKeyEventCallback callback, void* user_data) {
341 FlView* self = FL_VIEW(view_delegate);
342 if (self->engine != nullptr) {
343 fl_engine_send_key_event(self->engine, event, callback, user_data);
344 };
345 };
346
347 iface->text_filter_key_press = [](FlKeyboardViewDelegate* view_delegate,
348 FlKeyEvent* event) {
349 FlView* self = FL_VIEW(view_delegate);
350 return fl_text_input_handler_filter_keypress(self->text_input_handler,
351 event);
352 };
353
354 iface->get_messenger = [](FlKeyboardViewDelegate* view_delegate) {
355 FlView* self = FL_VIEW(view_delegate);
356 return fl_engine_get_binary_messenger(self->engine);
357 };
358
359 iface->redispatch_event = [](FlKeyboardViewDelegate* view_delegate,
360 FlKeyEvent* event) {
361 GdkEventType event_type =
362 gdk_event_get_event_type(fl_key_event_get_origin(event));
363 g_return_if_fail(event_type == GDK_KEY_PRESS ||
364 event_type == GDK_KEY_RELEASE);
365 gdk_event_put(fl_key_event_get_origin(event));
366 };
367
368 iface->subscribe_to_layout_change = [](FlKeyboardViewDelegate* view_delegate,
369 KeyboardLayoutNotifier notifier) {
370 FlView* self = FL_VIEW(view_delegate);
371 self->keyboard_layout_notifier = std::move(notifier);
372 };
373
374 iface->lookup_key = [](FlKeyboardViewDelegate* view_delegate,
375 const GdkKeymapKey* key) -> guint {
376 FlView* self = FL_VIEW(view_delegate);
377 g_return_val_if_fail(self->keymap != nullptr, 0);
378 return gdk_keymap_lookup_key(self->keymap, key);
379 };
380
381 iface->get_keyboard_state =
382 [](FlKeyboardViewDelegate* view_delegate) -> GHashTable* {
383 FlView* self = FL_VIEW(view_delegate);
384 return fl_view_get_keyboard_state(self);
385 };
386 }

References callback, event, fl_engine_get_binary_messenger(), fl_engine_send_key_event(), fl_key_event_get_origin(), fl_text_input_handler_filter_keypress(), fl_view_get_keyboard_state(), and user_data.

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

829 {
830 g_autoptr(FlEngine) engine = fl_engine_new(project);
831 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
832
833 self->view_id = flutter::kFlutterImplicitViewId;
834 self->engine = FL_ENGINE(g_object_ref(engine));
835 FlRenderer* renderer = fl_engine_get_renderer(engine);
836 g_assert(FL_IS_RENDERER_GDK(renderer));
837 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
838
839 fl_engine_set_update_semantics_handler(self->engine, update_semantics_cb,
840 self, nullptr);
841 self->on_pre_engine_restart_handler =
842 g_signal_connect_swapped(engine, "on-pre-engine-restart",
843 G_CALLBACK(on_pre_engine_restart_cb), self);
844
845 g_signal_connect_swapped(self->gl_area, "create-context",
846 G_CALLBACK(create_context_cb), self);
847 g_signal_connect_swapped(self->gl_area, "realize", G_CALLBACK(realize_cb),
848 self);
849 g_signal_connect_swapped(self->gl_area, "unrealize", G_CALLBACK(unrealize_cb),
850 self);
851
852 return self;
853 }

References create_context_cb(), fl_engine_get_renderer(), fl_engine_new(), fl_engine_set_update_semantics_handler(), on_pre_engine_restart_cb(), realize_cb(), unrealize_cb(), and update_semantics_cb().

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_new_for_engine()

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

fl_view_new_for_engine: @engine: an #FlEngine.

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

Returns: a new #FlView.

Definition at line 855 of file fl_view.cc.

855 {
856 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
857
858 self->engine = FL_ENGINE(g_object_ref(engine));
859 FlRenderer* renderer = fl_engine_get_renderer(engine);
860 g_assert(FL_IS_RENDERER_GDK(renderer));
861 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
862
863 self->on_pre_engine_restart_handler =
864 g_signal_connect_swapped(engine, "on-pre-engine-restart",
865 G_CALLBACK(on_pre_engine_restart_cb), self);
866
867 self->view_id = fl_engine_add_view(self->engine, 1, 1, 1.0, self->cancellable,
868 view_added_cb, self);
869 fl_renderer_add_view(FL_RENDERER(self->renderer), self->view_id, self);
870
871 return self;
872 }

References fl_engine_add_view(), fl_engine_get_renderer(), fl_renderer_add_view(), on_pre_engine_restart_cb(), and view_added_cb().

Referenced by TEST().

## ◆ fl_view_notify()

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

Definition at line 672 of file fl_view.cc.

672 {
673 FlView* self = FL_VIEW(object);
674
675 if (strcmp(pspec->name, "scale-factor") == 0) {
676 handle_geometry_changed(self);
677 }
678
679 if (G_OBJECT_CLASS(fl_view_parent_class)->notify != nullptr) {
680 G_OBJECT_CLASS(fl_view_parent_class)->notify(object, pspec);
681 }
682 }

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

332 {
333 iface->get_registrar_for_plugin = fl_view_get_registrar_for_plugin;
334 }

References fl_view_get_registrar_for_plugin().

## ◆ fl_view_realize()

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

Definition at line 726 of file fl_view.cc.

726 {
727 FlView* self = FL_VIEW(widget);
728
729 GTK_WIDGET_CLASS(fl_view_parent_class)->realize(widget);
730
731 // Realize the child widgets.
732 gtk_widget_realize(GTK_WIDGET(self->gl_area));
733 }

Referenced by fl_view_class_init().

## ◆ fl_view_redraw()

void fl_view_redraw | ( | FlView * | view | ) |

fl_view_redraw: @view: an #FlView.

Indicate the view needs to redraw.

Definition at line 892 of file fl_view.cc.

892 {
893 g_return_if_fail(FL_IS_VIEW(self));
894
895 gtk_widget_queue_draw(GTK_WIDGET(self->gl_area));
896
897 if (!self->have_first_frame) {
898 self->have_first_frame = TRUE;
899 // This is not the main thread, so the signal needs to be done via an idle
900 // callback.
901 g_idle_add(first_frame_idle_cb, self);
902 }
903 }

References TRUE.

Referenced by fl_renderer_present_layers(), and TEST().

## ◆ fl_view_scrolling_delegate_iface_init()

static void fl_view_scrolling_delegate_iface_init | ( | FlScrollingViewDelegateInterface * | iface | ) |
| static

Definition at line 388 of file fl_view.cc.

389 {
390 iface->send_mouse_pointer_event =
391 [](FlScrollingViewDelegate* view_delegate, FlutterPointerPhase phase,
392 size_t timestamp, double x, double y,
393 FlutterPointerDeviceKind device_kind, double scroll_delta_x,
394 double scroll_delta_y, int64_t buttons) {
395 FlView* self = FL_VIEW(view_delegate);
396 if (self->engine != nullptr) {
397 fl_engine_send_mouse_pointer_event(
398 self->engine, self->view_id, phase, timestamp, x, y, device_kind,
399 scroll_delta_x, scroll_delta_y, buttons);
400 }
401 };
402 iface->send_pointer_pan_zoom_event =
403 [](FlScrollingViewDelegate* view_delegate, size_t timestamp, double x,
404 double y, FlutterPointerPhase phase, double pan_x, double pan_y,
405 double scale, double rotation) {
406 FlView* self = FL_VIEW(view_delegate);
407 if (self->engine != nullptr) {
408 fl_engine_send_pointer_pan_zoom_event(self->engine, self->view_id,
409 timestamp, x, y, phase, pan_x,
410 pan_y, scale, rotation);
411 };
412 };
413 }

References fl_engine_send_mouse_pointer_event(), and fl_engine_send_pointer_pan_zoom_event().

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

886 {
887 g_return_if_fail(FL_IS_VIEW(self));
888 gdk_rgba_free(self->background_color);
889 self->background_color = gdk_rgba_copy(color);
890 }

## ◆ fl_view_text_input_delegate_iface_init()

static void fl_view_text_input_delegate_iface_init | ( | FlTextInputViewDelegateInterface * | iface | ) |
| static

Definition at line 415 of file fl_view.cc.

416 {
417 iface->translate_coordinates = [](FlTextInputViewDelegate* delegate,
418 gint view_x, gint view_y, gint* window_x,
419 gint* window_y) {
420 FlView* self = FL_VIEW(delegate);
421 gtk_widget_translate_coordinates(GTK_WIDGET(self),
422 gtk_widget_get_toplevel(GTK_WIDGET(self)),
423 view_x, view_y, window_x, window_y);
424 };
425 }

## ◆ 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) G_IMPLEMENT_INTERFACE(fl_keyboard_view_delegate_get_type(), fl_view_keyboard_delegate_iface_init) G_IMPLEMENT_INTERFACE(fl_scrolling_view_delegate_get_type(), fl_view_scrolling_delegate_iface_init) G_IMPLEMENT_INTERFACE(fl_text_input_view_delegate_get_type(), fl_view_text_input_delegate_iface_init) |
| ) |  |

Definition at line 106 of file fl_view.cc.

120 {
121 FlView* self = FL_VIEW(user_data);
122
123 g_signal_emit(self, fl_view_signals[kSignalFirstFrame], 0);
124
125 return FALSE;
126 }

References fl_view_signals, kSignalFirstFrame, and user_data.

## ◆ gesture_rotation_begin_cb()

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

Definition at line 547 of file fl_view.cc.

547 {
548 fl_scrolling_manager_handle_rotation_begin(self->scrolling_manager);
549 }

References fl_scrolling_manager_handle_rotation_begin().

Referenced by fl_view_init().

## ◆ gesture_rotation_end_cb()

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

Definition at line 558 of file fl_view.cc.

558 {
559 fl_scrolling_manager_handle_rotation_end(self->scrolling_manager);
560 }

References fl_scrolling_manager_handle_rotation_end().

Referenced by fl_view_init().

## ◆ gesture_rotation_update_cb()

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

Definition at line 551 of file fl_view.cc.

553 {
554 fl_scrolling_manager_handle_rotation_update(self->scrolling_manager,
555 rotation);
556 }

References fl_scrolling_manager_handle_rotation_update().

Referenced by fl_view_init().

## ◆ gesture_zoom_begin_cb()

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

Definition at line 562 of file fl_view.cc.

562 {
563 fl_scrolling_manager_handle_zoom_begin(self->scrolling_manager);
564 }

References fl_scrolling_manager_handle_zoom_begin().

Referenced by fl_view_init().

## ◆ gesture_zoom_end_cb()

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

Definition at line 570 of file fl_view.cc.

570 {
571 fl_scrolling_manager_handle_zoom_end(self->scrolling_manager);
572 }

References fl_scrolling_manager_handle_zoom_end().

Referenced by fl_view_init().

## ◆ gesture_zoom_update_cb()

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

Definition at line 566 of file fl_view.cc.

566 {
567 fl_scrolling_manager_handle_zoom_update(self->scrolling_manager, scale);
568 }

References fl_scrolling_manager_handle_zoom_update().

Referenced by fl_view_init().

## ◆ get_device_kind()

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

Definition at line 159 of file fl_view.cc.

159 {
160 GdkDevice* device = gdk_event_get_source_device(event);
161 GdkInputSource source = gdk_device_get_source(device);
162 switch (source) {
163 case GDK_SOURCE_PEN:
164 case GDK_SOURCE_ERASER:
165 case GDK_SOURCE_CURSOR:
166 case GDK_SOURCE_TABLET_PAD:
167 return kFlutterPointerDeviceKindStylus;
168 case GDK_SOURCE_TOUCHSCREEN:
169 return kFlutterPointerDeviceKindTouch;
170 case GDK_SOURCE_TOUCHPAD: // trackpad device type is reserved for gestures
171 case GDK_SOURCE_TRACKPOINT:
172 case GDK_SOURCE_KEYBOARD:
173 case GDK_SOURCE_MOUSE:
174 return kFlutterPointerDeviceKindMouse;
175 }
176 }

References event.

Referenced by check_pointer_inside(), leave_notify_event_cb(), motion_notify_event_cb(), and send_pointer_button_event().

## ◆ handle_geometry_changed()

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

Definition at line 260 of file fl_view.cc.

260 {
261 GtkAllocation allocation;
262 gtk_widget_get_allocation(GTK_WIDGET(self), &allocation);
263 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
264 fl_engine_send_window_metrics_event(
265 self->engine, self->view_id, allocation.width * scale_factor,
266 allocation.height * scale_factor, scale_factor);
267
268 // Make sure the view has been realized and its size has been allocated before
269 // waiting for a frame. `fl_view_realize()` and `fl_view_size_allocate()` may
270 // be called in either order depending on the order in which the window is
271 // shown and the view is added to a container in the app runner.
272 //
273 // Note: `gtk_widget_init()` initializes the size allocation to 1x1.
274 if (allocation.width > 1 && allocation.height > 1 &&
275 gtk_widget_get_realized(GTK_WIDGET(self))) {
276 fl_renderer_wait_for_frame(FL_RENDERER(self->renderer),
277 allocation.width * scale_factor,
278 allocation.height * scale_factor);
279 }
280 }

References fl_engine_send_window_metrics_event(), and fl_renderer_wait_for_frame().

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

## ◆ init_keyboard()

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

Definition at line 136 of file fl_view.cc.

136 {
137 FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
138
139 GdkWindow* window =
140 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(self)));
141 g_return_if_fail(GDK_IS_WINDOW(window));
142 g_autoptr(GtkIMContext) im_context = gtk_im_multicontext_new();
143 gtk_im_context_set_client_window(im_context, window);
144
145 g_clear_object(&self->text_input_handler);
146 self->text_input_handler = fl_text_input_handler_new(
147 messenger, im_context, FL_TEXT_INPUT_VIEW_DELEGATE(self));
148 g_clear_object(&self->keyboard_handler);
149 self->keyboard_handler =
150 fl_keyboard_handler_new(messenger, FL_KEYBOARD_VIEW_DELEGATE(self));
151 }

References fl_engine_get_binary_messenger(), fl_keyboard_handler_new(), and fl_text_input_handler_new().

Referenced by on_pre_engine_restart_cb(), and realize_cb().

## ◆ init_scrolling()

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

Definition at line 153 of file fl_view.cc.

153 {
154 g_clear_object(&self->scrolling_manager);
155 self->scrolling_manager =
156 fl_scrolling_manager_new(FL_SCROLLING_VIEW_DELEGATE(self));
157 }

References fl_scrolling_manager_new().

Referenced by create_context_cb(), and on_pre_engine_restart_cb().

## ◆ keymap_keys_changed_cb()

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

Definition at line 539 of file fl_view.cc.

539 {
540 if (self->keyboard_layout_notifier == nullptr) {
541 return;
542 }
543
544 self->keyboard_layout_notifier();
545 }

Referenced by create_context_cb().

## ◆ leave_notify_event_cb()

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

Definition at line 507 of file fl_view.cc.

508 {
509 GdkEvent* event = reinterpret_cast<GdkEvent*>(crossing_event);
510
511 guint event_time = gdk_event_get_time(event);
512 gdouble event_x = 0.0, event_y = 0.0;
513 gdk_event_get_coords(event, &event_x, &event_y);
514
515 if (crossing_event->mode != GDK_CROSSING_NORMAL) {
516 return FALSE;
517 }
518
519 if (self->engine == nullptr) {
520 return FALSE;
521 }
522
523 // Don't remove pointer while button is down; In case of dragging outside of
524 // window with mouse grab active Gtk will send another leave notify on
525 // release.
526 if (self->pointer_inside && self->button_state == 0) {
527 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
528 fl_engine_send_mouse_pointer_event(
529 self->engine, self->view_id, kRemove,
530 event_time * kMicrosecondsPerMillisecond, event_x * scale_factor,
531 event_y * scale_factor, get_device_kind((GdkEvent*)event), 0, 0,
532 self->button_state);
533 self->pointer_inside = FALSE;
534 }
535
536 return TRUE;
537 }

References event, fl_engine_send_mouse_pointer_event(), get_device_kind(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by fl_view_init().

## ◆ motion_notify_event_cb()

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

Definition at line 463 of file fl_view.cc.

464 {
465 GdkEvent* event = reinterpret_cast<GdkEvent*>(motion_event);
466
467 if (self->engine == nullptr) {
468 return FALSE;
469 }
470
471 guint event_time = gdk_event_get_time(event);
472 GdkModifierType event_state = static_cast<GdkModifierType>(0);
473 gdk_event_get_state(event, &event_state);
474 gdouble event_x = 0.0, event_y = 0.0;
475 gdk_event_get_coords(event, &event_x, &event_y);
476
477 check_pointer_inside(self, event);
478
479 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
480
481 fl_keyboard_handler_sync_modifier_if_needed(self->keyboard_handler,
482 event_state, event_time);
483 fl_engine_send_mouse_pointer_event(
484 self->engine, self->view_id, self->button_state != 0 ? kMove : kHover,
485 event_time * kMicrosecondsPerMillisecond, event_x * scale_factor,
486 event_y * scale_factor, get_device_kind((GdkEvent*)event), 0, 0,
487 self->button_state);
488
489 return TRUE;
490 }

References check_pointer_inside(), event, fl_engine_send_mouse_pointer_event(), fl_keyboard_handler_sync_modifier_if_needed(), get_device_kind(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by fl_view_init().

## ◆ on_pre_engine_restart_cb()

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

Definition at line 315 of file fl_view.cc.

315 {
316 init_keyboard(self);
317 init_scrolling(self);
318 }

References init_keyboard(), and init_scrolling().

Referenced by fl_view_new(), and fl_view_new_for_engine().

## ◆ realize_cb()

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

Definition at line 599 of file fl_view.cc.

599 {
600 g_autoptr(GError) error = nullptr;
601
602 fl_renderer_make_current(FL_RENDERER(self->renderer));
603
604 GError* gl_error = gtk_gl_area_get_error(self->gl_area);
605 if (gl_error != NULL) {
606 g_warning("Failed to initialize GLArea: %s", gl_error->message);
607 return;
608 }
609
610 fl_renderer_setup(FL_RENDERER(self->renderer));
611
612 GtkWidget* toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(self));
613
614 self->window_state_monitor =
615 fl_window_state_monitor_new(fl_engine_get_binary_messenger(self->engine),
616 GTK_WINDOW(toplevel_window));
617
618 // Handle requests by the user to close the application.
619 g_signal_connect_swapped(toplevel_window, "delete-event",
620 G_CALLBACK(window_delete_event_cb), self);
621
622 init_keyboard(self);
623
624 fl_renderer_add_view(FL_RENDERER(self->renderer), self->view_id, self);
625
626 if (!fl_engine_start(self->engine, &error)) {
627 g_warning("Failed to start Flutter engine: %s", error->message);
628 return;
629 }
630
631 handle_geometry_changed(self);
632
633 self->view_accessible = fl_view_accessible_new(self->engine);
634 fl_socket_accessible_embed(
635 FL_SOCKET_ACCESSIBLE(gtk_widget_get_accessible(GTK_WIDGET(self))),
636 atk_plug_get_id(ATK_PLUG(self->view_accessible)));
637 }

References error, fl_engine_get_binary_messenger(), fl_engine_start(), fl_renderer_add_view(), fl_renderer_make_current(), fl_renderer_setup(), fl_socket_accessible_embed(), fl_view_accessible_new(), fl_window_state_monitor_new(), handle_geometry_changed(), init_keyboard(), and window_delete_event_cb().

Referenced by fl_view_new().

## ◆ render_cb()

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

Definition at line 639 of file fl_view.cc.

639 {
640 if (gtk_gl_area_get_error(self->gl_area) != NULL) {
641 return FALSE;
642 }
643
644 int width = gtk_widget_get_allocated_width(GTK_WIDGET(self->gl_area));
645 int height = gtk_widget_get_allocated_height(GTK_WIDGET(self->gl_area));
646 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self->gl_area));
647 fl_renderer_render(FL_RENDERER(self->renderer), self->view_id,
648 width * scale_factor, height * scale_factor,
649 self->background_color);
650
651 return TRUE;
652 }

References fl_renderer_render(), height, TRUE, and width.

Referenced by fl_view_init().

## ◆ scroll_event_cb()

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

Definition at line 452 of file fl_view.cc.

452 {
453 // TODO(robert-ancell): Update to use GtkEventControllerScroll when we can
454 // depend on GTK 3.24.
455
456 fl_scrolling_manager_handle_scroll_event(
457 self->scrolling_manager, event,
458 gtk_widget_get_scale_factor(GTK_WIDGET(self)));
459 return TRUE;
460 }

References event, fl_scrolling_manager_handle_scroll_event(), and TRUE.

Referenced by fl_view_init().

## ◆ send_pointer_button_event()

static gboolean send_pointer_button_event | ( | FlView * | self,
|  | GdkEvent * | event
| ) |  |
| static

Definition at line 179 of file fl_view.cc.

179 {
180 guint event_time = gdk_event_get_time(event);
181 GdkEventType event_type = gdk_event_get_event_type(event);
182 GdkModifierType event_state = static_cast<GdkModifierType>(0);
183 gdk_event_get_state(event, &event_state);
184 guint event_button = 0;
185 gdk_event_get_button(event, &event_button);
186 gdouble event_x = 0.0, event_y = 0.0;
187 gdk_event_get_coords(event, &event_x, &event_y);
188
189 int64_t button;
190 switch (event_button) {
191 case 1:
192 button = kFlutterPointerButtonMousePrimary;
193 break;
194 case 2:
195 button = kFlutterPointerButtonMouseMiddle;
196 break;
197 case 3:
198 button = kFlutterPointerButtonMouseSecondary;
199 break;
200 default:
201 return FALSE;
202 }
203 int old_button_state = self->button_state;
204 FlutterPointerPhase phase = kMove;
205 if (event_type == GDK_BUTTON_PRESS) {
206 // Drop the event if Flutter already thinks the button is down.
207 if ((self->button_state & button) != 0) {
208 return FALSE;
209 }
210 self->button_state ^= button;
211
212 phase = old_button_state == 0 ? kDown : kMove;
213 } else if (event_type == GDK_BUTTON_RELEASE) {
214 // Drop the event if Flutter already thinks the button is up.
215 if ((self->button_state & button) == 0) {
216 return FALSE;
217 }
218 self->button_state ^= button;
219
220 phase = self->button_state == 0 ? kUp : kMove;
221 }
222
223 if (self->engine == nullptr) {
224 return FALSE;
225 }
226
227 gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self));
228 fl_scrolling_manager_set_last_mouse_position(
229 self->scrolling_manager, event_x * scale_factor, event_y * scale_factor);
230 fl_keyboard_handler_sync_modifier_if_needed(self->keyboard_handler,
231 event_state, event_time);
232 fl_engine_send_mouse_pointer_event(
233 self->engine, self->view_id, phase,
234 event_time * kMicrosecondsPerMillisecond, event_x * scale_factor,
235 event_y * scale_factor, get_device_kind((GdkEvent*)event), 0, 0,
236 self->button_state);
237
238 return TRUE;
239 }

References event, fl_engine_send_mouse_pointer_event(), fl_keyboard_handler_sync_modifier_if_needed(), fl_scrolling_manager_set_last_mouse_position(), get_device_kind(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by button_press_event_cb(), and button_release_event_cb().

## ◆ size_allocate_cb()

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

Definition at line 668 of file fl_view.cc.

668 {
669 handle_geometry_changed(self);
670 }

References handle_geometry_changed().

Referenced by fl_view_init().

## ◆ unrealize_cb()

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

Definition at line 654 of file fl_view.cc.

654 {
655 g_autoptr(GError) error = nullptr;
656
657 fl_renderer_make_current(FL_RENDERER(self->renderer));
658
659 GError* gl_error = gtk_gl_area_get_error(self->gl_area);
660 if (gl_error != NULL) {
661 g_warning("Failed to uninitialize GLArea: %s", gl_error->message);
662 return;
663 }
664
665 fl_renderer_cleanup(FL_RENDERER(self->renderer));
666 }

References error, fl_renderer_cleanup(), and fl_renderer_make_current().

Referenced by fl_view_new().

## ◆ update_semantics_cb()

static void update_semantics_cb | ( | FlEngine * | engine,
|  | const FlutterSemanticsUpdate2 * | update,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 302 of file fl_view.cc.

304 {
305 FlView* self = FL_VIEW(user_data);
306
307 fl_view_accessible_handle_update_semantics(self->view_accessible, update);
308 }

References fl_view_accessible_handle_update_semantics(), and user_data.

Referenced by fl_view_new().

## ◆ view_added_cb()

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

Definition at line 282 of file fl_view.cc.

284 {
285 FlView* self = FL_VIEW(user_data);
286
287 g_autoptr(GError) error = nullptr;
288 if (!fl_engine_add_view_finish(FL_ENGINE(object), result, &error)) {
289 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
290 return;
291 }
292
293 g_warning("Failed to add view: %s", error->message);
294 // FIXME: Show on the GLArea
295 return;
296 }
297
298 handle_geometry_changed(self);
299 }

References error, fl_engine_add_view_finish(), handle_geometry_changed(), result, 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 129 of file fl_view.cc.

129 {
130 fl_platform_handler_request_app_exit(self->platform_handler);
131 // Stop the event from propagating.
132 return TRUE;
133 }

References fl_platform_handler_request_app_exit(), and TRUE.

Referenced by realize_cb().

## Variable Documentation

## ◆ fl_view_signals

guint fl_view_signals[kSignalLastSignal]
| static

Definition at line 92 of file fl_view.cc.

Referenced by fl_view_class_init(), and G_DEFINE_TYPE_WITH_CODE().

## ◆ kMicrosecondsPerMillisecond

constexpr int kMicrosecondsPerMillisecond = 1000
| static constexpr

Definition at line 35 of file fl_view.cc.

Referenced by check_pointer_inside(), leave_notify_event_cb(), motion_notify_event_cb(), and send_pointer_button_event().

fl_view_realize
static void fl_view_realize(GtkWidget *widget)
Definition: fl_view.cc:726
window_delete_event_cb
static gboolean window_delete_event_cb(FlView *self)
Definition: fl_view.cc:129
fl_keyboard_handler_handle_event
gboolean fl_keyboard_handler_handle_event(FlKeyboardHandler *self, FlKeyEvent *event)
Definition: fl_keyboard_handler.cc:541
fl_renderer_remove_view
void fl_renderer_remove_view(FlRenderer *self, FlutterViewId view_id)
Definition: fl_renderer.cc:325
gesture_rotation_update_cb
static void gesture_rotation_update_cb(FlView *self, gdouble rotation, gdouble delta)
Definition: fl_view.cc:551
fl_renderer_wait_for_frame
void fl_renderer_wait_for_frame(FlRenderer *self, int target_width, int target_height)
Definition: fl_renderer.cc:409
fl_renderer_gdk_set_window
void fl_renderer_gdk_set_window(FlRendererGdk *self, GdkWindow *window)
Definition: fl_renderer_gdk.cc:88
enter_notify_event_cb
static gboolean enter_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:493
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
leave_notify_event_cb
static gboolean leave_notify_event_cb(FlView *self, GdkEventCrossing *crossing_event)
Definition: fl_view.cc:507
fl_scrolling_manager_handle_zoom_end
void fl_scrolling_manager_handle_zoom_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:208
fl_engine_send_key_event
void fl_engine_send_key_event(FlEngine *self, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Definition: fl_engine.cc:940
fl_key_event_new_from_gdk_event
FlKeyEvent * fl_key_event_new_from_gdk_event(GdkEvent *event)
Definition: fl_key_event.cc:53
kMicrosecondsPerMillisecond
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_view.cc:35
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:74
fl_view_accessible_handle_update_semantics
void fl_view_accessible_handle_update_semantics(FlViewAccessible *self, const FlutterSemanticsUpdate2 *update)
Definition: fl_view_accessible.cc:142
kSignalFirstFrame
@ kSignalFirstFrame
Definition: fl_view.cc:90
init_scrolling
static void init_scrolling(FlView *self)
Definition: fl_view.cc:153
fl_renderer_gdk_get_context
GdkGLContext * fl_renderer_gdk_get_context(FlRendererGdk *self)
Definition: fl_renderer_gdk.cc:125
create_context_cb
static GdkGLContext * create_context_cb(FlView *self)
Definition: fl_view.cc:574
fl_platform_handler_request_app_exit
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)
Definition: fl_platform_handler.cc:421
get_device_kind
static FlutterPointerDeviceKind get_device_kind(GdkEvent *event)
Definition: fl_view.cc:159
fl_view_get_registrar_for_plugin
static FlPluginRegistrar * fl_view_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_view.cc:321
fl_keyboard_handler_get_pressed_state
GHashTable * fl_keyboard_handler_get_pressed_state(FlKeyboardHandler *self)
Definition: fl_keyboard_handler.cc:590
on_pre_engine_restart_cb
static void on_pre_engine_restart_cb(FlView *self)
Definition: fl_view.cc:315
fl_engine_get_renderer
FlRenderer * fl_engine_get_renderer(FlEngine *self)
Definition: fl_engine.cc:504
size_allocate_cb
static void size_allocate_cb(FlView *self)
Definition: fl_view.cc:668
unrealize_cb
static void unrealize_cb(FlView *self)
Definition: fl_view.cc:654
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:686
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
keymap_keys_changed_cb
static void keymap_keys_changed_cb(FlView *self)
Definition: fl_view.cc:539
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
fl_platform_handler_new
FlPlatformHandler * fl_platform_handler_new(FlBinaryMessenger *messenger)
Definition: fl_platform_handler.cc:405
fl_text_input_handler_new
FlTextInputHandler * fl_text_input_handler_new(FlBinaryMessenger *messenger, GtkIMContext *im_context, FlTextInputViewDelegate *view_delegate)
Definition: fl_text_input_handler.cc:747
realize_cb
static void realize_cb(FlView *self)
Definition: fl_view.cc:599
fl_engine_send_window_metrics_event
void fl_engine_send_window_metrics_event(FlEngine *self, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
Definition: fl_engine.cc:854
scroll_event_cb
static gboolean scroll_event_cb(FlView *self, GdkEventScroll *event)
Definition: fl_view.cc:452
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:995
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:282
fl_key_event_get_origin
GdkEvent * fl_key_event_get_origin(FlKeyEvent *self)
Definition: fl_key_event.cc:109
update_semantics_cb
static void update_semantics_cb(FlEngine *engine, const FlutterSemanticsUpdate2 *update, gpointer user_data)
Definition: fl_view.cc:302
render_cb
static gboolean render_cb(FlView *self, GdkGLContext *context)
Definition: fl_view.cc:639
gesture_zoom_end_cb
static void gesture_zoom_end_cb(FlView *self)
Definition: fl_view.cc:570
button_release_event_cb
static gboolean button_release_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:445
KeyboardLayoutNotifier
std::function< void()> KeyboardLayoutNotifier
Definition: fl_keyboard_view_delegate.h:17
fl_engine_add_view_finish
gboolean fl_engine_add_view_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:679
fl_scrolling_manager_new
FlScrollingManager * fl_scrolling_manager_new(FlScrollingViewDelegate *view_delegate)
Definition: fl_scrolling_manager.cc:47
fl_view_key_press_event
static gboolean fl_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
Definition: fl_view.cc:736
fl_view_key_release_event
static gboolean fl_view_key_release_event(GtkWidget *widget, GdkEventKey *event)
Definition: fl_view.cc:745
fl_text_input_handler_filter_keypress
gboolean fl_text_input_handler_filter_keypress(FlTextInputHandler *self, FlKeyEvent *event)
Definition: fl_text_input_handler.cc:778
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:66
fl_view_dispose
static void fl_view_dispose(GObject *object)
Definition: fl_view.cc:684
fl_view_signals
static guint fl_view_signals[kSignalLastSignal]
Definition: fl_view.cc:92
fl_renderer_gdk_create_contexts
gboolean fl_renderer_gdk_create_contexts(FlRendererGdk *self, GError **error)
Definition: fl_renderer_gdk.cc:95
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
fl_scrolling_manager_handle_zoom_update
void fl_scrolling_manager_handle_zoom_update(FlScrollingManager *self, gdouble scale)
Definition: fl_scrolling_manager.cc:198
check_pointer_inside
static void check_pointer_inside(FlView *self, GdkEvent *event)
Definition: fl_view.cc:242
fl_view_get_keyboard_state
GHashTable * fl_view_get_keyboard_state(FlView *self)
Definition: fl_view.cc:905
fl_window_state_monitor_new
FlWindowStateMonitor * fl_window_state_monitor_new(FlBinaryMessenger *messenger, GtkWindow *window)
Definition: fl_window_state_monitor.cc:104
fl_scrolling_manager_handle_rotation_update
void fl_scrolling_manager_handle_rotation_update(FlScrollingManager *self, gdouble rotation)
Definition: fl_scrolling_manager.cc:164
gesture_rotation_begin_cb
static void gesture_rotation_begin_cb(FlView *self)
Definition: fl_view.cc:547
fl_engine_add_view
FlutterViewId fl_engine_add_view(FlEngine *self, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:641
fl_socket_accessible_embed
void fl_socket_accessible_embed(FlSocketAccessible *self, gchar *id)
Definition: fl_socket_accessible.cc:55
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
handle_geometry_changed
static void handle_geometry_changed(FlView *self)
Definition: fl_view.cc:260
fl_renderer_cleanup
void fl_renderer_cleanup(FlRenderer *self)
Definition: fl_renderer.cc:528
gesture_rotation_end_cb
static void gesture_rotation_end_cb(FlView *self)
Definition: fl_view.cc:558
gesture_zoom_update_cb
static void gesture_zoom_update_cb(FlView *self, gdouble scale)
Definition: fl_view.cc:566
send_pointer_button_event
static gboolean send_pointer_button_event(FlView *self, GdkEvent *event)
Definition: fl_view.cc:179
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:494
fl_renderer_add_view
void fl_renderer_add_view(FlRenderer *self, FlutterViewId view_id, FlView *view)
Definition: fl_renderer.cc:314
gesture_zoom_begin_cb
static void gesture_zoom_begin_cb(FlView *self)
Definition: fl_view.cc:562
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_renderer_make_current
void fl_renderer_make_current(FlRenderer *self)
Definition: fl_renderer.cc:340
fl_engine_set_update_semantics_handler
void fl_engine_set_update_semantics_handler(FlEngine *self, FlEngineUpdateSemanticsHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:736
fl_engine_send_pointer_pan_zoom_event
void fl_engine_send_pointer_pan_zoom_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
Definition: fl_engine.cc:908
fl_keyboard_handler_sync_modifier_if_needed
void fl_keyboard_handler_sync_modifier_if_needed(FlKeyboardHandler *self, guint state, double event_time)
Definition: fl_keyboard_handler.cc:577
fl_view_notify
static void fl_view_notify(GObject *object, GParamSpec *pspec)
Definition: fl_view.cc:672
fl_renderer_render
void fl_renderer_render(FlRenderer *self, FlutterViewId view_id, int width, int height, const GdkRGBA *background_color)
Definition: fl_renderer.cc:501
fl_scrolling_manager_handle_rotation_end
void fl_scrolling_manager_handle_rotation_end(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:174
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:509
fl_scrolling_manager_handle_rotation_begin
void fl_scrolling_manager_handle_rotation_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:151
fl_plugin_registrar_new
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
Definition: fl_plugin_registrar.cc:87
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_channel_responder.cc:120
motion_notify_event_cb
static gboolean motion_notify_event_cb(FlView *self, GdkEventMotion *motion_event)
Definition: fl_view.cc:463
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
fl_scrolling_manager_handle_zoom_begin
void fl_scrolling_manager_handle_zoom_begin(FlScrollingManager *self)
Definition: fl_scrolling_manager.cc:185
fl_engine_send_mouse_pointer_event
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterViewId view_id, FlutterPointerPhase phase, size_t timestamp, double x, double y, FlutterPointerDeviceKind device_kind, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:874
fl_keyboard_handler_new
FlKeyboardHandler * fl_keyboard_handler_new(FlBinaryMessenger *messenger, FlKeyboardViewDelegate *view_delegate)
Definition: fl_keyboard_handler.cc:499
fl_view_accessible_new
FlViewAccessible * fl_view_accessible_new(FlEngine *engine)
Definition: fl_view_accessible.cc:133
init_keyboard
static void init_keyboard(FlView *self)
Definition: fl_view.cc:136
fl_engine_get_texture_registrar
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:1011
button_press_event_cb
static gboolean button_press_event_cb(FlView *self, GdkEventButton *button_event)
Definition: fl_view.cc:428
kSignalLastSignal
@ kSignalLastSignal
Definition: fl_view.cc:90
fl_mouse_cursor_handler_new
FlMouseCursorHandler * fl_mouse_cursor_handler_new(FlBinaryMessenger *messenger, FlView *view)
Definition: fl_mouse_cursor_handler.cc:164
fl_renderer_setup
void fl_renderer_setup(FlRenderer *self)
Definition: fl_renderer.cc:484