aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIlia Bozhinov <ammen99@gmail.com>2021-01-05 20:18:38 +0100
committerSimon Ser <contact@emersion.fr>2021-01-05 20:32:56 +0100
commit37602e153b1a8c020dbefe2a499851ac0edd2df8 (patch)
treeb29bb548e48c04d2a32871073dae4111eb6a986e /include
parent42d033e738d8ef213f13e1de849899d563f92a5b (diff)
types: add wlr_xdg_foreign_registry
Diffstat (limited to 'include')
-rw-r--r--include/meson.build5
-rw-r--r--include/wlr/config.h.in2
-rw-r--r--include/wlr/types/wlr_xdg_foreign_registry.h75
3 files changed, 82 insertions, 0 deletions
diff --git a/include/meson.build b/include/meson.build
index e2428e8d..dbd81a05 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -7,6 +7,11 @@ endif
if conf_data.get('WLR_HAS_XWAYLAND', 0) != 1
exclude_files += 'xwayland.h'
endif
+if conf_data.get('WLR_HAS_XDG_FOREIGN', 0) != 1
+ exclude_files += [
+ 'types/wlr_xdg_foreign_registry.h',
+ ]
+endif
install_subdir('wlr',
install_dir: get_option('includedir'),
diff --git a/include/wlr/config.h.in b/include/wlr/config.h.in
index c139a4d6..3cec1f1a 100644
--- a/include/wlr/config.h.in
+++ b/include/wlr/config.h.in
@@ -13,4 +13,6 @@
#mesondefine WLR_HAS_XCB_ERRORS
#mesondefine WLR_HAS_XCB_ICCCM
+#mesondefine WLR_HAS_XDG_FOREIGN
+
#endif
diff --git a/include/wlr/types/wlr_xdg_foreign_registry.h b/include/wlr/types/wlr_xdg_foreign_registry.h
new file mode 100644
index 00000000..462a9a86
--- /dev/null
+++ b/include/wlr/types/wlr_xdg_foreign_registry.h
@@ -0,0 +1,75 @@
+/*
+ * This an unstable interface of wlroots. No guarantees are made regarding the
+ * future consistency of this API.
+ */
+#ifndef WLR_USE_UNSTABLE
+#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
+#endif
+
+#ifndef WLR_TYPES_WLR_XDG_FOREIGN_REGISTRY_H
+#define WLR_TYPES_WLR_XDG_FOREIGN_REGISTRY_H
+
+#include <wayland-server-core.h>
+
+#define WLR_XDG_FOREIGN_HANDLE_SIZE 37
+
+/**
+ * wlr_xdg_foreign_registry is used for storing a list of exported surfaces with
+ * the xdg-foreign family of protocols.
+ *
+ * It can be used to allow interoperability between clients using different
+ * versions of the protocol (if all versions use the same registry).
+ */
+struct wlr_xdg_foreign_registry {
+ struct wl_list exported_surfaces; // struct wlr_xdg_foreign_exported_surface
+
+ struct wl_listener display_destroy;
+ struct {
+ struct wl_signal destroy;
+ } events;
+};
+
+struct wlr_xdg_foreign_exported {
+ struct wl_list link; // wlr_xdg_foreign_registry::exported_surfaces
+ struct wlr_xdg_foreign_registry *registry;
+
+ struct wlr_surface *surface;
+
+ char handle[WLR_XDG_FOREIGN_HANDLE_SIZE];
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+};
+
+/**
+ * Create an empty wlr_xdg_foreign_registry.
+ *
+ * It will be destroyed when the associated display is destroyed.
+ */
+struct wlr_xdg_foreign_registry *wlr_xdg_foreign_registry_create(
+ struct wl_display *display);
+
+/**
+ * Add the given exported surface to the registry and assign it a unique handle.
+ * The caller is responsible for removing the exported surface from the repository
+ * if it is destroyed.
+ *
+ * Returns true if the initialization was successful.
+ */
+bool wlr_xdg_foreign_exported_init(struct wlr_xdg_foreign_exported *surface,
+ struct wlr_xdg_foreign_registry *registry);
+
+/**
+ * Find an exported surface with the given handle, or NULL if such a surface
+ * does not exist.
+ */
+struct wlr_xdg_foreign_exported *wlr_xdg_foreign_registry_find_by_handle(
+ struct wlr_xdg_foreign_registry *registry, const char *handle);
+
+/**
+ * Remove the given surface from the registry it was previously added in.
+ */
+void wlr_xdg_foreign_exported_finish(struct wlr_xdg_foreign_exported *surface);
+
+#endif