| Flutter Linux Embedder |

Classes | Functions
fl_window_monitor.cc File Reference
`#include <gtk/gtk.h>`
`#include "flutter/shell/platform/common/isolate_scope.h"`
`#include "flutter/shell/platform/linux/fl_window_monitor.h"`

Go to the source code of this file.

## Classes
struct | _FlWindowMonitor

## Functions
static gboolean | configure_event_cb (FlWindowMonitor *self, GdkEventConfigure *event)
static gboolean | window_state_event_cb (FlWindowMonitor *self, GdkEventWindowState *event)
static void | is_active_notify_cb (FlWindowMonitor *self)
static void | title_notify_cb (FlWindowMonitor *self)
static gboolean | delete_event_cb (FlWindowMonitor *self, GdkEvent *event)
static void | destroy_cb (FlWindowMonitor *self)
static void | fl_window_monitor_dispose (GObject *object)
static void | fl_window_monitor_class_init (FlWindowMonitorClass *klass)
static void | fl_window_monitor_init (FlWindowMonitor *self)
G_MODULE_EXPORT FlWindowMonitor * | fl_window_monitor_new (GtkWindow *window, void(*on_configure)(void), void(*on_state_changed)(void), void(*on_is_active_notify)(void), void(*on_title_notify)(void), void(*on_close)(void), void(*on_destroy)(void))

## Function Documentation

## ◆ configure_event_cb()

static gboolean configure_event_cb | ( | FlWindowMonitor * | self,
|  | GdkEventConfigure * | event
| ) |  |
| static

Definition at line 30 of file fl_window_monitor.cc.

31 {
32 flutter::IsolateScope scope(self->isolate);
33 self->on_configure();
34
35 return FALSE;
36 }
flutter::IsolateScope
Definition: isolate_scope.h:33

Referenced by fl_window_monitor_new().

## ◆ delete_event_cb()

static gboolean delete_event_cb | ( | FlWindowMonitor * | self,
|  | GdkEvent * | event
| ) |  |
| static

Definition at line 56 of file fl_window_monitor.cc.

56 {
57 flutter::IsolateScope scope(self->isolate);
58 self->on_close();
59
60 // Stop default behaviour of destroying the window.
61 return TRUE;
62 }
TRUE
return TRUE
Definition: fl_compositor_software.cc:68

References TRUE.

Referenced by fl_window_monitor_new().

## ◆ destroy_cb()

static void destroy_cb | ( | FlWindowMonitor * | self | ) |
| static

Definition at line 64 of file fl_window_monitor.cc.

64 {
65 flutter::IsolateScope scope(self->isolate);
66 self->on_destroy();
67 }

Referenced by fl_window_monitor_new().

## ◆ fl_window_monitor_class_init()

static void fl_window_monitor_class_init | ( | FlWindowMonitorClass * | klass | ) |
| static

Definition at line 80 of file fl_window_monitor.cc.

80 {
81 G_OBJECT_CLASS(klass)->dispose = fl_window_monitor_dispose;
82 }
fl_window_monitor_dispose
static void fl_window_monitor_dispose(GObject *object)
Definition: fl_window_monitor.cc:69

References fl_window_monitor_dispose().

## ◆ fl_window_monitor_dispose()

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

Definition at line 69 of file fl_window_monitor.cc.

69 {
70 FlWindowMonitor* self = FL_WINDOW_MONITOR(object);
71
72 // Disconnect all handlers using data. If we try and disconnect them
73 // individually they generated warnings after the widget has been destroyed.
74 g_signal_handlers_disconnect_by_data(self->window, self);
75 g_clear_object(&self->window);
76
77 G_OBJECT_CLASS(fl_window_monitor_parent_class)->dispose(object);
78 }

Referenced by fl_window_monitor_class_init().

## ◆ fl_window_monitor_init()

static void fl_window_monitor_init | ( | FlWindowMonitor * | self | ) |
| static

Definition at line 84 of file fl_window_monitor.cc.

84 {}

## ◆ fl_window_monitor_new()

