Flutter Engine
 
Loading...
Searching...
No Matches
fl_windowing_channel.cc File Reference

Go to the source code of this file.

Classes

struct  _FlWindowingChannel
 

Functions

static gboolean is_valid_size_argument (FlValue *value)
 
static FlWindowingSizeparse_size_value (FlValue *value)
 
static gboolean parse_window_state_value (FlValue *value, FlWindowState *state)
 
static const gchar * window_state_to_string (FlWindowState state)
 
static FlMethodResponse * create_regular (FlWindowingChannel *self, FlValue *args)
 
static FlMethodResponse * modify_regular (FlWindowingChannel *self, FlValue *args)
 
static FlMethodResponse * destroy_window (FlWindowingChannel *self, FlValue *args)
 
static void method_call_cb (FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data)
 
static void fl_windowing_channel_dispose (GObject *object)
 
static void fl_windowing_channel_class_init (FlWindowingChannelClass *klass)
 
static void fl_windowing_channel_init (FlWindowingChannel *self)
 
FlWindowingChannel * fl_windowing_channel_new (FlBinaryMessenger *messenger, FlWindowingChannelVTable *vtable, gpointer user_data)
 
FlMethodResponse * fl_windowing_channel_make_create_regular_response (int64_t view_id, FlWindowingSize *size, FlWindowState state)
 
FlMethodResponse * fl_windowing_channel_make_modify_regular_response ()
 
FlMethodResponse * fl_windowing_channel_make_destroy_window_response ()
 

Variables

static constexpr char kChannelName [] = "flutter/windowing"
 
static constexpr char kBadArgumentsError [] = "Bad Arguments"
 
static constexpr char kCreateRegularMethod [] = "createRegular"
 
static constexpr char kModifyRegularMethod [] = "modifyRegular"
 
static constexpr char kDestroyWindowMethod [] = "destroyWindow"
 
static constexpr char kSizeKey [] = "size"
 
static constexpr char kMinSizeKey [] = "minSize"
 
static constexpr char kMaxSizeKey [] = "maxSize"
 
static constexpr char kTitleKey [] = "title"
 
static constexpr char kStateKey [] = "state"
 
static constexpr char kViewIdKey [] = "viewId"
 

Function Documentation

◆ create_regular()

static FlMethodResponse * create_regular ( FlWindowingChannel *  self,
FlValue args 
)
static

Definition at line 93 of file fl_windowing_channel.cc.

94 {
96 return FL_METHOD_RESPONSE(fl_method_error_response_new(
97 kBadArgumentsError, "Argument map missing or malformed", nullptr));
98 }
99
101 if (size_value == nullptr || !is_valid_size_argument(size_value)) {
102 return FL_METHOD_RESPONSE(fl_method_error_response_new(
103 kBadArgumentsError, "Missing/invalid size argument", nullptr));
104 }
106
108 g_autoptr(FlWindowingSize) min_size = nullptr;
109 if (min_size_value != nullptr) {
110 if (!is_valid_size_argument(min_size_value)) {
111 return FL_METHOD_RESPONSE(fl_method_error_response_new(
112 kBadArgumentsError, "Invalid minSize argument", nullptr));
113 }
114 min_size = parse_size_value(min_size_value);
115 }
116
118 g_autoptr(FlWindowingSize) max_size = nullptr;
119 if (max_size_value != nullptr) {
120 if (!is_valid_size_argument(max_size_value)) {
121 return FL_METHOD_RESPONSE(fl_method_error_response_new(
122 kBadArgumentsError, "Invalid maxSize argument", nullptr));
123 }
124 max_size = parse_size_value(max_size_value);
125 }
126
128 const gchar* title = nullptr;
129 if (title_value != nullptr) {
130 if (fl_value_get_type(title_value) != FL_VALUE_TYPE_STRING) {
131 return FL_METHOD_RESPONSE(fl_method_error_response_new(
132 kBadArgumentsError, "Invalid title argument", nullptr));
133 }
134 title = fl_value_get_string(title_value);
135 }
138 if (state_value != nullptr) {
139 if (!parse_window_state_value(state_value, &state)) {
140 return FL_METHOD_RESPONSE(fl_method_error_response_new(
141 kBadArgumentsError, "Invalid state argument", nullptr));
142 }
143 }
144
145 return self->vtable->create_regular(size, min_size, max_size, title, state,
146 self->user_data);
147}
g_autoptr(GMutexLocker) locker
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
Definition fl_value.cc:811
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition fl_value.cc:466
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition fl_value.cc:682
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
@ FL_VALUE_TYPE_STRING
Definition fl_value.h:68
@ FL_VALUE_TYPE_MAP
Definition fl_value.h:74
static constexpr char kStateKey[]
static FlWindowingSize * parse_size_value(FlValue *value)
static constexpr char kMaxSizeKey[]
static constexpr char kSizeKey[]
static constexpr char kMinSizeKey[]
static gboolean is_valid_size_argument(FlValue *value)
static gboolean parse_window_state_value(FlValue *value, FlWindowState *state)
static constexpr char kTitleKey[]
static constexpr char kBadArgumentsError[]
@ FL_WINDOW_STATE_UNDEFINED
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size

