[gtk/wip/otte/dnd: 9/21] Ensure all natives request at least a 1px wide surface
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/dnd: 9/21] Ensure all natives request at least a 1px wide surface
- Date: Sat, 22 Feb 2020 04:51:18 +0000 (UTC)
commit f656cbdc5b28f7855710598ccfaa4ad621c7eb91
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 22 04:49:52 2020 +0100
Ensure all natives request at least a 1px wide surface
FIXME: Is this necessary?
Could the surfaces just clamp to 1x1 themselves?
We recently declared that surfaces can decide on whatever size they want
so natives need to inspect the size they requested anyway.
gtk/gtkdragicon.c | 6 +++---
gtk/gtkpopover.c | 3 ++-
gtk/gtktooltipwindow.c | 33 ++++++++++-----------------------
gtk/gtkwindow.c | 4 ++--
4 files changed, 17 insertions(+), 29 deletions(-)
---
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,35 +125,24 @@ create_popup_layout (GtkTooltipWindow *window)
}
static void
-relayout_popup (GtkTooltipWindow *window)
+gtk_tooltip_window_relayout (GtkTooltipWindow *window)
{
+ GtkRequisition req;
GdkPopupLayout *layout;
- if (!gtk_widget_get_visible (GTK_WIDGET (window)))
+ if (!gtk_widget_get_visible (GTK_WIDGET (window)) ||
+ window->surface == NULL)
return;
+ gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &req);
layout = create_popup_layout (window);
gdk_surface_present_popup (window->surface,
- gdk_surface_get_width (window->surface),
- gdk_surface_get_height (window->surface),
+ MAX (req.width, 1),
+ MAX (req.height, 1),
layout);
gdk_popup_layout_unref (layout);
}
-static void
-gtk_tooltip_window_move_resize (GtkTooltipWindow *window)
-{
- GtkRequisition req;
-
- if (window->surface)
- {
- gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &req);
- gdk_surface_resize (window->surface, req.width, req.height);
-
- relayout_popup (window);
- }
-}
-
static void
gtk_tooltip_window_native_check_resize (GtkNative *native)
{
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]