18 Nov 2011

Wayland desktop-shell

When I started on Wayland, it already had a fade to black type of screensaver, which triggered after an idle timeout. Actually, one should talk about wayland-demos and the demo compositor, as Wayland itself is just a protocol and a C-library implementing the protocol.

My plan was to add a locking feature. People usually like to lock their desktop when they leave, to prevent unauthorized access. Locking a desktop means that all windows should be hidden and interaction with any windows should be disabled. In X, implementing a lock requires lots and lots of tricks, and even then, you are not absolutely guaranteed, that it really works. In Wayland on the other hand, where locking can be implemented in the display server  which also manages all windows and input, you can be sure the lock holds.

The Wayland demo compositor consists of the core, backend plugins, and a shell plugin. The backend plugins handle interfacing with the system: getting images out and input events in. There are three backends: x11 for X, drm for running on DRM/KMS without X, and wayland for running the compositor inside another wayland compositor. The shell plugin is where all the excitement happens with respect to locking.

The shell plugin has a client counterpart, called desktop-shell. Between these two is a special interface, also called desktop-shell. The desktop-shell interface is an extension to the Wayland core protocol. Desktop-shell client is responsible for drawing the background and the panel.

Not every client should be able to lock the screen at will, or unlock it. Therefore I made the desktop-shell interface "privileged", which means that only a known client can bind to it. The easiest way to have a known or authenticated client is to have the compositor execute the client directly, and set up a secure communication channel to it, allowing only this client to bind to the interface. Having the whole interface protected, it is easy to define an unlock request that cannot be abused.

As a result, desktop-shell client is nowadays started automatically by the demo compositor. Also, desktop-shell cannot be started manually anymore because it would not be privileged for the compositor. (commit)

Later, Kristian Høgsberg added a configuration file for the desktop-shell client. You can set the panel buttons and the background image (which must be JPEG) in it. The sample file is wayland-desktop-shell.ini and you must copy it to $HOME/.config/ directory and edit for the background image to have a nice demo experience.

The actual screen locking in Wayland demos will be explained in a future post.

No comments:

Post a Comment