pushUpdates
Must be called at the end of each frame. Pushes any nodes created during the frame to the accesskit tree.
Parameters
- self:*AccessKit
- *AccessKit
Source
Implementation
pub fn pushUpdates(self: *AccessKit) void {
const io = dvui.io;
self.mutex.lockUncancelable(io);
defer self.mutex.unlock(io);
if (builtin.os.tag == .linux)
c.accesskit_unix_adapter_update_window_focus_state(self.adapter.?, true);
if (self.status != .on) {
return;
}
const window: *dvui.Window = @alignCast(@fieldParentPtr("accesskit", self));
if (debug_textruns) {
var current_parent: dvui.Id = .zero;
for (self.text_runs.items) |run| {
std.debug.print("---------------------------------\n", .{});
const ak_node = self.nodes.get(run.node_id) orelse unreachable;
const char_lengths = nodeCharacterLengths(ak_node);
const char_widths = nodeCharacterWidths(ak_node);
const char_pos = nodeCharacterPositions(ak_node);
const word_starts = nodeWordStarts(ak_node);
std.debug.print("TEXT_RUN [{x}:{x}]: value = `{s}`\n", .{ run.node_parent_id, run.node_id, std.mem.span(nodeValue(ak_node)) });
std.debug.print("TEXT_RUN [{x}:{x}]: bounds = {any}\n", .{ run.node_parent_id, run.node_id, nodeBounds(ak_node) });
std.debug.print("TEXT_RUN [{x}:{x}]: controlling_widget = {x}\n", .{ run.node_parent_id, run.node_id, run.controlling_widget_id });
std.debug.print("TEXT_RUN [{x}:{x}]: lengths = {s}\n", .{ run.node_parent_id, run.node_id, fmtSlice(window.arena(), char_lengths.values[0..char_lengths.length]) });
std.debug.print("TEXT_RUN [{x}:{x}]: positions = {any}\n", .{ run.node_parent_id, run.node_id, char_pos.values[0..char_pos.length] });
std.debug.print("TEXT_RUN [{x}:{x}]: widths = {any}\n", .{ run.node_parent_id, run.node_id, char_widths.values[0..char_widths.length] });
std.debug.print("TEXT_RUN [{x}:{x}]: word_starts = {any}\n", .{ run.node_parent_id, run.node_id, word_starts.values[0..word_starts.length] });
std.debug.print("TEXT_RUN [{x}:{x}]: prev_on_line = {?x}\n", .{ run.node_parent_id, run.node_id, fmtOptional(nodePreviousOnLine(ak_node)) });
std.debug.print("TEXT_RUN [{x}:{x}]: next_on_line = {?x}\n", .{ run.node_parent_id, run.node_id, fmtOptional(nodeNextOnLine(ak_node)) });
if (current_parent != run.node_parent_id) {
const ak_node_parent = self.nodes.get(run.node_parent_id) orelse unreachable;
const parent_val = nodeValue(ak_node);
if (parent_val != null)
std.debug.print("TEXT_RUN [{x}:{x}]: parent_value = `{s}`\n", .{ run.node_parent_id, run.node_id, std.mem.span(parent_val) })
else
std.debug.print("TEXT_RUN [{x}:{x}]: parent_value = null\n", .{ run.node_parent_id, run.node_id });
const sel = nodeTextSelection(ak_node_parent);
if (!sel.has_value) {
std.debug.print("TEXT_RUN [{x}:{x}]: text_selection = null\n", .{ run.node_parent_id, run.node_id });
} else {
std.debug.print(
"TEXT_RUN [{x}:{x}]: text_selection = {{ anchor = {{ node = {x}, character_index = {} }}, focus = {{ node = {x}, character_index = {} }} }}\n",
.{ run.node_parent_id, run.node_id, sel.value.anchor.node, sel.value.anchor.character_index, sel.value.focus.node, sel.value.focus.character_index },
);
}
current_parent = run.node_parent_id;
}
}
}
// Take any actions from this frame and create events for them.
// Created events will not be processed until the start of the next frame.
self.processActions();
if (builtin.os.tag == .windows) {
if (dvui.backend.kind == .dx11) {
const queued_events = c.accesskit_windows_adapter_update_if_active(self.adapter.?, frameTreeUpdate, self);
if (queued_events) |events| {
c.accesskit_windows_queued_events_raise(events);
}
} else {
const queued_events = c.accesskit_windows_subclassing_adapter_update_if_active(self.adapter.?, frameTreeUpdate, self);
if (queued_events) |events| {
c.accesskit_windows_queued_events_raise(events);
}
}
} else if (builtin.os.tag.isDarwin()) {
const queued_events = c.accesskit_macos_subclassing_adapter_update_if_active(self.adapter.?, frameTreeUpdate, self);
if (queued_events) |events| {
c.accesskit_macos_queued_events_raise(events);
}
} else if (builtin.os.tag == .linux) {
c.accesskit_unix_adapter_update_if_active(self.adapter.?, frameTreeUpdate, self);
}
self.nodes.clearAndFree(window.gpa);
}