Using libweston with GTK/GDK

Pekka Paalanen ppaalanen at
Wed May 1 09:34:54 UTC 2019

On Wed, 1 May 2019 03:24:04 +0100
adlo <adloconwy at> wrote:

> > On 29 Oct 2018, at 09:33, Pekka Paalanen <ppaalanen at> wrote:
> > 
> > the only opinionated advice I can give you is don't do it. Instead, put
> > the GTK stuff in a separate process, let your compositor fork & exec
> > it, and talk to it through your own private protocol extension for the
> > special bits you need.  
> What are the basics for creating a private protocol extension, i.e. what's the minimum boilerplate code needed? What's a simple example of how to implement a request between the two processes? The Weston source code is difficult to follow.
> How do I allow the child process to call functions and pass data to the parent and vice versa?

Hi adlo,

it is all just the normal Wayland protocol exchange but with a new
interface of your own design. I'm not sure if there is a really
minimal example, but I'll list at least some.

One example of such private protocol extension is

The server-side implementation of it is in shell.c and the
entrypoint to that is

			     &weston_desktop_shell_interface, 1,
			     shell, bind_desktop_shell)

which installs the protocol extension in the compositor. You can
see everything about the implementation by following all callbacks
that get registered, starting with bind_desktop_shell().

The privacy of the protocol extension, the installed wayland global
really, is achieved in

	shell->child.client = weston_client_start(shell->compositor,

which creates the Wayland connection before forking the child
process and bind_desktop_shell() then verifying the client trying
to bind to the global is the client that was forked.

The client-side implementation is in desktop-shell.c with the entry
point at

	if (!strcmp(interface, "weston_desktop_shell")) {
		desktop->shell = display_bind(desktop->display,
is another example of a custom protocol extension (not for a shell
helper client though), with implementations in
Again, you can find the entry points with wl_global_create() and
display_bind(), respectively.

There is also
used by the test suite exclusively, implemented in
this time using wl_global_create() and wl_registry_bind().

Yet another external example is which contains its own
additional protocol extensions and both a weston plugin and a
GTK-based helper client. Unfortunately it hasn't been touched in a
few years, so it probably won't work with a recent Weston.

Hope this helps.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the wayland-devel mailing list