Force assertive politeness policy for highlighted/focused object 43/293343/1 accepted/tizen/unified/20230613.170821
authorLukasz Oleksak <l.oleksak@samsung.com>
Wed, 24 May 2023 15:08:32 +0000 (17:08 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Wed, 24 May 2023 15:08:32 +0000 (17:08 +0200)
Change-Id: I1d15b32a2eeb5e12d7bec30a16e00ec6f24c74b7

include/utils.h
src/app_tracker.c
src/screen_reader_spi.c
src/utils.c

index e7c8e94ba9ebbf8e840f55ead9282d553f0c65d5..916cf2eda782680996520ea3baeb798373cb2efb 100644 (file)
@@ -148,7 +148,7 @@ int get_percent_value(double value, double lower, double upper);
 
 Eina_Bool is_same_str (const char *s1, const char *s2);
 
-Live_Region_Politeness try_parse_politeness(GHashTable *attrs);
+Live_Region_Politeness try_parse_politeness(GHashTable *attrs, Eina_Bool assertive_by_default);
 
 static inline void ESAL(Eina_Strbuf *buf, const char *txt)
 {
index f512733f75dd0bb958da73e98e7d04d53263742d..83bfa5223789179fb21f67411a5d2dabc66ed704 100644 (file)
@@ -148,8 +148,8 @@ static void _read_value(AtspiAccessible *obj)
        if (!rcd)
                return;
 
-       Live_Region_Politeness mode = try_parse_politeness(rcd->attributes);
-       if (object_has_highlighted_state(obj) || mode != ACCESSIBLE_LIVE_REGION_OFF) {
+       Live_Region_Politeness mode = try_parse_politeness(rcd->attributes, object_has_highlighted_state(obj));
+       if (mode != ACCESSIBLE_LIVE_REGION_OFF) {
                char* text_to_speak = reading_composer_value_text_get(rcd);
                tw_speak_and_free(text_to_speak, mode == ACCESSIBLE_LIVE_REGION_ASSERTIVE ? 1 : 0);
        }
@@ -521,7 +521,7 @@ static void _on_atspi_event_cb(AtspiEvent *event, void *user_data)
 
                        GHashTable *attrs = atspi_accessible_get_attributes(event->source, NULL);
 
-                       Live_Region_Politeness mode = try_parse_politeness(attrs);
+                       Live_Region_Politeness mode = try_parse_politeness(attrs, object_has_highlighted_state(event->source));
 
                        if (attrs)
                                g_hash_table_destroy(attrs);
index 7a395cf66572d32b1c0a4fa6f828e6291148ffa0..e6bf8767d815e657ab2ed181e4c9ee64c4bb938c 100644 (file)
@@ -306,15 +306,15 @@ void spi_event_get_text_to_read(
        } 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 = try_parse_politeness(attrs);
-               if (object_has_focused_state(event->source) || mode != ACCESSIBLE_LIVE_REGION_OFF) {
+               Live_Region_Politeness mode = try_parse_politeness(attrs, object_has_focused_state(event->source));
+               if (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)) {
-               Live_Region_Politeness mode = try_parse_politeness(attrs);
-               if (object_has_focused_state(event->source) || mode != ACCESSIBLE_LIVE_REGION_OFF) {
+               Live_Region_Politeness mode = try_parse_politeness(attrs, object_has_focused_state(event->source));
+               if (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;
@@ -324,8 +324,8 @@ void spi_event_get_text_to_read(
                        spi->ignore_next_caret_move = EINA_TRUE;
                }
        } else if (!g_strcmp0(event->type, VALUE_CHANGED_SIG)) {
-               Live_Region_Politeness mode = try_parse_politeness(attrs);
-               if (object_has_focused_state(event->source) || mode != ACCESSIBLE_LIVE_REGION_OFF) {
+               Live_Region_Politeness mode = try_parse_politeness(attrs, object_has_focused_state(event->source));
+               if (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;
index e4765ae8ee9fa7fd58dafab33cf32db6cd4b8684..f8d7da4397cd160f3a01ccea104d9461e35d8d09 100644 (file)
@@ -318,15 +318,16 @@ Eina_Bool is_same_str (const char *s1, const char *s2)
   return !strncmp (s1, s2, l1);
 }
 
-Live_Region_Politeness try_parse_politeness(GHashTable *attrs)
+Live_Region_Politeness try_parse_politeness(GHashTable *attrs, Eina_Bool assertive_by_default)
 {
-       Live_Region_Politeness mode = ACCESSIBLE_LIVE_REGION_OFF;
+       Live_Region_Politeness mode = assertive_by_default ? ACCESSIBLE_LIVE_REGION_ASSERTIVE : 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;
+                       else if (g_strcmp0(val, "off") == 0) mode = ACCESSIBLE_LIVE_REGION_OFF;
                }
        }
        DEBUG("speaking politeness mode is %d", mode);