barrier: Get rid of private instance struct

The struct is private to begin with, so no need for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2442>
This commit is contained in:
Jonas Ådahl 2022-07-26 21:44:23 +02:00 committed by Marge Bot
parent 3c6c1af0a0
commit 4095c2431c

View File

@ -26,19 +26,15 @@
struct _MetaBarrier struct _MetaBarrier
{ {
GObject parent; GObject parent;
};
typedef struct _MetaBarrierPrivate
{
MetaBackend *backend; MetaBackend *backend;
MetaBorder border; MetaBorder border;
MetaBarrierImpl *impl; MetaBarrierImpl *impl;
} MetaBarrierPrivate; };
static void initable_iface_init (GInitableIface *initable_iface); static void initable_iface_init (GInitableIface *initable_iface);
G_DEFINE_TYPE_WITH_CODE (MetaBarrier, meta_barrier, G_TYPE_OBJECT, G_DEFINE_TYPE_WITH_CODE (MetaBarrier, meta_barrier, G_TYPE_OBJECT,
G_ADD_PRIVATE (MetaBarrier)
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
initable_iface_init)) initable_iface_init))
@ -104,31 +100,30 @@ meta_barrier_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
MetaBarrier *barrier = META_BARRIER (object); MetaBarrier *barrier = META_BARRIER (object);
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier);
switch (prop_id) switch (prop_id)
{ {
case PROP_BACKEND: case PROP_BACKEND:
g_value_set_object (value, priv->backend); g_value_set_object (value, barrier->backend);
break; break;
case PROP_DISPLAY: case PROP_DISPLAY:
g_value_set_object (value, display_from_backend (priv->backend)); g_value_set_object (value, display_from_backend (barrier->backend));
break; break;
case PROP_X1: case PROP_X1:
g_value_set_int (value, priv->border.line.a.x); g_value_set_int (value, barrier->border.line.a.x);
break; break;
case PROP_Y1: case PROP_Y1:
g_value_set_int (value, priv->border.line.a.y); g_value_set_int (value, barrier->border.line.a.y);
break; break;
case PROP_X2: case PROP_X2:
g_value_set_int (value, priv->border.line.b.x); g_value_set_int (value, barrier->border.line.b.x);
break; break;
case PROP_Y2: case PROP_Y2:
g_value_set_int (value, priv->border.line.b.y); g_value_set_int (value, barrier->border.line.b.y);
break; break;
case PROP_DIRECTIONS: case PROP_DIRECTIONS:
g_value_set_flags (value, g_value_set_flags (value,
meta_border_get_allows_directions (&priv->border)); meta_border_get_allows_directions (&barrier->border));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -143,12 +138,11 @@ meta_barrier_set_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
MetaBarrier *barrier = META_BARRIER (object); MetaBarrier *barrier = META_BARRIER (object);
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier);
switch (prop_id) switch (prop_id)
{ {
case PROP_BACKEND: case PROP_BACKEND:
priv->backend = g_value_get_object (value); barrier->backend = g_value_get_object (value);
break; break;
case PROP_DISPLAY: case PROP_DISPLAY:
{ {
@ -156,23 +150,23 @@ meta_barrier_set_property (GObject *object,
display = g_value_get_object (value); display = g_value_get_object (value);
if (display) if (display)
priv->backend = backend_from_display (g_value_get_object (value)); barrier->backend = backend_from_display (g_value_get_object (value));
break; break;
} }
case PROP_X1: case PROP_X1:
priv->border.line.a.x = g_value_get_int (value); barrier->border.line.a.x = g_value_get_int (value);
break; break;
case PROP_Y1: case PROP_Y1:
priv->border.line.a.y = g_value_get_int (value); barrier->border.line.a.y = g_value_get_int (value);
break; break;
case PROP_X2: case PROP_X2:
priv->border.line.b.x = g_value_get_int (value); barrier->border.line.b.x = g_value_get_int (value);
break; break;
case PROP_Y2: case PROP_Y2:
priv->border.line.b.y = g_value_get_int (value); barrier->border.line.b.y = g_value_get_int (value);
break; break;
case PROP_DIRECTIONS: case PROP_DIRECTIONS:
meta_border_set_allows_directions (&priv->border, meta_border_set_allows_directions (&barrier->border,
g_value_get_flags (value)); g_value_get_flags (value));
break; break;
default: default:
@ -185,7 +179,6 @@ static void
meta_barrier_dispose (GObject *object) meta_barrier_dispose (GObject *object)
{ {
MetaBarrier *barrier = META_BARRIER (object); MetaBarrier *barrier = META_BARRIER (object);
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier);
if (meta_barrier_is_active (barrier)) if (meta_barrier_is_active (barrier))
{ {
@ -193,7 +186,7 @@ meta_barrier_dispose (GObject *object)
barrier); barrier);
} }
g_clear_object (&priv->impl); g_clear_object (&barrier->impl);
G_OBJECT_CLASS (meta_barrier_parent_class)->dispose (object); G_OBJECT_CLASS (meta_barrier_parent_class)->dispose (object);
} }
@ -201,8 +194,7 @@ meta_barrier_dispose (GObject *object)
gboolean gboolean
meta_barrier_is_active (MetaBarrier *barrier) meta_barrier_is_active (MetaBarrier *barrier)
{ {
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier); MetaBarrierImpl *impl = barrier->impl;
MetaBarrierImpl *impl = priv->impl;
if (impl) if (impl)
return META_BARRIER_IMPL_GET_CLASS (impl)->is_active (impl); return META_BARRIER_IMPL_GET_CLASS (impl)->is_active (impl);
@ -224,8 +216,7 @@ void
meta_barrier_release (MetaBarrier *barrier, meta_barrier_release (MetaBarrier *barrier,
MetaBarrierEvent *event) MetaBarrierEvent *event)
{ {
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier); MetaBarrierImpl *impl = barrier->impl;
MetaBarrierImpl *impl = priv->impl;
if (impl) if (impl)
META_BARRIER_IMPL_GET_CLASS (impl)->release (impl, event); META_BARRIER_IMPL_GET_CLASS (impl)->release (impl, event);
@ -237,10 +228,8 @@ meta_barrier_initable_init (GInitable *initable,
GError **error) GError **error)
{ {
MetaBarrier *barrier = META_BARRIER (initable); MetaBarrier *barrier = META_BARRIER (initable);
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier);
priv = meta_barrier_get_instance_private (barrier); if (!barrier->impl)
if (!priv->impl)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Failed to create barrier impl"); "Failed to create barrier impl");
@ -259,25 +248,23 @@ initable_iface_init (GInitableIface *initable_iface)
static void static void
init_barrier_impl (MetaBarrier *barrier) init_barrier_impl (MetaBarrier *barrier)
{ {
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier); g_return_if_fail (barrier->backend);
g_return_if_fail (barrier->border.line.a.x == barrier->border.line.b.x ||
g_return_if_fail (priv->backend); barrier->border.line.a.y == barrier->border.line.b.y);
g_return_if_fail (priv->border.line.a.x == priv->border.line.b.x || g_return_if_fail (barrier->border.line.a.x >= 0);
priv->border.line.a.y == priv->border.line.b.y); g_return_if_fail (barrier->border.line.a.y >= 0);
g_return_if_fail (priv->border.line.a.x >= 0); g_return_if_fail (barrier->border.line.b.x >= 0);
g_return_if_fail (priv->border.line.a.y >= 0); g_return_if_fail (barrier->border.line.b.y >= 0);
g_return_if_fail (priv->border.line.b.x >= 0);
g_return_if_fail (priv->border.line.b.y >= 0);
#if defined(HAVE_NATIVE_BACKEND) #if defined(HAVE_NATIVE_BACKEND)
if (META_IS_BACKEND_NATIVE (priv->backend)) if (META_IS_BACKEND_NATIVE (barrier->backend))
priv->impl = meta_barrier_impl_native_new (barrier); barrier->impl = meta_barrier_impl_native_new (barrier);
#endif #endif
if (META_IS_BACKEND_X11 (priv->backend) && if (META_IS_BACKEND_X11 (barrier->backend) &&
!meta_is_wayland_compositor ()) !meta_is_wayland_compositor ())
priv->impl = meta_barrier_impl_x11_new (barrier); barrier->impl = meta_barrier_impl_x11_new (barrier);
g_warn_if_fail (priv->impl); g_warn_if_fail (barrier->impl);
} }
static void static void
@ -410,8 +397,7 @@ meta_barrier_class_init (MetaBarrierClass *klass)
void void
meta_barrier_destroy (MetaBarrier *barrier) meta_barrier_destroy (MetaBarrier *barrier)
{ {
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier); MetaBarrierImpl *impl = barrier->impl;
MetaBarrierImpl *impl = priv->impl;
if (impl) if (impl)
META_BARRIER_IMPL_GET_CLASS (impl)->destroy (impl); META_BARRIER_IMPL_GET_CLASS (impl)->destroy (impl);
@ -461,17 +447,13 @@ meta_barrier_emit_left_signal (MetaBarrier *barrier,
MetaBackend * MetaBackend *
meta_barrier_get_backend (MetaBarrier *barrier) meta_barrier_get_backend (MetaBarrier *barrier)
{ {
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier); return barrier->backend;
return priv->backend;
} }
MetaBorder * MetaBorder *
meta_barrier_get_border (MetaBarrier *barrier) meta_barrier_get_border (MetaBarrier *barrier)
{ {
MetaBarrierPrivate *priv = meta_barrier_get_instance_private (barrier); return &barrier->border;
return &priv->border;
} }
static void static void