Flutter Linux Embedder
fl_view_monitor.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <gtk/gtk.h>
6 
9 
11  GObject parent_instance;
12 
13  // View being monitored.
14  FlView* view;
15 
16  // Isolate to call callbacks with.
18 
19  // Callbacks.
20  void (*on_first_frame)(void);
21 };
22 
23 G_DEFINE_TYPE(FlViewMonitor, fl_view_monitor, G_TYPE_OBJECT)
24 
25 static void first_frame_cb(FlViewMonitor* self) {
26  flutter::IsolateScope scope(self->isolate);
27  if (self->on_first_frame) {
28  self->on_first_frame();
29  }
30 }
31 
32 static void fl_view_monitor_dispose(GObject* object) {
33  FlViewMonitor* self = FL_VIEW_MONITOR(object);
34 
35  g_clear_object(&self->view);
36 
37  G_OBJECT_CLASS(fl_view_monitor_parent_class)->dispose(object);
38 }
39 
40 static void fl_view_monitor_class_init(FlViewMonitorClass* klass) {
41  G_OBJECT_CLASS(klass)->dispose = fl_view_monitor_dispose;
42 }
43 
44 static void fl_view_monitor_init(FlViewMonitor* self) {}
45 
46 G_MODULE_EXPORT FlViewMonitor* fl_view_monitor_new(
47  FlView* view,
48  void (*on_first_frame)(void)) {
49  FlViewMonitor* self =
50  FL_VIEW_MONITOR(g_object_new(fl_view_monitor_get_type(), nullptr));
51 
52  self->view = FL_VIEW(g_object_ref(view));
53  self->isolate = flutter::Isolate::Current();
54  self->on_first_frame = on_first_frame;
55  g_signal_connect_object(view, "first-frame", G_CALLBACK(first_frame_cb), self,
56  G_CONNECT_SWAPPED);
57 
58  return self;
59 }
static Isolate Current()
Definition: isolate_scope.cc:9
FlView * view
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
G_MODULE_EXPORT FlViewMonitor * fl_view_monitor_new(FlView *view, void(*on_first_frame)(void))
static void fl_view_monitor_dispose(GObject *object)
static void fl_view_monitor_class_init(FlViewMonitorClass *klass)
static void fl_view_monitor_init(FlViewMonitor *self)
static void first_frame_cb(FlViewMonitor *self)
void(* on_first_frame)(void)
GObject parent_instance
flutter::Isolate isolate