gtkwidget: Widgets are now always double-buffered

gtk_widget_set_double_buffered is now deprecated, and we don't support
non-double-buffered widgets. This means that under normal circumstances,
paints are never outside of a begin_paint / end_paint sequence, which
natively-double-buffered backends like Wayland can't possibly support.
This commit is contained in:
Jasper St. Pierre 2014-06-20 11:11:24 -04:00
parent a85f7028d4
commit b875572f2a
3 changed files with 17 additions and 57 deletions

View File

@ -2728,9 +2728,7 @@ gdk_window_begin_paint_rect (GdkWindow *window,
* #GdkEventExpose has already been cleared to the window background, * #GdkEventExpose has already been cleared to the window background,
* is already set as the clip region, and already has a backing store. * is already set as the clip region, and already has a backing store.
* Therefore in most cases, application code need not call * Therefore in most cases, application code need not call
* gdk_window_begin_paint_region(). (You can disable the automatic * gdk_window_begin_paint_region().
* calls around expose events on a widget-by-widget basis by calling
* gtk_widget_set_double_buffered().)
* *
* If you call this function multiple times before calling the * If you call this function multiple times before calling the
* matching gdk_window_end_paint(), the backing stores are pushed onto * matching gdk_window_end_paint(), the backing stores are pushed onto

View File

@ -1647,23 +1647,16 @@ gtk_main_do_event (GdkEvent *event)
break; break;
case GDK_EXPOSE: case GDK_EXPOSE:
if (event->any.window && gtk_widget_get_double_buffered (event_widget)) /* We handle exposes only on native windows, relying on the
{ * draw() handler to propagate down to non-native windows.
/* We handle exposes only on native windows, relying on the * This is ok now that we child windows always are considered
* draw() handler to propagate down to non-native windows. * (semi)transparent.
* This is ok now that we child windows always are considered */
* (semi)transparent. if (event->any.window && gdk_window_has_native (event->expose.window))
*/
if (gdk_window_has_native (event->expose.window))
{
gdk_window_begin_paint_region (event->any.window, event->expose.region);
gtk_widget_send_expose (event_widget, event);
gdk_window_end_paint (event->any.window);
}
}
else
{ {
gdk_window_begin_paint_region (event->any.window, event->expose.region);
gtk_widget_send_expose (event_widget, event); gtk_widget_send_expose (event_widget, event);
gdk_window_end_paint (event->any.window);
} }
break; break;

View File

