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



commit 809c4c2b68ce57415584f7ca85fbd49ae56d07c3
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 ff30bc8..4f0d66f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5066,14 +5066,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);
 }
 
 /**
@@ -5097,23 +5104,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)
@@ -5126,7 +5127,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);
@@ -5167,7 +5168,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 a0faa7d..41e5ac0 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -924,6 +924,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]