diff --git a/gtk/gtkdragicon.c b/gtk/gtkdragicon.c index 2e33f1c66c..e0b957bf56 100644 --- a/gtk/gtkdragicon.c +++ b/gtk/gtkdragicon.c @@ -129,7 +129,9 @@ gtk_drag_icon_move_resize (GtkDragIcon *icon) if (icon->surface) { gtk_widget_get_preferred_size (GTK_WIDGET (icon), NULL, &req); - gdk_surface_resize (icon->surface, req.width, req.height); + gdk_surface_resize (icon->surface, + MAX (1, req.width), + MAX (1, req.height)); } } @@ -256,8 +258,6 @@ gtk_drag_icon_size_allocate (GtkWidget *widget, { GtkDragIcon *icon = GTK_DRAG_ICON (widget); - gtk_drag_icon_move_resize (icon); - if (icon->widget) gtk_widget_allocate (icon->widget, width, height, baseline, NULL); } diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 7c202414ee..286388bb2d 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -546,7 +546,8 @@ present_popup (GtkPopover *popover) layout = create_popup_layout (popover); gtk_widget_get_preferred_size (GTK_WIDGET (popover), NULL, &req); if (gdk_surface_present_popup (priv->surface, - req.width, req.height, + MAX (req.width, 1), + MAX (req.height, 1), layout)) update_popover_layout (popover, layout); } diff --git a/gtk/gtktooltipwindow.c b/gtk/gtktooltipwindow.c index 4af7fc613d..bd95379fb0 100644 --- a/gtk/gtktooltipwindow.c +++ b/gtk/gtktooltipwindow.c @@ -125,33 +125,22 @@ create_popup_layout (GtkTooltipWindow *window) } static void -relayout_popup (GtkTooltipWindow *window) -{ - GdkPopupLayout *layout; - - if (!gtk_widget_get_visible (GTK_WIDGET (window))) - return; - - layout = create_popup_layout (window); - gdk_surface_present_popup (window->surface, - gdk_surface_get_width (window->surface), - gdk_surface_get_height (window->surface), - layout); - gdk_popup_layout_unref (layout); -} - -static void -gtk_tooltip_window_move_resize (GtkTooltipWindow *window) +gtk_tooltip_window_relayout (GtkTooltipWindow *window) { GtkRequisition req; + GdkPopupLayout *layout; - if (window->surface) - { - gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &req); - gdk_surface_resize (window->surface, req.width, req.height); + if (!gtk_widget_get_visible (GTK_WIDGET (window)) || + window->surface == NULL) + return; - relayout_popup (window); - } + gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &req); + layout = create_popup_layout (window); + gdk_surface_present_popup (window->surface, + MAX (req.width, 1), + MAX (req.height, 1), + layout); + gdk_popup_layout_unref (layout); } static void @@ -164,7 +153,7 @@ gtk_tooltip_window_native_check_resize (GtkNative *native) gtk_widget_ensure_allocate (widget); else if (gtk_widget_get_visible (widget)) { - gtk_tooltip_window_move_resize (window); + gtk_tooltip_window_relayout (window); if (window->surface) gtk_widget_allocate (GTK_WIDGET (window), gdk_surface_get_width (window->surface), @@ -281,7 +270,7 @@ surface_transform_changed_cb (GtkWidget *widget, { GtkTooltipWindow *window = GTK_TOOLTIP_WINDOW (widget); - relayout_popup (window); + gtk_tooltip_window_relayout (window); return G_SOURCE_CONTINUE; } @@ -361,8 +350,6 @@ gtk_tooltip_window_size_allocate (GtkWidget *widget, GtkTooltipWindow *window = GTK_TOOLTIP_WINDOW (widget); GtkWidget *child; - gtk_tooltip_window_move_resize (window); - child = gtk_bin_get_child (GTK_BIN (window)); if (child) @@ -608,6 +595,6 @@ gtk_tooltip_window_position (GtkTooltipWindow *window, window->dx = dx; window->dy = dy; - relayout_popup (window); + gtk_tooltip_window_relayout (window); } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 7b1c9c2f6d..c62fa14567 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -5484,8 +5484,8 @@ gtk_window_realize (GtkWidget *widget) gtk_widget_get_allocation (widget, &allocation); surface = gdk_surface_new_toplevel (gtk_widget_get_display (widget), - allocation.width, - allocation.height); + MAX (1, allocation.width), + MAX (1, allocation.height)); priv->surface = surface; gdk_surface_set_widget (surface, widget);