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

seemingly no way to take events from ZwpInputMethodContextV1? #756

Open
chayleaf opened this issue Aug 27, 2024 · 3 comments
Open

seemingly no way to take events from ZwpInputMethodContextV1? #756

chayleaf opened this issue Aug 27, 2024 · 3 comments

Comments

@chayleaf
Copy link

I'm new to using smithay, and I've been trying to implement an IME. From what I can tell, you have to register a global ZwpInputMethodV1, listen for the Activate { id: ZwpInputMethodContextV1 } event, and then additionally listen for events on that id, However, ZwpInputMethodContextV1 doesn't seem to provide any methods that take a QueueHandle. Am I missing something?

@chayleaf chayleaf changed the title seemingly no way to take events from ZwpInputMethodV1? seemingly no way to take events from ZwpInputMethodContextV1? Aug 27, 2024
@laycookie
Copy link

Hello, sadly I haven't ever worked with "Input method v1" and due to its limited support I don't have a way to test it out. However from a quick glance, you are correct that you have to register ZwpInputMethodV1 global and listen to the Activate event, however I'm not exactly sure what you mean by "listen for events on that id".
In any case, my assumption is that when you register ZwpInputMethodV1 and it emits activate event with ZwpInputMethodContextV1. ZwpInputMethodContextV1 will also automatically start emitting events until it is deactivated. However again I don't have a way to test it out so I might be wrong.

You can test it out by just listening if ZwpInputMethodContextV1 is emitting any events with code similar to this.

impl Dispatch<ZwpInputMethodContextV1, ()> for Delegate {
    fn event(
        _: &mut Self,
        _: &WlRegistry,
        event: wl_registry::Event,
        _: &GlobalListContents,
        _: &Connection,
        _: &QueueHandle<Self>,
    ) {
    println!("{:?}", event);
    }
}

It is also worth mentioning that there is Input method v2 which appears to be more widely supported.

@elinorbgr
Copy link
Member

Objects created by an event (like ZwpInputMethodContextV1) are automatically registered to the same event queue as their parent object, so indeed you just need to have the appropriate Dispatch<_> implementation.

One part that is a little clunky is the initialization of the user-data associated with these objects, which is currently done through the event_created_child! macro.

@chayleaf
Copy link
Author

how does a trait implementation even affect behaviour? the current code doesn't complain about Dispatch<ZwpInputMethodContextV1> missing, so I don't think implementing it would change much?

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

No branches or pull requests

3 participants