flat_navi: Support returning directly to the old root 44/287144/1
authorArtur Świgoń <a.swigon@samsung.com>
Fri, 13 Jan 2023 12:42:57 +0000 (13:42 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Fri, 20 Jan 2023 11:12:15 +0000 (12:12 +0100)
This functionality can be used with drop-down lists, where after dismissing
the list, navigation should resume at the drop-down button.

Change-Id: I067c6a5501e14ea1d46c3d1ab1f30fb1c355450f

src/flat_navi.c

index fd815c4bc077be2f9c2fdaabfbe9806067b3923d..cc83d7957eed0c6081326c1b8d05ac20d80ac148 100644 (file)
@@ -423,8 +423,18 @@ FlatNaviContext *flat_navi_context_create()
        return ret;
 }
 
+static bool _return_to_old_root(AtspiAccessible *old_root)
+{
+       AtspiRole role = atspi_accessible_get_role(old_root, NULL);
+
+       // TODO: check attributes?
+       return (role == ATSPI_ROLE_COMBO_BOX);
+}
+
 int flat_navi_context_setup(FlatNaviContext *ctx, AtspiAccessible *root)
 {
+       AtspiAccessible *old_root;
+
        DEBUG("START");
        if (!ctx) {
                DEBUG("END -- no context");
@@ -436,12 +446,18 @@ int flat_navi_context_setup(FlatNaviContext *ctx, AtspiAccessible *root)
        g_free(id);
        g_free(root_name);
 
-       g_object_unref(ctx->root);
+       old_root = ctx->root;
        ctx->root = root;
        g_object_ref(ctx->root);
 
        g_object_unref(ctx->current);
-       ctx->current = _first(ctx);
+       if (_return_to_old_root(old_root)) {
+               DEBUG("Will return to old root");
+               ctx->current = old_root;
+       } else {
+               g_object_unref(old_root);
+               ctx->current = _first(ctx);
+       }
        ctx->last_entry = LAST_ENTRY_NONE;
 
        DEBUG("END");