-/**
- * gdk_cursor_new_from_pixmap:
- * @source: the pixmap specifying the cursor.
- * @mask: the pixmap specifying the mask, which must be the same size as
- * @source.
- * @fg: the foreground color, used for the bits in the source which are 1.
- * The color does not have to be allocated first.
- * @bg: the background color, used for the bits in the source which are 0.
- * The color does not have to be allocated first.
- * @x: the horizontal offset of the 'hotspot' of the cursor.
- * @y: the vertical offset of the 'hotspot' of the cursor.
- *
- * Creates a new cursor from a given pixmap and mask. Both the pixmap and mask
- * must have a depth of 1 (i.e. each pixel has only 2 values - on or off).
- * The standard cursor size is 16 by 16 pixels. You can create a bitmap
- * from inline data as in the below example.
- *
- * <example><title>Creating a custom cursor</title>
- * <programlisting>
- * /<!-- -->* This data is in X bitmap format, and can be created with the 'bitmap'
- * utility. *<!-- -->/
- * #define cursor1_width 16
- * #define cursor1_height 16
- * static unsigned char cursor1_bits[] = {
- * 0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20,
- * 0x82, 0x41, 0x41, 0x82, 0x41, 0x82, 0x82, 0x41, 0x04, 0x20, 0x08, 0x10,
- * 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01};
- *
- * static unsigned char cursor1mask_bits[] = {
- * 0x80, 0x01, 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x8c, 0x31,
- * 0xc6, 0x63, 0x63, 0xc6, 0x63, 0xc6, 0xc6, 0x63, 0x8c, 0x31, 0x18, 0x18,
- * 0x30, 0x0c, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01};
- *
- *
- * GdkCursor *cursor;
- * GdkPixmap *source, *mask;
- * GdkColor fg = { 0, 65535, 0, 0 }; /<!-- -->* Red. *<!-- -->/
- * GdkColor bg = { 0, 0, 0, 65535 }; /<!-- -->* Blue. *<!-- -->/
- *
- *
- * source = gdk_bitmap_create_from_data (NULL, cursor1_bits,
- * cursor1_width, cursor1_height);
- * mask = gdk_bitmap_create_from_data (NULL, cursor1mask_bits,
- * cursor1_width, cursor1_height);
- * cursor = gdk_cursor_new_from_pixmap (source, mask, &fg, &bg, 8, 8);
- * gdk_pixmap_unref (source);
- * gdk_pixmap_unref (mask);
- *
- *
- * gdk_window_set_cursor (widget->window, cursor);
- * </programlisting>
- * </example>
- *
- * Return value: a new #GdkCursor.
- **/
-GdkCursor*
-gdk_cursor_new_from_pixmap (GdkPixmap *source,
- GdkPixmap *mask,
- const GdkColor *fg,
- const GdkColor *bg,
- gint x,
- gint y)
-{
- GdkCursorPrivate *private;
- GdkCursor *cursor;
- Pixmap source_pixmap, mask_pixmap;
- Cursor xcursor;
- XColor xfg, xbg;
+/* Returns the cursor if there is a match, NULL if not
+ * For named cursors type shall be GDK_CURSOR_IS_PIXMAP
+ * For unnamed, typed cursors, name shall be NULL
+ */
+static GdkX11Cursor*
+find_in_cache (GdkDisplay *display,
+ GdkCursorType type,
+ const char *name)
+{
+ GSList* res;
+ struct cursor_cache_key key;
+
+ key.display = display;
+ key.type = type;
+ key.name = name;
+
+ res = g_slist_find_custom (cursor_cache, &key, cache_compare_func);
+
+ if (res)
+ return (GdkX11Cursor *) res->data;
+
+ return NULL;
+}
+
+/* Called by gdk_x11_display_finalize to flush any cached cursors
+ * for a dead display.
+ */
+void
+_gdk_x11_cursor_display_finalize (GdkDisplay *display)
+{
+ GSList* item;
+ GSList** itemp; /* Pointer to the thing to fix when we delete an item */
+ item = cursor_cache;
+ itemp = &cursor_cache;
+ while (item)
+ {
+ GdkX11Cursor* cursor = (GdkX11Cursor*)(item->data);
+ if (gdk_cursor_get_display (GDK_CURSOR (cursor)) == display)
+ {
+ GSList* olditem;
+ g_object_unref ((GdkCursor*) cursor);
+ /* Remove this item from the list */
+ *(itemp) = item->next;
+ olditem = item;
+ item = g_slist_next (item);
+ g_slist_free_1 (olditem);
+ }
+ else
+ {
+ itemp = &(item->next);
+ item = g_slist_next (item);
+ }
+ }
+}
+
+/*** GdkX11Cursor ***/
+
+G_DEFINE_TYPE (GdkX11Cursor, gdk_x11_cursor, GDK_TYPE_CURSOR)
+
+static GdkPixbuf* gdk_x11_cursor_get_image (GdkCursor *cursor);
+
+static void
+gdk_x11_cursor_finalize (GObject *object)
+{
+ GdkX11Cursor *private = GDK_X11_CURSOR (object);