pywlroots
pywlroots copied to clipboard
Question: implementing custom protocol on the server side.
I was trying to bind a protocol I am developing but I've never done this in python so all of this is pretty much a guess.
import logging
from typing import Any
# TODO: Figure out why this breaks mypy.
from pywayland.protocol.next_control_v1 import NextControlV1 # ignore: type
from pywayland.protocol_core.globals import Global
from pywayland.protocol_core.resource import Resource
from pywayland.server import Display
from pywayland.server.client import Client
log = logging.getLogger("Next: Control")
class Control(Global):
def __init__(self, display: Display) -> None:
self.interface = NextControlV1
self._callback_info = {"interface": self.interface, "bind_func": self.bind}
super().__init__(display, 1)
self.bind_func(self.bind)
log.info("Created next_control_v1 global")
def bind(self, client: Client, data: Any = None, version: int=0, id: int=1) -> None:
NextControlV1.resource_class(client)
def destroy(self) -> None:
super().destroy()
this is the gist of what I came up with but the bind function doesn't seem to return a client which tells me I'm implementing the bind func incorrectly, @m-col. Is there any example I can maybe look at?
Sorry, I don't know, I'm not aware of any examples with pywlroots and I've never done anything with globals or custom protocols so can't help here :/
Hmm, interesting. Is the protocol defined in xml or are you doing it purely in Python? If it were, you could use the pywayland scanner to generate the protocol. I'm honestly not sure what it'd mean to define one Python alone, a lot of the functionality was setup to be built up from xml. There is a reasonable amount of things that are done in some of the automagic decorators and cffi cdata generation that might need to be setup manually here.
Hmm, interesting. Is the protocol defined in xml or are you doing it purely in Python? If it were, you could use the pywayland scanner to generate the protocol. I'm honestly not sure what it'd mean to define one Python alone, a lot of the functionality was setup to be built up from xml. There is a reasonable amount of things that are done in some of the automagic decorators and cffi cdata generation that might need to be setup manually here.
It's this protocol https://github.com/Shinyzenith/NextWM/blob/master/protocols/next-control-v1.xml
Hence the following import: from pywayland.protocol.next_control_v1 import NextControlV1 # ignore: type