x11: Use subclassing macros for CursorRendererX11

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3520>
This commit is contained in:
Bilal Elmoussaoui 2024-01-08 13:56:24 +01:00 committed by Marge Bot
parent d90a938c17
commit 4f96b43222
2 changed files with 12 additions and 27 deletions

View File

@ -30,20 +30,20 @@
#include "backends/meta-stage-private.h" #include "backends/meta-stage-private.h"
#include "backends/x11/meta-backend-x11.h" #include "backends/x11/meta-backend-x11.h"
struct _MetaCursorRendererX11Private struct _MetaCursorRendererX11
{ {
MetaCursorRenderer parent_instance;
gboolean server_cursor_visible; gboolean server_cursor_visible;
}; };
typedef struct _MetaCursorRendererX11Private MetaCursorRendererX11Private;
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRendererX11, meta_cursor_renderer_x11, META_TYPE_CURSOR_RENDERER); G_DEFINE_FINAL_TYPE (MetaCursorRendererX11, meta_cursor_renderer_x11, META_TYPE_CURSOR_RENDERER);
static gboolean static gboolean
meta_cursor_renderer_x11_update_cursor (MetaCursorRenderer *renderer, meta_cursor_renderer_x11_update_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite) MetaCursorSprite *cursor_sprite)
{ {
MetaCursorRendererX11 *x11 = META_CURSOR_RENDERER_X11 (renderer); MetaCursorRendererX11 *x11 = META_CURSOR_RENDERER_X11 (renderer);
MetaCursorRendererX11Private *priv = meta_cursor_renderer_x11_get_instance_private (x11);
MetaBackend *backend = meta_cursor_renderer_get_backend (renderer); MetaBackend *backend = meta_cursor_renderer_get_backend (renderer);
MetaBackendX11 *backend_x11 = META_BACKEND_X11 (backend); MetaBackendX11 *backend_x11 = META_BACKEND_X11 (backend);
Window xwindow = meta_backend_x11_get_xwindow (backend_x11); Window xwindow = meta_backend_x11_get_xwindow (backend_x11);
@ -78,20 +78,20 @@ meta_cursor_renderer_x11_update_cursor (MetaCursorRenderer *renderer,
} }
} }
if (has_server_cursor != priv->server_cursor_visible) if (has_server_cursor != x11->server_cursor_visible)
{ {
if (has_server_cursor) if (has_server_cursor)
XFixesShowCursor (xdisplay, xwindow); XFixesShowCursor (xdisplay, xwindow);
else else
XFixesHideCursor (xdisplay, xwindow); XFixesHideCursor (xdisplay, xwindow);
priv->server_cursor_visible = has_server_cursor; x11->server_cursor_visible = has_server_cursor;
} }
if (cursor_sprite) if (cursor_sprite)
meta_cursor_sprite_realize_texture (cursor_sprite); meta_cursor_sprite_realize_texture (cursor_sprite);
return !priv->server_cursor_visible; return !x11->server_cursor_visible;
} }
static void static void
@ -105,8 +105,6 @@ meta_cursor_renderer_x11_class_init (MetaCursorRendererX11Class *klass)
static void static void
meta_cursor_renderer_x11_init (MetaCursorRendererX11 *x11) meta_cursor_renderer_x11_init (MetaCursorRendererX11 *x11)
{ {
MetaCursorRendererX11Private *priv = meta_cursor_renderer_x11_get_instance_private (x11);
/* XFixes has no way to retrieve the current cursor visibility. */ /* XFixes has no way to retrieve the current cursor visibility. */
priv->server_cursor_visible = TRUE; x11->server_cursor_visible = TRUE;
} }

View File

@ -25,23 +25,10 @@
#include "backends/meta-cursor-renderer.h" #include "backends/meta-cursor-renderer.h"
#define META_TYPE_CURSOR_RENDERER_X11 (meta_cursor_renderer_x11_get_type ()) #define META_TYPE_CURSOR_RENDERER_X11 (meta_cursor_renderer_x11_get_type ())
#define META_CURSOR_RENDERER_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_CURSOR_RENDERER_X11, MetaCursorRendererX11))
#define META_CURSOR_RENDERER_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_CURSOR_RENDERER_X11, MetaCursorRendererX11Class))
#define META_IS_CURSOR_RENDERER_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_CURSOR_RENDERER_X11))
#define META_IS_CURSOR_RENDERER_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_CURSOR_RENDERER_X11))
#define META_CURSOR_RENDERER_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_CURSOR_RENDERER_X11, MetaCursorRendererX11Class))
typedef struct _MetaCursorRendererX11 MetaCursorRendererX11; typedef struct _MetaCursorRendererX11 MetaCursorRendererX11;
typedef struct _MetaCursorRendererX11Class MetaCursorRendererX11Class;
struct _MetaCursorRendererX11 G_DECLARE_FINAL_TYPE (MetaCursorRendererX11,
{ meta_cursor_renderer_x11,
MetaCursorRenderer parent; META, CURSOR_RENDERER_X11,
}; MetaCursorRenderer)
struct _MetaCursorRendererX11Class
{
MetaCursorRendererClass parent_class;
};
GType meta_cursor_renderer_x11_get_type (void) G_GNUC_CONST;