Notify, AT-SPI roles and window stubs said once; build.ps1 keeps -D off -Arch
reaktor_notify checks its notification in one place before the platform backend, and a build without D-Bus links the module's none twin instead of a fourth copy of it. AT-SPI's role codes and names are one table, and the per-window no-op stubs one file the none module, the web and the non-Windows bridges share. build.ps1 passed a -D option after -Out to -Arch, which rejected it; it now checks -Arch itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+6
-4
@@ -301,14 +301,14 @@ option(REAKTOR_A11Y
|
||||
|
||||
set(_a11y "${CMAKE_CURRENT_SOURCE_DIR}/platform/a11y")
|
||||
add_library(reaktor_a11y_none INTERFACE)
|
||||
target_sources(reaktor_a11y_none INTERFACE "${_a11y}/a11y_none.c")
|
||||
target_sources(reaktor_a11y_none INTERFACE "${_a11y}/a11y_none.c" "${_a11y}/a11y_window_none.c")
|
||||
|
||||
add_library(reaktor_a11y INTERFACE)
|
||||
if(NOT REAKTOR_A11Y)
|
||||
target_link_libraries(reaktor_a11y INTERFACE reaktor_a11y_none)
|
||||
message(STATUS "a11y: off; the tree is built and served to nothing")
|
||||
elseif(EMSCRIPTEN)
|
||||
target_sources(reaktor_a11y INTERFACE "${_a11y}/a11y_web.c")
|
||||
target_sources(reaktor_a11y INTERFACE "${_a11y}/a11y_web.c" "${_a11y}/a11y_window_none.c")
|
||||
elseif(WIN32)
|
||||
target_sources(reaktor_a11y INTERFACE
|
||||
"${_a11y}/a11y_snapshot.c" "${_a11y}/a11y_win32.c")
|
||||
@@ -321,7 +321,8 @@ elseif(APPLE)
|
||||
target_compile_definitions(reaktor_a11y_macos PRIVATE REAKTOR_HAVE_NSACCESSIBILITY)
|
||||
target_link_libraries(reaktor_a11y_macos PRIVATE reaktor_runtime)
|
||||
target_sources(reaktor_a11y INTERFACE
|
||||
"${_a11y}/a11y_snapshot.c" "$<TARGET_OBJECTS:reaktor_a11y_macos>")
|
||||
"${_a11y}/a11y_snapshot.c" "${_a11y}/a11y_window_none.c"
|
||||
"$<TARGET_OBJECTS:reaktor_a11y_macos>")
|
||||
target_compile_definitions(reaktor_a11y INTERFACE REAKTOR_HAVE_NSACCESSIBILITY)
|
||||
target_link_libraries(reaktor_a11y INTERFACE "-framework Cocoa")
|
||||
else()
|
||||
@@ -331,7 +332,7 @@ else()
|
||||
endif()
|
||||
if(REAKTOR_DBUS_FOUND)
|
||||
target_sources(reaktor_a11y INTERFACE
|
||||
"${_a11y}/a11y_snapshot.c" "${_a11y}/a11y_atspi.c")
|
||||
"${_a11y}/a11y_snapshot.c" "${_a11y}/a11y_window_none.c" "${_a11y}/a11y_atspi.c")
|
||||
target_compile_definitions(reaktor_a11y INTERFACE REAKTOR_HAVE_ATSPI)
|
||||
target_link_libraries(reaktor_a11y INTERFACE PkgConfig::REAKTOR_DBUS)
|
||||
message(STATUS "a11y: AT-SPI over libdbus ${REAKTOR_DBUS_VERSION}")
|
||||
@@ -497,6 +498,7 @@ else()
|
||||
target_compile_definitions(reaktor_notify INTERFACE REAKTOR_HAVE_DBUS)
|
||||
target_link_libraries(reaktor_notify INTERFACE PkgConfig::REAKTOR_DBUS)
|
||||
else()
|
||||
target_link_libraries(reaktor_notify INTERFACE reaktor_notify_none)
|
||||
message(STATUS "notify: no dbus-1; notifications are not sent")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
param([string]$Target = "", [ValidateSet("", "x64", "x86", "arm64")][string]$Arch = "",
|
||||
[string]$Out = "", [string]$Source = "")
|
||||
param([string]$Target = "", [string]$Arch = "", [string]$Out = "", [string]$Source = "")
|
||||
|
||||
$extra = @($args)
|
||||
# CMake options bind to whichever positional parameters are left.
|
||||
if ($Source -like '-*') { $extra = @($Source) + $extra; $Source = "" }
|
||||
if ($Out -like '-*') { $extra = @($Out) + $extra; $Out = "" }
|
||||
if ($Arch -like '-*') { $extra = @($Arch) + $extra; $Arch = "" }
|
||||
if ($Target -like '-*') { $extra = @($Target) + $extra; $Target = "" }
|
||||
if ($Arch -notin @("", "x64", "x86", "arm64")) { throw "-Arch must be x64, x86 or arm64, not '$Arch'" }
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = $PSScriptRoot
|
||||
$hostArch = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
|
||||
|
||||
+29
-46
@@ -97,60 +97,43 @@ id_of(const char *path)
|
||||
return (long)strtoul(tail, NULL, 10);
|
||||
}
|
||||
|
||||
static const struct {
|
||||
unsigned code;
|
||||
const char *name;
|
||||
} g_roles[REAKTOR_A11Y_ROLE_COUNT] = {
|
||||
[REAKTOR_A11Y_WINDOW] = { ATSPI_ROLE_FRAME, "frame" },
|
||||
[REAKTOR_A11Y_GROUP] = { ATSPI_ROLE_PANEL, "panel" },
|
||||
[REAKTOR_A11Y_TABLIST] = { ATSPI_ROLE_PAGE_TAB_LIST, "page tab list" },
|
||||
[REAKTOR_A11Y_TAB] = { ATSPI_ROLE_PAGE_TAB, "page tab" },
|
||||
[REAKTOR_A11Y_BUTTON] = { ATSPI_ROLE_PUSH_BUTTON, "push button" },
|
||||
[REAKTOR_A11Y_LINK] = { ATSPI_ROLE_LINK, "link" },
|
||||
[REAKTOR_A11Y_CHECKBOX] = { ATSPI_ROLE_CHECK_BOX, "check box" },
|
||||
[REAKTOR_A11Y_RADIO] = { ATSPI_ROLE_RADIO_BUTTON, "radio button" },
|
||||
[REAKTOR_A11Y_TEXTBOX] = { ATSPI_ROLE_TEXT, "text" },
|
||||
[REAKTOR_A11Y_SLIDER] = { ATSPI_ROLE_SLIDER, "slider" },
|
||||
[REAKTOR_A11Y_SPINBUTTON] = { ATSPI_ROLE_SPIN_BUTTON, "spin button" },
|
||||
[REAKTOR_A11Y_PROGRESS] = { ATSPI_ROLE_PROGRESS_BAR, "progress bar" },
|
||||
[REAKTOR_A11Y_COMBOBOX] = { ATSPI_ROLE_COMBO_BOX, "combo box" },
|
||||
[REAKTOR_A11Y_LISTITEM] = { ATSPI_ROLE_LIST_ITEM, "list item" },
|
||||
[REAKTOR_A11Y_TREEITEM] = { ATSPI_ROLE_TREE_ITEM, "tree item" },
|
||||
[REAKTOR_A11Y_MENUBAR] = { ATSPI_ROLE_MENU_BAR, "menu bar" },
|
||||
[REAKTOR_A11Y_MENU] = { ATSPI_ROLE_MENU, "menu" },
|
||||
[REAKTOR_A11Y_MENUITEM] = { ATSPI_ROLE_MENU_ITEM, "menu item" },
|
||||
[REAKTOR_A11Y_DIALOG] = { ATSPI_ROLE_DIALOG, "dialog" },
|
||||
[REAKTOR_A11Y_LABEL] = { ATSPI_ROLE_LABEL, "label" },
|
||||
};
|
||||
|
||||
static unsigned
|
||||
role_of(unsigned char role)
|
||||
{
|
||||
switch (role) {
|
||||
case REAKTOR_A11Y_WINDOW: return ATSPI_ROLE_FRAME;
|
||||
case REAKTOR_A11Y_GROUP: return ATSPI_ROLE_PANEL;
|
||||
case REAKTOR_A11Y_TABLIST: return ATSPI_ROLE_PAGE_TAB_LIST;
|
||||
case REAKTOR_A11Y_TAB: return ATSPI_ROLE_PAGE_TAB;
|
||||
case REAKTOR_A11Y_BUTTON: return ATSPI_ROLE_PUSH_BUTTON;
|
||||
case REAKTOR_A11Y_LINK: return ATSPI_ROLE_LINK;
|
||||
case REAKTOR_A11Y_CHECKBOX: return ATSPI_ROLE_CHECK_BOX;
|
||||
case REAKTOR_A11Y_RADIO: return ATSPI_ROLE_RADIO_BUTTON;
|
||||
case REAKTOR_A11Y_TEXTBOX: return ATSPI_ROLE_TEXT;
|
||||
case REAKTOR_A11Y_SLIDER: return ATSPI_ROLE_SLIDER;
|
||||
case REAKTOR_A11Y_SPINBUTTON: return ATSPI_ROLE_SPIN_BUTTON;
|
||||
case REAKTOR_A11Y_PROGRESS: return ATSPI_ROLE_PROGRESS_BAR;
|
||||
case REAKTOR_A11Y_COMBOBOX: return ATSPI_ROLE_COMBO_BOX;
|
||||
case REAKTOR_A11Y_LISTITEM: return ATSPI_ROLE_LIST_ITEM;
|
||||
case REAKTOR_A11Y_TREEITEM: return ATSPI_ROLE_TREE_ITEM;
|
||||
case REAKTOR_A11Y_MENUBAR: return ATSPI_ROLE_MENU_BAR;
|
||||
case REAKTOR_A11Y_MENU: return ATSPI_ROLE_MENU;
|
||||
case REAKTOR_A11Y_MENUITEM: return ATSPI_ROLE_MENU_ITEM;
|
||||
case REAKTOR_A11Y_DIALOG: return ATSPI_ROLE_DIALOG;
|
||||
case REAKTOR_A11Y_LABEL: return ATSPI_ROLE_LABEL;
|
||||
default: return ATSPI_ROLE_FILLER;
|
||||
}
|
||||
return role < REAKTOR_A11Y_ROLE_COUNT && g_roles[role].name ? g_roles[role].code
|
||||
: ATSPI_ROLE_FILLER;
|
||||
}
|
||||
|
||||
static const char *
|
||||
role_name(unsigned char role)
|
||||
{
|
||||
switch (role) {
|
||||
case REAKTOR_A11Y_WINDOW: return "frame";
|
||||
case REAKTOR_A11Y_GROUP: return "panel";
|
||||
case REAKTOR_A11Y_TABLIST: return "page tab list";
|
||||
case REAKTOR_A11Y_TAB: return "page tab";
|
||||
case REAKTOR_A11Y_BUTTON: return "push button";
|
||||
case REAKTOR_A11Y_LINK: return "link";
|
||||
case REAKTOR_A11Y_CHECKBOX: return "check box";
|
||||
case REAKTOR_A11Y_RADIO: return "radio button";
|
||||
case REAKTOR_A11Y_TEXTBOX: return "text";
|
||||
case REAKTOR_A11Y_SLIDER: return "slider";
|
||||
case REAKTOR_A11Y_SPINBUTTON: return "spin button";
|
||||
case REAKTOR_A11Y_PROGRESS: return "progress bar";
|
||||
case REAKTOR_A11Y_COMBOBOX: return "combo box";
|
||||
case REAKTOR_A11Y_LISTITEM: return "list item";
|
||||
case REAKTOR_A11Y_TREEITEM: return "tree item";
|
||||
case REAKTOR_A11Y_MENUBAR: return "menu bar";
|
||||
case REAKTOR_A11Y_MENU: return "menu";
|
||||
case REAKTOR_A11Y_MENUITEM: return "menu item";
|
||||
case REAKTOR_A11Y_DIALOG: return "dialog";
|
||||
case REAKTOR_A11Y_LABEL: return "label";
|
||||
default: return "filler";
|
||||
}
|
||||
return role < REAKTOR_A11Y_ROLE_COUNT && g_roles[role].name ? g_roles[role].name : "filler";
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -17,23 +17,3 @@ void
|
||||
reaktor_a11y_platform_drain(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_push(struct SDL_Window *win, const reaktor_a11y *a,
|
||||
unsigned focus_id, reaktor_a11y_action activate,
|
||||
reaktor_a11y_action focus, void *user)
|
||||
{
|
||||
(void)win; (void)a; (void)focus_id; (void)activate; (void)focus; (void)user;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_drain(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_gone(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
|
||||
@@ -435,25 +435,3 @@ void reaktor_snap_request_focus(unsigned id)
|
||||
void reaktor_snap_request_activate(unsigned id)
|
||||
{ reaktor_snap_request_activate_in(&g, id); }
|
||||
void reaktor_snap_drain(void) { reaktor_snap_drain_in(&g); }
|
||||
|
||||
#ifndef _WIN32
|
||||
void
|
||||
reaktor_a11y_platform_window_push(struct SDL_Window *win, const reaktor_a11y *a,
|
||||
unsigned focus_id, reaktor_a11y_action activate,
|
||||
reaktor_a11y_action focus, void *user)
|
||||
{
|
||||
(void)win; (void)a; (void)focus_id; (void)activate; (void)focus; (void)user;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_drain(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_gone(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -168,23 +168,3 @@ reaktor_a11y_platform_push(const reaktor_a11y *a, unsigned focus_id)
|
||||
}
|
||||
web_a11y_end(focus_id);
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_push(struct SDL_Window *win, const reaktor_a11y *a,
|
||||
unsigned focus_id, reaktor_a11y_action activate,
|
||||
reaktor_a11y_action focus, void *user)
|
||||
{
|
||||
(void)win; (void)a; (void)focus_id; (void)activate; (void)focus; (void)user;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_drain(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_gone(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Windows other than the main one, where only UI Automation serves them. */
|
||||
#include "a11y.h"
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_push(struct SDL_Window *win, const reaktor_a11y *a,
|
||||
unsigned focus_id, reaktor_a11y_action activate,
|
||||
reaktor_a11y_action focus, void *user)
|
||||
{
|
||||
(void)win; (void)a; (void)focus_id; (void)activate; (void)focus; (void)user;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_drain(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_a11y_platform_window_gone(struct SDL_Window *win)
|
||||
{
|
||||
(void)win;
|
||||
}
|
||||
+22
-22
@@ -12,12 +12,11 @@ EM_JS(void, notify_web, (const char *title, const char *text), {
|
||||
});
|
||||
});
|
||||
|
||||
int
|
||||
reaktor_notify(App *app, const reaktor_notification *n)
|
||||
static int
|
||||
notify_os(App *app, const char *title, const char *text)
|
||||
{
|
||||
(void)app;
|
||||
if (!n || !n->title) return 0;
|
||||
notify_web(n->title, n->text ? n->text : "");
|
||||
notify_web(title, text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -58,15 +57,15 @@ notify_text(const char *s, WCHAR *out, int cap)
|
||||
}
|
||||
|
||||
/* A balloon from an icon of our own, which Windows 10 and 11 show as a toast. */
|
||||
int
|
||||
reaktor_notify(App *app, const reaktor_notification *n)
|
||||
static int
|
||||
notify_os(App *app, const char *title, const char *text)
|
||||
{
|
||||
static unsigned gone;
|
||||
static int watched;
|
||||
HWND hwnd;
|
||||
int added;
|
||||
|
||||
if (!app || !n || !n->title) return 0;
|
||||
if (!app) return 0;
|
||||
hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(app->win),
|
||||
SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
if (!hwnd) return 0;
|
||||
@@ -78,9 +77,9 @@ reaktor_notify(App *app, const reaktor_notification *n)
|
||||
g_icon.uFlags = NIF_ICON | NIF_TIP | NIF_INFO;
|
||||
g_icon.hIcon = (HICON)SendMessageW(hwnd, WM_GETICON, ICON_SMALL, 0);
|
||||
if (!g_icon.hIcon) g_icon.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
|
||||
notify_text(n->title, g_icon.szInfoTitle, (int)SDL_arraysize(g_icon.szInfoTitle));
|
||||
notify_text(n->title, g_icon.szTip, (int)SDL_arraysize(g_icon.szTip));
|
||||
notify_text(n->text ? n->text : "", g_icon.szInfo, (int)SDL_arraysize(g_icon.szInfo));
|
||||
notify_text(title, g_icon.szInfoTitle, (int)SDL_arraysize(g_icon.szInfoTitle));
|
||||
notify_text(title, g_icon.szTip, (int)SDL_arraysize(g_icon.szTip));
|
||||
notify_text(text, g_icon.szInfo, (int)SDL_arraysize(g_icon.szInfo));
|
||||
g_icon.dwInfoFlags = NIIF_USER | NIIF_RESPECT_QUIET_TIME;
|
||||
if (!Shell_NotifyIconW(added ? NIM_MODIFY : NIM_ADD, &g_icon)) {
|
||||
g_icon.hWnd = NULL;
|
||||
@@ -96,29 +95,28 @@ reaktor_notify(App *app, const reaktor_notification *n)
|
||||
#elif defined(REAKTOR_HAVE_DBUS)
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
int
|
||||
reaktor_notify(App *app, const reaktor_notification *n)
|
||||
static int
|
||||
notify_os(App *app, const char *title, const char *body)
|
||||
{
|
||||
DBusConnection *c;
|
||||
DBusMessage *m;
|
||||
DBusMessageIter it, sub;
|
||||
const char *name = reaktor_app_ident(), *icon = "", *body;
|
||||
const char *name = reaktor_app_ident(), *icon = "";
|
||||
dbus_uint32_t replaces = 0;
|
||||
dbus_int32_t expire = -1;
|
||||
int ok;
|
||||
|
||||
(void)app;
|
||||
if (!n || !n->title || !(c = dbus_bus_get(DBUS_BUS_SESSION, NULL))) return 0;
|
||||
if (!(c = dbus_bus_get(DBUS_BUS_SESSION, NULL))) return 0;
|
||||
m = dbus_message_new_method_call("org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications", "Notify");
|
||||
if (!m) return 0;
|
||||
body = n->text ? n->text : "";
|
||||
dbus_message_iter_init_append(m, &it);
|
||||
dbus_message_iter_append_basic(&it, DBUS_TYPE_STRING, &name);
|
||||
dbus_message_iter_append_basic(&it, DBUS_TYPE_UINT32, &replaces);
|
||||
dbus_message_iter_append_basic(&it, DBUS_TYPE_STRING, &icon);
|
||||
dbus_message_iter_append_basic(&it, DBUS_TYPE_STRING, &n->title);
|
||||
dbus_message_iter_append_basic(&it, DBUS_TYPE_STRING, &title);
|
||||
dbus_message_iter_append_basic(&it, DBUS_TYPE_STRING, &body);
|
||||
dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY, "s", &sub);
|
||||
dbus_message_iter_close_container(&it, &sub);
|
||||
@@ -135,18 +133,20 @@ reaktor_notify(App *app, const reaktor_notification *n)
|
||||
#elif defined(__APPLE__)
|
||||
int reaktor_notify_macos(const char *title, const char *text);
|
||||
|
||||
int
|
||||
reaktor_notify(App *app, const reaktor_notification *n)
|
||||
static int
|
||||
notify_os(App *app, const char *title, const char *text)
|
||||
{
|
||||
(void)app;
|
||||
return n && n->title ? reaktor_notify_macos(n->title, n->text ? n->text : "") : 0;
|
||||
return reaktor_notify_macos(title, text);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* Without a backend the module is notify_none.c instead. */
|
||||
#if defined(__EMSCRIPTEN__) || defined(_WIN32) || defined(REAKTOR_HAVE_DBUS) || defined(__APPLE__)
|
||||
int
|
||||
reaktor_notify(App *app, const reaktor_notification *n)
|
||||
{
|
||||
(void)app; (void)n;
|
||||
return 0;
|
||||
if (!n || !n->title) return 0;
|
||||
return notify_os(app, n->title, n->text ? n->text : "");
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user