Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider Simpler Event Types #77

Closed
TTWNO opened this issue Apr 29, 2023 · 0 comments · Fixed by #82
Closed

Consider Simpler Event Types #77

TTWNO opened this issue Apr 29, 2023 · 0 comments · Fixed by #82

Comments

@TTWNO
Copy link
Member

TTWNO commented Apr 29, 2023

My Odilia PR #116 is causing me serious headaches trying to send events down the pipe. Is it really necessary that an Event be build from a zbus::Message?

Based on what info we have, it should be fairly easy to have each event be a struct with the names of fields. For example:

struct TextCaretMovedEvent {
    pub id: AccessiblePrimitive,
    pub position: i32
}
// or
struct TextChangedEvent {
    pub id: AccessiblePrimitive,
    pub start: i32,
    pub length: i32,
    pub text: String,
}

This makes creating new events and sending them through a function like events::dispatch in Odilia much easier if the innermost type can be easily filled like this with simple public fields.

I also see that Cache::* and Available methods are written manually, which shouldn't be necessary under the new system. I'll basically wrire a macro that generates a slightly modified zvariant::Type implementation for each event.

It would also be nice if any event type could be trivially converted into a Signal that could be sent over DBus. This could simplify a lot of tests.

Imagine code like this in tests:

let a11y_bus = accessibility_,bus::connect().await?;
let caret_moved = CaretMovedEvent {
  id: AccessiblePrimitive {
    id: "/org/a11y/atspi/accessible/69",
    sender: ":1.1",
  },
  position: 420,
};
let msg = caret_moved.try_into()?;
a11y_bus.send_message(msg).await;
@TTWNO TTWNO linked a pull request Apr 30, 2023 that will close this issue
3 tasks
@TTWNO TTWNO linked a pull request May 14, 2023 that will close this issue
5 tasks
@TTWNO TTWNO closed this as completed in #82 Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant