[RFC weston 0/2] Plugin registry

Pekka Paalanen ppaalanen at gmail.com
Wed Mar 23 13:56:35 UTC 2016

From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


here are two patches. The first one implements the plugin registry, and the
second one is a demonstration on how you might use it.

Plugin registry is meant for plugins to hook up to other plugins. A plugin
exporting an API registers it, and a plugin looking for to use an API can find
it. An API is essentially a virtual function table, a struct filled with
function pointers. Each API has a name that identifies it. Multiple plugins
cannot register the same API name, nor can an API be unregistered to keep the
implementation simple.

The main benefit of this approach is that we do not need to store an explicit
pointer in struct weston_compositor for evert API one might expose to other
plugins or the core. It's a tiny step towards making weston_compositor opaque.

APIs like struct weston_renderer probably would not use plugin registry as is,
because the core always needs exactly one renderer, and a renderer is
initialized explicitly by a backend. The plugin registry is meant for more
dynamic things. The example of using a shell API from the xwayland plugin is
more towards the intended use, though perhaps arguable.

I am working on something that is not ready to be posted yet, but I thought
this little piece of it might be of interest already, particularly for
libweston, maybe.

I would consider patch 1 to be of mergeable quality, if there just was a user
for the feature.


Pekka Paalanen (2):
  compositor: add plugin-registry
  RFC: Example of using plugin-registry

 Makefile.am                  |   8 +++
 desktop-shell/shell-api.h    | 125 +++++++++++++++++++++++++++++++++
 desktop-shell/shell.c        |  27 +++++++
 src/compositor.c             |   6 ++
 src/compositor.h             |   2 +
 src/plugin-registry.c        | 163 +++++++++++++++++++++++++++++++++++++++++++
 src/plugin-registry.h        |  55 +++++++++++++++
 tests/plugin-registry-test.c | 101 +++++++++++++++++++++++++++
 xwayland/launcher.c          |  16 +++++
 xwayland/xwayland.h          |   3 +
 10 files changed, 506 insertions(+)
 create mode 100644 desktop-shell/shell-api.h
 create mode 100644 src/plugin-registry.c
 create mode 100644 src/plugin-registry.h
 create mode 100644 tests/plugin-registry-test.c


More information about the wayland-devel mailing list