Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ doc = false
cbindgen = []

[dependencies]
accesskit = "0.22.0"
accesskit = "0.23.0"

[target.'cfg(target_os = "windows")'.dependencies]
accesskit_windows = "0.30.0"
accesskit_windows = "0.31.1"

[target.'cfg(target_os = "macos")'.dependencies]
accesskit_macos = "0.23.0"
accesskit_macos = "0.24.1"

[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies]
accesskit_unix = "0.18.0"
accesskit_unix = "0.19.1"

[profile.release]
lto = true
Expand Down
1 change: 1 addition & 0 deletions cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ renaming_overrides_prefixing = true
"SortDirection" = "accesskit_sort_direction"
"TextAlign" = "accesskit_text_align"
"TextDecoration" = "accesskit_text_decoration"
"TextDecorationStyle" = "accesskit_text_decoration_style"
"TextDirection" = "accesskit_text_direction"
"Toggled" = "accesskit_toggled"
"Vec2" = "accesskit_vec2"
Expand Down
2 changes: 1 addition & 1 deletion examples/sdl/hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void do_action(accesskit_action_request *request, void *userdata) {
SDL_zero(event);
event.type = state->event_type;
event.user.windowID = state->window_id;
event.user.data1 = (void *)((uintptr_t)(request->target));
event.user.data1 = (void *)((uintptr_t)(request->target_node));
if (request->action == ACCESSKIT_ACTION_FOCUS) {
event.user.code = SET_FOCUS_MSG;
SDL_PushEvent(&event);
Expand Down
4 changes: 2 additions & 2 deletions examples/windows/hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ accesskit_tree_update *build_initial_tree(void *userdata) {
void do_action(accesskit_action_request *request, void *userdata) {
HWND window = userdata;
if (request->action == ACCESSKIT_ACTION_FOCUS) {
LPARAM lparam = (LPARAM)(request->target);
LPARAM lparam = (LPARAM)(request->target_node);
PostMessage((HWND)window, SET_FOCUS_MSG, 0, lparam);
} else if (request->action == ACCESSKIT_ACTION_CLICK) {
LPARAM lparam = (LPARAM)(request->target);
LPARAM lparam = (LPARAM)(request->target_node);
PostMessage((HWND)window, DO_DEFAULT_ACTION_MSG, 0, lparam);
}
accesskit_action_request_free(request);
Expand Down
67 changes: 55 additions & 12 deletions include/accesskit.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,19 @@ enum accesskit_text_align
typedef uint8_t accesskit_text_align;
#endif // __cplusplus

enum accesskit_text_decoration
enum accesskit_text_decoration_style
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
ACCESSKIT_TEXT_DECORATION_SOLID,
ACCESSKIT_TEXT_DECORATION_DOTTED,
ACCESSKIT_TEXT_DECORATION_DASHED,
ACCESSKIT_TEXT_DECORATION_DOUBLE,
ACCESSKIT_TEXT_DECORATION_WAVY,
ACCESSKIT_TEXT_DECORATION_STYLE_SOLID,
ACCESSKIT_TEXT_DECORATION_STYLE_DOTTED,
ACCESSKIT_TEXT_DECORATION_STYLE_DASHED,
ACCESSKIT_TEXT_DECORATION_STYLE_DOUBLE,
ACCESSKIT_TEXT_DECORATION_STYLE_WAVY,
};
#ifndef __cplusplus
typedef uint8_t accesskit_text_decoration;
typedef uint8_t accesskit_text_decoration_style;
#endif // __cplusplus

enum accesskit_text_direction
Expand Down Expand Up @@ -625,6 +625,24 @@ typedef struct accesskit_opt_node_id {
accesskit_node_id value;
} accesskit_opt_node_id;

/**
* A 128-bit identifier for a tree, represented as a UUID in big-endian byte
* order.
*/
typedef struct accesskit_tree_id {
uint8_t bytes[16];
} accesskit_tree_id;

/**
* Represents an optional value.
*
* If `has_value` is false, do not read the `value` field.
*/
typedef struct accesskit_opt_tree_id {
bool has_value;
struct accesskit_tree_id value;
} accesskit_opt_tree_id;

/**
* Represents an optional value.
*
Expand Down Expand Up @@ -675,14 +693,22 @@ typedef struct accesskit_opt_color {
struct accesskit_color value;
} accesskit_opt_color;

/**
* The style and color for a type of text decoration.
*/
typedef struct accesskit_text_decoration {
accesskit_text_decoration_style style;
struct accesskit_color color;
} accesskit_text_decoration;

/**
* Represents an optional value.
*
* If `has_value` is false, do not read the `value` field.
*/
typedef struct accesskit_opt_text_decoration {
bool has_value;
accesskit_text_decoration value;
struct accesskit_text_decoration value;
} accesskit_opt_text_decoration;

typedef struct accesskit_lengths {
Expand Down Expand Up @@ -963,7 +989,8 @@ typedef struct accesskit_opt_action_data {

typedef struct accesskit_action_request {
accesskit_action action;
accesskit_node_id target;
struct accesskit_tree_id target_tree;
accesskit_node_id target_node;
struct accesskit_opt_action_data data;
} accesskit_action_request;

Expand Down Expand Up @@ -1036,6 +1063,8 @@ typedef struct accesskit_opt_lresult {
extern "C" {
#endif // __cplusplus

extern const struct accesskit_tree_id ACCESSKIT_TREE_ID_ROOT;

accesskit_role accesskit_node_role(const struct accesskit_node *node);

void accesskit_node_set_role(struct accesskit_node *node, accesskit_role value);
Expand Down Expand Up @@ -1354,6 +1383,14 @@ void accesskit_node_set_popup_for(struct accesskit_node *node,

void accesskit_node_clear_popup_for(struct accesskit_node *node);

struct accesskit_opt_tree_id accesskit_node_tree_id(
const struct accesskit_node *node);

void accesskit_node_set_tree_id(struct accesskit_node *node,
struct accesskit_tree_id value);

void accesskit_node_clear_tree_id(struct accesskit_node *node);

/**
* Only call this function with a string that originated from AccessKit.
*/
Expand Down Expand Up @@ -1932,23 +1969,23 @@ struct accesskit_opt_text_decoration accesskit_node_overline(
const struct accesskit_node *node);

void accesskit_node_set_overline(struct accesskit_node *node,
accesskit_text_decoration value);
struct accesskit_text_decoration value);

void accesskit_node_clear_overline(struct accesskit_node *node);

struct accesskit_opt_text_decoration accesskit_node_strikethrough(
const struct accesskit_node *node);

void accesskit_node_set_strikethrough(struct accesskit_node *node,
accesskit_text_decoration value);
struct accesskit_text_decoration value);

void accesskit_node_clear_strikethrough(struct accesskit_node *node);

struct accesskit_opt_text_decoration accesskit_node_underline(
const struct accesskit_node *node);

void accesskit_node_set_underline(struct accesskit_node *node,
accesskit_text_decoration value);
struct accesskit_text_decoration value);

void accesskit_node_clear_underline(struct accesskit_node *node);

Expand Down Expand Up @@ -2263,6 +2300,12 @@ void accesskit_tree_update_clear_tree(struct accesskit_tree_update *update);
void accesskit_tree_update_set_focus(struct accesskit_tree_update *update,
accesskit_node_id focus);

struct accesskit_tree_id accesskit_tree_update_get_tree_id(
const struct accesskit_tree_update *update);

void accesskit_tree_update_set_tree_id(struct accesskit_tree_update *update,
struct accesskit_tree_id tree_id);

/**
* Caller must call `accesskit_string_free` with the return value.
*/
Expand Down
52 changes: 50 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,29 @@ macro_rules! vec_property_methods {

pub type node_id = u64;

/// A 128-bit identifier for a tree, represented as a UUID in big-endian byte order.
#[repr(C)]
pub struct tree_id {
pub bytes: [u8; 16],
}

impl From<TreeId> for tree_id {
fn from(id: TreeId) -> Self {
Self {
bytes: *id.0.as_bytes(),
}
}
}

impl From<tree_id> for TreeId {
fn from(id: tree_id) -> Self {
TreeId(Uuid::from_bytes(id.bytes))
}
}

#[no_mangle]
pub static ACCESSKIT_TREE_ID_ROOT: tree_id = tree_id { bytes: [0; 16] };

slice_struct! { node_ids, NodeId, node_id }

macro_rules! node_id_vec_property_methods {
Expand Down Expand Up @@ -468,6 +491,12 @@ node_id_property_methods! {
(accesskit_node_popup_for, popup_for, accesskit_node_set_popup_for, set_popup_for, accesskit_node_clear_popup_for, clear_popup_for)
}

opt_struct! { opt_tree_id, tree_id }

simple_property_methods! {
accesskit_node_tree_id, tree_id, opt_tree_id, accesskit_node_set_tree_id, set_tree_id, tree_id, accesskit_node_clear_tree_id, clear_tree_id
}

/// Only call this function with a string that originated from AccessKit.
#[no_mangle]
pub extern "C" fn accesskit_string_free(string: *mut c_char) {
Expand Down Expand Up @@ -938,6 +967,7 @@ impl tree_update {
let update = TreeUpdate {
nodes: vec![],
tree: None,
tree_id: TreeId::ROOT,
focus: focus.into(),
};
BoxCastPtr::to_mut_ptr(update)
Expand All @@ -951,6 +981,7 @@ impl tree_update {
let update = TreeUpdate {
nodes: Vec::with_capacity(capacity),
tree: None,
tree_id: TreeId::ROOT,
focus: focus.into(),
};
BoxCastPtr::to_mut_ptr(update)
Expand Down Expand Up @@ -992,6 +1023,21 @@ impl tree_update {
update.focus = focus.into();
}

#[no_mangle]
pub extern "C" fn accesskit_tree_update_get_tree_id(update: *const tree_update) -> tree_id {
let update = ref_from_ptr(update);
update.tree_id.into()
}

#[no_mangle]
pub extern "C" fn accesskit_tree_update_set_tree_id(
update: *mut tree_update,
tree_id: tree_id,
) {
let update = mut_from_ptr(update);
update.tree_id = tree_id.into();
}

/// Caller must call `accesskit_string_free` with the return value.
#[no_mangle]
pub extern "C" fn accesskit_tree_update_debug(tree_update: *const tree_update) -> *mut c_char {
Expand Down Expand Up @@ -1042,15 +1088,17 @@ impl From<ActionData> for action_data {
#[repr(C)]
pub struct action_request {
pub action: Action,
pub target: node_id,
pub target_tree: tree_id,
pub target_node: node_id,
pub data: opt_action_data,
}

impl From<ActionRequest> for action_request {
fn from(request: ActionRequest) -> action_request {
Self {
action: request.action,
target: request.target.into(),
target_tree: request.target_tree.into(),
target_node: request.target_node.into(),
data: request.data.into(),
}
}
Expand Down
Loading