mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 00:30:08 +00:00
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:
parent
8d3319f088
commit
55c4cdab1a
@ -805,8 +805,9 @@ gdk_display_get_default_cursor_size (GdkDisplay *display)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
static GdkCursor*
|
static GdkCursor*
|
||||||
gdk_cursor_new_from_pixmap (GdkPixmap *source,
|
gdk_cursor_new_from_pixmap (GdkDisplay *display,
|
||||||
GdkPixmap *mask,
|
Pixmap source_pixmap,
|
||||||
|
Pixmap mask_pixmap,
|
||||||
const GdkColor *fg,
|
const GdkColor *fg,
|
||||||
const GdkColor *bg,
|
const GdkColor *bg,
|
||||||
gint x,
|
gint x,
|
||||||
@ -814,20 +815,12 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
|
|||||||
{
|
{
|
||||||
GdkCursorPrivate *private;
|
GdkCursorPrivate *private;
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
Pixmap source_pixmap, mask_pixmap;
|
|
||||||
Cursor xcursor;
|
Cursor xcursor;
|
||||||
XColor xfg, xbg;
|
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 (fg != NULL, NULL);
|
||||||
g_return_val_if_fail (bg != 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.pixel = fg->pixel;
|
||||||
xfg.red = fg->red;
|
xfg.red = fg->red;
|
||||||
xfg.blue = fg->blue;
|
xfg.blue = fg->blue;
|
||||||
@ -862,7 +855,7 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
|
|||||||
gint y)
|
gint y)
|
||||||
{
|
{
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
GdkPixmap *pixmap, *mask;
|
cairo_surface_t *pixmap, *mask;
|
||||||
guint width, height, n_channels, rowstride, data_stride, i, j;
|
guint width, height, n_channels, rowstride, data_stride, i, j;
|
||||||
guint8 *data, *mask_data, *pixels;
|
guint8 *data, *mask_data, *pixels;
|
||||||
GdkColor fg = { 0, 0, 0, 0 };
|
GdkColor fg = { 0, 0, 0, 0 };
|
||||||
@ -913,9 +906,9 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
|
|||||||
|
|
||||||
screen = gdk_display_get_default_screen (display);
|
screen = gdk_display_get_default_screen (display);
|
||||||
|
|
||||||
pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
|
pixmap = _gdk_x11_window_create_bitmap_surface (gdk_screen_get_root_window (screen),
|
||||||
width, height, 1);
|
width, height);
|
||||||
cr = gdk_cairo_create (pixmap);
|
cr = cairo_create (pixmap);
|
||||||
image = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_A1,
|
image = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_A1,
|
||||||
width, height, data_stride);
|
width, height, data_stride);
|
||||||
cairo_set_source_surface (cr, image, 0, 0);
|
cairo_set_source_surface (cr, image, 0, 0);
|
||||||
@ -924,9 +917,9 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
|
|||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
mask = gdk_pixmap_new (gdk_screen_get_root_window (screen),
|
mask = _gdk_x11_window_create_bitmap_surface (gdk_screen_get_root_window (screen),
|
||||||
width, height, 1);
|
width, height);
|
||||||
cr = gdk_cairo_create (mask);
|
cr = cairo_create (mask);
|
||||||
image = cairo_image_surface_create_for_data (mask_data, CAIRO_FORMAT_A1,
|
image = cairo_image_surface_create_for_data (mask_data, CAIRO_FORMAT_A1,
|
||||||
width, height, data_stride);
|
width, height, data_stride);
|
||||||
cairo_set_source_surface (cr, image, 0, 0);
|
cairo_set_source_surface (cr, image, 0, 0);
|
||||||
@ -935,10 +928,14 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
|
|||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
cairo_destroy (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);
|
cairo_surface_destroy (pixmap);
|
||||||
g_object_unref (mask);
|
cairo_surface_destroy (mask);
|
||||||
|
|
||||||
g_free (data);
|
g_free (data);
|
||||||
g_free (mask_data);
|
g_free (mask_data);
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#ifndef __GDK_PRIVATE_X11_H__
|
#ifndef __GDK_PRIVATE_X11_H__
|
||||||
#define __GDK_PRIVATE_X11_H__
|
#define __GDK_PRIVATE_X11_H__
|
||||||
|
|
||||||
|
#include <cairo-xlib.h>
|
||||||
|
|
||||||
#include <gdk/gdkcursor.h>
|
#include <gdk/gdkcursor.h>
|
||||||
#include <gdk/gdkprivate.h>
|
#include <gdk/gdkprivate.h>
|
||||||
#include <gdk/x11/gdkwindow-x11.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);
|
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 GdkDrawableClass _gdk_x11_drawable_class;
|
||||||
extern gboolean _gdk_use_xshm;
|
extern gboolean _gdk_use_xshm;
|
||||||
|
@ -261,8 +261,8 @@ attach_free_pixmap_handler (cairo_surface_t *surface,
|
|||||||
* pixmap or bitmap in the X11 API.
|
* pixmap or bitmap in the X11 API.
|
||||||
* These functions ensure an Xlib surface.
|
* These functions ensure an Xlib surface.
|
||||||
*/
|
*/
|
||||||
static cairo_surface_t *
|
cairo_surface_t *
|
||||||
gdk_x11_window_create_bitmap_surface (GdkWindow *window,
|
_gdk_x11_window_create_bitmap_surface (GdkWindow *window,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
@ -3774,7 +3774,7 @@ gdk_window_update_icon (GdkWindow *window,
|
|||||||
|
|
||||||
if (gdk_pixbuf_get_has_alpha (best_icon))
|
if (gdk_pixbuf_get_has_alpha (best_icon))
|
||||||
{
|
{
|
||||||
toplevel->icon_mask = gdk_x11_window_create_bitmap_surface (window,
|
toplevel->icon_mask = _gdk_x11_window_create_bitmap_surface (window,
|
||||||
width,
|
width,
|
||||||
height);
|
height);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user