[gtk+] widget: Handle setting clip differently
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget: Handle setting clip differently
- Date: Fri, 19 Dec 2014 18:51:01 +0000 (UTC)
commit d23f3254b7fcef0fc57739ce5cd548742870b119
Author: Benjamin Otte <otte redhat com>
Date: Fri Dec 19 19:05:12 2014 +0100
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.
gtk/gtkwidget.c | 55 ++++++++++---------------------------------------------
1 files changed, 10 insertions(+), 45 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4d54206..6794e9e 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -519,7 +519,6 @@ struct _GtkWidgetPrivate
guint multidevice : 1;
guint has_shape_mask : 1;
guint in_reparent : 1;
- guint supports_clip : 1;
/* Queue-resize related flags */
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)
goto out;
- memset (&priv->clip, 0, sizeof (priv->clip));
- priv->supports_clip = FALSE;
-
priv->allocated_baseline = baseline;
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 */
priv->alloc_needed = FALSE;
- if (priv->supports_clip)
- {
- size_changed |= (old_clip.width != priv->clip.width ||
- old_clip.height != priv->clip.height);
- position_changed |= (old_clip.x != priv->clip.x ||
- old_clip.y != priv->clip.y);
- }
- else
- {
- priv->clip = priv->allocation;
- }
+ size_changed |= (old_clip.width != priv->clip.width ||
+ old_clip.height != priv->clip.height);
+ position_changed |= (old_clip.x != priv->clip.x ||
+ old_clip.y != priv->clip.y);
if (gtk_widget_get_mapped (widget) && priv->redraw_on_alloc)
{
@@ -15531,23 +15520,16 @@ gtk_widget_get_clip (GtkWidget *widget,
* @widget: a #GtkWidget
* @clip: a pointer to a #GtkAllocation to copy from
*
- * Sets the widget’s clip. This must not be used
- * directly, but from within a widget’s size_allocate method.
+ * Sets the widget’s clip. This must not be used directly,
+ * 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
* #GtkContainer, the area must contain all children's clips.
*
* 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
- * 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.
+ * the clip will be set to @widget's allocation.
*
* Since: 3.14
*/
@@ -15564,24 +15546,6 @@ gtk_widget_set_clip (GtkWidget *widget,
priv = widget->priv;
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
@@ -15713,6 +15677,7 @@ gtk_widget_set_allocation (GtkWidget *widget,
priv = widget->priv;
priv->allocation = *allocation;
+ priv->clip = *allocation;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]