XDG_decoration protocol questions
Mariano
malfer at telefonica.net
Tue May 21 16:55:50 UTC 2024
I have added to my MGRX Wayland videodriver (mgrx.fgrim.com) support for the
XDG_decoration protocol to have server side window decorations.
After doing the wayland-scanner magic to generate the .h include and the
.c glue code
Adding the include:
#include "xdg-decoration-client-protocol.h"
Bind the global register:
} else if (strcmp(interface,
zxdg_decoration_manager_v1_interface.name) == 0) {
state->zxdg_decoration_manager_v1 = wl_registry_bind(
wl_registry, name, &zxdg_decoration_manager_v1_interface, 1);
//fprintf(stderr, "zxdg_decoration_manager_v1 detected\n");
}
After getting the xdg_surface get the zxdg_toplevel_decoration_v1 object
and add the listener:
/* if the compositor support it (like the KDE one) ask for server
side decoration */
if (_WGrState.zxdg_decoration_manager_v1) {
_WGrState.zxdg_toplevel_decoration_v1 =
zxdg_decoration_manager_v1_get_toplevel_decoration(
_WGrState.zxdg_decoration_manager_v1,
_WGrState.xdg_toplevel);
zxdg_toplevel_decoration_v1_add_listener(_WGrState.zxdg_toplevel_decoration_v1,
&zxdg_toplevel_decoration_v1_listener, &_WGrState);
}
And declare the listener:
static void toplevel_decoration_v1_configure(void *data,
struct zxdg_toplevel_decoration_v1
*zxdg_toplevel_decoration_v1,
uint32_t mode)
{
//fprintf(stderr, "zxdg_decoration_manager_v1 mode %d\n", mode);
}
static const struct zxdg_toplevel_decoration_v1_listener
zxdg_toplevel_decoration_v1_listener = {
.configure = toplevel_decoration_v1_configure,
};
After that you have (in KDE) your window magically server side decorated.
My questions are (thinking in servers other than KDE):
1-Can I assume the server will send the configure event even if I have not
sent a set_mode request?
2-If the mode reported by the configure event is not 2, must we need to send
a set_mode(2) request and wait for the next configure event before attaching
the first buffer to the wl_surface?
Thanks
Mariano Alvarez
More information about the wayland-devel
mailing list