[gtk+/client-side-windows: 55/284] Create _gdk_drawable_create_cairo_surface to ugly typechecking



commit 0d540e935b045c41afbca0e87a5b89d56006c8bf
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Dec 15 15:50:41 2008 +0100

    Create _gdk_drawable_create_cairo_surface to ugly typechecking
---
 gdk/gdkdraw.c      |   10 ++++++++++
 gdk/gdkdrawable.h  |    6 +++++-
 gdk/gdkinternals.h |    3 +++
 gdk/gdkpixmap.c    |   15 +++++++++++++++
 gdk/gdkwindow.c    |   25 ++++++++++++++++++-------
 5 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c
index 8e8a3be..73f262a 100644
--- a/gdk/gdkdraw.c
+++ b/gdk/gdkdraw.c
@@ -1804,5 +1804,15 @@ _gdk_drawable_get_source_drawable (GdkDrawable *drawable)
   return drawable;
 }
 
+cairo_surface_t *
+_gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
+				    int width,
+				    int height)
+{
+  return GDK_DRAWABLE_GET_CLASS (drawable)->create_cairo_surface (drawable,
+								  width, height);
+}
+
+
 #define __GDK_DRAW_C__
 #include "gdkaliasdef.c"
diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h
index 10910c0..50904fc 100644
--- a/gdk/gdkdrawable.h
+++ b/gdk/gdkdrawable.h
@@ -204,8 +204,12 @@ struct _GdkDrawableClass
 
   void         (*set_cairo_clip)      (GdkDrawable *drawable,
 				       cairo_t *cr);
+
+  cairo_surface_t * (*create_cairo_surface) (GdkDrawable *drawable,
+					     int width,
+					     int height);
+
   /* Padding for future expansion */
-  void         (*_gdk_reserved6)  (void);
   void         (*_gdk_reserved7)  (void);
   void         (*_gdk_reserved9)  (void);
   void         (*_gdk_reserved10) (void);
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 322825f..65f426b 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -234,6 +234,9 @@ GdkImage *_gdk_drawable_copy_to_image (GdkDrawable  *drawable,
 cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable);
 
 GdkDrawable *_gdk_drawable_get_source_drawable (GdkDrawable *drawable);
+cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
+						      int width,
+						      int height);
 
 /* GC caching */
 GdkGC *_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c
index 3b27eda..f52bc8c 100644
--- a/gdk/gdkpixmap.c
+++ b/gdk/gdkpixmap.c
@@ -145,6 +145,9 @@ static GdkImage* gdk_pixmap_copy_to_image (GdkDrawable *drawable,
 					   gint         height);
 
 static cairo_surface_t *gdk_pixmap_ref_cairo_surface (GdkDrawable *drawable);
+static cairo_surface_t *gdk_pixmap_create_cairo_surface (GdkDrawable *drawable,
+							 int width,
+							 int height);
 
 static GdkVisual*   gdk_pixmap_real_get_visual   (GdkDrawable *drawable);
 static gint         gdk_pixmap_real_get_depth    (GdkDrawable *drawable);
@@ -216,6 +219,7 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
   drawable_class->get_visual = gdk_pixmap_real_get_visual;
   drawable_class->_copy_to_image = gdk_pixmap_copy_to_image;
   drawable_class->ref_cairo_surface = gdk_pixmap_ref_cairo_surface;
+  drawable_class->create_cairo_surface = gdk_pixmap_create_cairo_surface;
 }
 
 static void
@@ -605,6 +609,17 @@ gdk_pixmap_ref_cairo_surface (GdkDrawable *drawable)
   return _gdk_drawable_ref_cairo_surface (((GdkPixmapObject*)drawable)->impl);
 }
 
