-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add wl_resource_get_client to lib #39
Conversation
I'm fine with this. Is this something that we could wrap in a |
Something equivalent to this (though the construction could be moved to @classmethod
def from_resource(cls, resource: Resource) -> Client:
"""Look up the corresponding wl_client for a wl_resource
:param resource: The wl_resource
:type resource: pywayland.protocol_core.Resource
:returns:
A `Client` instance.
"""
client = Client.__new__()
client._ptr = lib.wl_resource_get_client(res_ptr)
client._display = None
return client That would be nice. Currently |
Right, something like that! |
807a732
to
69a39aa
Compare
Commit message for info on the updates:
|
This is causing an interesting mypy error:
The new C function added to the ffi lib isn't found by mypy so mypy is complaining about the absent attr. Any ideas how this can be resolved? Not sure I've seen this before with all of the ffi modules we use! |
Right, you can add the stubs to |
69a39aa
to
c526c35
Compare
This provides 2 alternative ways to construct Client instances: - via the `from_resource` class method, from a wl_resource pointer. This accepts a pointer cdata rather than a `Resource` instance, as should be feasible to use this method without requiring an interface to implement the `Resource` generic for it. E.g. the layer shell protocol doesn't have a `Resource` class and this is fine; the requirement would disable usage of `Client.from_resource` from layer shell components. - by passing `ptr=` to `Client` directly to represent an existing wl_client rather than creating a fresh one.
c526c35
to
e70aef5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
I used this for qtile/qtile#3663
Is there a more appropriate way to get access to this function, considering it isn't used by pywayland directly, or is this fine?