1
0
Fork 0

x11: Use the embedded xcursor functions where possible

Makes those functions that are intended to be used in wayland-only
builds to be tested in x11 code paths as well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3607>
This commit is contained in:
Bilal Elmoussaoui 2024-05-14 17:33:46 +02:00 committed by Marge Bot
parent 0a46ca67ec
commit 7f213c2a2f
6 changed files with 35 additions and 35 deletions

View file

@ -100,8 +100,8 @@ create_blank_cursor_images (void)
{
XcursorImages *images;
images = XcursorImagesCreate (1);
images->images[0] = XcursorImageCreate (1, 1);
images = xcursor_images_create (1);
images->images[0] = xcursor_image_create (1, 1);
images->images[0]->xhot = 0;
images->images[0]->yhot = 0;
@ -130,9 +130,9 @@ load_cursor_on_client (MetaCursor cursor, int scale)
for (i = 0; i < G_N_ELEMENTS (cursors); i++)
{
xcursor_images =
XcursorLibraryLoadImages (meta_cursor_get_name (cursors[i]),
meta_prefs_get_cursor_theme (),
meta_prefs_get_cursor_size () * scale);
xcursor_library_load_images (meta_cursor_get_name (cursors[i]),
meta_prefs_get_cursor_theme (),
meta_prefs_get_cursor_size () * scale);
if (xcursor_images)
return xcursor_images;
}
@ -140,8 +140,8 @@ load_cursor_on_client (MetaCursor cursor, int scale)
g_warning_once ("No cursor theme available, please install a cursor theme");
fallback_size = 24 * scale;
xcursor_images = XcursorImagesCreate (1);
xcursor_images->images[0] = XcursorImageCreate (fallback_size, fallback_size);
xcursor_images = xcursor_images_create (1);
xcursor_images->images[0] = xcursor_image_create (fallback_size, fallback_size);
xcursor_images->images[0]->xhot = 0;
xcursor_images->images[0]->yhot = 0;
memset (xcursor_images->images[0]->pixels, 0xc0,
@ -274,7 +274,7 @@ load_cursor_from_theme (MetaCursorSprite *sprite)
if (sprite_xcursor->xcursor_images)
{
meta_cursor_sprite_clear_texture (sprite);
XcursorImagesDestroy (sprite_xcursor->xcursor_images);
xcursor_images_destroy (sprite_xcursor->xcursor_images);
}
sprite_xcursor->current_frame = 0;
@ -330,7 +330,7 @@ meta_cursor_sprite_xcursor_finalize (GObject *object)
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (object);
g_clear_pointer (&sprite_xcursor->xcursor_images,
XcursorImagesDestroy);
xcursor_images_destroy);
G_OBJECT_CLASS (meta_cursor_sprite_xcursor_parent_class)->finalize (object);
}

View file

@ -19,14 +19,10 @@
#pragma once
#include <glib-object.h>
#ifdef HAVE_X11_CLIENT
#include <X11/Xcursor/Xcursor.h>
#else
#include "third_party/xcursor/xcursor.h"
#endif
#include "backends/meta-cursor.h"
#include "meta/types.h"
#include "third_party/xcursor/xcursor.h"
#define META_TYPE_CURSOR_SPRITE_XCURSOR meta_cursor_sprite_xcursor_get_type ()
G_DECLARE_FINAL_TYPE (MetaCursorSpriteXcursor, meta_cursor_sprite_xcursor,

View file

@ -24,9 +24,8 @@
#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
#include <X11/Xcursor/Xcursor.h>
#include "backends/x11/meta-backend-x11.h"
#include "third_party/xcursor/xcursor.h"
struct _MetaCursorRendererX11Nested
{
@ -52,7 +51,7 @@ create_empty_cursor (Display *xdisplay)
XcursorPixel *pixels;
Cursor xcursor;
image = XcursorImageCreate (1, 1);
image = xcursor_image_create (1, 1);
if (image == NULL)
return None;

View file

@ -504,8 +504,8 @@ finish:
}
XcursorImage *
XcursorImageCreate (int width,
int height)
xcursor_image_create (int width,
int height)
{
XcursorImage *image;
@ -533,7 +533,7 @@ XcursorImageDestroy (XcursorImage *image)
}
XcursorImages *
XcursorImagesCreate (int size)
xcursor_images_create (int size)
{
XcursorImages *images;
@ -547,7 +547,7 @@ XcursorImagesCreate (int size)
}
void
XcursorImagesDestroy (XcursorImages *images)
xcursor_images_destroy (XcursorImages *images)
{
int n;
@ -781,7 +781,7 @@ _XcursorReadImage (XcursorFile *file,
return NULL;
/* Create the image and initialize it */
image = XcursorImageCreate (head.width, head.height);
image = xcursor_image_create (head.width, head.height);
if (image == NULL)
return NULL;
if (chunkHeader.version < image->version)
@ -826,7 +826,7 @@ XcursorXcFileLoadImages (XcursorFile *file,
_XcursorFileHeaderDestroy (fileHeader);
return NULL;
}
images = XcursorImagesCreate (nsize);
images = xcursor_images_create (nsize);
if (!images)
{
_XcursorFileHeaderDestroy (fileHeader);
@ -846,7 +846,7 @@ XcursorXcFileLoadImages (XcursorFile *file,
_XcursorFileHeaderDestroy (fileHeader);
if (images->nimage != nsize)
{
XcursorImagesDestroy (images);
xcursor_images_destroy (images);
images = NULL;
}
return images;
@ -893,9 +893,9 @@ XcursorFileLoadImages (FILE *file,
}
XcursorImages *
XcursorLibraryLoadImages (const char *file,
const char *theme,
int size)
xcursor_library_load_images (const char *file,
const char *theme,
int size)
{
FILE *f = NULL;
XcursorImages *images = NULL;

View file

@ -26,6 +26,9 @@
*/
#pragma once
#ifdef HAVE_X11_CLIENT
#include <X11/Xcursor/Xcursor.h>
#else
typedef unsigned int XcursorPixel;
typedef struct _XcursorImage {
@ -44,14 +47,16 @@ typedef struct _XcursorImages {
XcursorImage **images; /* array of XcursorImage pointers */
char *name; /* name used to load images */
} XcursorImages;
#endif
void XcursorImagesDestroy (XcursorImages *images);
XcursorImages * XcursorImagesCreate (int size);
void xcursor_images_destroy (XcursorImages *images);
XcursorImages * XcursorLibraryLoadImages (const char *library,
const char *theme,
int size);
XcursorImages * xcursor_images_create (int size);
XcursorImage * XcursorImageCreate (int width,
int height);
XcursorImages * xcursor_library_load_images (const char *library,
const char *theme,
int size);
XcursorImage * xcursor_image_create (int width,
int height);

View file

@ -39,7 +39,6 @@
#include <X11/Xatom.h>
#include <X11/XKBlib.h>
#include <X11/extensions/shape.h>
#include <X11/Xcursor/Xcursor.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xfixes.h>
@ -59,6 +58,7 @@
#include "core/workspace-private.h"
#include "meta/main.h"
#include "mtk/mtk-x11.h"
#include "third_party/xcursor/xcursor.h"
#include "x11/events.h"
#include "x11/group-props.h"
#include "x11/meta-x11-selection-private.h"