10000 [window_size] Fix incorrect value for unconstrained maximum size. (#847) · google/flutter-desktop-embedding@52de5f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52de5f2

Browse files
[window_size] Fix incorrect value for unconstrained maximum size. (#847)
The previous code used (-1, -1), which means use the requistion size (the size that GTK has determined for the window) and resulted in windows that were unresizable. Fixes #844
1 parent 7812516 commit 52de5f2

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

plugins/window_size/linux/window_size_plugin.cc

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ static FlMethodResponse* set_window_maximum_size(FlWindowSizePlugin* self,
237237
self->window_geometry.max_width = static_cast<gint>(width);
238238
self->window_geometry.max_height = static_cast<gint>(height);
239239

240+
// Flutter uses -1 as unconstrained, GTK doesn't have an unconstrained value.
241+
if (self->window_geometry.max_width < 0) {
242+
self->window_geometry.max_width = G_MAXINT;
243+
}
244+
if (self->window_geometry.max_height < 0) {
245+
self->window_geometry.max_height = G_MAXINT;
246+
}
247+
240248
update_window_geometry(self);
241249

242250
return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
@@ -296,10 +304,20 @@ static FlMethodResponse* get_window_minimum_size(FlWindowSizePlugin* self) {
296304
// Gets the window maximum size.
297305
static FlMethodResponse* get_window_maximum_size(FlWindowSizePlugin* self) {
298306
g_autoptr(FlValue) size = fl_value_new_list();
299-
fl_value_append_take(size,
300-
fl_value_new_float(self->window_geometry.max_width));
301-
fl_value_append_take(size,
302-
fl_value_new_float(self->window_geometry.max_height));
307+
308+
gint max_width = self->window_geometry.max_width;
309+
gint max_height = self->window_geometry.max_height;
310+
311+
// Flutter uses -1 as unconstrained, GTK doesn't have an unconstrained value.
312+
if (max_width == G_MAXINT) {
313+
max_width = -1;
314+
}
315+
if (max_height == G_MAXINT) {
316+
max_height = -1;
317+
}
318+
319+
fl_value_append_take(size, fl_value_new_float(max_width));
320+
fl_value_append_take(size, fl_value_new_float(max_height));
303321

304322
return FL_METHOD_RESPONSE(fl_method_success_response_new(size));
305323
}
@@ -356,8 +374,8 @@ static void fl_window_size_plugin_class_init(FlWindowSizePluginClass* klass) {
356374
static void fl_window_size_plugin_init(FlWindowSizePlugin* self) {
357375
self->window_geometry.min_width = -1;
358376
self->window_geometry.min_height = -1;
359-
self->window_geometry.max_width = -1;
360-
self->window_geometry.max_height = -1;
377+
self->window_geometry.max_width = G_MAXINT;
378+
self->window_geometry.max_height = G_MAXINT;
361379
}
362380

363381
FlWindowSizePlugin* fl_window_size_plugin_new(FlPluginRegistrar* registrar) {

0 commit comments

Comments
 (0)
0