References args, fl_method_error_response_new(), fl_value_get_string(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_STRING, FL_WINDOW_STATE_UNDEFINED, g_autoptr(), is_valid_size_argument(), kBadArgumentsError, kMaxSizeKey, kMinSizeKey, kSizeKey, kStateKey, kTitleKey, parse_size_value(), parse_window_state_value(), and self.

Referenced by method_call_cb().

◆ destroy_window()

static FlMethodResponse * destroy_window ( FlWindowingChannel *  self,
FlValue args 
)
static

Definition at line 197 of file fl_windowing_channel.cc.

198 {
200 return FL_METHOD_RESPONSE(fl_method_error_response_new(
201 kBadArgumentsError, "Argument map missing or malformed", nullptr));
202 }
203
205 if (view_id_value == nullptr ||
206 fl_value_get_type(view_id_value) != FL_VALUE_TYPE_INT) {
207 return FL_METHOD_RESPONSE(fl_method_error_response_new(
208 kBadArgumentsError, "Missing/invalid viewId argument", nullptr));
209 }
210 int64_t view_id = fl_value_get_int(view_id_value);
211
212 return self->vtable->destroy_window(view_id, self->user_data);
213}
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition fl_value.cc:668
@ FL_VALUE_TYPE_INT
Definition fl_value.h:66
G_BEGIN_DECLS FlutterViewId view_id
static constexpr char kViewIdKey[]

