From 6b9efc3b0cc24aaf2dd9254d96e090a4128d8c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Mon, 26 Jun 2023 16:08:08 +0200 Subject: [PATCH] wayland: Make the MetaWaylandCompositor type public Allows mutter implementation to have access to the underlying wl_display. Part-of: --- src/core/meta-context-private.h | 3 -- src/core/meta-context.c | 10 +++++++ src/meta/meson.build | 1 + src/meta/meta-wayland-compositor.h | 46 ++++++++++++++++++++++++++++++ src/wayland/meta-wayland-private.h | 5 +--- src/wayland/meta-wayland.c | 6 ++++ src/wayland/meta-wayland.h | 4 +-- 7 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 src/meta/meta-wayland-compositor.h diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h index cb23e621b..e9852631f 100644 --- a/src/core/meta-context-private.h +++ b/src/core/meta-context-private.h @@ -69,9 +69,6 @@ void meta_context_set_unsafe_mode (MetaContext *context, gboolean enable); #ifdef HAVE_WAYLAND -META_EXPORT_TEST -MetaWaylandCompositor * meta_context_get_wayland_compositor (MetaContext *context); - META_EXPORT_TEST MetaServiceChannel * meta_context_get_service_channel (MetaContext *context); #endif diff --git a/src/core/meta-context.c b/src/core/meta-context.c index a85cb2cc6..6f1a676d5 100644 --- a/src/core/meta-context.c +++ b/src/core/meta-context.c @@ -242,6 +242,16 @@ meta_context_get_display (MetaContext *context) } #ifdef HAVE_WAYLAND +/** + * meta_context_get_wayland_compositor: + * @context: The #MetaContext + * + * Get the #MetaWaylandCompositor associated with the MetaContext. The might be + * none currently associated if the context hasn't been started or if the + * requested compositor type is not %META_COMPOSITOR_TYPE_WAYLAND. + * + * Returns: (transfer none) (nullable): the #MetaWaylandCompositor + */ MetaWaylandCompositor * meta_context_get_wayland_compositor (MetaContext *context) { diff --git a/src/meta/meson.build b/src/meta/meson.build index 94b385310..dece2feb3 100644 --- a/src/meta/meson.build +++ b/src/meta/meson.build @@ -49,6 +49,7 @@ mutter_public_headers = [ if have_wayland mutter_public_headers += [ 'meta-wayland-client.h', + 'meta-wayland-compositor.h', ] endif diff --git a/src/meta/meta-wayland-compositor.h b/src/meta/meta-wayland-compositor.h new file mode 100644 index 000000000..c5acf51bf --- /dev/null +++ b/src/meta/meta-wayland-compositor.h @@ -0,0 +1,46 @@ +/* + * Copyright 2023 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_WAYLAND_COMPOSITOR_H +#define META_WAYLAND_COMPOSITOR_H + +#include +#include +#include + +#include "meta/meta-context.h" + +G_BEGIN_DECLS + +#define META_TYPE_WAYLAND_COMPOSITOR (meta_wayland_compositor_get_type ()) +META_EXPORT +G_DECLARE_FINAL_TYPE (MetaWaylandCompositor, + meta_wayland_compositor, + META, WAYLAND_COMPOSITOR, + GObject) + +META_EXPORT +MetaWaylandCompositor *meta_context_get_wayland_compositor (MetaContext *context); + +META_EXPORT +struct wl_display *meta_wayland_compositor_get_wayland_display (MetaWaylandCompositor *compositor); + +G_END_DECLS + +#endif /* META_WAYLAND_COMPOSITOR_H */ diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h index 2a28ccd61..7530a9d81 100644 --- a/src/wayland/meta-wayland-private.h +++ b/src/wayland/meta-wayland-private.h @@ -26,6 +26,7 @@ #include "clutter/clutter.h" #include "core/window-private.h" #include "meta/meta-cursor-tracker.h" +#include "meta/meta-wayland-compositor.h" #include "wayland/meta-wayland-pointer-gestures.h" #include "wayland/meta-wayland-presentation-time-private.h" #include "wayland/meta-wayland-seat.h" @@ -113,10 +114,6 @@ struct _MetaWaylandCompositor GQueue committed_transactions; }; -#define META_TYPE_WAYLAND_COMPOSITOR (meta_wayland_compositor_get_type ()) -G_DECLARE_FINAL_TYPE (MetaWaylandCompositor, meta_wayland_compositor, - META, WAYLAND_COMPOSITOR, GObject) - gboolean meta_wayland_compositor_is_egl_display_bound (MetaWaylandCompositor *compositor); #endif /* META_WAYLAND_PRIVATE_H */ diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index eef7a63d8..f485bdb3a 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -1034,6 +1034,12 @@ meta_wayland_compositor_is_grabbed (MetaWaylandCompositor *compositor) return meta_wayland_seat_is_grabbed (compositor->seat); } +/** + * meta_wayland_compositor_get_wayland_display: + * @compositor: The #MetaWaylandCompositor + * + * Returns: (transfer none): the Wayland display object + */ struct wl_display * meta_wayland_compositor_get_wayland_display (MetaWaylandCompositor *compositor) { diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h index 98bee3f61..2a121e555 100644 --- a/src/wayland/meta-wayland.h +++ b/src/wayland/meta-wayland.h @@ -27,6 +27,7 @@ #include "core/meta-context-private.h" #include "core/util-private.h" #include "meta/types.h" +#include "meta/meta-wayland-compositor.h" #include "wayland/meta-wayland-text-input.h" #include "wayland/meta-wayland-types.h" @@ -103,9 +104,6 @@ MetaXWaylandManager * meta_wayland_compositor_get_xwayland_manager (MetaWaylan META_EXPORT_TEST MetaContext * meta_wayland_compositor_get_context (MetaWaylandCompositor *compositor); -META_EXPORT_TEST -struct wl_display * meta_wayland_compositor_get_wayland_display (MetaWaylandCompositor *compositor); - gboolean meta_wayland_compositor_is_grabbed (MetaWaylandCompositor *compositor); META_EXPORT_TEST