7 #include <gdk/gdkwayland.h>
8 #include <wayland-client.h>
22 G_DEFINE_TYPE(FlWaylandDisplay, fl_wayland_display, G_TYPE_OBJECT)
26 struct wl_registry* registry,
28 const
char* interface,
30 FlWaylandDisplay*
self = FL_WAYLAND_DISPLAY(data);
31 if (g_strcmp0(interface, wl_compositor_interface.name) == 0) {
32 self->compositor =
static_cast<struct wl_compositor*
>(wl_registry_bind(
33 registry, name, &wl_compositor_interface, MIN(version, 4)));
34 }
else if (g_strcmp0(interface, wl_subcompositor_interface.name) == 0) {
35 self->subcompositor =
static_cast<struct wl_subcompositor*
>(
36 wl_registry_bind(registry, name, &wl_subcompositor_interface, 1));
41 struct wl_registry* registry,
52 struct wl_display* display) {
53 struct wl_registry* registry = wl_display_get_registry(display);
55 wl_display_roundtrip(display);
56 wl_registry_destroy(registry);
58 return self->compositor !=
nullptr &&
self->subcompositor !=
nullptr;
62 FlWaylandDisplay*
self = FL_WAYLAND_DISPLAY(
object);
64 g_clear_pointer(&self->subcompositor, wl_subcompositor_destroy);
65 g_clear_pointer(&self->compositor, wl_compositor_destroy);
67 G_OBJECT_CLASS(fl_wayland_display_parent_class)->dispose(
object);
77 FlWaylandDisplay*
self =
78 FL_WAYLAND_DISPLAY(g_object_new(fl_wayland_display_get_type(),
nullptr));
81 g_warning(
"Required Wayland globals not available");
90 g_return_val_if_fail(GDK_IS_WAYLAND_DISPLAY(gdk_display),
nullptr);
92 FlWaylandDisplay*
self = FL_WAYLAND_DISPLAY(
94 if (
self !=
nullptr) {
100 if (
self ==
nullptr) {
113 FlWaylandDisplay*
self,
114 struct wl_surface* parent_surface) {
115 g_return_val_if_fail(FL_IS_WAYLAND_DISPLAY(
self),
nullptr);
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
FlSubsurface * fl_subsurface_new(struct wl_compositor *compositor, struct wl_subcompositor *subcompositor, struct wl_surface *parent_surface)
static void registry_global_remove(void *data, struct wl_registry *registry, uint32_t name)
static const char * kWaylandDisplayKey
FlSubsurface * fl_wayland_display_create_subsurface(FlWaylandDisplay *self, struct wl_surface *parent_surface)
static void registry_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
FlWaylandDisplay * fl_wayland_display_get_for_display(GdkDisplay *gdk_display)
static const struct wl_registry_listener kRegistryListener
FlWaylandDisplay * fl_wayland_display_open(struct wl_display *wl_display)
static gboolean bind_globals(FlWaylandDisplay *self, struct wl_display *display)
static void fl_wayland_display_dispose(GObject *object)
static void fl_wayland_display_init(FlWaylandDisplay *self)
static void fl_wayland_display_class_init(FlWaylandDisplayClass *klass)
struct wl_subcompositor * subcompositor
struct wl_compositor * compositor