From fdbc99a274e6a806f0b324bf920fd0a4bd3b4a90 Mon Sep 17 00:00:00 2001 From: Peterino2 Date: Fri, 18 Sep 2026 14:24:34 -0700 Subject: [PATCH] Vendor KDE appmenu protocol and runtime D-Bus export declarations --- src/linux/bindings.h | 1 + src/linux/build.zig | 2 +- src/linux/dbus-imports.h | 6 + src/linux/functions.inc | 6 + src/linux/protocols/generated/appmenu.c | 55 +++++ src/linux/protocols/generated/appmenu.h | 203 ++++++++++++++++++ .../protocols/generated/private-symbols.h | 2 + src/linux/protocols/xml/appmenu.xml | 40 ++++ src/linux/vendor/README.md | 2 + src/linux/vendor/manifest.json | 18 +- .../vendor/plasma-wayland-protocols/MIT.txt | 19 ++ 11 files changed, 351 insertions(+), 3 deletions(-) create mode 100644 src/linux/protocols/generated/appmenu.c create mode 100644 src/linux/protocols/generated/appmenu.h create mode 100644 src/linux/protocols/xml/appmenu.xml create mode 100644 src/linux/vendor/plasma-wayland-protocols/MIT.txt diff --git a/src/linux/bindings.h b/src/linux/bindings.h index bb40f17..3910bf4 100644 --- a/src/linux/bindings.h +++ b/src/linux/bindings.h @@ -36,6 +36,7 @@ #include "xdg-activation-v1.h" #include "xdg-foreign-unstable-v2.h" #include "xdg-toplevel-icon-v1.h" +#include "appmenu.h" int z_linux_libraries_open(void); int z_linux_egl_available(void); int z_linux_xkb_available(void); diff --git a/src/linux/build.zig b/src/linux/build.zig index 0cc90f4..abe9270 100644 --- a/src/linux/build.zig +++ b/src/linux/build.zig @@ -12,7 +12,7 @@ pub fn configure(b: *std.Build, module: *std.Build.Module, target: std.Build.Res } module.addImport("linux_c", bindings.createModule()); module.addCSourceFile(.{ .file = b.path("src/linux/libraries.c"), .flags = &.{ "-std=gnu11", "-Wall", "-Wextra", "-Werror", "-fvisibility=hidden" } }); - for ([_][]const u8{ "wayland", "xdg-shell", "xdg-decoration-unstable-v1", "viewporter", "fractional-scale-v1", "cursor-shape-v1", "tablet-v2", "text-input-unstable-v3", "xdg-activation-v1", "xdg-foreign-unstable-v2", "xdg-toplevel-icon-v1" }) |name| { + for ([_][]const u8{ "wayland", "xdg-shell", "xdg-decoration-unstable-v1", "viewporter", "fractional-scale-v1", "cursor-shape-v1", "tablet-v2", "text-input-unstable-v3", "xdg-activation-v1", "xdg-foreign-unstable-v2", "xdg-toplevel-icon-v1", "appmenu" }) |name| { module.addCSourceFile(.{ .file = b.path(b.fmt("src/linux/protocols/generated/{s}.c", .{name})), .flags = &.{ "-std=c99", "-include", b.path("src/linux/protocols/generated/private-symbols.h").getPath(b) }, diff --git a/src/linux/dbus-imports.h b/src/linux/dbus-imports.h index f522228..240d412 100644 --- a/src/linux/dbus-imports.h +++ b/src/linux/dbus-imports.h @@ -66,4 +66,10 @@ extern void (*z_dbus_message_iter_abandon_container_if_open)( DBusMessageIter *sub ); extern dbus_bool_t (*z_dbus_threads_init_default)(void); +extern DBusMessage *(*z_dbus_message_new_method_return)(DBusMessage *message); +extern DBusMessage *(*z_dbus_message_new_error)(DBusMessage *message, const char *name, const char *text); +extern DBusMessage *(*z_dbus_message_new_signal)(const char *path, const char *iface, const char *name); +extern const char *(*z_dbus_message_get_interface)(DBusMessage *message); +extern const char *(*z_dbus_message_get_member)(DBusMessage *message); +extern dbus_bool_t (*z_dbus_message_get_no_reply)(DBusMessage *message); #endif diff --git a/src/linux/functions.inc b/src/linux/functions.inc index 45759cc..66b4888 100644 --- a/src/linux/functions.inc +++ b/src/linux/functions.inc @@ -81,3 +81,9 @@ Z_FUNCTION(dbus_message_iter_open_container) Z_FUNCTION(dbus_message_iter_close_container) Z_FUNCTION(dbus_message_iter_abandon_container_if_open) Z_FUNCTION(dbus_threads_init_default) +Z_FUNCTION(dbus_message_new_method_return) +Z_FUNCTION(dbus_message_new_error) +Z_FUNCTION(dbus_message_new_signal) +Z_FUNCTION(dbus_message_get_interface) +Z_FUNCTION(dbus_message_get_member) +Z_FUNCTION(dbus_message_get_no_reply) diff --git a/src/linux/protocols/generated/appmenu.c b/src/linux/protocols/generated/appmenu.c new file mode 100644 index 0000000..ca064ce --- /dev/null +++ b/src/linux/protocols/generated/appmenu.c @@ -0,0 +1,55 @@ +/* Generated by wayland-scanner 1.24.0 */ + +/* + * SPDX-FileCopyrightText: 2017 David Edmundson + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface org_kde_kwin_appmenu_interface; +extern const struct wl_interface wl_surface_interface; + +static const struct wl_interface *appmenu_types[] = { + NULL, + NULL, + &org_kde_kwin_appmenu_interface, + &wl_surface_interface, +}; + +static const struct wl_message org_kde_kwin_appmenu_manager_requests[] = { + { "create", "no", appmenu_types + 2 }, + { "release", "2", appmenu_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface org_kde_kwin_appmenu_manager_interface = { + "org_kde_kwin_appmenu_manager", 2, + 2, org_kde_kwin_appmenu_manager_requests, + 0, NULL, +}; + +static const struct wl_message org_kde_kwin_appmenu_requests[] = { + { "set_address", "ss", appmenu_types + 0 }, + { "release", "", appmenu_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface org_kde_kwin_appmenu_interface = { + "org_kde_kwin_appmenu", 2, + 2, org_kde_kwin_appmenu_requests, + 0, NULL, +}; + diff --git a/src/linux/protocols/generated/appmenu.h b/src/linux/protocols/generated/appmenu.h new file mode 100644 index 0000000..760d0e6 --- /dev/null +++ b/src/linux/protocols/generated/appmenu.h @@ -0,0 +1,203 @@ +/* Generated by wayland-scanner 1.24.0 */ + +#ifndef APPMENU_CLIENT_PROTOCOL_H +#define APPMENU_CLIENT_PROTOCOL_H + +#include +#include +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_appmenu The appmenu protocol + * @section page_ifaces_appmenu Interfaces + * - @subpage page_iface_org_kde_kwin_appmenu_manager - appmenu dbus address interface + * - @subpage page_iface_org_kde_kwin_appmenu - appmenu dbus address interface + * @section page_copyright_appmenu Copyright + *
+ *
+ * SPDX-FileCopyrightText: 2017 David Edmundson
+ *
+ * SPDX-License-Identifier: MIT
+ * 
+ */ +struct org_kde_kwin_appmenu; +struct org_kde_kwin_appmenu_manager; +struct wl_surface; + +#ifndef ORG_KDE_KWIN_APPMENU_MANAGER_INTERFACE +#define ORG_KDE_KWIN_APPMENU_MANAGER_INTERFACE +/** + * @page page_iface_org_kde_kwin_appmenu_manager org_kde_kwin_appmenu_manager + * @section page_iface_org_kde_kwin_appmenu_manager_desc Description + * + * This interface allows a client to link a window (or wl_surface) to an com.canonical.dbusmenu + * interface registered on DBus. + * @section page_iface_org_kde_kwin_appmenu_manager_api API + * See @ref iface_org_kde_kwin_appmenu_manager. + */ +/** + * @defgroup iface_org_kde_kwin_appmenu_manager The org_kde_kwin_appmenu_manager interface + * + * This interface allows a client to link a window (or wl_surface) to an com.canonical.dbusmenu + * interface registered on DBus. + */ +extern const struct wl_interface org_kde_kwin_appmenu_manager_interface; +#endif +#ifndef ORG_KDE_KWIN_APPMENU_INTERFACE +#define ORG_KDE_KWIN_APPMENU_INTERFACE +/** + * @page page_iface_org_kde_kwin_appmenu org_kde_kwin_appmenu + * @section page_iface_org_kde_kwin_appmenu_desc Description + * + * The DBus service name and object path where the appmenu interface is present + * The object should be registered on the session bus before sending this request. + * If not applicable, clients should remove this object. + * @section page_iface_org_kde_kwin_appmenu_api API + * See @ref iface_org_kde_kwin_appmenu. + */ +/** + * @defgroup iface_org_kde_kwin_appmenu The org_kde_kwin_appmenu interface + * + * The DBus service name and object path where the appmenu interface is present + * The object should be registered on the session bus before sending this request. + * If not applicable, clients should remove this object. + */ +extern const struct wl_interface org_kde_kwin_appmenu_interface; +#endif + +#define ORG_KDE_KWIN_APPMENU_MANAGER_CREATE 0 +#define ORG_KDE_KWIN_APPMENU_MANAGER_RELEASE 1 + + +/** + * @ingroup iface_org_kde_kwin_appmenu_manager + */ +#define ORG_KDE_KWIN_APPMENU_MANAGER_CREATE_SINCE_VERSION 1 +/** + * @ingroup iface_org_kde_kwin_appmenu_manager + */ +#define ORG_KDE_KWIN_APPMENU_MANAGER_RELEASE_SINCE_VERSION 2 + +/** @ingroup iface_org_kde_kwin_appmenu_manager */ +static inline void +org_kde_kwin_appmenu_manager_set_user_data(struct org_kde_kwin_appmenu_manager *org_kde_kwin_appmenu_manager, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) org_kde_kwin_appmenu_manager, user_data); +} + +/** @ingroup iface_org_kde_kwin_appmenu_manager */ +static inline void * +org_kde_kwin_appmenu_manager_get_user_data(struct org_kde_kwin_appmenu_manager *org_kde_kwin_appmenu_manager) +{ + return wl_proxy_get_user_data((struct wl_proxy *) org_kde_kwin_appmenu_manager); +} + +static inline uint32_t +org_kde_kwin_appmenu_manager_get_version(struct org_kde_kwin_appmenu_manager *org_kde_kwin_appmenu_manager) +{ + return wl_proxy_get_version((struct wl_proxy *) org_kde_kwin_appmenu_manager); +} + +/** @ingroup iface_org_kde_kwin_appmenu_manager */ +static inline void +org_kde_kwin_appmenu_manager_destroy(struct org_kde_kwin_appmenu_manager *org_kde_kwin_appmenu_manager) +{ + wl_proxy_destroy((struct wl_proxy *) org_kde_kwin_appmenu_manager); +} + +/** + * @ingroup iface_org_kde_kwin_appmenu_manager + */ +static inline struct org_kde_kwin_appmenu * +org_kde_kwin_appmenu_manager_create(struct org_kde_kwin_appmenu_manager *org_kde_kwin_appmenu_manager, struct wl_surface *surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) org_kde_kwin_appmenu_manager, + ORG_KDE_KWIN_APPMENU_MANAGER_CREATE, &org_kde_kwin_appmenu_interface, wl_proxy_get_version((struct wl_proxy *) org_kde_kwin_appmenu_manager), 0, NULL, surface); + + return (struct org_kde_kwin_appmenu *) id; +} + +/** + * @ingroup iface_org_kde_kwin_appmenu_manager + */ +static inline void +org_kde_kwin_appmenu_manager_release(struct org_kde_kwin_appmenu_manager *org_kde_kwin_appmenu_manager) +{ + wl_proxy_marshal_flags((struct wl_proxy *) org_kde_kwin_appmenu_manager, + ORG_KDE_KWIN_APPMENU_MANAGER_RELEASE, NULL, wl_proxy_get_version((struct wl_proxy *) org_kde_kwin_appmenu_manager), WL_MARSHAL_FLAG_DESTROY); +} + +#define ORG_KDE_KWIN_APPMENU_SET_ADDRESS 0 +#define ORG_KDE_KWIN_APPMENU_RELEASE 1 + + +/** + * @ingroup iface_org_kde_kwin_appmenu + */ +#define ORG_KDE_KWIN_APPMENU_SET_ADDRESS_SINCE_VERSION 1 +/** + * @ingroup iface_org_kde_kwin_appmenu + */ +#define ORG_KDE_KWIN_APPMENU_RELEASE_SINCE_VERSION 1 + +/** @ingroup iface_org_kde_kwin_appmenu */ +static inline void +org_kde_kwin_appmenu_set_user_data(struct org_kde_kwin_appmenu *org_kde_kwin_appmenu, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) org_kde_kwin_appmenu, user_data); +} + +/** @ingroup iface_org_kde_kwin_appmenu */ +static inline void * +org_kde_kwin_appmenu_get_user_data(struct org_kde_kwin_appmenu *org_kde_kwin_appmenu) +{ + return wl_proxy_get_user_data((struct wl_proxy *) org_kde_kwin_appmenu); +} + +static inline uint32_t +org_kde_kwin_appmenu_get_version(struct org_kde_kwin_appmenu *org_kde_kwin_appmenu) +{ + return wl_proxy_get_version((struct wl_proxy *) org_kde_kwin_appmenu); +} + +/** @ingroup iface_org_kde_kwin_appmenu */ +static inline void +org_kde_kwin_appmenu_destroy(struct org_kde_kwin_appmenu *org_kde_kwin_appmenu) +{ + wl_proxy_destroy((struct wl_proxy *) org_kde_kwin_appmenu); +} + +/** + * @ingroup iface_org_kde_kwin_appmenu + * + * Set or update the service name and object path. + * Strings should be formatted in Latin-1 matching the relevant DBus specifications. + */ +static inline void +org_kde_kwin_appmenu_set_address(struct org_kde_kwin_appmenu *org_kde_kwin_appmenu, const char *service_name, const char *object_path) +{ + wl_proxy_marshal_flags((struct wl_proxy *) org_kde_kwin_appmenu, + ORG_KDE_KWIN_APPMENU_SET_ADDRESS, NULL, wl_proxy_get_version((struct wl_proxy *) org_kde_kwin_appmenu), 0, service_name, object_path); +} + +/** + * @ingroup iface_org_kde_kwin_appmenu + */ +static inline void +org_kde_kwin_appmenu_release(struct org_kde_kwin_appmenu *org_kde_kwin_appmenu) +{ + wl_proxy_marshal_flags((struct wl_proxy *) org_kde_kwin_appmenu, + ORG_KDE_KWIN_APPMENU_RELEASE, NULL, wl_proxy_get_version((struct wl_proxy *) org_kde_kwin_appmenu), WL_MARSHAL_FLAG_DESTROY); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/linux/protocols/generated/private-symbols.h b/src/linux/protocols/generated/private-symbols.h index 51a98ed..33c5592 100644 --- a/src/linux/protocols/generated/private-symbols.h +++ b/src/linux/protocols/generated/private-symbols.h @@ -1,4 +1,6 @@ /* Generated by tools/protocols.py; private protocol descriptors. */ +#define org_kde_kwin_appmenu_manager_interface z_uhdk_org_kde_kwin_appmenu_manager_interface +#define org_kde_kwin_appmenu_interface z_uhdk_org_kde_kwin_appmenu_interface #define wp_cursor_shape_manager_v1_interface z_uhdk_wp_cursor_shape_manager_v1_interface #define wp_cursor_shape_device_v1_interface z_uhdk_wp_cursor_shape_device_v1_interface #define wp_fractional_scale_manager_v1_interface z_uhdk_wp_fractional_scale_manager_v1_interface diff --git a/src/linux/protocols/xml/appmenu.xml b/src/linux/protocols/xml/appmenu.xml new file mode 100644 index 0000000..02a72f7 --- /dev/null +++ b/src/linux/protocols/xml/appmenu.xml @@ -0,0 +1,40 @@ + + + + + + This interface allows a client to link a window (or wl_surface) to an com.canonical.dbusmenu + interface registered on DBus. + + + + + + + + + + + + + The DBus service name and object path where the appmenu interface is present + The object should be registered on the session bus before sending this request. + If not applicable, clients should remove this object. + + + + Set or update the service name and object path. + Strings should be formatted in Latin-1 matching the relevant DBus specifications. + + + + + + + + + diff --git a/src/linux/vendor/README.md b/src/linux/vendor/README.md index 74e1d08..6c26da6 100644 --- a/src/linux/vendor/README.md +++ b/src/linux/vendor/README.md @@ -11,6 +11,8 @@ per-file digests, and the scanner version. cursor-shape, tablet descriptors, text-input-v3, xdg-foreign-v2, activation, and toplevel icons. License in `wayland-protocols/COPYING` and each XML's copyright element. +- plasma-wayland-protocols revision `382dfabda886d3f2f5c067b22e5a22376685ba78`: + KDE appmenu surface association; MIT license in `plasma-wayland-protocols/MIT.txt`. - Khronos EGL-Registry revision `5961a7fe64cf8a126890ced6f13d69e0a1e1b83e`: EGL and platform ABI headers. Apache-2.0 text is in `khronos/LICENSE-2.0.txt`; copyright/SPDX and full MIT notices remain in the headers. diff --git a/src/linux/vendor/manifest.json b/src/linux/vendor/manifest.json index 0615601..a28b051 100644 --- a/src/linux/vendor/manifest.json +++ b/src/linux/vendor/manifest.json @@ -96,6 +96,16 @@ "dbus/dbus-bus.h": "vendor/dbus/dbus/dbus-bus.h", "dbus/dbus-address.h": "vendor/dbus/dbus/dbus-address.h" } + }, + { + "url": "https://raw.githubusercontent.com/KDE/plasma-wayland-protocols/382dfabda886d3f2f5c067b22e5a22376685ba78/src/protocols/appmenu.xml", + "sha256": "7d0251ee00d3d4bc7ee41e3cd1161beaf68a0c18c4f56f48ff1907a475846022", + "destination": "protocols/xml/appmenu.xml" + }, + { + "url": "https://raw.githubusercontent.com/KDE/plasma-wayland-protocols/382dfabda886d3f2f5c067b22e5a22376685ba78/LICENSES/MIT.txt", + "sha256": "8f25018489d6fe0dec34a352314c38dc146247b7de65735790f4398a92afa84b", + "destination": "vendor/plasma-wayland-protocols/MIT.txt" } ], "files": { @@ -146,15 +156,19 @@ "protocols/xml/xdg-foreign-unstable-v2.xml": "625d83fbb068f48e69e739eafde507f10cdfe7480146f3ac10af9a2ddf551c80", "protocols/xml/xdg-activation-v1.xml": "d8418be2d5738d50aff788bef1c7574f33f26659aa045447ff2ef9b78c58fe01", "protocols/xml/xdg-toplevel-icon-v1.xml": "791dbfed89280c1b8031689955a03e9b2da55601be3c5854a6198e38cea4978f", - "vendor/xkbcommon/xkbcommon-compat.h": "fb0384a704897c0dcfcc49f021ad38fadbbedc3307d5390f4f0d1019e3d1a4d9" + "vendor/xkbcommon/xkbcommon-compat.h": "fb0384a704897c0dcfcc49f021ad38fadbbedc3307d5390f4f0d1019e3d1a4d9", + "protocols/xml/appmenu.xml": "7d0251ee00d3d4bc7ee41e3cd1161beaf68a0c18c4f56f48ff1907a475846022", + "vendor/plasma-wayland-protocols/MIT.txt": "8f25018489d6fe0dec34a352314c38dc146247b7de65735790f4398a92afa84b" }, "generated": { + "protocols/generated/appmenu.c": "4705014be761bdc059357f1731e9d68004531b1ec3db1469f4b2f823d0a4bc97", + "protocols/generated/appmenu.h": "9627af04a4dd8f057f06e79761401ced0c4f10191a107510764dc8e57371ea0a", "protocols/generated/cursor-shape-v1.c": "6027922a5c0a8e0d70ee6948e32aa8231b23cd3f82d323875186b29d36881f78", "protocols/generated/cursor-shape-v1.h": "87edf9719e935db05a0f5545e20d8bdf67f2c2557676f9d1e697b83cc98d6529", "protocols/generated/dbus/dbus-arch-deps.h": "87a896df22f7b5e6ec5367cc9b3ed7c77c65b54405a50fd3c7133cd4c6fc3281", "protocols/generated/fractional-scale-v1.c": "fb40e729ee05acafe996d1261367424b47722be02dbee65c90b3f4972f259dca", "protocols/generated/fractional-scale-v1.h": "9243e57b2ce11317f6aaa2cd76c0a9f999fb54ced38b880d81891a6ee5dd27df", - "protocols/generated/private-symbols.h": "93778cae319dc148bd51ec6ec9725f89735c8a9ccf937f9c52ae45b6768cc02d", + "protocols/generated/private-symbols.h": "a1c6d71c84c40c8ea0d2023ec650f219227c8059009f915497f07f06acd9161e", "protocols/generated/tablet-v2.c": "6ce7899f31da919e1f04a8bd44038df5095b58a98b1178f9aa0a84d0835424c0", "protocols/generated/tablet-v2.h": "eff5398428ff21523ae6c745d57081f3bd5c18509c4bf5b18de75d89d58d18cd", "protocols/generated/text-input-unstable-v3.c": "5de60647b6e122860802d59b547632d4bcf838a443cebeb04429bbb17b5c971b", diff --git a/src/linux/vendor/plasma-wayland-protocols/MIT.txt b/src/linux/vendor/plasma-wayland-protocols/MIT.txt new file mode 100644 index 0000000..204b93d --- /dev/null +++ b/src/linux/vendor/plasma-wayland-protocols/MIT.txt @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.