References args, fl_method_error_response_new(), fl_value_get_int(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_INT, FL_VALUE_TYPE_MAP, kBadArgumentsError, kViewIdKey, self, and view_id.

Referenced by method_call_cb().

◆ fl_windowing_channel_class_init()

static void fl_windowing_channel_class_init ( FlWindowingChannelClass *  klass)
static

Definition at line 251 of file fl_windowing_channel.cc.

251 {
252 G_OBJECT_CLASS(klass)->dispose = fl_windowing_channel_dispose;
253}
static void fl_windowing_channel_dispose(GObject *object)

References fl_windowing_channel_dispose().

◆ fl_windowing_channel_dispose()

static void fl_windowing_channel_dispose ( GObject *  object)
static

Definition at line 243 of file fl_windowing_channel.cc.

243 {
244 FlWindowingChannel* self = FL_WINDOWING_CHANNEL(object);
245
246 g_clear_object(&self->channel);
247
248 G_OBJECT_CLASS(fl_windowing_channel_parent_class)->dispose(object);
249}

References self.

Referenced by fl_windowing_channel_class_init().

◆ fl_windowing_channel_init()

static void fl_windowing_channel_init ( FlWindowingChannel *  self)
static

Definition at line 255 of file fl_windowing_channel.cc.

255{}

◆ fl_windowing_channel_make_create_regular_response()

FlMethodResponse * fl_windowing_channel_make_create_regular_response ( int64_t  view_id,
FlWindowingSize size,
FlWindowState  state 
)

Definition at line 275 of file fl_windowing_channel.cc.

278 {
281 g_autoptr(FlValue) size_value = fl_value_new_list();
282 fl_value_append_take(size_value, fl_value_new_float(size->width));
283 fl_value_append_take(size_value, fl_value_new_float(size->height));
284 fl_value_set_string(result, kSizeKey, size_value);
287 return FL_METHOD_RESPONSE(fl_method_success_response_new(result));
288}
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
G_MODULE_EXPORT void fl_value_set_string(FlValue *self, const gchar *key, FlValue *value)
Definition fl_value.cc:639
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition fl_value.cc:366
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition fl_value.cc:650
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition fl_value.cc:276
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition fl_value.cc:262
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition fl_value.cc:269
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition fl_value.cc:600
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition fl_value.cc:349
static const gchar * window_state_to_string(FlWindowState state)

References fl_method_success_response_new(), fl_value_append_take(), fl_value_new_float(), fl_value_new_int(), fl_value_new_list(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string(), fl_value_set_string_take(), g_autoptr(), kSizeKey, kStateKey, kViewIdKey, view_id, and window_state_to_string().

Referenced by create_regular().

◆ fl_windowing_channel_make_destroy_window_response()

FlMethodResponse * fl_windowing_channel_make_destroy_window_response ( )

Definition at line 294 of file fl_windowing_channel.cc.

294 {
295 return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
296}

References fl_method_success_response_new().

Referenced by destroy_window().

◆ fl_windowing_channel_make_modify_regular_response()

FlMethodResponse * fl_windowing_channel_make_modify_regular_response ( )

Definition at line 290 of file fl_windowing_channel.cc.

290 {
291 return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
292}

References fl_method_success_response_new().

Referenced by modify_regular().

◆ fl_windowing_channel_new()

FlWindowingChannel * fl_windowing_channel_new ( FlBinaryMessenger *  messenger,
FlWindowingChannelVTable vtable,
gpointer  user_data 
)

fl_windowing_channel_new: @messenger: an #FlBinaryMessenger @vtable: callbacks for incoming method calls. @user_data: data to pass in callbacks.

Creates a new channel that sends handled windowing requests from the platform.

Returns: a new #FlWindowingChannel

Definition at line 257 of file fl_windowing_channel.cc.

259 {
260 FlWindowingChannel* self = FL_WINDOWING_CHANNEL(
261 g_object_new(fl_windowing_channel_get_type(), nullptr));
262
263 self->vtable = vtable;
264 self->user_data = user_data;
265
266 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
267 self->channel =
268 fl_method_channel_new(messenger, kChannelName, FL_METHOD_CODEC(codec));
270 nullptr);
271
272 return self;
273}
G_MODULE_EXPORT FlMethodChannel * fl_method_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMethodCodec *codec)
G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(FlMethodChannel *self, FlMethodChannelMethodCallHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new()
static void method_call_cb(FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data)
static constexpr char kChannelName[]

References fl_method_channel_new(), fl_method_channel_set_method_call_handler(), fl_standard_method_codec_new(), g_autoptr(), kChannelName, method_call_cb(), self, and user_data.

Referenced by fl_windowing_handler_new().

◆ is_valid_size_argument()

static gboolean is_valid_size_argument ( FlValue value)
static

Definition at line 39 of file fl_windowing_channel.cc.

39 {
40 return fl_value_get_type(value) == FL_VALUE_TYPE_LIST &&
41 fl_value_get_length(value) == 2 &&
46}
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition fl_value.cc:776
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition fl_value.cc:724
@ FL_VALUE_TYPE_LIST
Definition fl_value.h:73
@ FL_VALUE_TYPE_FLOAT
Definition fl_value.h:67

References fl_value_get_length(), fl_value_get_list_value(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_LIST, and value.

Referenced by create_regular(), and modify_regular().

◆ method_call_cb()

static void method_call_cb ( FlMethodChannel *  channel,
FlMethodCall *  method_call,
gpointer  user_data 
)
static

Definition at line 216 of file fl_windowing_channel.cc.

218 {
219 FlWindowingChannel* self = FL_WINDOWING_CHANNEL(user_data);
220
221 const gchar* method = fl_method_call_get_name(method_call);
223 g_autoptr(FlMethodResponse) response = nullptr;
224
225 if (strcmp(method, kCreateRegularMethod) == 0) {
226 response = create_regular(self, args);
227 } else if (strcmp(method, kModifyRegularMethod) == 0) {
228 response = modify_regular(self, args);
229 } else if (strcmp(method, kDestroyWindowMethod) == 0) {
230 response = destroy_window(self, args);
231 } else {
232 response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
233 }
234
235 if (response != nullptr) {
236 g_autoptr(GError) error = nullptr;
237 if (!fl_method_call_respond(method_call, response, &error)) {
238 g_warning("Failed to send method call response: %s", error->message);
239 }
240 }
241}
G_MODULE_EXPORT const gchar * fl_method_call_get_name(FlMethodCall *self)
G_MODULE_EXPORT gboolean fl_method_call_respond(FlMethodCall *self, FlMethodResponse *response, GError **error)
G_MODULE_EXPORT FlValue * fl_method_call_get_args(FlMethodCall *self)
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()
const uint8_t uint32_t uint32_t GError ** error
static FlMethodResponse * destroy_window(FlWindowingChannel *self, FlValue *args)
static FlMethodResponse * modify_regular(FlWindowingChannel *self, FlValue *args)
static constexpr char kCreateRegularMethod[]
static constexpr char kDestroyWindowMethod[]
static FlMethodResponse * create_regular(FlWindowingChannel *self, FlValue *args)
static constexpr char kModifyRegularMethod[]

References args, create_regular(), destroy_window(), error, fl_method_call_get_args(), fl_method_call_get_name(), fl_method_call_respond(), fl_method_not_implemented_response_new(), g_autoptr(), kCreateRegularMethod, kDestroyWindowMethod, kModifyRegularMethod, method_call, modify_regular(), self, and user_data.

Referenced by fl_windowing_channel_new().

◆ modify_regular()

static FlMethodResponse * modify_regular ( FlWindowingChannel *  self,
FlValue args 
)
static

Definition at line 150 of file fl_windowing_channel.cc.

151 {
153 return FL_METHOD_RESPONSE(fl_method_error_response_new(
154 kBadArgumentsError, "Argument map missing or malformed", nullptr));
155 }
156
158 if (view_id_value == nullptr ||
159 fl_value_get_type(view_id_value) != FL_VALUE_TYPE_INT) {
160 return FL_METHOD_RESPONSE(fl_method_error_response_new(
161 kBadArgumentsError, "Missing/invalid viewId argument", nullptr));
162 }
163 int64_t view_id = fl_value_get_int(view_id_value);
164
165 g_autoptr(FlWindowingSize) size = nullptr;
167 if (size_value != nullptr) {
168 if (!is_valid_size_argument(size_value)) {
169 return FL_METHOD_RESPONSE(fl_method_error_response_new(
170 kBadArgumentsError, "Invalid size argument", nullptr));
171 }
172 size = parse_size_value(size_value);
173 }
175 const gchar* title = nullptr;
176 if (title_value != nullptr) {
177 if (fl_value_get_type(title_value) != FL_VALUE_TYPE_STRING) {
178 return FL_METHOD_RESPONSE(fl_method_error_response_new(
179 kBadArgumentsError, "Invalid title argument", nullptr));
180 }
181 title = fl_value_get_string(title_value);
182 }
185 if (state_value != nullptr) {
186 if (!parse_window_state_value(state_value, &state)) {
187 return FL_METHOD_RESPONSE(fl_method_error_response_new(
188 kBadArgumentsError, "Invalid state argument", nullptr));
189 }
190 }
191
192 return self->vtable->modify_regular(view_id, size, title, state,
193 self->user_data);
194}

References args, fl_method_error_response_new(), fl_value_get_int(), fl_value_get_string(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_INT, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_STRING, FL_WINDOW_STATE_UNDEFINED, g_autoptr(), is_valid_size_argument(), kBadArgumentsError, kSizeKey, kStateKey, kTitleKey, kViewIdKey, parse_size_value(), parse_window_state_value(), self, and view_id.

Referenced by method_call_cb().

◆ parse_size_value()

static FlWindowingSize * parse_size_value ( FlValue value)
static

Definition at line 50 of file fl_windowing_channel.cc.

50 {
54 return size;
55}
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition fl_value.cc:675

References fl_value_get_float(), fl_value_get_list_value(), and value.

Referenced by create_regular(), and modify_regular().

◆ parse_window_state_value()

static gboolean parse_window_state_value ( FlValue value,
FlWindowState state 
)
static

Definition at line 57 of file fl_windowing_channel.cc.

57 {
59 return FALSE;
60 }
61
62 const gchar* text = fl_value_get_string(value);
63 if (strcmp(text, "WindowState.restored") == 0) {
65 return TRUE;
66 } else if (strcmp(text, "WindowState.maximized") == 0) {
68 return TRUE;
69 } else if (strcmp(text, "WindowState.minimized") == 0) {
71 return TRUE;
72 }
73
74 return FALSE;
75}
return TRUE
@ FL_WINDOW_STATE_MINIMIZED
@ FL_WINDOW_STATE_MAXIMIZED
@ FL_WINDOW_STATE_RESTORED
std::u16string text

References fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_STRING, FL_WINDOW_STATE_MAXIMIZED, FL_WINDOW_STATE_MINIMIZED, FL_WINDOW_STATE_RESTORED, text, TRUE, and value.

Referenced by create_regular(), and modify_regular().

◆ window_state_to_string()

static const gchar * window_state_to_string ( FlWindowState  state)
static

Definition at line 77 of file fl_windowing_channel.cc.

77 {
78 switch (state) {
80 return nullptr;
82 return "WindowState.restored";
84 return "WindowState.maximized";
86 return "WindowState.minimized";
87 }
88
89 return nullptr;
90}

References FL_WINDOW_STATE_MAXIMIZED, FL_WINDOW_STATE_MINIMIZED, FL_WINDOW_STATE_RESTORED, and FL_WINDOW_STATE_UNDEFINED.

Referenced by fl_windowing_channel_make_create_regular_response().

Variable Documentation

◆ kBadArgumentsError

constexpr char kBadArgumentsError[] = "Bad Arguments"
staticconstexpr

Definition at line 11 of file fl_windowing_channel.cc.

Referenced by create_regular(), destroy_window(), and modify_regular().

◆ kChannelName

constexpr char kChannelName[] = "flutter/windowing"
staticconstexpr

Definition at line 10 of file fl_windowing_channel.cc.

Referenced by fl_windowing_channel_new().

◆ kCreateRegularMethod

constexpr char kCreateRegularMethod[] = "createRegular"
staticconstexpr

Definition at line 13 of file fl_windowing_channel.cc.

Referenced by method_call_cb().

◆ kDestroyWindowMethod

constexpr char kDestroyWindowMethod[] = "destroyWindow"
staticconstexpr

Definition at line 15 of file fl_windowing_channel.cc.

Referenced by method_call_cb().

◆ kMaxSizeKey

constexpr char kMaxSizeKey[] = "maxSize"
staticconstexpr

Definition at line 19 of file fl_windowing_channel.cc.

Referenced by create_regular().

◆ kMinSizeKey

constexpr char kMinSizeKey[] = "minSize"
staticconstexpr

Definition at line 18 of file fl_windowing_channel.cc.

Referenced by create_regular().

◆ kModifyRegularMethod

constexpr char kModifyRegularMethod[] = "modifyRegular"
staticconstexpr

Definition at line 14 of file fl_windowing_channel.cc.

Referenced by method_call_cb().

◆ kSizeKey

constexpr char kSizeKey[] = "size"
staticconstexpr

◆ kStateKey

constexpr char kStateKey[] = "state"
staticconstexpr

◆ kTitleKey

constexpr char kTitleKey[] = "title"
staticconstexpr

Definition at line 20 of file fl_windowing_channel.cc.

Referenced by create_regular(), and modify_regular().

◆ kViewIdKey

constexpr char kViewIdKey[] = "viewId"
staticconstexpr