forked from AuroraMiddleware/gtk
gdk: Remove ability to download a cursor
This commit is contained in:
parent
ca3c23662c
commit
81c2bebaca
@ -829,8 +829,6 @@ gdk_cursor_new_from_surface
|
||||
gdk_cursor_new_from_name
|
||||
gdk_cursor_get_display
|
||||
gdk_cursor_get_name
|
||||
gdk_cursor_get_image
|
||||
gdk_cursor_get_surface
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GDK_TYPE_CURSOR_TYPE
|
||||
|
@ -51,25 +51,9 @@ struct _GdkBroadwayCursorClass
|
||||
|
||||
G_DEFINE_TYPE (GdkBroadwayCursor, gdk_broadway_cursor, GDK_TYPE_CURSOR)
|
||||
|
||||
static cairo_surface_t * gdk_broadway_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot);
|
||||
|
||||
static void
|
||||
gdk_broadway_cursor_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (gdk_broadway_cursor_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_cursor_class_init (GdkBroadwayCursorClass *xcursor_class)
|
||||
{
|
||||
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (xcursor_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (xcursor_class);
|
||||
|
||||
object_class->finalize = gdk_broadway_cursor_finalize;
|
||||
|
||||
cursor_class->get_surface = gdk_broadway_cursor_get_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -85,16 +69,6 @@ _gdk_broadway_cursor_display_finalize (GdkDisplay *display)
|
||||
{
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_broadway_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
g_return_val_if_fail (cursor != NULL, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_broadway_cursor_update_theme (GdkCursor *cursor)
|
||||
{
|
||||
|
@ -374,92 +374,3 @@ gdk_cursor_get_name (GdkCursor *cursor)
|
||||
return cursor->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cursor_get_image:
|
||||
* @cursor: a #GdkCursor
|
||||
*
|
||||
* Returns a #GdkPixbuf with the image used to display the cursor.
|
||||
*
|
||||
* Note that depending on the capabilities of the windowing system and
|
||||
* on the cursor, GDK may not be able to obtain the image data. In this
|
||||
* case, %NULL is returned.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): a #GdkPixbuf representing
|
||||
* @cursor, or %NULL
|
||||
*
|
||||
* Since: 2.8
|
||||
*/
|
||||
GdkPixbuf*
|
||||
gdk_cursor_get_image (GdkCursor *cursor)
|
||||
{
|
||||
int w, h;
|
||||
cairo_surface_t *surface;
|
||||
GdkPixbuf *pixbuf;
|
||||
gchar buf[32];
|
||||
double x_hot, y_hot;
|
||||
double x_scale, y_scale;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_CURSOR (cursor), NULL);
|
||||
|
||||
surface = gdk_cursor_get_surface (cursor, &x_hot, &y_hot);
|
||||
if (surface == NULL)
|
||||
return NULL;
|
||||
|
||||
w = cairo_image_surface_get_width (surface);
|
||||
h = cairo_image_surface_get_height (surface);
|
||||
|
||||
x_scale = y_scale = 1;
|
||||
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, w, h);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
if (x_scale != 1)
|
||||
{
|
||||
GdkPixbuf *old;
|
||||
|
||||
old = pixbuf;
|
||||
pixbuf = gdk_pixbuf_scale_simple (old,
|
||||
w / x_scale, h / y_scale,
|
||||
GDK_INTERP_HYPER);
|
||||
g_object_unref (old);
|
||||
}
|
||||
|
||||
|
||||
g_snprintf (buf, 32, "%d", (int)x_hot);
|
||||
gdk_pixbuf_set_option (pixbuf, "x_hot", buf);
|
||||
|
||||
g_snprintf (buf, 32, "%d", (int)y_hot);
|
||||
gdk_pixbuf_set_option (pixbuf, "y_hot", buf);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cursor_get_surface:
|
||||
* @cursor: a #GdkCursor
|
||||
* @x_hot: (optional) (out): Location to store the hotspot x position,
|
||||
* or %NULL
|
||||
* @y_hot: (optional) (out): Location to store the hotspot y position,
|
||||
* or %NULL
|
||||
*
|
||||
* Returns a cairo image surface with the image used to display the cursor.
|
||||
*
|
||||
* Note that depending on the capabilities of the windowing system and
|
||||
* on the cursor, GDK may not be able to obtain the image data. In this
|
||||
* case, %NULL is returned.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): a #cairo_surface_t
|
||||
* representing @cursor, or %NULL
|
||||
*
|
||||
* Since: 3.10
|
||||
*/
|
||||
cairo_surface_t *
|
||||
gdk_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_CURSOR (cursor), NULL);
|
||||
|
||||
return GDK_CURSOR_GET_CLASS (cursor)->get_surface (cursor, x_hot, y_hot);
|
||||
}
|
||||
|
@ -62,12 +62,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay* gdk_cursor_get_display (GdkCursor *cursor);
|
||||
GDK_AVAILABLE_IN_3_94
|
||||
const char *gdk_cursor_get_name (GdkCursor *cursor);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkPixbuf* gdk_cursor_get_image (GdkCursor *cursor);
|
||||
GDK_AVAILABLE_IN_3_10
|
||||
cairo_surface_t *gdk_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -46,10 +46,6 @@ struct _GdkCursor
|
||||
struct _GdkCursorClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
cairo_surface_t * (* get_surface) (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot);
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -142,14 +142,6 @@ _gdk_mir_cursor_get_name (GdkCursor *cursor)
|
||||
return mir_cursor->name;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
gdk_mir_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_cursor_init (GdkMirCursor *cursor)
|
||||
{
|
||||
@ -168,9 +160,7 @@ gdk_mir_cursor_finalize (GObject *object)
|
||||
static void
|
||||
gdk_mir_cursor_class_init (GdkMirCursorClass *klass)
|
||||
{
|
||||
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
cursor_class->get_surface = gdk_mir_cursor_get_surface;
|
||||
object_class->finalize = gdk_mir_cursor_finalize;
|
||||
}
|
||||
|
@ -410,10 +410,6 @@ _gdk_quartz_display_get_cursor_for_name (GdkDisplay *display,
|
||||
|
||||
G_DEFINE_TYPE (GdkQuartzCursor, gdk_quartz_cursor, GDK_TYPE_CURSOR)
|
||||
|
||||
static cairo_surface_t *gdk_quartz_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot);
|
||||
|
||||
static void
|
||||
gdk_quartz_cursor_finalize (GObject *object)
|
||||
{
|
||||
@ -427,12 +423,9 @@ gdk_quartz_cursor_finalize (GObject *object)
|
||||
static void
|
||||
gdk_quartz_cursor_class_init (GdkQuartzCursorClass *quartz_cursor_class)
|
||||
{
|
||||
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (quartz_cursor_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (quartz_cursor_class);
|
||||
|
||||
object_class->finalize = gdk_quartz_cursor_finalize;
|
||||
|
||||
cursor_class->get_surface = gdk_quartz_cursor_get_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -487,12 +480,3 @@ _gdk_quartz_cursor_get_ns_cursor (GdkCursor *cursor)
|
||||
|
||||
return cursor_private->nscursor;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_quartz_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
return NULL;
|
||||
}
|
||||
|
@ -202,14 +202,6 @@ gdk_wayland_cursor_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (_gdk_wayland_cursor_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_wayland_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wl_buffer *
|
||||
_gdk_wayland_cursor_get_buffer (GdkCursor *cursor,
|
||||
guint image_index,
|
||||
@ -319,12 +311,9 @@ _gdk_wayland_cursor_set_scale (GdkCursor *cursor,
|
||||
static void
|
||||
_gdk_wayland_cursor_class_init (GdkWaylandCursorClass *wayland_cursor_class)
|
||||
{
|
||||
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (wayland_cursor_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (wayland_cursor_class);
|
||||
|
||||
object_class->finalize = gdk_wayland_cursor_finalize;
|
||||
|
||||
cursor_class->get_surface = gdk_wayland_cursor_get_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -896,27 +896,6 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_gdk_win32_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
g_return_val_if_fail (cursor != NULL, NULL);
|
||||
|
||||
pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (((GdkWin32Cursor *) cursor)->hcursor, x_hot, y_hot);
|
||||
|
||||
if (pixbuf == NULL)
|
||||
return NULL;
|
||||
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
GdkCursor *
|
||||
_gdk_win32_display_get_cursor_for_surface (GdkDisplay *display,
|
||||
cairo_surface_t *surface,
|
||||
@ -1300,9 +1279,6 @@ static void
|
||||
gdk_win32_cursor_class_init(GdkWin32CursorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass);
|
||||
|
||||
object_class->finalize = _gdk_win32_cursor_finalize;
|
||||
|
||||
cursor_class->get_surface = _gdk_win32_cursor_get_surface;
|
||||
}
|
||||
|
@ -160,10 +160,6 @@ _gdk_x11_cursor_display_finalize (GdkDisplay *display)
|
||||
|
||||
G_DEFINE_TYPE (GdkX11Cursor, gdk_x11_cursor, GDK_TYPE_CURSOR)
|
||||
|
||||
static cairo_surface_t *gdk_x11_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot);
|
||||
|
||||
static void
|
||||
gdk_x11_cursor_finalize (GObject *object)
|
||||
{
|
||||
@ -180,12 +176,9 @@ gdk_x11_cursor_finalize (GObject *object)
|
||||
static void
|
||||
gdk_x11_cursor_class_init (GdkX11CursorClass *xcursor_class)
|
||||
{
|
||||
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (xcursor_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (xcursor_class);
|
||||
|
||||
object_class->finalize = gdk_x11_cursor_finalize;
|
||||
|
||||
cursor_class->get_surface = gdk_x11_cursor_get_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -259,64 +252,6 @@ gdk_x11_cursor_get_xcursor (GdkCursor *cursor)
|
||||
|
||||
#if defined(HAVE_XCURSOR) && defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_x11_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
Display *xdisplay;
|
||||
XcursorImages *images;
|
||||
XcursorImage *image;
|
||||
gint size;
|
||||
cairo_surface_t *surface;
|
||||
gint scale;
|
||||
gchar *theme;
|
||||
const char *name;
|
||||
|
||||
display = gdk_cursor_get_display (cursor);
|
||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||
|
||||
size = XcursorGetDefaultSize (xdisplay);
|
||||
theme = XcursorGetTheme (xdisplay);
|
||||
|
||||
name = gdk_cursor_get_name (cursor);
|
||||
if (name)
|
||||
images = XcursorLibraryLoadImages (name, theme, size);
|
||||
else
|
||||
images = NULL;
|
||||
|
||||
if (!images)
|
||||
return NULL;
|
||||
|
||||
image = images->images[0];
|
||||
|
||||
/* Assume the currently set cursor was defined for the screen
|
||||
scale */
|
||||
scale =
|
||||
gdk_monitor_get_scale_factor (gdk_display_get_primary_monitor (display));
|
||||
|
||||
surface = gdk_window_create_similar_image_surface (NULL,
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
image->width,
|
||||
image->height,
|
||||
scale);
|
||||
|
||||
memcpy (cairo_image_surface_get_data (surface),
|
||||
image->pixels, 4 * image->width * image->height);
|
||||
|
||||
cairo_surface_mark_dirty (surface);
|
||||
|
||||
if (x_hot)
|
||||
*x_hot = (double)image->xhot / scale;
|
||||
if (y_hot)
|
||||
*y_hot = (double)image->yhot / scale;
|
||||
|
||||
XcursorImagesDestroy (images);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_x11_cursor_update_theme (GdkCursor *cursor)
|
||||
{
|
||||
@ -420,14 +355,6 @@ gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||
|
||||
#else
|
||||
|
||||
static cairo_surface_t *
|
||||
gdk_x11_cursor_get_surface (GdkCursor *cursor,
|
||||
gdouble *x_hot,
|
||||
gdouble *y_hot)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_x11_display_set_cursor_theme (GdkDisplay *display,
|
||||
const gchar *theme,
|
||||
|
Loading…
Reference in New Issue
Block a user