Interrupt speech before key feedback

This commit is contained in:
Storm Dragon
2026-07-17 13:53:03 -04:00
parent 590006ca7d
commit 270b9bc19b
+33 -27
View File
@@ -31,6 +31,8 @@ struct screen_reader {
const char *service; const char *service;
const char *path; const char *path;
const char *interface; const char *interface;
const char *interrupt_path;
const char *interrupt_interface;
}; };
static const struct screen_reader screen_readers[] = { static const struct screen_reader screen_readers[] = {
@@ -38,11 +40,15 @@ static const struct screen_reader screen_readers[] = {
"org.stormux.Cthulhu1.Service", "org.stormux.Cthulhu1.Service",
"/org/stormux/Cthulhu1/Service", "/org/stormux/Cthulhu1/Service",
"org.stormux.Cthulhu1.Service", "org.stormux.Cthulhu1.Service",
"/org/stormux/Cthulhu1/Service/SpeechManager",
"org.stormux.Cthulhu1.SpeechManager",
}, },
{ {
"org.gnome.Orca1.Service", "org.gnome.Orca1.Service",
"/org/gnome/Orca1/Service", "/org/gnome/Orca1/Service",
"org.gnome.Orca1.Service", "org.gnome.Orca1.Service",
NULL,
NULL,
}, },
}; };
@@ -135,6 +141,31 @@ static bool own_secure_input_name(GDBusConnection *connection) {
reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER; reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER;
} }
static void interrupt_speech(GDBusConnection *connection, const struct screen_reader *reader) {
if (reader->interrupt_path == NULL || reader->interrupt_interface == NULL) {
return;
}
GError *error = NULL;
GVariant *result = g_dbus_connection_call_sync(
connection,
reader->service,
reader->interrupt_path,
reader->interrupt_interface,
"InterruptSpeech",
g_variant_new("(b)", TRUE),
G_VARIANT_TYPE("(b)"),
G_DBUS_CALL_FLAGS_NONE,
250,
NULL,
&error);
if (result != NULL) {
g_variant_unref(result);
}
g_clear_error(&error);
}
static void report_worker_ready(int ready_fd, bool is_ready) { static void report_worker_ready(int ready_fd, bool is_ready) {
char status = is_ready ? ACCESSIBILITY_READY_OK : ACCESSIBILITY_READY_FAILED; char status = is_ready ? ACCESSIBILITY_READY_OK : ACCESSIBILITY_READY_FAILED;
ssize_t result; ssize_t result;
@@ -178,6 +209,8 @@ static void present_message(GDBusConnection *connection, const char *message) {
continue; continue;
} }
interrupt_speech(connection, reader);
GError *error = NULL; GError *error = NULL;
GVariant *result = g_dbus_connection_call_sync( GVariant *result = g_dbus_connection_call_sync(
connection, connection,
@@ -200,18 +233,6 @@ static void present_message(GDBusConnection *connection, const char *message) {
} }
} }
static void flush_stars(GDBusConnection *connection, size_t count) {
char message[640];
size_t position = 0;
for (size_t i = 0; i < count; i++) {
const char *separator = (i == 0 ? "" : " ");
position += snprintf(message + position, sizeof(message) - position, "%sstar", separator);
}
present_message(connection, message);
}
static void close_sleep_lock_fd(void) { static void close_sleep_lock_fd(void) {
const char *sleep_lock_fd = getenv("XSS_SLEEP_LOCK_FD"); const char *sleep_lock_fd = getenv("XSS_SLEEP_LOCK_FD");
if (sleep_lock_fd == NULL || *sleep_lock_fd == '\0') { if (sleep_lock_fd == NULL || *sleep_lock_fd == '\0') {
@@ -260,27 +281,12 @@ static void feedback_worker(int read_fd, int inherited_xcb_fd, int ready_fd) {
} }
size_t count = (size_t)bytes_read / sizeof(feedback[0]); size_t count = (size_t)bytes_read / sizeof(feedback[0]);
size_t stars = 0;
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
if (feedback[i] == ACCESSIBILITY_CHARACTER_TYPED) {
stars++;
continue;
}
if (connection != NULL && stars > 0) {
flush_stars(connection, stars);
}
stars = 0;
const char *message = feedback_message(feedback[i]); const char *message = feedback_message(feedback[i]);
if (connection != NULL && message != NULL) { if (connection != NULL && message != NULL) {
present_message(connection, message); present_message(connection, message);
} }
} }
if (connection != NULL && stars > 0) {
flush_stars(connection, stars);
}
} }
if (connection != NULL) { if (connection != NULL) {