summaryrefslogtreecommitdiff
path: root/gtk/gtkcontainer.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-04-17 20:55:26 +0200
committerAlexander Larsson <alexl@redhat.com>2013-05-07 16:33:01 +0200
commitd22fd7223c75f4720ddb982c659efb0d8d7543c4 (patch)
tree6c215ea16969c85cbbdcbccda304cd4cdf9d3e74 /gtk/gtkcontainer.c
parentfc645f2865344a5f481ceed1e90deb23f3f02f31 (diff)
downloadgtk+-d22fd7223c75f4720ddb982c659efb0d8d7543c4.tar.gz
Only handle exposes on native window, propagate to children via draw()
We now consider non-native windows non-opaque, which means any invalid area in a subwindow will also be invalid all the way up to the nearest native windows. We take advantage of this by ignoring all expose events on non-native windows (which typically means just the toplevel) and instead propagating down the draw() calls to children directly via gtk_container_propagate_draw. This is nice as it means we always draw widgets the same way, and it will let us do some interesting ways in the future. We also clean up the GtkWidget opacity handling as we can now always rely on the draing happening via cairo. We can't really just draw by walking down the widget hierarchy, as this doesn't get the clipping right (so e.g. widgets doing cairo_paint may draw outside the expected gdkwindow subarea) nor does it let us paint window backgrounds. So, we now do multiple draws for each widget, once for each GdkWindow, although we still do it on the same base cairo_t that we get for the toplevel native window. The difference is only the clipping, the rendering order, and which other widgets we propagate into. We also collect all the windows of a widget so we can expose them inside the same opacity group if needed. NOTE: This change neuters gtk_widget_set_double_buffered for widgets without native windows. Its impossible to disable the double buffering in this model.
Diffstat (limited to 'gtk/gtkcontainer.c')
-rw-r--r--gtk/gtkcontainer.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 2d7ab23d34..dc81530908 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -3366,7 +3366,7 @@ gtk_container_propagate_draw (GtkContainer *container,
{
GdkEventExpose *event;
GtkAllocation allocation;
- GdkWindow *window, *w;
+ GdkWindow *window, *w, *event_window, *child_in_window;
int x, y;
g_return_if_fail (GTK_IS_CONTAINER (container));
@@ -3375,13 +3375,26 @@ gtk_container_propagate_draw (GtkContainer *container,
g_assert (gtk_widget_get_parent (child) == GTK_WIDGET (container));
+ if (!gtk_widget_is_drawable (child))
+ return;
+
+ /* Only propagate to native child window if we're not handling
+ an expose (i.e. in a pure gtk_widget_draw() call */
event = _gtk_cairo_get_event (cr);
- if (event)
- {
- if (gtk_widget_get_has_window (child) ||
- gtk_widget_get_window (child) != event->window)
- return;
- }
+ if (event &&
+ (gtk_widget_get_has_window (child) &&
+ gdk_window_has_native (gtk_widget_get_window (child))))
+ return;
+
+ /* Never propagate to a child window when exposing a window
+ that is not the one the child widget is in. */
+ event_window = _gtk_cairo_get_event_window (cr);
+ if (gtk_widget_get_has_window (child))
+ child_in_window = gdk_window_get_parent (gtk_widget_get_window (child));
+ else
+ child_in_window = gtk_widget_get_window (child);
+ if (event_window != NULL && child_in_window != event_window)
+ return;
cairo_save (cr);
@@ -3423,7 +3436,7 @@ gtk_container_propagate_draw (GtkContainer *container,
cairo_translate (cr, x, y);
- _gtk_widget_draw_internal (child, cr, TRUE);
+ _gtk_widget_draw (child, cr);
cairo_restore (cr);
}