From 2ff74eb667c2cbe293c7309d5661fa438e8431c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 30 Jul 2020 23:06:59 +0200 Subject: gdk/toplevel: Negotiate surface size via a compute-size signal GTK will not up front know how to correctly calculate a size, since it will not be able to reliably predict the constraints that may exist where it will be mapped. Thus, to handle this, calculate the size of the toplevel by having GDK emitting a signal called 'compute-size' that will contain information needed for computing a toplevel window size. This signal may be emitted at any time, e.g. during gdk_toplevel_present(), or spontaneously if constraints change. This also drops the max size from the toplevel layout, while moving the min size from the toplevel layout struct to the struct passed via the signal, This needs changes to a test case where we make sure we process GDK_CONFIGURE etc, which means we also needs to show the window and process all pending events in the test-focus-chain test case. --- tests/rendernode.c | 2 +- tests/showrendernode.c | 4 ++-- tests/testfullscreen.c | 14 ++++---------- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/rendernode.c b/tests/rendernode.c index 49a6c8601c..786cc6d050 100644 --- a/tests/rendernode.c +++ b/tests/rendernode.c @@ -128,7 +128,7 @@ main(int argc, char **argv) GdkSurface *window; GdkTexture *texture = NULL; - window = gdk_surface_new_toplevel (gdk_display_get_default(), 10 , 10); + window = gdk_surface_new_toplevel (gdk_display_get_default()); renderer = gsk_renderer_new_for_surface (window); for (run = 0; run < runs; run++) diff --git a/tests/showrendernode.c b/tests/showrendernode.c index 670e776e1d..25e9960251 100644 --- a/tests/showrendernode.c +++ b/tests/showrendernode.c @@ -181,7 +181,7 @@ main (int argc, char **argv) if (write_to_filename != NULL) { - GdkSurface *surface = gdk_surface_new_toplevel (gdk_display_get_default(), 10 , 10); + GdkSurface *surface = gdk_surface_new_toplevel (gdk_display_get_default()); GskRenderer *renderer = gsk_renderer_new_for_surface (surface); GdkTexture *texture = gsk_renderer_render_texture (renderer, GTK_NODE_VIEW (nodeview)->node, NULL); @@ -201,7 +201,7 @@ main (int argc, char **argv) if (compare_node) { GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); - GdkSurface *gdk_surface = gdk_surface_new_toplevel (gdk_display_get_default(), 10 , 10); + GdkSurface *gdk_surface = gdk_surface_new_toplevel (gdk_display_get_default()); GskRenderer *renderer = gsk_renderer_new_for_surface (gdk_surface); GdkTexture *texture = gsk_renderer_render_texture (renderer, GTK_NODE_VIEW (nodeview)->node, NULL); GtkWidget *image = gtk_image_new_from_paintable (GDK_PAINTABLE (texture)); diff --git a/tests/testfullscreen.c b/tests/testfullscreen.c index c7deda5e92..3adc82310f 100644 --- a/tests/testfullscreen.c +++ b/tests/testfullscreen.c @@ -34,13 +34,10 @@ set_fullscreen_monitor_cb (GtkWidget *widget, gpointer user_data) monitor = gdk_display_get_monitor_at_surface (display, surface); else monitor = NULL; - layout = gdk_toplevel_layout_new (0, 0); + layout = gdk_toplevel_layout_new (); gdk_toplevel_layout_set_resizable (layout, TRUE); gdk_toplevel_layout_set_fullscreen (layout, TRUE, monitor); - gdk_toplevel_present (GDK_TOPLEVEL (surface), - gdk_surface_get_width (surface), - gdk_surface_get_height (surface), - layout); + gdk_toplevel_present (GDK_TOPLEVEL (surface), layout); gdk_toplevel_layout_unref (layout); } @@ -51,13 +48,10 @@ remove_fullscreen_cb (GtkWidget *widget, gpointer user_data) GdkToplevelLayout *layout; surface = gtk_native_get_surface (gtk_widget_get_native (widget)); - layout = gdk_toplevel_layout_new (0, 0); + layout = gdk_toplevel_layout_new (); gdk_toplevel_layout_set_resizable (layout, TRUE); gdk_toplevel_layout_set_fullscreen (layout, FALSE, NULL); - gdk_toplevel_present (GDK_TOPLEVEL (surface), - gdk_surface_get_width (surface), - gdk_surface_get_height (surface), - layout); + gdk_toplevel_present (GDK_TOPLEVEL (surface), layout); gdk_toplevel_layout_unref (layout); } -- cgit v1.2.1