diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 17:05:59 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 17:05:59 +0300 |
| commit | d4d13e616cb15ef22479d9cb97922af93317a01a (patch) | |
| tree | 17f812ae15c239ce7d6c2a50a292ebd91375db8e /src/platform/wayland | |
| parent | 305a341022c8119b89b32420445bb38154073fc4 (diff) | |
Add desktop services: open URI, notify, appearance, bell, and paths
wsap_term keeps per-platform code for opening links, notifications, the
bell, high-contrast detection, the executable and bundle paths, and the
default locale. These now live behind <yasl/desktop.h>.
On Linux, src/platform/freedesktop serves both backends. Opening a URI
runs xdg-open from PATH through a double fork, so the opener gets default
signal dispositions, an empty mask, a new session, and none of the
application's descriptors. Notifications and the Settings portal use the
session bus through libdbus-1, an optional dependency behind -Ddbus.
Appearance falls back to GTK_THEME without a portal. The bell uses
xdg-system-bell on Wayland and the XKB bell on X11.
Cocoa implements the same calls with NSWorkspace, UserNotifications, the
effective appearance, NSBeep, the bundle, and CFLocale. That code is not
built or run here; it needs a macOS check.
The desktop test runs under dbus-run-session against a fake notification
server and portal, and uses a fake xdg-open to check argument passing,
signal state, and descriptor inheritance.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/platform/wayland')
| -rw-r--r-- | src/platform/wayland/api.h | 1 | ||||
| -rw-r--r-- | src/platform/wayland/backend.c | 6 | ||||
| -rw-r--r-- | src/platform/wayland/internal.h | 2 | ||||
| -rw-r--r-- | src/platform/wayland/shell.c | 9 | ||||
| -rw-r--r-- | src/platform/wayland/surface.c | 2 |
5 files changed, 20 insertions, 0 deletions
diff --git a/src/platform/wayland/api.h b/src/platform/wayland/api.h index e5e933e..6c3154c 100644 --- a/src/platform/wayland/api.h +++ b/src/platform/wayland/api.h @@ -38,5 +38,6 @@ bool wayland_surface_start_interactive_resize(struct wayland_surface *s, enum ya bool wayland_surface_show_window_menu(struct wayland_surface *s, struct yasl_vector2i pos); bool wayland_surface_drag_carry(struct wayland_surface *s, struct yasl_vector2i offset); bool wayland_surface_place_under_pointer(struct wayland_surface *s, struct yasl_vector2i at); +bool wayland_surface_bell(struct wayland_surface *s); #endif diff --git a/src/platform/wayland/backend.c b/src/platform/wayland/backend.c index c3c7bed..c6272ce 100644 --- a/src/platform/wayland/backend.c +++ b/src/platform/wayland/backend.c @@ -177,6 +177,11 @@ static bool impl_surface_place_under_pointer(struct yasl_surface *s, struct yasl return wayland_surface_place_under_pointer((struct wayland_surface *)s, at); } +static bool impl_surface_bell(struct yasl_surface *s) +{ + return wayland_surface_bell((struct wayland_surface *)s); +} + static void *impl_display_get_native_handle(struct yasl_display *d) { struct wayland_display *w = (struct wayland_display *)d; @@ -225,6 +230,7 @@ const struct yasl_backend_ops yasl_wayland_backend = { .surface_show_window_menu = impl_surface_show_window_menu, .surface_drag_carry = impl_surface_drag_carry, .surface_place_under_pointer = impl_surface_place_under_pointer, + .surface_bell = impl_surface_bell, .display_get_native_handle = impl_display_get_native_handle, .surface_get_native_handle = impl_surface_get_native_handle, }; diff --git a/src/platform/wayland/internal.h b/src/platform/wayland/internal.h index c35db7f..84a603d 100644 --- a/src/platform/wayland/internal.h +++ b/src/platform/wayland/internal.h @@ -25,6 +25,7 @@ #include "protocols/primary-selection-unstable-v1-client-protocol.h" #include "protocols/relative-pointer-unstable-v1-client-protocol.h" #include "protocols/pointer-constraints-unstable-v1-client-protocol.h" +#include "protocols/xdg-system-bell-v1-client-protocol.h" #include <fcntl.h> #include <limits.h> @@ -217,6 +218,7 @@ struct wayland_display { struct wp_cursor_shape_manager_v1 *cursor_shape_mgr; struct zwp_relative_pointer_manager_v1 *relative_pointer_mgr; struct zwp_pointer_constraints_v1 *pointer_constraints; + struct xdg_system_bell_v1 *system_bell; struct wl_cursor_theme *cursor_theme; const char *cursor_theme_name; struct zwp_tablet_manager_v2 *tablet_mgr; diff --git a/src/platform/wayland/shell.c b/src/platform/wayland/shell.c index a12bd4d..8795989 100644 --- a/src/platform/wayland/shell.c +++ b/src/platform/wayland/shell.c @@ -214,6 +214,8 @@ static void registry_global(void *data, struct wl_registry *registry, } else if (strcmp(interface, zwp_pointer_constraints_v1_interface.name) == 0) { c->pointer_constraints = wl_registry_bind(registry, name, &zwp_pointer_constraints_v1_interface, 1); + } else if (strcmp(interface, xdg_system_bell_v1_interface.name) == 0) { + c->system_bell = wl_registry_bind(registry, name, &xdg_system_bell_v1_interface, 1); } else if (strcmp(interface, wp_fractional_scale_manager_v1_interface.name) == 0) { c->scale_mgr = wl_registry_bind(registry, name, &wp_fractional_scale_manager_v1_interface, 1); @@ -403,3 +405,10 @@ int surface_init_shell(struct wayland_surface *w, const char *title) } return 0; } + +bool wayland_surface_bell(struct wayland_surface *w) +{ + if (!w || w->closed || !w->conn || !w->conn->system_bell || !w->surface) return false; + xdg_system_bell_v1_ring(w->conn->system_bell, w->surface); + return true; +} diff --git a/src/platform/wayland/surface.c b/src/platform/wayland/surface.c index 0f6d7d7..cf1877d 100644 --- a/src/platform/wayland/surface.c +++ b/src/platform/wayland/surface.c @@ -202,6 +202,7 @@ static void display_free(struct wayland_display *c) if (c->cursor_shape_mgr) wp_cursor_shape_manager_v1_destroy(c->cursor_shape_mgr); if (c->relative_pointer_mgr) zwp_relative_pointer_manager_v1_destroy(c->relative_pointer_mgr); if (c->pointer_constraints) zwp_pointer_constraints_v1_destroy(c->pointer_constraints); + if (c->system_bell) xdg_system_bell_v1_destroy(c->system_bell); if (c->cursor_theme) wl_cursor_theme_destroy(c->cursor_theme); if (c->tablet_mgr) zwp_tablet_manager_v2_destroy(c->tablet_mgr); if (c->text_input_mgr) zwp_text_input_manager_v3_destroy(c->text_input_mgr); @@ -246,6 +247,7 @@ struct wayland_display *wayland_display_open(struct yasl_loop *loop, const struc c->cbs = &c->base.callbacks; c->ud = spec->ud; if (spec->app_id) c->app_id = strdup(spec->app_id); + c->base.app_id = c->app_id; } c->xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); c->wl = c->xkb_ctx ? wl_display_connect(NULL) : NULL; |
