forked from AuroraMiddleware/gtk
widget: Clip drawing to the widget's allocation.
I've seen (and written) quite some widgets (and theme engines) that use cairo_paint() to draw the background. So avoiding overdraw makes sense. Also move all that setup into a _gtk_widget_draw_internal() function that will be used by all functions that can be used by other functions that draw widgets.
This commit is contained in:
parent
0c285bad75
commit
0acec382c8
@ -5119,6 +5119,32 @@ gtk_cairo_should_draw_window (cairo_t *cr,
|
||||
event->window == window;
|
||||
}
|
||||
|
||||
/* code shared by gtk_container_propagate_draw() and
|
||||
* gtk_widget_draw()
|
||||
*/
|
||||
void
|
||||
_gtk_widget_draw_internal (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
if (!gtk_widget_is_drawable (widget))
|
||||
return;
|
||||
|
||||
cairo_rectangle (cr,
|
||||
0, 0,
|
||||
widget->priv->allocation.width,
|
||||
widget->priv->allocation.height);
|
||||
cairo_clip (cr);
|
||||
|
||||
if (gdk_cairo_get_clip_rectangle (cr, NULL))
|
||||
{
|
||||
gboolean result;
|
||||
|
||||
g_signal_emit (widget, widget_signals[DRAW],
|
||||
0, cr,
|
||||
&result);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_widget_real_expose_event (GtkWidget *widget,
|
||||
GdkEventExpose *expose)
|
||||
@ -5166,9 +5192,7 @@ gtk_widget_real_expose_event (GtkWidget *widget,
|
||||
widget->priv->allocation.y);
|
||||
}
|
||||
|
||||
g_signal_emit (widget, widget_signals[DRAW],
|
||||
0, cr,
|
||||
&result);
|
||||
_gtk_widget_draw_internal (widget, cr);
|
||||
|
||||
/* unset here, so if someone keeps a reference to cr we
|
||||
* don't leak the window. */
|
||||
|
@ -947,8 +947,10 @@ GtkRequisition *gtk_requisition_new (void) G_GNUC_MALLOC;
|
||||
GtkRequisition *gtk_requisition_copy (const GtkRequisition *requisition);
|
||||
void gtk_requisition_free (GtkRequisition *requisition);
|
||||
|
||||
GdkEventExpose * _gtk_cairo_get_event (cairo_t *cr);
|
||||
GdkEventExpose * _gtk_cairo_get_event (cairo_t *cr);
|
||||
|
||||
void _gtk_widget_draw_internal (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
void _gtk_widget_set_has_default (GtkWidget *widget,
|
||||
gboolean has_default);
|
||||
void _gtk_widget_set_has_grab (GtkWidget *widget,
|
||||
|
Loading…
Reference in New Issue
Block a user