Eldbus_Connection *utils_a11y_bus_connection_get(void);
Eina_Bool object_has_modal_role(AtspiRole role);
+Eina_Bool object_has_focused_state(AtspiAccessible *obj);
Eina_Bool object_has_defunct_state(AtspiAccessible *obj);
Eina_Bool object_has_highlighted_state(AtspiAccessible *obj);
Eina_Bool is_same_str (const char *s1, const char *s2);
+Live_Region_Politeness try_parse_politeness(GHashTable *attrs);
+
static inline void ESAL(Eina_Strbuf *buf, const char *txt)
{
// Note: This was previously defined as a macro:
GHashTable *attrs = atspi_accessible_get_attributes(event->source, NULL);
- Live_Region_Politeness mode = ACCESSIBLE_LIVE_REGION_ASSERTIVE;
- if (attrs) {
- char *val = g_hash_table_lookup(attrs, "container-live");
- DEBUG("got attributes, containter-live is '%s'", val);
- if (val) {
- if (g_strcmp0(val, "polite") == 0) mode = ACCESSIBLE_LIVE_REGION_POLITE;
- else if (g_strcmp0(val, "off") == 0) mode = ACCESSIBLE_LIVE_REGION_OFF;
- }
+ Live_Region_Politeness mode = try_parse_politeness(attrs);
+
+ if (attrs)
g_hash_table_destroy(attrs);
- }
DEBUG("speaking mode is %d", mode);
if (mode != ACCESSIBLE_LIVE_REGION_OFF)
} else if (!g_strcmp0(event->type, TEXT_INSERT_SIG)) {
DEBUG("Set ignore_next_caret_move event to true");
spi->ignore_next_caret_move = EINA_TRUE;
- Live_Region_Politeness mode = ACCESSIBLE_LIVE_REGION_ASSERTIVE;
- if (attrs) {
- char *val = g_hash_table_lookup(attrs, "container-live");
- DEBUG("got attributes, containter-live is '%s'", val);
- if (val) {
- if (g_strcmp0(val, "polite") == 0) mode = ACCESSIBLE_LIVE_REGION_POLITE;
- else if (g_strcmp0(val, "off") == 0) mode = ACCESSIBLE_LIVE_REGION_OFF;
- }
- }
- DEBUG("speaking mode is %d", mode);
- if (mode != ACCESSIBLE_LIVE_REGION_OFF) {
+ Live_Region_Politeness mode = try_parse_politeness(attrs);
+ if (object_has_focused_state(event->source) || mode != ACCESSIBLE_LIVE_REGION_OFF) {
*text_to_read = spi_on_text_insert_get_text(spi, event);
if (cancel)
*cancel = mode == ACCESSIBLE_LIVE_REGION_ASSERTIVE ? 1 : 0;
}
} else if (!g_strcmp0(event->type, TEXT_DELETE_SIG)) {
- int mode = ACCESSIBLE_LIVE_REGION_ASSERTIVE;
- if (attrs) {
- char *val = g_hash_table_lookup(attrs, "container-live");
- DEBUG("got attributes, containter-live is '%s'", val);
- if (val) {
- if (g_strcmp0(val, "polite") == 0) mode = ACCESSIBLE_LIVE_REGION_POLITE;
- else if (g_strcmp0(val, "off") == 0) mode = ACCESSIBLE_LIVE_REGION_OFF;
- }
- }
- DEBUG("speaking mode is %d", mode);
- if (mode != ACCESSIBLE_LIVE_REGION_OFF) {
+ Live_Region_Politeness mode = try_parse_politeness(attrs);
+ if (object_has_focused_state(event->source) || mode != ACCESSIBLE_LIVE_REGION_OFF) {
*text_to_read = spi_on_text_delete_get_text(spi, event);
if (cancel)
*cancel = mode == ACCESSIBLE_LIVE_REGION_ASSERTIVE ? 1 : 0;
spi->ignore_next_caret_move = EINA_TRUE;
}
} else if (!g_strcmp0(event->type, VALUE_CHANGED_SIG)) {
- *text_to_read = spi_on_value_changed_get_text(spi, event);
-
+ Live_Region_Politeness mode = try_parse_politeness(attrs);
+ if (object_has_focused_state(event->source) || mode != ACCESSIBLE_LIVE_REGION_OFF) {
+ *text_to_read = spi_on_value_changed_get_text(spi, event);
+ if (cancel)
+ *cancel = mode == ACCESSIBLE_LIVE_REGION_ASSERTIVE ? 1 : 0;
+ }
} else if (!g_strcmp0(event->type, STATE_CHECKED_SIG)) {
if (event->detail1)
*text_to_read = g_strdup(_("IDS_ACCS_TBOPT_CHECKED_TTS"));
else
*text_to_read = g_strdup(_("IDS_ACCS_TBOPT_NOT_CHECKED_TTS"));
-
} else {
ERROR("Unknown event type");
}
* limitations under the License.
*/
-#include <atspi/atspi.h>
#include <glib.h>
#include <string.h>
#include <math.h>
return ret;
}
-Eina_Bool object_has_defunct_state(AtspiAccessible *obj)
+static Eina_Bool _object_has_state(AtspiAccessible *obj, AtspiStateType state)
{
if (!obj)
return EINA_FALSE;
AtspiStateSet *ss = atspi_accessible_get_state_set(obj);
- if (atspi_state_set_contains(ss, ATSPI_STATE_DEFUNCT))
+ if (atspi_state_set_contains(ss, state))
ret = EINA_TRUE;
g_object_unref(ss);
return ret;
}
-Eina_Bool object_has_highlighted_state(AtspiAccessible *obj)
+Eina_Bool object_has_defunct_state(AtspiAccessible *obj)
{
- if (!obj)
- return EINA_FALSE;
-
- Eina_Bool ret = EINA_FALSE;
+ return _object_has_state(obj, ATSPI_STATE_DEFUNCT);
+}
- AtspiStateSet *ss = atspi_accessible_get_state_set(obj);
+Eina_Bool object_has_focused_state(AtspiAccessible *obj)
+{
+ return _object_has_state(obj, ATSPI_STATE_FOCUSED);
+}
- if (atspi_state_set_contains(ss, ATSPI_STATE_HIGHLIGHTED))
- ret = EINA_TRUE;
- g_object_unref(ss);
- return ret;
+Eina_Bool object_has_highlighted_state(AtspiAccessible *obj)
+{
+ return _object_has_state(obj, ATSPI_STATE_HIGHLIGHTED);
}
int get_percent_value(double value, double lower, double upper)
return !strncmp (s1, s2, l1);
}
+
+Live_Region_Politeness try_parse_politeness(GHashTable *attrs)
+{
+ Live_Region_Politeness mode = ACCESSIBLE_LIVE_REGION_OFF;
+ if (attrs) {
+ const char *val = g_hash_table_lookup(attrs, "container-live");
+ DEBUG("got attributes, containter-live is '%s'", val);
+ if (val) {
+ if (g_strcmp0(val, "polite") == 0) mode = ACCESSIBLE_LIVE_REGION_POLITE;
+ else if (g_strcmp0(val, "assertive") == 0) mode = ACCESSIBLE_LIVE_REGION_ASSERTIVE;
+ }
+ }
+ DEBUG("speaking politeness mode is %d", mode);
+ return mode;
+}