Scriptable window management
With Weston, it is relatively hard to customize window management for special use cases. One possibility to make it easier is to have a scriptable window management API.
I think embedding Lua in desktop-shell plugin might be a good start. The scripting should be in-process, fast, single-threaded, synchronous, and not compromise the size or stability of Weston. It would be a single script, and if not provided externally, a built-in default script would be used. @daniels characterizes Lua like this:
it's easy to write, has good tooling, a really tiny runtime to embed, no strong dependency system like Ruby/Node/Rust/etc, already used for a lot of extension scripting in a lot of other places, and really really easy FFI for C
#518 made me think about this (once again) and would be a good first goal use case.
We'd start with two hooks that can be implemented in the script, according to the xdg-shell window mapping procedure:
- initial top-level configure: basically setting the initial window state and preferred size before the client draws the first time;
-
map: set the window position and layer (by
enum weston_layer_position
)
Input to the hooks would be an object representing the top-level window, allowing to inspect app-id and title, which the script can use to key off special handling.
We'd have a new debug scope that would print all calls into and from a WM script. Perhaps another scope to dump the WM script as a whole (so you can get the default script out of Weston, too).
The script needs to be versioned, probably just to recognize and avoid loading incompatible scripts when the API evolves. Perhaps a simple semantic versioning, where the script declares what version it requires? This should probably be independent from libweston versioning (it is provided by desktop-shell plugin too, which is a Weston and not libweston plugin).
Long term goal could be to move all the generic policy from shell.c
to a default script.
This could also be useful for automated testing of xdg-shell and desktop-shell features as a test could have the window manager perform specific actions.