flat_navi: Support returning directly to the old root 45/286845/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, 13 Jan 2023 12:43:00 +0000 (13:43 +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 a76ac6d8331addbb486374beb34610403aaede0f..4d5fcb8e97152d466e8a2d34e024649eecee2b2f 100644 (file)
@@ -416,8 +416,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");
@@ -429,12 +439,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");