Compare commits
3 Commits
drop-defin
...
wip/queue-
Author | SHA1 | Date | |
---|---|---|---|
|
14562498ea | ||
|
6141b3f9f2 | ||
|
caadc20ebc |
@@ -1941,34 +1941,6 @@ gtk_container_queue_resize_handler (GtkContainer *container)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_container_queue_resize_internal (GtkContainer *container,
|
||||
gboolean invalidate_only)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
g_return_if_fail (GTK_IS_CONTAINER (container));
|
||||
|
||||
widget = GTK_WIDGET (container);
|
||||
|
||||
do
|
||||
{
|
||||
_gtk_widget_set_alloc_needed (widget, TRUE);
|
||||
_gtk_size_request_cache_clear (_gtk_widget_peek_request_cache (widget));
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
if (GTK_IS_RESIZE_CONTAINER (widget))
|
||||
break;
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
widget = gtk_widget_get_parent (widget);
|
||||
}
|
||||
while (widget);
|
||||
|
||||
if (widget && !invalidate_only)
|
||||
gtk_container_queue_resize_handler (GTK_CONTAINER (widget));
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_container_queue_restyle (GtkContainer *container)
|
||||
{
|
||||
@@ -1999,20 +1971,28 @@ _gtk_container_queue_restyle (GtkContainer *container)
|
||||
void
|
||||
_gtk_container_queue_resize (GtkContainer *container)
|
||||
{
|
||||
_gtk_container_queue_resize_internal (container, FALSE);
|
||||
}
|
||||
GtkWidget *widget;
|
||||
|
||||
/**
|
||||
* _gtk_container_resize_invalidate:
|
||||
* @container: a #GtkContainer
|
||||
*
|
||||
* Invalidates cached sizes like _gtk_container_queue_resize() but doesn't
|
||||
* actually queue the resize container for resize.
|
||||
*/
|
||||
void
|
||||
_gtk_container_resize_invalidate (GtkContainer *container)
|
||||
{
|
||||
_gtk_container_queue_resize_internal (container, TRUE);
|
||||
g_return_if_fail (GTK_IS_CONTAINER (container));
|
||||
|
||||
widget = GTK_WIDGET (container);
|
||||
|
||||
do
|
||||
{
|
||||
_gtk_widget_set_alloc_needed (widget, TRUE);
|
||||
_gtk_size_request_cache_clear (_gtk_widget_peek_request_cache (widget));
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
if (GTK_IS_RESIZE_CONTAINER (widget))
|
||||
break;
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
widget = gtk_widget_get_parent (widget);
|
||||
}
|
||||
while (widget);
|
||||
|
||||
if (widget)
|
||||
gtk_container_queue_resize_handler (GTK_CONTAINER (widget));
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -28,7 +28,6 @@ G_BEGIN_DECLS
|
||||
GList * _gtk_container_get_all_children (GtkContainer *container);
|
||||
void _gtk_container_queue_resize (GtkContainer *container);
|
||||
void _gtk_container_queue_restyle (GtkContainer *container);
|
||||
void _gtk_container_resize_invalidate (GtkContainer *container);
|
||||
void _gtk_container_clear_resize_widgets (GtkContainer *container);
|
||||
gchar* _gtk_container_child_composite_name (GtkContainer *container,
|
||||
GtkWidget *child);
|
||||
|
@@ -23,26 +23,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* GtkQueueResizeFlags:
|
||||
* @GTK_QUEUE_RESIZE_INVALIDATE_ONLY: invalidate all cached sizes
|
||||
* as we would normally do when a widget is queued for resize,
|
||||
* but don’t actually add the toplevel resize container to the
|
||||
* resize queue. Useful if we want to change the size of a widget
|
||||
* see how that would affect the overall layout, then restore
|
||||
* the old size.
|
||||
*
|
||||
* Flags that affect the operation of queueing a widget for resize.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_QUEUE_RESIZE_INVALIDATE_ONLY = 1 << 0
|
||||
} GtkQueueResizeFlags;
|
||||
|
||||
GHashTable * _gtk_size_group_get_widget_peers (GtkWidget *for_widget,
|
||||
GtkOrientation orientation);
|
||||
void _gtk_size_group_queue_resize (GtkWidget *widget,
|
||||
GtkQueueResizeFlags flags);
|
||||
void _gtk_size_group_queue_resize (GtkWidget *widget);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -203,8 +203,7 @@ _gtk_size_group_get_widget_peers (GtkWidget *for_widget,
|
||||
}
|
||||
|
||||
static void
|
||||
real_queue_resize (GtkWidget *widget,
|
||||
GtkQueueResizeFlags flags)
|
||||
real_queue_resize (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *container;
|
||||
|
||||
@@ -218,17 +217,13 @@ real_queue_resize (GtkWidget *widget,
|
||||
|
||||
if (container)
|
||||
{
|
||||
if (flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY)
|
||||
_gtk_container_resize_invalidate (GTK_CONTAINER (container));
|
||||
else
|
||||
_gtk_container_queue_resize (GTK_CONTAINER (container));
|
||||
_gtk_container_queue_resize (GTK_CONTAINER (container));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
queue_resize_on_widget (GtkWidget *widget,
|
||||
gboolean check_siblings,
|
||||
GtkQueueResizeFlags flags)
|
||||
queue_resize_on_widget (GtkWidget *widget,
|
||||
gboolean check_siblings)
|
||||
{
|
||||
GtkWidget *parent = widget;
|
||||
|
||||
@@ -241,7 +236,7 @@ queue_resize_on_widget (GtkWidget *widget,
|
||||
|
||||
if (widget == parent && !check_siblings)
|
||||
{
|
||||
real_queue_resize (widget, flags);
|
||||
real_queue_resize (widget);
|
||||
parent = gtk_widget_get_parent (parent);
|
||||
continue;
|
||||
}
|
||||
@@ -250,7 +245,7 @@ queue_resize_on_widget (GtkWidget *widget,
|
||||
if (!widget_groups)
|
||||
{
|
||||
if (widget == parent)
|
||||
real_queue_resize (widget, flags);
|
||||
real_queue_resize (widget);
|
||||
|
||||
parent = gtk_widget_get_parent (parent);
|
||||
continue;
|
||||
@@ -264,14 +259,14 @@ queue_resize_on_widget (GtkWidget *widget,
|
||||
if (current == parent)
|
||||
{
|
||||
if (widget == parent)
|
||||
real_queue_resize (parent, flags);
|
||||
real_queue_resize (parent);
|
||||
}
|
||||
else if (current == widget)
|
||||
{
|
||||
g_warning ("A container and its child are part of this SizeGroup");
|
||||
}
|
||||
else
|
||||
queue_resize_on_widget (current, FALSE, flags);
|
||||
queue_resize_on_widget (current, FALSE);
|
||||
}
|
||||
|
||||
g_hash_table_destroy (widgets);
|
||||
@@ -284,14 +279,14 @@ queue_resize_on_widget (GtkWidget *widget,
|
||||
if (current == parent)
|
||||
{
|
||||
if (widget == parent)
|
||||
real_queue_resize (parent, flags);
|
||||
real_queue_resize (parent);
|
||||
}
|
||||
else if (current == widget)
|
||||
{
|
||||
g_warning ("A container and its child are part of this SizeGroup");
|
||||
}
|
||||
else
|
||||
queue_resize_on_widget (current, FALSE, flags);
|
||||
queue_resize_on_widget (current, FALSE);
|
||||
}
|
||||
|
||||
g_hash_table_destroy (widgets);
|
||||
@@ -301,12 +296,12 @@ queue_resize_on_widget (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
queue_resize_on_group (GtkSizeGroup *size_group)
|
||||
queue_resize_on_group (GtkSizeGroup *size_group)
|
||||
{
|
||||
GtkSizeGroupPrivate *priv = size_group->priv;
|
||||
|
||||
if (priv->widgets)
|
||||
queue_resize_on_widget (priv->widgets->data, TRUE, 0);
|
||||
queue_resize_on_widget (priv->widgets->data, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -636,10 +631,9 @@ gtk_size_group_get_widgets (GtkSizeGroup *size_group)
|
||||
* Queue a resize on a widget, and on all other widgets grouped with this widget.
|
||||
**/
|
||||
void
|
||||
_gtk_size_group_queue_resize (GtkWidget *widget,
|
||||
GtkQueueResizeFlags flags)
|
||||
_gtk_size_group_queue_resize (GtkWidget *widget)
|
||||
{
|
||||
queue_resize_on_widget (widget, TRUE, flags);
|
||||
queue_resize_on_widget (widget, TRUE);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@@ -925,8 +925,7 @@ static gboolean setup_template_child (GtkWidgetTemplat
|
||||
|
||||
static void gtk_widget_set_usize_internal (GtkWidget *widget,
|
||||
gint width,
|
||||
gint height,
|
||||
GtkQueueResizeFlags flags);
|
||||
gint height);
|
||||
|
||||
static void gtk_widget_add_events_internal (GtkWidget *widget,
|
||||
GdkDevice *device,
|
||||
@@ -3813,10 +3812,10 @@ gtk_widget_set_property (GObject *object,
|
||||
gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
|
||||
break;
|
||||
case PROP_WIDTH_REQUEST:
|
||||
gtk_widget_set_usize_internal (widget, g_value_get_int (value), -2, 0);
|
||||
gtk_widget_set_usize_internal (widget, g_value_get_int (value), -2);
|
||||
break;
|
||||
case PROP_HEIGHT_REQUEST:
|
||||
gtk_widget_set_usize_internal (widget, -2, g_value_get_int (value), 0);
|
||||
gtk_widget_set_usize_internal (widget, -2, g_value_get_int (value));
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
gtk_widget_set_visible (widget, g_value_get_boolean (value));
|
||||
@@ -5748,7 +5747,7 @@ gtk_widget_queue_resize (GtkWidget *widget)
|
||||
if (gtk_widget_get_realized (widget))
|
||||
gtk_widget_queue_draw (widget);
|
||||
|
||||
_gtk_size_group_queue_resize (widget, 0);
|
||||
_gtk_size_group_queue_resize (widget);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5765,7 +5764,7 @@ gtk_widget_queue_resize_no_redraw (GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
_gtk_size_group_queue_resize (widget, 0);
|
||||
_gtk_size_group_queue_resize (widget);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -10957,8 +10956,7 @@ gtk_widget_error_bell (GtkWidget *widget)
|
||||
static void
|
||||
gtk_widget_set_usize_internal (GtkWidget *widget,
|
||||
gint width,
|
||||
gint height,
|
||||
GtkQueueResizeFlags flags)
|
||||
gint height)
|
||||
{
|
||||
GtkWidgetAuxInfo *aux_info;
|
||||
gboolean changed = FALSE;
|
||||
@@ -10969,25 +10967,20 @@ gtk_widget_set_usize_internal (GtkWidget *widget,
|
||||
|
||||
if (width > -2 && aux_info->width != width)
|
||||
{
|
||||
if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
|
||||
g_object_notify (G_OBJECT (widget), "width-request");
|
||||
g_object_notify (G_OBJECT (widget), "width-request");
|
||||
aux_info->width = width;
|
||||
changed = TRUE;
|
||||
}
|
||||
if (height > -2 && aux_info->height != height)
|
||||
{
|
||||
if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
|
||||
g_object_notify (G_OBJECT (widget), "height-request");
|
||||
g_object_notify (G_OBJECT (widget), "height-request");
|
||||
aux_info->height = height;
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
if (gtk_widget_get_visible (widget) && changed)
|
||||
{
|
||||
if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
|
||||
gtk_widget_queue_resize (widget);
|
||||
else
|
||||
_gtk_size_group_queue_resize (widget, GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (widget));
|
||||
@@ -11044,7 +11037,7 @@ gtk_widget_set_size_request (GtkWidget *widget,
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
gtk_widget_set_usize_internal (widget, width, height, 0);
|
||||
gtk_widget_set_usize_internal (widget, width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -11080,52 +11073,6 @@ gtk_widget_get_size_request (GtkWidget *widget,
|
||||
*height = aux_info->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_widget_override_size_request:
|
||||
* @widget: a #GtkWidget
|
||||
* @width: new forced minimum width
|
||||
* @height: new forced minimum height
|
||||
* @old_width: location to store previous forced minimum width
|
||||
* @old_height: location to store previous forced minumum height
|
||||
*
|
||||
* Temporarily establishes a forced minimum size for a widget; this
|
||||
* is used by GtkWindow when calculating the size to add to the
|
||||
* window’s geometry widget. Cached sizes for the widget and its
|
||||
* parents are invalidated, so that subsequent calls to the size
|
||||
* negotiation machinery produce the overriden result, but the
|
||||
* widget is not queued for relayout or redraw. The old size must
|
||||
* be restored with _gtk_widget_restore_size_request() or things
|
||||
* will go screwy.
|
||||
*/
|
||||
void
|
||||
_gtk_widget_override_size_request (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int *old_width,
|
||||
int *old_height)
|
||||
{
|
||||
gtk_widget_get_size_request (widget, old_width, old_height);
|
||||
gtk_widget_set_usize_internal (widget, width, height,
|
||||
GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_widget_restore_size_request:
|
||||
* @widget: a #GtkWidget
|
||||
* @old_width: saved forced minimum size
|
||||
* @old_height: saved forced minimum size
|
||||
*
|
||||
* Undoes the operation of_gtk_widget_override_size_request().
|
||||
*/
|
||||
void
|
||||
_gtk_widget_restore_size_request (GtkWidget *widget,
|
||||
int old_width,
|
||||
int old_height)
|
||||
{
|
||||
gtk_widget_set_usize_internal (widget, old_width, old_height,
|
||||
GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_set_events:
|
||||
* @widget: a #GtkWidget
|
||||
|
@@ -63,14 +63,6 @@ void _gtk_widget_add_attached_window (GtkWidget *widget,
|
||||
void _gtk_widget_remove_attached_window (GtkWidget *widget,
|
||||
GtkWindow *window);
|
||||
|
||||
void _gtk_widget_override_size_request (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int *old_width,
|
||||
int *old_height);
|
||||
void _gtk_widget_restore_size_request (GtkWidget *widget,
|
||||
int old_width,
|
||||
int old_height);
|
||||
void _gtk_widget_get_preferred_size_for_size (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
gint size,
|
||||
|
@@ -335,7 +335,6 @@ struct _GtkWindowGeometryInfo
|
||||
*/
|
||||
GdkGeometry geometry; /* Geometry hints */
|
||||
GdkWindowHints mask;
|
||||
GtkWidget *widget; /* subwidget to which hints apply */
|
||||
/* from last gtk_window_resize () - if > 0, indicates that
|
||||
* we should resize to this size.
|
||||
*/
|
||||
@@ -3868,7 +3867,6 @@ gtk_window_get_geometry_info (GtkWindow *window,
|
||||
info->last.configure_request.y = 0;
|
||||
info->last.configure_request.width = -1;
|
||||
info->last.configure_request.height = -1;
|
||||
info->widget = NULL;
|
||||
info->mask = 0;
|
||||
priv->geometry_info = info;
|
||||
}
|
||||
@@ -3879,7 +3877,9 @@ gtk_window_get_geometry_info (GtkWindow *window,
|
||||
/**
|
||||
* gtk_window_set_geometry_hints:
|
||||
* @window: a #GtkWindow
|
||||
* @geometry_widget: (allow-none): widget the geometry hints will be applied to or %NULL
|
||||
* @geometry_widget: (allow-none): widget the geometry hints used to be applied to
|
||||
* or %NULL. Since 3.18 this argument is ignored and GTK behaves as if %NULL was
|
||||
* set.
|
||||
* @geometry: (allow-none): struct containing geometry information or %NULL
|
||||
* @geom_mask: mask indicating which struct fields should be paid attention to
|
||||
*
|
||||
@@ -3902,17 +3902,6 @@ gtk_window_set_geometry_hints (GtkWindow *window,
|
||||
|
||||
info = gtk_window_get_geometry_info (window, TRUE);
|
||||
|
||||
if (info->widget)
|
||||
g_signal_handlers_disconnect_by_func (info->widget,
|
||||
gtk_widget_destroyed,
|
||||
&info->widget);
|
||||
|
||||
info->widget = geometry_widget;
|
||||
if (info->widget)
|
||||
g_signal_connect (geometry_widget, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&info->widget);
|
||||
|
||||
if (geometry)
|
||||
info->geometry = *geometry;
|
||||
|
||||
@@ -5648,10 +5637,6 @@ gtk_window_finalize (GObject *object)
|
||||
|
||||
if (priv->geometry_info)
|
||||
{
|
||||
if (priv->geometry_info->widget)
|
||||
g_signal_handlers_disconnect_by_func (priv->geometry_info->widget,
|
||||
gtk_widget_destroyed,
|
||||
&priv->geometry_info->widget);
|
||||
g_free (priv->geometry_info);
|
||||
}
|
||||
|
||||
@@ -9523,56 +9508,6 @@ gtk_window_compute_hints (GtkWindow *window,
|
||||
*new_flags = 0;
|
||||
}
|
||||
|
||||
if (geometry_info && geometry_info->widget)
|
||||
{
|
||||
/* If the geometry widget is set, then the hints really apply to that
|
||||
* widget. This is pretty much meaningless unless the window layout
|
||||
* is such that the rest of the window adds fixed size borders to
|
||||
* the geometry widget. Our job is to figure the size of the borders;
|
||||
* We do that by asking how big the toplevel would be if the
|
||||
* geometry widget was *really big*.
|
||||
*
|
||||
* +----------+
|
||||
* |AAAAAAAAA | At small sizes, the minimum sizes of widgets
|
||||
* |GGGGG B| in the border can confuse things
|
||||
* |GGGGG B|
|
||||
* | B|
|
||||
* +----------+
|
||||
*
|
||||
* +-----------+
|
||||
* |AAAAAAAAA | When the geometry widget is large, things are
|
||||
* |GGGGGGGGGGB| clearer.
|
||||
* |GGGGGGGGGGB|
|
||||
* |GGGGGGGGGG |
|
||||
* +-----------+
|
||||
*/
|
||||
#define TEMPORARY_SIZE 10000 /* 10,000 pixels should be bigger than real widget sizes */
|
||||
GtkRequisition req;
|
||||
int current_width, current_height;
|
||||
|
||||
_gtk_widget_override_size_request (geometry_info->widget,
|
||||
TEMPORARY_SIZE, TEMPORARY_SIZE,
|
||||
¤t_width, ¤t_height);
|
||||
gtk_widget_get_preferred_size (widget,
|
||||
&req, NULL);
|
||||
_gtk_widget_restore_size_request (geometry_info->widget,
|
||||
current_width, current_height);
|
||||
|
||||
extra_width = req.width - TEMPORARY_SIZE;
|
||||
extra_height = req.height - TEMPORARY_SIZE;
|
||||
|
||||
if (extra_width < 0 || extra_height < 0)
|
||||
{
|
||||
g_warning("Toplevel size doesn't seem to directly depend on the "
|
||||
"size of the geometry widget from gtk_window_set_geometry_hints(). "
|
||||
"The geometry widget might not be in the window, or it might not "
|
||||
"be packed into the window appropriately");
|
||||
extra_width = MAX(extra_width, 0);
|
||||
extra_height = MAX(extra_height, 0);
|
||||
}
|
||||
#undef TEMPORARY_SIZE
|
||||
}
|
||||
|
||||
/* We don't want to set GDK_HINT_POS in here, we just set it
|
||||
* in gtk_window_move_resize() when we want the position
|
||||
* honored.
|
||||
|
Reference in New Issue
Block a user