[gtk+/rendering-cleanup: 87/92] x11: Make fallback cursor code not use pixmaps



commit 2d9cc26171265d903cffa1b2699927f0753157ad
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 27 15:09:49 2010 +0200

    x11: Make fallback cursor code not use pixmaps
    
    The fallback code for when XCursor wasn't available was still using
    GdkPixmap to create the bitmaps.

 gdk/x11/gdkcursor-x11.c  |   37 +++++++++++++++++--------------------
 gdk/x11/gdkprivate-x11.h |    5 +++++
 gdk/x11/gdkwindow-x11.c  |   14 +++++++-------
 3 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c
index 13e0c1c..d4d44ec 100644
--- a/gdk/x11/gdkcursor-x11.c
+++ b/gdk/x11/gdkcursor-x11.c
@@ -805,8 +805,9 @@ gdk_display_get_default_cursor_size (GdkDisplay *display)
 #else
 
 static GdkCursor*
-gdk_cursor_new_from_pixmap (GdkPixmap      *source,
-			    GdkPixmap      *mask,
+gdk_cursor_new_from_pixmap (GdkDisplay     *display,
+                            Pixmap          source_pixmap,
+			    Pixmap          mask_pixmap,
 			    const GdkColor *fg,
 			    const GdkColor *bg,
 			    gint            x,
@@ -814,20 +815,12 @@ gdk_cursor_new_from_pixmap (GdkPixmap      *source,
 {
   GdkCursorPrivate *private;
   GdkCursor *cursor;
-  Pixmap source_pixmap, mask_pixmap;
   Cursor xcursor;
   XColor xfg, xbg;
-  GdkDisplay *display;
 
-  g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
-  g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
   g_return_val_if_fail (fg != NULL, NULL);
   g_return_val_if_fail (bg != NULL, NULL);
 
-  source_pixmap = GDK_PIXMAP_XID (source);
-  mask_pixmap   = GDK_PIXMAP_XID (mask);
-  display = GDK_PIXMAP_DISPLAY (source);
-
   xfg.pixel = fg->pixel;
   xfg.red = fg->red;
   xfg.blue = fg->blue;
@@ -862,7 +855,7 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
 			    gint        y)
 {
   GdkCursor *cursor;
-  GdkPixmap *pixmap, *mask;
+  cairo_surface_t *pixmap, *mask;
   guint width, height, n_channels, rowstride, data_stride, i, j;
   guint8 *data, *mask_data, *pixels;
   GdkColor fg = { 0, 0, 0, 0 };
@@ -913,9 +906,9 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
       
   screen = gdk_display_get_default_screen (display);
 
-  pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen), 
-			   width, height, 1);
-  cr = gdk_cairo_create (pixmap);
+  pixmap = _gdk_x11_window_create_bitmap_surface (gdk_screen_get_root_window (screen), 
+	 		                          width, height);
+  cr = cairo_create (pixmap);
   image = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_A1,
                                                width, height, data_stride);
   cairo_set_source_surface (cr, image, 0, 0);
@@ -924,9 +917,9 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
   cairo_paint (cr);
   cairo_destroy (cr);
  
-  mask = gdk_pixmap_new (gdk_screen_get_root_window (screen), 
-			 width, height, 1);
-  cr = gdk_cairo_create (mask);
+  mask = _gdk_x11_window_create_bitmap_surface (gdk_screen_get_root_window (screen), 
+			                        width, height);
+  cr = cairo_create (mask);
   image = cairo_image_surface_create_for_data (mask_data, CAIRO_FORMAT_A1,
                                                width, height, data_stride);
   cairo_set_source_surface (cr, image, 0, 0);
@@ -935,10 +928,14 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
   cairo_paint (cr);
   cairo_destroy (cr);
  
-  cursor = gdk_cursor_new_from_pixmap (pixmap, mask, &fg, &bg, x, y);
+  cursor = gdk_cursor_new_from_pixmap (display,
+                                       cairo_xlib_surface_get_drawable (pixmap),
+                                       cairo_xlib_surface_get_drawable (mask),
+                                       &fg, &bg,
+                                       x, y);
    
-  g_object_unref (pixmap);
-  g_object_unref (mask);
+  cairo_surface_destroy (pixmap);
+  cairo_surface_destroy (mask);
 
   g_free (data);
   g_free (mask_data);
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 70693b4..95c55ee 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -31,6 +31,8 @@
 #ifndef __GDK_PRIVATE_X11_H__
 #define __GDK_PRIVATE_X11_H__
 
+#include <cairo-xlib.h>
+
 #include <gdk/gdkcursor.h>
 #include <gdk/gdkprivate.h>
 #include <gdk/x11/gdkwindow-x11.h>
@@ -146,6 +148,9 @@ gboolean _gdk_x11_get_xft_setting (GdkScreen   *screen,
 
 GdkGrabStatus _gdk_x11_convert_grab_status (gint status);
 
+cairo_surface_t * _gdk_x11_window_create_bitmap_surface (GdkWindow *window,
+                                                         int        width,
+                                                         int        height);
 
 extern GdkDrawableClass  _gdk_x11_drawable_class;
 extern gboolean	         _gdk_use_xshm;
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 760e483..ad51e8c 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -261,10 +261,10 @@ attach_free_pixmap_handler (cairo_surface_t *surface,
  * pixmap or bitmap in the X11 API.
  * These functions ensure an Xlib surface.
  */
-static cairo_surface_t *
-gdk_x11_window_create_bitmap_surface (GdkWindow *window,
-                                      int        width,
-                                      int        height)
+cairo_surface_t *
+_gdk_x11_window_create_bitmap_surface (GdkWindow *window,
+                                       int        width,
+                                       int        height)
 {
   cairo_surface_t *surface;
   Pixmap pixmap;
@@ -3837,9 +3837,9 @@ gdk_window_update_icon (GdkWindow *window,
 
       if (gdk_pixbuf_get_has_alpha (best_icon))
         {
-          toplevel->icon_mask = gdk_x11_window_create_bitmap_surface (window,
-                                                                      width,
-                                                                      height);
+          toplevel->icon_mask = _gdk_x11_window_create_bitmap_surface (window,
+                                                                       width,
+                                                                       height);
 
           cr = cairo_create (toplevel->icon_mask);
           gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0);



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