Casilda 1.6 Released!
DnD Release
I am very happy to announce a new version of Casilda!
A simple Wayland compositor widget for Gtk 4 originally created for Cambalache
This new version brings Drag&Drop and clipboard support / integration with the host compositor which means you can drag something from a host application and drop it on an application window embedded in a Casilda compositor widget and vice versa!
After a very rugged GUADEC presentation where I tried to show how to create simple Gtk application from slides made with Cambalache using a Casilda compositor to embed GNOME Builder and Cambalache itself I decided to fix all the issues I found so I could redo the presentation and upload it as a video.

This is a screenshot of the slider window, inside it there is a Casilda compositor (green line) used to embed a Cambalache instance which uses another CasildaCompositor (red line) to preview the UI.
Things that possi-bly could go wrong and did:
- Clipboard (Could not copy paste snippets)
- Keyboard numeric pad
- Keyboard modifiers in pointer events (I could not use Alt+Click to force create widgets)
- Example application connected to host compositor instead of Casilda widget
- Gnome Builder fullscreen window state broken
- Popover tooltips crash
After fixing all the bugs and keyboard support I started working on adding Clipboard integration with the host.
Clipboard support
Integrating the clipboard between Casilda and Gtk was fairly easy since all I needs to be done is copy all the clipboard data provided by wlroots wlr_seat::request_set_selection event to GdkClipboard and call wlr_seat_set_selection() on GdkClipboard changed signal.
Wlroots client to Gtk
In other to do this I created a new GdkContentProvider that uses a wlr_data_source as the source of the data and set the provider as the content of the clipboard with gdk_clipboard_set_content().
Internally when a clients wants to get data from the clipboard the new provider creates a unix pipe to read data from wlroots by writing to the pipe with wlr_data_source_send() and reading form the other end using g_output_stream_splice_async().
Gtk to wlroots to client
To go in the other direction I created a new wlr_data_source that uses a GdkClipboard as source and set selection with wlr_seat_set_selection()
Internally gdk_clipboard_read_async() is called to initiate the data read when wlr_data_source send() method is invoked to send the data to the client.
Drag & Drop support
Integrating D&D was not as easy as the clipboard. Setting it up to work within Casilda is easy enough other than wiring up some events all I had to do was draw the drag icon surface.
The first thing I did after getting the drag surface was draw it at the pointer coordinates which produced blurry results since pointer coordinates are fractional which means they do not always align with the pixel grid.
That was all nice and good but now I needed to start integrating the drag with Gtk (host compositor) so right after calling wlr_seat_start_pointer_drag() I created a GdkDrag with gdk_drag_begin() and used gtk_drag_icon_set_from_paintable() to set the drag icon and I noticed it was still blurry!!!

After a minute of confusion I realized that Gnome Shell (mutter) must be making the same mistake I did before so I decided to see if I could fix it!
Thanks to for guiding me and reviewing my MR, Gnome Shell 51 should have sharp drag icons!

Now back to integrating DnD with the host compositor.
These are all the different use cases that are needed to make D&D work transparently across host and guest compositors:
- Casilda client to Casilda client
- Casilda client to Host client
- Host client to Casilda client
Of course wlroots only contemplates the first use case, the other two cases are specific to Casilda.
Casilda to Host
So far we can detect when a client start a drag, let wlroot handle it and create a GdkDrag to let Gtk initiate another drag at the host level.
This means that when a client embedded in a CasildaCompositor initiates a drag there are two simultaneous drags at the same time, in the guest and host compositors. Keep in mind Casilda always delegates drag icon rendering to the host compositor.
During normal operation Casilda gets events from an event controller, but while on a drag operation events are not sent to the client at least not in the normal way, for that you can use a GtkDropTargetAsync and connect to the various signals for example I use drag-motion to forward events to the client.
Host to Casilda
When a Drag is initiated in the host compositor Casilda reuses the GtkDropTargetAsync created to track motion events and connects to drag-enter signal to create a proxy drag source in wlroots and synthesize a button release event on GtkDropTargetAsync::drop to trigger the drop on the guest side.
Here is a screencast off all the different use cases in action.

As you can imagine getting all this to work together correctly is not trivial and I expect to be subtle bugs in different corner cases so please if you find one of those file a bug and include a screencast if possible.
Release Notes
- Add DnD and clipboard support
- Add support xdg_foreign protocol
- Fix modifiers in pointer button press events
- Add keyboard Caps/Num/Scroll Lock support
- Fix popup of popup crash
- Fix maximized/fullscreen state handling
- Fix modifiers flags creation (Evgenii Danilin)
- Drop cursor surface listeners when the surface is destroyed (Evgenii Danilin)
- Close dup’d plane FDs when a dmabuf import fails (Evgenii Danilin)
- Advertise a valid output scale to avoid a scale-0 assert (Evgenii Danilin)
- Unref the wayland GSource (Evgenii Danilin)
- Meson config cleanup (Val Packett)
- Use gtk api for snapping to device pixel grid
Fixed Issues
- #20 “SIGSEGV in server_request_acvtivate”
Where to get it?
Source code lives on GNOME gitlab here
git clone https://gitlab.gnome.org/jpu/casilda.git
Matrix channel
Have any question? come chat with us at #cambalache:gnome.org
Mastodon
Follow me in Mastodon @xjuan to get news related to Casilda and Cambalache development.
Happy coding!




















Until the next update!