forked from AuroraMiddleware/gtk
widget: Handle setting clip differently
(1) Get rid of supports_clip flag. All widgets (implicitly) support clip. (2) Don't reset the clip to { 0, 0, 0, 0 } before the "size-allocate" signal. (3) Make gtk_widget_set_allocation() set the clip (to the allocation). This ensures that eveyr widget has a clip set. Note: It overrides previous calls to gtk_widget_set_clip(), while in 3.14 this didn't happen. (4) As the clip is set by gtk_widget_set_allocation() now, don't set it after the "size-allocate" signal anymore. This fixes calls to gtk_widget_queue_draw() from inside the size_allocate vfunc.
This commit is contained in:
parent
f0a40b1a23
commit
d23f3254b7
@ -519,7 +519,6 @@ struct _GtkWidgetPrivate
|
|||||||
guint multidevice : 1;
|
guint multidevice : 1;
|
||||||
guint has_shape_mask : 1;
|
guint has_shape_mask : 1;
|
||||||
guint in_reparent : 1;
|
guint in_reparent : 1;
|
||||||
guint supports_clip : 1;
|
|
||||||
|
|
||||||
/* Queue-resize related flags */
|
/* Queue-resize related flags */
|
||||||
guint alloc_needed : 1;
|
guint alloc_needed : 1;
|
||||||
@ -6090,26 +6089,16 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
|
|||||||
if (!alloc_needed && !size_changed && !position_changed && !baseline_changed)
|
if (!alloc_needed && !size_changed && !position_changed && !baseline_changed)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
memset (&priv->clip, 0, sizeof (priv->clip));
|
|
||||||
priv->supports_clip = FALSE;
|
|
||||||
|
|
||||||
priv->allocated_baseline = baseline;
|
priv->allocated_baseline = baseline;
|
||||||
g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
|
g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
|
||||||
|
|
||||||
/* Size allocation is god... after consulting god, no further requests or allocations are needed */
|
/* Size allocation is god... after consulting god, no further requests or allocations are needed */
|
||||||
priv->alloc_needed = FALSE;
|
priv->alloc_needed = FALSE;
|
||||||
|
|
||||||
if (priv->supports_clip)
|
|
||||||
{
|
|
||||||
size_changed |= (old_clip.width != priv->clip.width ||
|
size_changed |= (old_clip.width != priv->clip.width ||
|
||||||
old_clip.height != priv->clip.height);
|
old_clip.height != priv->clip.height);
|
||||||
position_changed |= (old_clip.x != priv->clip.x ||
|
position_changed |= (old_clip.x != priv->clip.x ||
|
||||||
old_clip.y != priv->clip.y);
|
old_clip.y != priv->clip.y);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
priv->clip = priv->allocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gtk_widget_get_mapped (widget) && priv->redraw_on_alloc)
|
if (gtk_widget_get_mapped (widget) && priv->redraw_on_alloc)
|
||||||
{
|
{
|
||||||
@ -15531,23 +15520,16 @@ gtk_widget_get_clip (GtkWidget *widget,
|
|||||||
* @widget: a #GtkWidget
|
* @widget: a #GtkWidget
|
||||||
* @clip: a pointer to a #GtkAllocation to copy from
|
* @clip: a pointer to a #GtkAllocation to copy from
|
||||||
*
|
*
|
||||||
* Sets the widget’s clip. This must not be used
|
* Sets the widget’s clip. This must not be used directly,
|
||||||
* directly, but from within a widget’s size_allocate method.
|
* but from within a widget’s size_allocate method.
|
||||||
|
* It must be called after gtk_widget_set_allocation() (or after chaning up
|
||||||
|
* to the parent class), because that function resets the clip.
|
||||||
*
|
*
|
||||||
* The clip set should be the area that @widget draws on. If @widget is a
|
* The clip set should be the area that @widget draws on. If @widget is a
|
||||||
* #GtkContainer, the area must contain all children's clips.
|
* #GtkContainer, the area must contain all children's clips.
|
||||||
*
|
*
|
||||||
* If this function is not called by @widget during a ::size-allocate handler,
|
* If this function is not called by @widget during a ::size-allocate handler,
|
||||||
* it is assumed to be equal to the allocation. However, if the function is
|
* the clip will be set to @widget's allocation.
|
||||||
* not called, certain features that might extend a widget's allocation will
|
|
||||||
* not be available:
|
|
||||||
*
|
|
||||||
* * The #GtkWidget::draw signal will be clipped to the widget's allocation
|
|
||||||
* to avoid overdraw.
|
|
||||||
* * Calling gtk_render_background() will not draw outset shadows.
|
|
||||||
*
|
|
||||||
* It is therefore suggested that you always call gtk_widget_set_clip() during
|
|
||||||
* a ::size-allocate handler.
|
|
||||||
*
|
*
|
||||||
* Since: 3.14
|
* Since: 3.14
|
||||||
*/
|
*/
|
||||||
@ -15564,24 +15546,6 @@ gtk_widget_set_clip (GtkWidget *widget,
|
|||||||
priv = widget->priv;
|
priv = widget->priv;
|
||||||
|
|
||||||
priv->clip = *clip;
|
priv->clip = *clip;
|
||||||
priv->supports_clip = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* _gtk_widget_supports_clip:
|
|
||||||
* @widget: The #GtkWidget to check
|
|
||||||
*
|
|
||||||
* Returns %TRUE if the widget called gtk_widget_set_clip() during
|
|
||||||
* size allocation. See that function for details.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if the widget handles a clip separate from its allocation.
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
_gtk_widget_supports_clip (GtkWidget *widget)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
|
|
||||||
|
|
||||||
return widget->priv->supports_clip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -15713,6 +15677,7 @@ gtk_widget_set_allocation (GtkWidget *widget,
|
|||||||
priv = widget->priv;
|
priv = widget->priv;
|
||||||
|
|
||||||
priv->allocation = *allocation;
|
priv->allocation = *allocation;
|
||||||
|
priv->clip = *allocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user