[gtk+/rendering-cleanup-next: 33/153] widget: Store the expose event in the cairo_t, not just the window



commit 7be1d8eed577b2c5e9abb827e2b4f3e56e887ee7
Author: Benjamin Otte <otte redhat com>
Date:   Mon Sep 6 11:33:21 2010 +0200

    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 9340c41..687cbe2 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4680,14 +4680,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);
 }
 
 /**
@@ -4711,23 +4718,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)
@@ -4740,7 +4741,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);
@@ -4783,7 +4784,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 67a1301..67bec89 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -885,6 +885,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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]