@ -432,7 +432,6 @@ struct _GtkWidgetPrivate
guint shadowed : 1; guint shadowed : 1;
guint style_update_pending : 1; guint style_update_pending : 1;
guint app_paintable : 1; guint app_paintable : 1;
guint double_buffered : 1;
guint redraw_on_alloc : 1; guint redraw_on_alloc : 1;
guint no_show_all : 1; guint no_show_all : 1;
guint child_visible : 1; guint child_visible : 1;
@ -1369,6 +1368,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
* Whether the widget is double buffered. * Whether the widget is double buffered.
* *
* Since: 2.18 * Since: 2.18
*
* Deprecated: 3.14
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_DOUBLE_BUFFERED, PROP_DOUBLE_BUFFERED,
@ -1376,7 +1377,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
P_("Double Buffered"), P_("Double Buffered"),
P_("Whether the widget is double buffered"), P_("Whether the widget is double buffered"),
TRUE, TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED));
/** /**
* GtkWidget:halign: * GtkWidget:halign:
@ -3811,7 +3812,6 @@ gtk_widget_set_property (GObject *object,
gtk_widget_queue_tooltip_query (widget); gtk_widget_queue_tooltip_query (widget);
break; break;
case PROP_DOUBLE_BUFFERED: case PROP_DOUBLE_BUFFERED:
gtk_widget_set_double_buffered (widget, g_value_get_boolean (value));
break; break;
case PROP_HALIGN: case PROP_HALIGN:
gtk_widget_set_halign (widget, g_value_get_enum (value)); gtk_widget_set_halign (widget, g_value_get_enum (value));
@ -3975,7 +3975,7 @@ gtk_widget_get_property (GObject *object,
g_value_set_object (value, gtk_widget_get_window (widget)); g_value_set_object (value, gtk_widget_get_window (widget));
break; break;
case PROP_DOUBLE_BUFFERED: case PROP_DOUBLE_BUFFERED:
g_value_set_boolean (value, gtk_widget_get_double_buffered (widget)); g_value_set_boolean (value, TRUE);
break; break;
case PROP_HALIGN: case PROP_HALIGN:
g_value_set_enum (value, gtk_widget_get_halign (widget)); g_value_set_enum (value, gtk_widget_get_halign (widget));
@ -4377,7 +4377,6 @@ gtk_widget_init (GtkWidget *widget)
priv->sensitive = TRUE; priv->sensitive = TRUE;
priv->composite_child = composite_child_stack != 0; priv->composite_child = composite_child_stack != 0;
priv->double_buffered = TRUE;
priv->redraw_on_alloc = TRUE; priv->redraw_on_alloc = TRUE;
priv->alloc_needed = TRUE; priv->alloc_needed = TRUE;
@ -6963,11 +6962,8 @@ _gtk_widget_draw_windows (GdkWindow *window,
{ {
gdk_window_get_user_data (window, (gpointer *) &widget); gdk_window_get_user_data (window, (gpointer *) &widget);
/* Only clear bg if double bufferer. This is what we used
to do before, where begin_paint() did the clearing. */
pattern = gdk_window_get_background_pattern (window); pattern = gdk_window_get_background_pattern (window);
if (pattern != NULL && if (pattern != NULL)
widget->priv->double_buffered)
{ {
cairo_save (cr); cairo_save (cr);
cairo_set_source (cr, pattern); cairo_set_source (cr, pattern);
@ -9208,42 +9204,15 @@ gtk_widget_get_app_paintable (GtkWidget *widget)
* @widget: a #GtkWidget * @widget: a #GtkWidget
* @double_buffered: %TRUE to double-buffer a widget * @double_buffered: %TRUE to double-buffer a widget
* *
* Widgets are double buffered by default; you can use this function * Widgets are always double-buffered. This function does nothing.
* to turn off the buffering. Double buffered simply means that
* gdk_window_begin_paint_region() and gdk_window_end_paint() are called
* automatically around expose events sent to the
* widget. gdk_window_begin_paint_region() diverts all drawing to a widget's
* window to an offscreen buffer, and gdk_window_end_paint() draws the
* buffer to the screen. The result is that users see the window
* update in one smooth step, and dont see individual graphics
* primitives being rendered.
* *
* In very simple terms, double buffered widgets dont flicker, * Deprecated: 3.14
* so you would only use this function to turn off double buffering
* if you had special needs and really knew what you were doing.
*
* Note: if you turn off double-buffering, you have to handle
* expose events, since even the clearing to the background color or
* pixmap will not happen automatically (as it is done in
* gdk_window_begin_paint_region()).
*
* Since 3.10 this function only works for widgets with native
* windows.
**/ **/
void void
gtk_widget_set_double_buffered (GtkWidget *widget, gtk_widget_set_double_buffered (GtkWidget *widget,
gboolean double_buffered) gboolean double_buffered)
{ {
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
double_buffered = (double_buffered != FALSE);
if (widget->priv->double_buffered != double_buffered)
{
widget->priv->double_buffered = double_buffered;
g_object_notify (G_OBJECT (widget), "double-buffered");
}
} }
/** /**
@ -9263,7 +9232,7 @@ gtk_widget_get_double_buffered (GtkWidget *widget)
{ {
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
return widget->priv->double_buffered; return TRUE;
} }
/** /**