| Flutter Linux Embedder |

Classes | Functions
fl_display_monitor.cc File Reference
`#include "flutter/shell/platform/linux/fl_display_monitor.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`

Go to the source code of this file.

## Classes
struct | _FlDisplayMonitor

## Functions
static void | notify_display_update (FlDisplayMonitor *self)
static void | monitor_added_cb (FlDisplayMonitor *self, GdkMonitor *monitor)
static void | monitor_removed_cb (FlDisplayMonitor *self, GdkMonitor *monitor)
static void | fl_display_monitor_dispose (GObject *object)
static void | fl_display_monitor_class_init (FlDisplayMonitorClass *klass)
static void | fl_display_monitor_init (FlDisplayMonitor *self)
FlDisplayMonitor * | fl_display_monitor_new (FlEngine *engine, GdkDisplay *display)
void | fl_display_monitor_start (FlDisplayMonitor *self)
FlutterEngineDisplayId | fl_display_monitor_get_display_id (FlDisplayMonitor *self, GdkMonitor *monitor)

## Function Documentation

## ◆ fl_display_monitor_class_init()

static void fl_display_monitor_class_init | ( | FlDisplayMonitorClass * | klass | ) |
| static

Definition at line 83 of file fl_display_monitor.cc.

83 {
84 GObjectClass* object_class = G_OBJECT_CLASS(klass);
85 object_class->dispose = fl_display_monitor_dispose;
86 }
fl_display_monitor_dispose
static void fl_display_monitor_dispose(GObject *object)
Definition: fl_display_monitor.cc:73

References fl_display_monitor_dispose().

## ◆ fl_display_monitor_dispose()

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

Definition at line 73 of file fl_display_monitor.cc.

73 {
74 FlDisplayMonitor* self = FL_DISPLAY_MONITOR(object);
75
76 g_weak_ref_clear(&self->engine);
77 g_clear_object(&self->display);
78 g_clear_pointer(&self->display_ids_by_monitor, g_hash_table_unref);
79
80 G_OBJECT_CLASS(fl_display_monitor_parent_class)->dispose(object);
81 }

Referenced by fl_display_monitor_class_init().

## ◆ fl_display_monitor_get_display_id()

FlutterEngineDisplayId fl_display_monitor_get_display_id | ( | FlDisplayMonitor * | monitor,
|  | GdkMonitor * | gdk_monitor
| ) |  |

fl_display_monitor_get_display_id: @monitor: an #FlDisplayMonitor. @gdk_monitor: GDK monitor to get display ID for.

Get the ID Flutter is using for a given monitor.

Returns: an ID or 0 if unknown.

Definition at line 115 of file fl_display_monitor.cc.

116 {
117 g_return_val_if_fail(FL_IS_DISPLAY_MONITOR(self), 0);
118 return GPOINTER_TO_INT(
119 g_hash_table_lookup(self->display_ids_by_monitor, monitor));
120 }

Referenced by handle_geometry_changed().

## ◆ fl_display_monitor_init()

static void fl_display_monitor_init | ( | FlDisplayMonitor * | self | ) |
| static

Definition at line 88 of file fl_display_monitor.cc.

88 {
89 self->display_ids_by_monitor = g_hash_table_new_full(
90 g_direct_hash, g_direct_equal, g_object_unref, nullptr);
91 self->next_display_id = 1;
92 }

## ◆ fl_display_monitor_new()

FlDisplayMonitor* fl_display_monitor_new | ( | FlEngine * | engine,
|  | GdkDisplay * | display
| ) |  |

fl_display_monitor_new: @engine: engine to update. @display: display to monitor.

Creates a new object to keep the engine updated with the currently used displays. In GDK, a display is called a "monitor".

Returns: a new #FlDisplayMontior.

Definition at line 94 of file fl_display_monitor.cc.

95 {
96 FlDisplayMonitor* self =
97 FL_DISPLAY_MONITOR(g_object_new(fl_display_monitor_get_type(), nullptr));
98 g_weak_ref_init(&self->engine, engine);
99 self->display = GDK_DISPLAY(g_object_ref(display));
100 return self;
101 }

Referenced by fl_engine_init(), and TEST().

