8000 [window_size] Fix getWindowMinSize in Linux (#848) · google/flutter-desktop-embedding@57a2cd8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 57a2cd8

Browse files
[window_size] Fix getWindowMinSize in Linux (#848)
The GTK default is (-1, -1), which looks like Size(-1, -1) to Flutter. GTK uses -1 for requisition size (the size GTK has calculated), so we map that to (0, 0).
1 parent 52de5f2 commit 57a2cd8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

plugins/window_size/linux/window_size_plugin.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,21 @@ static FlMethodResponse* set_window_visible(FlWindowSizePlugin* self,
293293
// Gets the window minimum size.
294294
static FlMethodResponse* get_window_minimum_size(FlWindowSizePlugin* self) {
295295
g_autoptr(FlValue) size = fl_value_new_list();
296-
fl_value_append_take(size,
297-
fl_value_new_float(self->window_geometry.min_width));
298-
fl_value_append_take(size,
299-
fl_value_new_float(self->window_geometry.min_height));
296+
297+
gint min_width = self->window_geometry.min_width;
298+
gint min_height = self->window_geometry.min_height;
299+
300+
// GTK uses -1 for the requisition size (the size GTK has calculated).
301+
// Report this as zero (smallest possible) so this doesn't look like Size(-1, -1).
302+
if (min_width < 0) {
303+
min_width = 0;
304+
}
305+
if (min_height < 0) {
306+
min_height = 0;
307+
}
308+
309+
fl_value_append_take(size, fl_value_new_float(min_width));
310+
fl_value_append_take(size, fl_value_new_float(min_height));
300311

301312
return FL_METHOD_RESPONSE(fl_method_success_response_new(size));
302313
}

0 commit comments

Comments
 (0)
0