summaryrefslogtreecommitdiff
path: root/gtk/gtkwidget.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2014-12-19 19:05:12 +0100
committerBenjamin Otte <otte@redhat.com>2014-12-19 19:20:07 +0100
commitd23f3254b7fcef0fc57739ce5cd548742870b119 (patch)
tree9644632616e62a91f4ef2579a4a07646b19736d7 /gtk/gtkwidget.c
parentf0a40b1a2365e3357803342c29b89d215a1efe79 (diff)
downloadgtk+-d23f3254b7fcef0fc57739ce5cd548742870b119.tar.gz
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.
Diffstat (limited to 'gtk/gtkwidget.c')
-rw-r--r--gtk/gtkwidget.c55
1 files changed, 10 insertions, 45 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4d54206464..6794e9e54f 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;
}
/**