G_MODULE_EXPORT FlWindowMonitor* fl_window_monitor_new | ( | GtkWindow * | window,
|  | void(*)(void) | on_configure,
|  | void(*)(void) | on_state_changed,
|  | void(*)(void) | on_is_active_notify,
|  | void(*)(void) | on_title_notify,
|  | void(*)(void) | on_close,
|  | void(*)(void) | on_destroy
| ) |  |

fl_window_monitor_new: @window: the window being monitored. @on_configure: the function to call when the window changes size, position or stacking. @on_state_changed: the function to call when the window state changes. @on_is_active_notify: the function to call when the is-active property changes. @on_close: the function to call when the user requests the window to be closed. @on_destroy: the function to call when the window is destroyed.

Helper class to allow the Flutter engine to monitor a GtkWindow using FFI. Callbacks are called in the isolate this class was created with.

Returns: a new #FlWindowMonitor.

Definition at line 86 of file fl_window_monitor.cc.

93 {
94 FlWindowMonitor* self =
95 FL_WINDOW_MONITOR(g_object_new(fl_window_monitor_get_type(), nullptr));
96
97 self->window = GTK_WINDOW(g_object_ref(window));
98 self->isolate = flutter::Isolate::Current();
99 self->on_configure = on_configure;
100 self->on_state_changed = on_state_changed;
101 self->on_is_active_notify = on_is_active_notify;
102 self->on_title_notify = on_title_notify;
103 self->on_close = on_close;
104 self->on_destroy = on_destroy;
105 g_signal_connect_swapped(window, "configure-event",
106 G_CALLBACK(configure_event_cb), self);
107 g_signal_connect_swapped(window, "window-state-event",
108 G_CALLBACK(window_state_event_cb), self);
109 g_signal_connect_swapped(window, "notify::is-active",
110 G_CALLBACK(is_active_notify_cb), self);
111 g_signal_connect_swapped(window, "notify::title", G_CALLBACK(title_notify_cb),
112 self);
113 g_signal_connect_swapped(window, "delete-event", G_CALLBACK(delete_event_cb),
114 self);
115 g_signal_connect_swapped(window, "destroy", G_CALLBACK(destroy_cb), self);
116
117 return self;
118 }
flutter::Isolate::Current
static Isolate Current()
Definition: isolate_scope.cc:9
destroy_cb
static void destroy_cb(FlWindowMonitor *self)
Definition: fl_window_monitor.cc:64
is_active_notify_cb
static void is_active_notify_cb(FlWindowMonitor *self)
Definition: fl_window_monitor.cc:46
title_notify_cb
static void title_notify_cb(FlWindowMonitor *self)
Definition: fl_window_monitor.cc:51
configure_event_cb
static gboolean configure_event_cb(FlWindowMonitor *self, GdkEventConfigure *event)
Definition: fl_window_monitor.cc:30
window_state_event_cb
static gboolean window_state_event_cb(FlWindowMonitor *self, GdkEventWindowState *event)
Definition: fl_window_monitor.cc:38
delete_event_cb
static gboolean delete_event_cb(FlWindowMonitor *self, GdkEvent *event)
Definition: fl_window_monitor.cc:56

References configure_event_cb(), flutter::Isolate::Current(), delete_event_cb(), destroy_cb(), is_active_notify_cb(), title_notify_cb(), and window_state_event_cb().

## ◆ is_active_notify_cb()

static void is_active_notify_cb | ( | FlWindowMonitor * | self | ) |
| static

Definition at line 46 of file fl_window_monitor.cc.

46 {
47 flutter::IsolateScope scope(self->isolate);
48 self->on_is_active_notify();
49 }

Referenced by fl_window_monitor_new().

## ◆ title_notify_cb()

static void title_notify_cb | ( | FlWindowMonitor * | self | ) |
| static

Definition at line 51 of file fl_window_monitor.cc.

51 {
52 flutter::IsolateScope scope(self->isolate);
53 self->on_title_notify();
54 }

Referenced by fl_window_monitor_new().

## ◆ window_state_event_cb()

static gboolean window_state_event_cb | ( | FlWindowMonitor * | self,
|  | GdkEventWindowState * | event
| ) |  |
| static

Definition at line 38 of file fl_window_monitor.cc.

39 {
40 flutter::IsolateScope scope(self->isolate);
41 self->on_state_changed();
42
43 return FALSE;
44 }

Referenced by fl_window_monitor_new().