## ◆ fl_display_monitor_start()

void fl_display_monitor_start | ( | FlDisplayMonitor * | monitor | ) |

fl_display_monitor_start: @monitor: an #FlDisplayMonitor.

Start monitoring for display changes.

Definition at line 103 of file fl_display_monitor.cc.

103 {
104 g_return_if_fail(FL_IS_DISPLAY_MONITOR(self));
105
106 g_signal_connect_object(self->display, "monitor-added",
107 G_CALLBACK(monitor_added_cb), self,
108 G_CONNECT_SWAPPED);
109 g_signal_connect_object(self->display, "monitor-removed",
110 G_CALLBACK(monitor_removed_cb), self,
111 G_CONNECT_SWAPPED);
112 notify_display_update(self);
113 }
monitor_added_cb
static void monitor_added_cb(FlDisplayMonitor *self, GdkMonitor *monitor)
Definition: fl_display_monitor.cc:64
notify_display_update
static void notify_display_update(FlDisplayMonitor *self)
Definition: fl_display_monitor.cc:27
monitor_removed_cb
static void monitor_removed_cb(FlDisplayMonitor *self, GdkMonitor *monitor)
Definition: fl_display_monitor.cc:68

References monitor_added_cb(), monitor_removed_cb(), and notify_display_update().

Referenced by fl_engine_start(), and TEST().

## ◆ monitor_added_cb()

static void monitor_added_cb | ( | FlDisplayMonitor * | self,
|  | GdkMonitor * | monitor
| ) |  |
| static

Definition at line 64 of file fl_display_monitor.cc.

64 {
65 notify_display_update(self);
66 }

References notify_display_update().

Referenced by fl_display_monitor_start().

## ◆ monitor_removed_cb()

static void monitor_removed_cb | ( | FlDisplayMonitor * | self,
|  | GdkMonitor * | monitor
| ) |  |
| static

Definition at line 68 of file fl_display_monitor.cc.

68 {
69 g_hash_table_remove(self->display_ids_by_monitor, monitor);
70 notify_display_update(self);
71 }

References notify_display_update().

Referenced by fl_display_monitor_start().

## ◆ notify_display_update()

static void notify_display_update | ( | FlDisplayMonitor * | self | ) |
| static

Definition at line 27 of file fl_display_monitor.cc.

27 {
28 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
29 if (engine == nullptr) {
30 return;
31 }
32
33 int n_monitors = gdk_display_get_n_monitors(self->display);
34 g_autofree FlutterEngineDisplay* displays =
35 g_new0(FlutterEngineDisplay, n_monitors);
36 for (int i = 0; i < n_monitors; i++) {
37 FlutterEngineDisplay* display = &displays[i];
38
39 GdkMonitor* monitor = gdk_display_get_monitor(self->display, i);
40 FlutterEngineDisplayId display_id = GPOINTER_TO_INT(
41 g_hash_table_lookup(self->display_ids_by_monitor, monitor));
42 if (display_id == 0) {
43 display_id = self->next_display_id;
44 g_hash_table_insert(self->display_ids_by_monitor, g_object_ref(monitor),
45 GINT_TO_POINTER(display_id));
46 self->next_display_id++;
47 }
48
49 GdkRectangle geometry;
50 gdk_monitor_get_geometry(monitor, &geometry);
51
52 display->struct_size = sizeof(FlutterEngineDisplay);
53 display->display_id = display_id;
54 display->single_display = false;
55 display->refresh_rate = gdk_monitor_get_refresh_rate(monitor) / 1000.0;
56 display->width = geometry.width;
57 display->height = geometry.height;
58 display->device_pixel_ratio = gdk_monitor_get_scale_factor(monitor);
59 }
60
61 fl_engine_notify_display_update(engine, displays, n_monitors);
62 }
fl_engine_notify_display_update
void fl_engine_notify_display_update(FlEngine *self, const FlutterEngineDisplay *displays, size_t displays_length)
Definition: fl_engine.cc:862
i
int i
Definition: fl_socket_accessible.cc:18

References fl_engine_notify_display_update(), and i.

Referenced by fl_display_monitor_start(), monitor_added_cb(), and monitor_removed_cb().