DVUI

frameTreeUpdate

Pushes all the nodes created during the current frame to AccessKit Called once per frame (if accessibility is initialized) Note: This callback is only during the dynamic extent of pushUpdates on the same thread. TODO: verify this.

Parameters

#
instance:?*anyopaque
?*anyopaque

Source

Implementation

#
pub fn frameTreeUpdate(instance: ?*anyopaque) callconv(.c) ?*TreeUpdate {
    var self: *AccessKit = @ptrCast(@alignCast(instance));
    const window: *dvui.Window = @alignCast(@fieldParentPtr("accesskit", self));

    const tree = treeNew(window.wd.id.asU64()) orelse @panic("null");

    // Try and set focus to either focussed widget or sub window. If focus is with a widget without an
    // AccessKit node, default focus to whatever had focus in the previous frame, otherwise to the main window.
    var focused_id: dvui.Id = .zero;
    if (dvui.focusedWidgetId()) |wid| {
        if (self.nodes.contains(wid)) {
            focused_id = dvui.focusedWidgetId().?;
        }
    }
    if (focused_id == .zero) {
        if (self.nodes.contains(dvui.focusedSubwindowId())) {
            focused_id = dvui.focusedSubwindowId();
        } else if (self.nodes.contains(self.prev_focused_id)) {
            focused_id = self.prev_focused_id;
        } else {
            focused_id = window.data().id;
        }
    }
    self.prev_focused_id = focused_id;

    const result = treeUpdateWithCapacityAndFocus(self.nodes.count(), focused_id.asU64());
    treeUpdateSetTree(result, tree);
    var itr = self.nodes.iterator();
    while (itr.next()) |item| {
        treeUpdatePushNode(result, item.key_ptr.asU64(), item.value_ptr.*);
    }
    return result;
}