wayland: Avoid negative size constraints
authorOlivier Fourdan <ofourdan@redhat.com>
Tue, 27 Sep 2016 14:48:57 +0000 (16:48 +0200)
committerSjoerd Simons <sjoerd@debian.org>
Fri, 30 Sep 2016 12:36:52 +0000 (12:36 +0000)
Setting the shadow width earlier as done with commit 4cb1b96 to address
bug 771561 proved to cause unexpected side effects on size_allocate
signal propagation.

As the window is sized correctly earlier, the size_allocate signal is
not emitted again in gtk_widget_size_allocate_with_baseline() which
prevents clutter-gtk from relocating its child widget correctly.

To avoid this issue, revert commit 4cb1b96 but make sure the values
passed as min and max size is never negative in Wayland as this is a
protocol error.

With this, the min/max size will be wrong for a short amount of time,
during the state transition, until the shadow width is updated from
gdk_window_set_shadow_width().

This approach is much safer and less intrusive than changing the
size_allocate logic in gtk.

This reverts commit 4cb1b9645e84054c059f174240e8e288c4befe05.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=771915

Gbp-Pq: Name wayland-Avoid-negative-size-constraints.patch

gdk/wayland/gdkwindow-wayland.c
gtk/gtkwindow.c

index 59cdf0242d1f105ba0553e7da316aae697bb7ccd..7dbb97951db5f2a45ef92baca479fd07b1f2211d 100644 (file)
@@ -2992,8 +2992,8 @@ gdk_wayland_window_set_geometry_hints (GdkWindow         *window,
 
   if (geom_mask & GDK_HINT_MIN_SIZE)
     {
-      width = geometry->min_width - (impl->margin_left + impl->margin_right);
-      height = geometry->min_height - (impl->margin_top + impl->margin_bottom);
+      width = MAX (0, geometry->min_width - (impl->margin_left + impl->margin_right));
+      height = MAX (0, geometry->min_height - (impl->margin_top + impl->margin_bottom));
     }
   else
     {
@@ -3005,8 +3005,8 @@ gdk_wayland_window_set_geometry_hints (GdkWindow         *window,
 
   if (geom_mask & GDK_HINT_MAX_SIZE)
     {
-      width = geometry->max_width - (impl->margin_left + impl->margin_right);
-      height = geometry->max_height - (impl->margin_top + impl->margin_bottom);
+      width = MAX (0, geometry->max_width - (impl->margin_left + impl->margin_right));
+      height = MAX (0, geometry->max_height - (impl->margin_top + impl->margin_bottom));
     }
   else
     {
index 9808475f73f5be588da8bb665ebddf940f1b342c..fc1e050f77f0d07ec8f718cf9faad92d2fd947a0 100644 (file)
@@ -7528,19 +7528,6 @@ update_window_style_classes (GtkWindow *window)
     gtk_style_context_remove_class (context, "fullscreen");
 }
 
-static void
-update_window_borders (GtkWindow *window)
-{
-  GtkWindowPrivate *priv = window->priv;
-  GtkBorder window_border = { 0 };
-
-  if (priv->client_decorated && priv->use_client_shadow)
-    {
-      get_shadow_width (window, &window_border);
-      update_shadow_width (window, &window_border);
-    }
-}
-
 static void
 popover_size_allocate (GtkWidget        *widget,
                        GtkWindowPopover *popover,
@@ -7811,7 +7798,6 @@ gtk_window_state_event (GtkWidget           *widget,
     {
       update_window_style_classes (window);
       update_window_buttons (window);
-      update_window_borders (window);
       gtk_widget_queue_resize (widget);
     }