miral gets cut & paste

For some time now I’ve been intending to investigate the cut & paste mechanisms in the Unity8/Mir stack with the intention of ensuring they are supported in MirAL.

I’ve never had the time to do this, so I was surprised to discover that cut & paste is now working! (At least on Zesty.)

I assume that this is piggy-backing off the support being added to enable the “experimental” Unity8 desktop session, so I hope that this “magic” continues to work.

MirAL 1.3.1

There’s a bugfix MirAL release (1.3.1) available in ‘Zesty Zapus’ (Ubuntu 17.04) and the so-called “stable phone overlay” ppa for ‘Xenial Xerus’ (Ubuntu 16.04LTS). MirAL is a project aimed at simplifying the development of Mir servers and particularly providing a stable ABI and sensible default behaviors.

Unsurprisingly, given the project’s original goal, the ABI is unchanged.

The bugfixes in 1.3.1 fall are:

In libmiral a focus management fix:

When a dialog is hidden ensure that the active window focus goes to the parent. (LP: #1671072)

In the miral-shell example, two crashes fixed:

If a surface is deleted before its decoration is painted miral-shell can crash, or hang on exit (LP: #1673038)

If the specified “titlebar” font doesn’t exist the server crashes (LP: #1671028)

In addition a misspelling of “management” has been corrected:

SetWindowManagmentPolicy => SetWindowManagementPolicy

MirAL 1.3

There’s a new MirAL release (1.3.0) available in ‘Zesty Zapus’ (Ubuntu 17.04) and the so-called “stable phone overlay” ppa for ‘Xenial Xerus’ (Ubuntu 16.04LTS). MirAL is a project aimed at simplifying the development of Mir servers and particularly providing a stable ABI and sensible default behaviors.

Unsurprisingly, given the project’s original goal, the ABI is unchanged.

The changes in 1.3.0 fall are:

Support for “workspaces”

This is part of the enabling “workspaces” for Unity8 desktop. MirAL doesn’t provide fancy transitions and spreads, but you can see some basic workspace switching in the miral-shell example program:

$ apt install miral-examples
$ miral-app

There are four workspaces (corresponding to F1-F4) and you can switch using Meta-Alt-[F1|F2|F3|F4], or switch taking the active application to the new workspace using Meta-Ctrl-[F1|F2|F3|F4].

Support for “previous window in application”

You can now use Alt-Shift-` to switch to the previous in an application.

miral-shell adds a background

miral-shell now uses its background for a handy guide to the available keyboard shortcuts.

Bug fixes

Two bug fixes related to shutdown problems: one deals with a possible race in libmiral code, the other works around a bug in Mir.

  • [libmiral] Join internal client threads before server shutdown (LP: #1668651)
  • [miral-shell] Workaround for crash on exit (LP: #1667645)

miral-workspaces

“Workspaces” have arrived on MirAL trunk (lp:miral).

We won’t be releasing 1.3 with this feature just yet (as we want some experience with this internally first). But if you build from source there’s an example to play with (bin/miral-app).

As always, bug reports and other suggestions are welcome.

Note that the miral-shell doesn’t have transitions and other effects like fully featured desktop environments.

MirAL 1.2

There’s a new MirAL release (1.2.0) available in ‘Zesty Zapus’ (Ubuntu 17.04) and the so-called “stable phone overlay” ppa for ‘Xenial Xerus’ (Ubuntu 16.04LTS). MirAL is a project aimed at simplifying the development of Mir servers and particularly providing a stable ABI and sensible default behaviors.

Unsurprisingly, given the project’s original goal, the ABI is unchanged.

Since my last update the integration of libmiral into QtMir has progressed and libmiral has been used in the latest updates to Unity8.

The changes in 1.2.0 fall are:

A new libmirclientcpp-dev package

This is a “C++ wrapper for libmirclient” and has been split
from libmiral-dev.

Currently it comprises RAII wrappers for some Mir client library types: MirConnection, MirWindowSpec, MirWindow and MirWindowId. In addition, the WindowSpec wrapper provides named constructors and function chaining to enable code like the following:

auto const window = mir::client::WindowSpec::
    for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888)
    .set_buffer_usage(mir_buffer_usage_software)
    .set_name(a_window.c_str())
    .create_window();

Refresh the “Building and Using MirAL” doc

This has been rewritten (and renamed) to reflect the presence of MirAL in the Ubuntu archives and make installation (rather than “build it yourself”) the default approach.

Bug fixes

  • [libmiral] Chrome-less shell hint does not work any more (LP: #1658117)
  • “$ miral-app -kiosk” fails with “Unknown command line options:
    –desktop_file_hint=miral-shell.desktop” (LP: #1660933)
  • [libmiral] Fix focus and movement rules for Input Method and Satellite
    windows. (LP: #1660691)
  • [libmirclientcpp-dev] WindowSpec::set_state() wrapper for mir_window_spec_set_state()
    (LP: #1661256)

mircade-snap

mircade, miral-kiosk and snapcraft.io

mircade is a proof-of-concept game launcher for use with miral-kiosk. It looks for installed games, works out if they use a toolkit supported by Mir and allows the user to play them.

miral-kiosk is a proof-of-concept Mir server for kiosk style use. It has very basic window management designed to support a single fullscreen application.

snapcraft.io is a packaging system that allows you to package applications (as “snaps”) in a way that runs on multiple linux distributions. You first need to have snapcraft installed on your target system (I used a dragonboard with Ubuntu Core as described in my previous article).

The mircade snap takes mircade and a few open games from the Ubuntu archive to create an “arcade style” snap for playing these games.

Setting up the Mir snaps

The mircade snap is based on the “Mir Kiosk Snaps” described here.

Mir support on Ubuntu Core is currently work in progress so the exact incantations for installing the mir-libs and mir-kiosk snaps to work with mircade varies slightly from the referenced articles (to work around bugs) and will (hopefully) change in the near future. Here’s what I found works at the time of writing:

$ snap install mir-libs --channel edge
$ snap install mir-kiosk --channel edge --devmode
$ snap connect mir-kiosk:mir-libs mir-libs:mir-libs
$ sudo reboot

Installing the mircade-snap

I found that installing the mircade snap sometimes ran out of space on the dragonboard /tmp filesystem. So…

$ TMPDIR=/writable/ snap install mircade --devmode --channel=edge
$ snap connect mircade:mir-libs mir-libs:mir-libs
$ snap disconnect mircade:mir;snap connect mircade:mir mir-kiosk:mir
$ snap disable mircade;sudo /usr/lib/snapd/snap-discard-ns mircade;snap enable mircade

Using mircade on the dragonboard

At this point you should see an orange screen with the name of a game. You can change the game by touching/clicking the top or bottom of the screen (or using the arrow keys). Start the current game by touching/clicking the middle of the screen or pressing enter.

MirAL 1.0

There’s a new MirAL release (1.0.0) available in ‘Zesty Zapus’ (Ubuntu 17.04) and the so-called “stable phone overlay” ppa for ‘Xenial Xerus’ (Ubuntu 16.04LTS). MirAL is a project aimed at simplifying the development of Mir servers and particularly providing a stable ABI and sensible default behaviors.

Surprisingly, given the project’s original goal, the ABI is changed. This allowed us to address a couple of minor issues and the timing seemed good as downstreams are faced with Mir-0.25 moving some necessary APIs from libmircommon to the more ABI stable libmircore.

The changes in 1.0.0 are:

  1. The default movement of child windows can be overridden by the window management policy;
  2. A new “miral-app” script that runs the miral example servers as an application on an existing desktop;
  3. Bug fix LP: #1646431 “Examples fail to start under Unity8”;
  4. Bug fix LP: #1646735 “[miral-shell –window-manager tiling] windows are not correctly constrained to tiles”; and
  5. A couple of deprecated APIs have been removed.

Mircade

Mircade

I’ve been playing with the “kiosk” concept implemented by miral-kiosk. Kevin Gunn and Alberto Aguirre have been using it to demonstrate Mir snaps (kg’s blog) so I decided to join the fun.

Mircade is a very basic kiosk-launcher for whatever games are installed on a system. It tries to work out whether the game will run natively on Mir and, if not, will try running them on Xmir (if installed).

To play, you need the latest miral-examples and libmiral-dev installed. You can “apt install miral-examples” from Zesty archive/Xenial “stable phone overlay” PPA, or build it from source on Xenial or later.

$ sudo apt install miral-examples libmiral-dev mir-graphics-drivers-desktop xmir

Once you have that sorted, Mircade is available from github. It has a few dependencies (I’ve tried to list them, but have probably missed one).

$ git clone https://github.com/AlanGriffiths/mircade.git
$ sudo apt install libfreetype6-dev libboost-filesystem-dev libboost-system-dev cmake
$ cd mircade/
$ cmake .
$ make
$ miral-desktop -kiosk -launcher ./mircade

Navigation is by arrow keys (left/right) and selection by Space or Enter. When your game exits you return to the mircade launcher.

Not all games work perfectly on Mir (yet):

  • Most of the GTK based games (like gnome-chess) run, but sometimes fail to “fullscreen”;
  • SDL2 based games (like 7kaa) have a tendency to segfault on exit; and,
  • X11 based games using Xmir may or may not work.

Have fun!

MirAL 0.5

There’s a new MirAL release (0.5.0) available in ‘Zesty Zapus’ (Ubuntu 17.04) and the so-called “stable phone overlay” ppa for ‘Xenial Xerus’. MirAL is a project aimed at simplifying the development of Mir servers and particularly providing a stable ABI and sensible default behaviors.

Unsurprisingly, given the project’s original goal, the ABI is unchanged. The changes in 0.5.0 fall are:

  1. Some utility scripts to for common tasks;
  2. Improved “–window-manager tiling” mode of miral-shell;
  3. More configuration options for miral-kiosk;
  4. miral::DebugExtension; and,
  5. Some minor bug fixes.

Some utility scripts to for common tasks

There are two of these: miral-desktop and miral-screencast.

miral-desktop creates a pseudo-desktop session:

miral-desktop - Handy launch script for a miral "desktop session"
Usage: miral-desktop [options] [shell options]
Options are:
    -kiosk               use miral-kiosk instead of miral-shell
    -launcher <launcher> use <launcher> instead of 'gnome-terminal --app-id com.canonical.miral.Terminal'
    -vt       <termid>   set the virtual terminal [4]
    -socket   <socket>   set the mir socket [/run/user/1000/mir_socket]
    -bindir   <bindir>   path to the miral executable

For example, I use this to test the “tiling” window management with a UK keyboard layout:

$ miral-desktop -launcher qterminal --window-manager tiling --keymap gb

miral-screencast captures the Mir display (until you press enter) and then encodes it as an mp4:

miral-screencast - screencast capture script for use with Mir servers
Usage: /usr/bin/miral-screencast [options]
Options are:
    --width   set the capture width   [1920]
    --height  set the capture height  [1080]
    --output  set the output filename [screencast.mp4]
    --socket  set the mir socket      [/run/user/1000/mir_socket]

Improved “–window-manager tiling” mode of miral-shell

This has been updated to keep the focused window on the left half of the display (unless there’s only one window) and divide the right side vertically between the remaining windows. There’s also been a general refresh of the code that fixed a lot of minor issues.

More configuration options for miral-kiosk

The miral-kiosk now supports a few more options:

  • –keymap allows for non-US keyboard layout;
  • –kiosk-maximize-root-window kiosk has a new default behavior of maximizing root window, but this can be changed;
  • –kiosk-startup-apps-only prevents new connections after startup

miral::DebugExtension

This allows shells to enable (or disable) the client API “debug” extensions dynamically (AFAICS only useful for automated testing).

Some minor bug fixes

There was a race condition handling fullscreen surfaces when reconfiguring the display for hardware changes, the gmock version in zesty caused a FTBFS, and the clang version in zesty picked up some template instantiation issues.

Testing for Mir

Need a Mir server?

A couple of times in the last week I’ve been asked about a Mir server for testing. These requests have been from folks wanting to test their client-side work against Mir.

Most application developers will be using a toolkit or other graphics development library and not care if they are running on X11, Mir or even Windows. But the developers of those libraries will want to test with Mir.

For this purpose, the simplest Mir server to use is miral-shell. If you’re on Ubuntu Zesty Zapus then this is readily available:

$ sudo apt install miral-examples mir-graphics-drivers-desktop qtubuntu-desktop

If you’re on an earlier version of Ubuntu then you either need a ppa (such as the “stable phone overlay”) or, less risky to your system, just build and install it yourself. (If you’re not on Ubuntu this is still possible: there are some pointers here.)

What does miral-server provide?

Currently miral-server is the only Mir server to offer libmiral’s “basic window management”. That unique status is due to change real soon as this implementation is being merged into Unity8.

The simplest way way to run miral-shell is using Mir’s “Mir on X” support. From a terminal window just type:

$ miral-shell

Then you can connect your application from another terminal:

$ miral-run <application>

You should see your application appear in the “Mir on X” window.

A lot of the current work is focused on the placement of windows (menues, popup, etc.) and to help with this there’s a facility to trace the window management calls. Start miral-shell like this:

$ miral-shell --window-management-trace

And all the window management events and decisions are logged.

Another interesting option is to use a “tiling” window manager:

$ miral-shell --window-manager tiling

Which has a completely different approach to laying out the application windows.

For a full list of the option:

$ miral-shell --help

Documentation of the Mir “toolkit”API

A related question I’ve been asked is for documentation of the libmirclient API. You can find the documentation like this:

$ sudo apt install mir-doc
$ xdg-open /usr/share/doc/mir-doc/html/group__mir__toolkit.htm

This will open the default browser on the relevant page.