-
Notifications
You must be signed in to change notification settings - Fork 9
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
Docs #8
Comments
Hi, it's certainly possible to build your own compositor with it. pywm is meant to be quite generic to allow for different compositors (although not as generic as wlroots itself). At the moment I don't have time to provide pywm with a comprehensive documentation... but there are example, you can check out https://github.com/jbuchermn/pywm-fullscreen for a basic setup and trivial compositor and take a look at https://github.com/jbuchermn/newm for more details. Also check out the python sources of pywm (it's not much, compared to the c part). Feel free to ask specific questions here, I'm happy to help. |
Hi! Thank you for the reply!! However pywm and pywlroots still intrigue me. I'll test all three out and find what fits my workflow the best. |
After a few days flailing around newm source there were basic things I still didn't understand; reading the Python part of pywm helped a lot 👍 It is indeed pretty readable without reading the C. Suggested minimal reading order:
Meanwhile I'll start dumping some notes on what I learnt here (mistakes possible)... |
C <-> Python control flowThe C interface is remarkably narrow: from ._pywm import (
run,
register,
damage
) These are ignorant of Python classes; they mostly communicate by python primitive types (strings, numbers, tuples...). Views & widgets are referred to by "handle" integers. They manipulate global C state, so being wrapped by a The main event loop Except for def _query_new_widget(self, new_handle: int) -> int:
if len(self._pending_widgets) > 0:
...
def _query_destroy_widget(self) -> Optional[int]:
if len(self._pending_destroy_widgets) > 0:
return self._pending_destroy_widgets.pop(0)._handle where Python can't tell C create/destroy widgets, it can only queue the requests and wait for C to ask... This kind of buffering on Python side is pervasive, and allows Python code deriving from pywm base classes to run in multiple threads and to pretend it can make changes at any time, mostly forgetting about this inversion of control. Python->C data flow, "DownstreamState"C requests fresh data by calling Many things are buffered in Some data are wrapped in
The role of
|
C->Python data flow, events, "UpstreamState"In general, pywm's private callbacks for events e.g.
|
Widget lifecyclesequenceDiagram
participant C
participant wm as PyWM instance
participant down_state as PyWMDownstreamState instance
participant widget as SomeWidgetClass instance
note over wm: create_widget(WidgetClass, ...)
wm -->> widget: constructor(wm, ...)
activate widget
note over wm: _pending_widgets.push()
C -) wm: _query_new_widget(handle)
note over wm: _pending_widgets.pop(0)
note over wm: _widgets.push()
wm ->> widget: set ._handle
wm -->> C: confirm handle got used
activate C
note over wm, widget: ... Widget exists ...
loop
C -) wm: _update_widget(handle)
wm ->> widget: _update()
opt if damaged
widget ->> widget: process()
widget -->>+ down_state: constructor(...)
end
widget ->> down_state: get(...)
down_state -->>- C: data
end
note over widget: destroy()
widget ->> wm: widget_destroy(widget)
deactivate widget
note over wm: _widgets.pop(...)
note over wm: _pending_destroy_widgets.push()
C -) wm: _query_destroy_widget()
wm -->> C: handle
deactivate C
|
Another neat trick allowed by
|
Hi! Is it possible to make our own compositor with pywm? I find wlroots incredibly hard to understand and if this can help then I'm more than interested in trying it out.
Is there any possibility that documentation/examples will be added ?
The text was updated successfully, but these errors were encountered: