From 90379ed68af798d26272da559c07ff6b6202202a Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 6 Sep 2010 11:33:21 +0200 Subject: [PATCH] widget: Store the expose event in the cairo_t, not just the window This way we can grab it for propagating expose events. Not sure if we need to do this once we're all Cairo, but for now we do. --- gtk/gtkwidget.c | 33 +++++++++++++++++---------------- gtk/gtkwidget.h | 2 ++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index fb63f4b51a..8494855e7e 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5070,14 +5070,21 @@ gtk_widget_real_mnemonic_activate (GtkWidget *widget, return TRUE; } -static const cairo_user_data_key_t window_key; +static const cairo_user_data_key_t event_key; -static GdkWindow * -gtk_cairo_get_window (cairo_t *cr) +GdkEventExpose * +_gtk_cairo_get_event (cairo_t *cr) { g_return_val_if_fail (cr != NULL, NULL); - return cairo_get_user_data (cr, &window_key); + return cairo_get_user_data (cr, &event_key); +} + +static void +gtk_cairo_set_event (cairo_t *cr, + GdkEventExpose *event) +{ + cairo_set_user_data (cr, &event_key, event, NULL); } /** @@ -5101,23 +5108,17 @@ gboolean gtk_cairo_should_draw_window (cairo_t *cr, GdkWindow *window) { - GdkWindow *cairo_window; + GdkEventExpose *event; g_return_val_if_fail (cr != NULL, FALSE); g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - cairo_window = gtk_cairo_get_window (cr); + event = _gtk_cairo_get_event (cr); - return cairo_window == NULL || - cairo_window == window; + return event == NULL || + event->window == window; } -static void -gtk_cairo_set_window (cairo_t *cr, - GdkWindow *window) -{ - cairo_set_user_data (cr, &window_key, window, NULL); -} static gboolean gtk_widget_real_expose_event (GtkWidget *widget, GdkEventExpose *expose) @@ -5130,7 +5131,7 @@ gtk_widget_real_expose_event (GtkWidget *widget, return FALSE; cr = gdk_cairo_create (expose->window); - gtk_cairo_set_window (cr, expose->window); + gtk_cairo_set_event (cr, expose); gdk_cairo_region (cr, expose->region); cairo_clip (cr); @@ -5171,7 +5172,7 @@ gtk_widget_real_expose_event (GtkWidget *widget, /* unset here, so if someone keeps a reference to cr we * don't leak the window. */ - gtk_cairo_set_window (cr, NULL); + gtk_cairo_set_event (cr, NULL); cairo_destroy (cr); return result; diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index eba7ba3924..3c58cd7fd2 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -947,6 +947,8 @@ 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); + void _gtk_widget_set_has_default (GtkWidget *widget, gboolean has_default); void _gtk_widget_set_has_grab (GtkWidget *widget,