]> Pileus Git - ~andy/gtk/commitdiff
Patch from Erik van Pienbroek to implement drawing bg_pixmaps (#348145).
authorRichard Hult <richard@imendio.com>
Mon, 31 Jul 2006 21:05:12 +0000 (21:05 +0000)
committerRichard Hult <rhult@src.gnome.org>
Mon, 31 Jul 2006 21:05:12 +0000 (21:05 +0000)
2006-07-31  Richard Hult  <richard@imendio.com>

* gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable):
* gdk/quartz/gdkwindow-quartz.c:
(gdk_window_impl_quartz_begin_paint_region): Patch from Erik van
Pienbroek to implement drawing bg_pixmaps (#348145).

ChangeLog
ChangeLog.pre-2-10
gdk/quartz/gdkdrawable-quartz.c
gdk/quartz/gdkwindow-quartz.c

index cf4ded3165a6dde8d17ec215aa4554f0f2f519b4..4d0260cb2cae024c7781d2e3de63b53be563c792 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-31  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable):
+       * gdk/quartz/gdkwindow-quartz.c:
+       (gdk_window_impl_quartz_begin_paint_region): Patch from Erik van
+       Pienbroek to implement drawing bg_pixmaps (#348145).
+
 2006-07-29  Richard Hult  <richard@imendio.com>
 
        * gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always
index cf4ded3165a6dde8d17ec215aa4554f0f2f519b4..4d0260cb2cae024c7781d2e3de63b53be563c792 100644 (file)
@@ -1,3 +1,10 @@
+2006-07-31  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable):
+       * gdk/quartz/gdkwindow-quartz.c:
+       (gdk_window_impl_quartz_begin_paint_region): Patch from Erik van
+       Pienbroek to implement drawing bg_pixmaps (#348145).
+
 2006-07-29  Richard Hult  <richard@imendio.com>
 
        * gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always
index 11d49734978354133ab4ddf4d8072dcc0b418a7f..f25626255554a4ba9661043f11fa990e8c43df36 100644 (file)
@@ -264,14 +264,14 @@ gdk_quartz_draw_text_wc (GdkDrawable    *drawable,
 
 static void
 gdk_quartz_draw_drawable (GdkDrawable *drawable,
-                        GdkGC       *gc,
-                        GdkPixmap   *src,
-                        gint         xsrc,
-                        gint         ysrc,
-                        gint         xdest,
-                        gint         ydest,
-                        gint         width,
-                        gint         height)
+                         GdkGC       *gc,
+                         GdkPixmap   *src,
+                         gint         xsrc,
+                         gint         ysrc,
+                         gint         xdest,
+                         gint         ydest,
+                         gint         width,
+                         gint         height)
 {
   int src_depth = gdk_drawable_get_depth (src);
   int dest_depth = gdk_drawable_get_depth (drawable);
@@ -307,9 +307,10 @@ gdk_quartz_draw_drawable (GdkDrawable *drawable,
 
       CGContextClipToRect (context, CGRectMake (xdest, ydest, width, height));
       CGContextTranslateCTM (context, xdest - xsrc, ydest - ysrc);
-      CGContextDrawImage (context, CGRectMake(0, 0, 
-                                             GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width, 
-                                             GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height), 
+      CGContextDrawImage (context, 
+                         CGRectMake(0, 0, 
+                                    GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width, 
+                                    GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height), 
                          GDK_PIXMAP_IMPL_QUARTZ (src_impl)->image);
 
       gdk_quartz_drawable_release_context (drawable, context);
index 7fbd0e967c330985c9287ddb966a2084100037e1..4c5e1bed987872fe2022fe71be216fa06feaabfb 100644 (file)
@@ -141,9 +141,12 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
                                           GdkRegion    *region)
 {
   GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
-  CGContextRef context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
-  int i, n_rects;
+  int n_rects;
   GdkRectangle *rects;
+  GdkPixmap *bg_pixmap;
+  GdkWindow *window;
+  
+  bg_pixmap = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper)->bg_pixmap;
 
   if (impl->begin_paint_count == 0)
     impl->paint_clip_region = gdk_region_copy (region);
@@ -152,18 +155,76 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
 
   impl->begin_paint_count ++;
 
+  if (bg_pixmap == GDK_NO_BG)
+    return;
+       
   gdk_region_get_rectangles (region, &rects, &n_rects);
-  for (i = 0; i < n_rects; i++) 
+  
+  if (bg_pixmap == NULL)
+    {
+      CGContextRef context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
+      gint i;
+    
+      for (i = 0; i < n_rects; i++) 
+        {
+          gdk_quartz_set_context_fill_color_from_pixel 
+           (context, gdk_drawable_get_colormap (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper),
+            GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper)->bg_color.pixel);
+         
+          CGContextFillRect (context, CGRectMake (rects[i].x, rects[i].y, rects[i].width, rects[i].height));
+        }
+      
+      gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), context);
+    }
+  else
     {
-      gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper),
-                                                   GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper)->bg_color.pixel);
+      int x, y;
+      int x_offset, y_offset;
+      int width, height;
+      GdkGC *gc;
+      
+      x_offset = y_offset = 0;
+      
+      window = GDK_WINDOW (GDK_DRAWABLE_IMPL_QUARTZ (impl));
+      while (window && ((GdkWindowObject *) window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
+        {
+          /* If this window should have the same background as the parent,
+           * fetch the parent. (And if the same goes for the parent, fetch
+           * the grandparent, etc.)
+           */
+          x_offset += ((GdkWindowObject *) window)->x;
+          y_offset += ((GdkWindowObject *) window)->y;
+          window = GDK_WINDOW (((GdkWindowObject *) window)->parent);
+        }
+
+      /* Note: There should be a CG API to draw tiled images, we might
+       * want to look into that for this. 
+       */
+      gc = gdk_gc_new (GDK_DRAWABLE (impl));
+      
+      gdk_drawable_get_size (GDK_DRAWABLE (bg_pixmap), &width, &height);
       
-      CGContextFillRect (context, CGRectMake (rects[i].x, rects[i].y, rects[i].width, rects[i].height));
+      x = -x_offset;
+      while (x < (rects[0].x + rects[0].width))
+        {
+          if (x + width >= rects[0].x)
+           {
+              y = -y_offset;
+              while (y < (rects[0].y + rects[0].height))
+                {
+                  if (y + height >= rects[0].y)
+                    gdk_draw_drawable (GDK_DRAWABLE (impl), gc, bg_pixmap, 0, 0, x, y, width, height);
+                 
+                  y += height;
+                }
+            }
+          x += width;
+        }
       
+      g_object_unref (G_OBJECT (gc));
     }
+  
   g_free (rects);
-
-  gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), context);
 }
 
 static void