The principle Open Source project I’ve been working on for the last few years is Mir. Mir is a library for writing Linux display servers and shells that are independent of the underlying graphics stack. It fits into a similar role as an X server or Weston (a Wayland server) but was initially motivated by Canonical’s vision of “convergent” computing.
The Mir project has had some success in meeting Canonical’s immediate needs – it is running in the Ubuntu Touch phones and tablets, and as an experimental option for running the Unity8 shell on the desktop. But because of the concentration of effort on delivering the features needed for this internal use it hasn’t really addressed the needs of potential users outside of Canonical.
Mir provides two APIs for users: the “client” API is for applications that run on Mir and that is largely used by toolkits. There is support for Mir in the GTK and Qt toolkits, and in SDL. This works pretty well and the Mir client API has remained backwards compatible for a couple of years and can do so for the foreseeable future.
The problem is that the server-side ABI compatibility is broken by almost every release of Mir. This isn’t a big problem for Canonical, as the API is fairly stable and both Mir and Unity8 are in rapid development: rebuilding Unity8 every time Mir is released is a small overhead. But for independent developers the lack of a stable ABI is problematic as they cannot easily synchronize their releases to updates of Mir.
My answer to this is to provide a stable “abstraction layer” written over the top of the current Mir server API that will provide a stable ABI. There are a number of other goals that can be addressed at the same time:
- The API can be considerably narrowed as a lot of things can be customized that are of no interest to shell development;
- A more declarative design style can be followed than the implementation focused approach that the Mir server API follows; and,
- Common facilities can be provided that don’t belong in the Mir libraries.
At the time of writing the Mir Abstraction Layer (miral) is a proof-of-concept, but work is in progress to package an initial version that can support the functionality needed by some examples, and by qtmir (the Qt support used by Unity8).
Building and using MirAL
These instructions assume that you’re using Ubuntu 16.04LTS or later, I’ve not tested earlier Ubuntu versions or other distributions.
You’ll need a few development and utility packages installed, along with the Mir development packages:
$ sudo apt-get install cmake g++ make bzr python-pil uuid-dev libglib2.0-dev $ sudo apt-get install libmirserver-dev libmirclient-dev mirtest-dev $ sudo apt-get install mir-graphics-drivers-desktop libgles2-mesa-dev
(If you’re working on a phone or tablet use mir-graphics-drivers-android in place of mir-graphics-drivers-desktop.)
With these installed you can checkout and build miral:
$ bzr branch lp:miral $ mkdir miral/build $ cd miral/build $ cmake .. $ make
This creates libmiral.so in the lib directory and an example shell (miral-shell) in the bin directory. This can be run directly:
With the default options this runs in a window on X (which is convenient for development).
The miral-shell example is simple, don’t expect to see a sophisticated launcher by default. You can start mir apps from the command-line. For example:
$ bin/miral-run gnome-terminal
That’s right, a lot of standard GTK+ applications will “just work” (the GDK toolkit has a Mir backend). Any that assume the existence of an X11 and bypass the toolkit by making X11 protocol calls will have problems though.
To exit from miral-shell press Ctrl-Alt-BkSp.
To run independently of X11 you need to grant access to the graphics hardware (by running as root) and specify a VT to run in. For example:
$ sudo bin/miral-shell --vt 4 --arw-file --file $XDG_RUNTIME_DIR/mir_socket
For convenient testing there’s a “testrun” script that wraps this command to start the server (as root) and then launches the gnome-terminal (as the current user):
Running applications on MirAL
If you have a terminal session running in the MirAL desktop (as described above) you can start programs from it. GTK, Qt and SDL applications will “just work” provided that they don’t bypass the toolkit and attempt to make X11 protocol calls that are not available.
$ gedit $ 7kaa
From outside the MirAL session the “miral-run” script sets a few environment variables to configure the Mir support in the various toolkits. (There’s some special treatment for gnome-terminal as starting that can conflict with the desktop default.)
There are also some examples of native Mir client applications in the mir-demos package. These are typically basic graphics demos:
Support for X11 applications
If you want to run X11 applications that do not have native Mir support in the toolkit they use then the answer is Xmir: an X11 server that runs on Mir. First you need Xmir installed:
$ sudo apt install xmir
Then you can use the testrun script to start miral-shell with Xmir:
$ ../scripts/testrun -Xmir
This starts an X11 server on DISPLAY=:1. This is set in the terminal the script starts so that applications launched from it will automatically connect to miral through Xmir.
Running Qt applications
To run Qt applications under Mir you may need to install qtubuntu-desktop:
$ sudo apt-get install qtubuntu-desktopRead more