Pure Wayland client side decoration

I am currently building a pure Wayland Application (my target platform is Ubuntu 24), Mutter does not seem to support SSD: server side decoration . I am trying to use libdecor but for some reason the application exits. My code looks like this:

wl_surface_commit(mystate.surface);  //must commit everything before the loop

struct wl_callback *cb = wl_surface_frame(mystate.surface);
wl_callback_add_listener(cb, &callbackoutputlistener, &mystate);

auto context = libdecor_new(display, &libdecor_iface);
mystate.decorframe = libdecor_decorate(context, mystate.surface,&libdecor_frame_iface, &mystate);
libdecor_frame_set_app_id(mystate.decorframe, "libdecor-demo");
libdecor_frame_set_title(mystate.decorframe, "libdecor demo");
libdecor_frame_map(mystate.decorframe);
libdecor_frame_set_min_content_size(mystate.decorframe, 1000, 1000);

//then the loop
while(…){}

If I dont use libdecom, then everything works fine

Yes, mutter does not support server side decorations for Wayland clients.

My code is (stripped it down to only have wayland related stuff) is available here:
https://bitbucket.org/asif_bahrainwala/waylandclient/src

when I enable #define USELIBDECOR (in main.h) , I get a memory leak (address sanitizer says so) , when I comment it out, libdecor is not in use and everything works fine

I am unable to debug this. I believe that there must be an event pending.

The libdecor library I got from: libdecor / libdecor · GitLab

but then again, even the code at Gtk – 4.0: Getting Started with GTK shows memory leaks (on valgrind)

You should read the developer documentation for Valgrind before using it with GLib and GTK based application code.

1 Like