clutter/backend/x11: Keep a pointer to the actual backend
As with the native backend, eliminate going via some globals when getting the backend. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
This commit is contained in:
parent
1fbdfa8ca7
commit
6ae9bc9045
@ -620,7 +620,7 @@ meta_backend_x11_post_init (MetaBackend *backend)
|
||||
static ClutterBackend *
|
||||
meta_backend_x11_create_clutter_backend (MetaBackend *backend)
|
||||
{
|
||||
return g_object_new (META_TYPE_CLUTTER_BACKEND_X11, NULL);
|
||||
return CLUTTER_BACKEND (meta_clutter_backend_x11_new (backend));
|
||||
}
|
||||
|
||||
static ClutterSeat *
|
||||
|
@ -47,9 +47,13 @@ struct _MetaX11EventFilter
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaClutterBackendX11, meta_clutter_backend_x11,
|
||||
CLUTTER_TYPE_BACKEND)
|
||||
typedef struct _MetaClutterBackendX11Private
|
||||
{
|
||||
MetaBackend *backend;
|
||||
} MetaClutterBackendX11Private;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (MetaClutterBackendX11, meta_clutter_backend_x11,
|
||||
CLUTTER_TYPE_BACKEND)
|
||||
|
||||
/* atoms; remember to add the code that assigns the atom value to
|
||||
* the member of the MetaClutterBackendX11 structure if you add an
|
||||
@ -336,8 +340,11 @@ static CoglRenderer *
|
||||
meta_clutter_backend_x11_get_renderer (ClutterBackend *clutter_backend,
|
||||
GError **error)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
MetaClutterBackendX11 *clutter_backend_x11 =
|
||||
META_CLUTTER_BACKEND_X11 (clutter_backend);
|
||||
MetaClutterBackendX11Private *priv =
|
||||
meta_clutter_backend_x11_get_instance_private (clutter_backend_x11);
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (priv->backend);
|
||||
|
||||
return meta_renderer_create_cogl_renderer (renderer);
|
||||
}
|
||||
@ -407,7 +414,8 @@ meta_clutter_backend_x11_translate_event (ClutterBackend *clutter_backend,
|
||||
{
|
||||
MetaClutterBackendX11 *clutter_backend_x11 =
|
||||
META_CLUTTER_BACKEND_X11 (clutter_backend);
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaClutterBackendX11Private *priv =
|
||||
meta_clutter_backend_x11_get_instance_private (clutter_backend_x11);
|
||||
MetaStageX11 *stage_x11;
|
||||
ClutterSeat *seat;
|
||||
|
||||
@ -426,7 +434,7 @@ meta_clutter_backend_x11_translate_event (ClutterBackend *clutter_backend,
|
||||
if (meta_stage_x11_translate_event (stage_x11, native, event))
|
||||
return TRUE;
|
||||
|
||||
seat = meta_backend_get_default_seat (backend);
|
||||
seat = meta_backend_get_default_seat (priv->backend);
|
||||
if (meta_seat_x11_translate_event (META_SEAT_X11 (seat), native, event))
|
||||
return TRUE;
|
||||
|
||||
@ -436,9 +444,12 @@ meta_clutter_backend_x11_translate_event (ClutterBackend *clutter_backend,
|
||||
static ClutterSeat *
|
||||
meta_clutter_backend_x11_get_default_seat (ClutterBackend *clutter_backend)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaClutterBackendX11 *clutter_backend_x11 =
|
||||
META_CLUTTER_BACKEND_X11 (clutter_backend);
|
||||
MetaClutterBackendX11Private *priv =
|
||||
meta_clutter_backend_x11_get_instance_private (clutter_backend_x11);
|
||||
|
||||
return meta_backend_get_default_seat (backend);
|
||||
return meta_backend_get_default_seat (priv->backend);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -472,6 +483,19 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
|
||||
clutter_backend_class->is_display_server = meta_clutter_backend_x11_is_display_server;
|
||||
}
|
||||
|
||||
MetaClutterBackendX11 *
|
||||
meta_clutter_backend_x11_new (MetaBackend *backend)
|
||||
{
|
||||
MetaClutterBackendX11 *clutter_backend_x11;
|
||||
MetaClutterBackendX11Private *priv;
|
||||
|
||||
clutter_backend_x11 = g_object_new (META_TYPE_CLUTTER_BACKEND_X11, NULL);
|
||||
priv = meta_clutter_backend_x11_get_instance_private (clutter_backend_x11);
|
||||
priv->backend = backend;
|
||||
|
||||
return clutter_backend_x11;
|
||||
}
|
||||
|
||||
static int
|
||||
error_handler (Display *xdisplay,
|
||||
XErrorEvent *error)
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "backends/meta-backend-types.h"
|
||||
#include "clutter/clutter-mutter.h"
|
||||
|
||||
struct _MetaClutterBackendX11
|
||||
@ -73,6 +74,8 @@ typedef MetaX11FilterReturn (*MetaX11FilterFunc) (XEvent *xev,
|
||||
ClutterEvent *cev,
|
||||
gpointer data);
|
||||
|
||||
MetaClutterBackendX11 * meta_clutter_backend_x11_new (MetaBackend *backend);
|
||||
|
||||
void meta_clutter_x11_trap_x_errors (void);
|
||||
gint meta_clutter_x11_untrap_x_errors (void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user