+static cairo_surface_t *
+gdk_pixmap_create_cairo_surface (GdkDrawable *drawable,
+				 int width,
+				 int height)
+{
+  return _gdk_windowing_create_cairo_surface (GDK_PIXMAP_OBJECT(drawable)->impl,
+					      width, height);
+}
+
+
+
 static GdkBitmap *
 make_solid_mask (GdkScreen *screen, gint width, gint height)
 {
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index dd8cdfc..843116b 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -192,6 +192,9 @@ static GdkImage* gdk_window_copy_to_image (GdkDrawable *drawable,
 					   gint         height);
 
 static cairo_surface_t *gdk_window_ref_cairo_surface (GdkDrawable *drawable);
+static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable,
+							 int width,
+							 int height);
 static void             gdk_window_set_cairo_clip    (GdkDrawable *drawable,
 						      cairo_t *cr);
 
@@ -344,6 +347,7 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
   drawable_class->get_visual = gdk_window_real_get_visual;
   drawable_class->_copy_to_image = gdk_window_copy_to_image;
   drawable_class->ref_cairo_surface = gdk_window_ref_cairo_surface;
+  drawable_class->create_cairo_surface = gdk_window_create_cairo_surface;
   drawable_class->set_cairo_clip = gdk_window_set_cairo_clip;
   drawable_class->get_clip_region = gdk_window_get_clip_region;
   drawable_class->get_visible_region = gdk_window_get_visible_region;
@@ -2010,8 +2014,7 @@ gdk_window_begin_paint_region (GdkWindow       *window,
       width = private->abs_x + private->width;
       height = private->abs_y + private->height;
       
-      paint->surface = _gdk_windowing_create_cairo_surface (((GdkPixmapObject *)paint->pixmap)->impl,
-							    width, height);
+      paint->surface = _gdk_drawable_create_cairo_surface (paint->pixmap, width, height);
 
       /* Mark the region as valid on the implicit paint */
       gdk_region_offset (paint->region, private->abs_x, private->abs_y); 
@@ -3869,6 +3872,16 @@ gdk_window_cairo_surface_destroy (void *data)
 }
 
 static cairo_surface_t *
+gdk_window_create_cairo_surface (GdkDrawable *drawable,
+				 int width,
+				 int height)
+{
+  return _gdk_windowing_create_cairo_surface (GDK_WINDOW_OBJECT(drawable)->impl,
+					      width, height);
+}
+
+
+static cairo_surface_t *
 gdk_window_ref_cairo_surface (GdkDrawable *drawable)
 {
   GdkWindowObject *private = (GdkWindowObject*) drawable;
@@ -3900,8 +3913,7 @@ gdk_window_ref_cairo_surface (GdkDrawable *drawable)
 	  source = _gdk_drawable_get_source_drawable (drawable);
 
 	  /* TODO: Avoid the typecheck crap by adding virtual call */
-	  private->cairo_surface = _gdk_windowing_create_cairo_surface (GDK_IS_PIXMAP (source) ? GDK_PIXMAP_OBJECT(source)->impl : GDK_WINDOW_OBJECT(source)->impl,
-									width, height);
+	  private->cairo_surface = _gdk_drawable_create_cairo_surface (source, width, height);
 	  
 	  if (private->cairo_surface)
 	    {
@@ -5933,7 +5945,7 @@ update_cursor (GdkDisplay *display)
       !is_parent_of (display->pointer_grab.window, (GdkWindow *)cursor_window))
     cursor_window = (GdkWindowObject *)display->pointer_grab.window;
   
-  GDK_WINDOW_IMPL_GET_IFACE (pointer_window->impl)->set_cursor (pointer_window,
+  GDK_WINDOW_IMPL_GET_IFACE (pointer_window->impl)->set_cursor ((GdkWindow *)pointer_window,
 								cursor_window->cursor);
 }
 
@@ -7402,8 +7414,7 @@ proxy_button_event (GdkEvent *source_event)
 	    break;
 	  w = w->parent;
 	}
-      pointer_window = w;
-      
+      pointer_window = (GdkWindow *)w;
       
       if (pointer_window != NULL &&
 	  pointer_window != source_event->any.window)



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