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.
This commit is contained in:
Benjamin Otte 2010-08-27 15:09:49 +02:00
parent 8d3319f088
commit 55c4cdab1a
3 changed files with 29 additions and 27 deletions

View File

@ -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);

View File

@ -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>
@ -148,6 +150,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;

View File

@ -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;
@ -3774,9 +3774,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);