By reading multiple blogs/articles, I found an "user-friendly" api for creating a compositor based on Mir. This library is named Miral. Really easy to use for creating a simple compositor. I was able to get my first window with miral after few minutes.
I decided to get all applications with fullscreen by modifying the place_new_window
and handle_modify_window
(personnal choice).
The window manager policy also include a set of shortcuts such as :
- alt + tab : focus next application
- alt + F4 : close current applicaiton
- alt + shift + F8 : print count application
- alt + shift + F9 : print applications informations
The MirRunner comes with shortcuts as well :
- ctrl + alt + shift + backspace : stop MirRunner
- ctrl + alt + shift + G : launch gedit
- ctrl + alt + shift + X : launch xfce4-terminal
I lost a lot of time trying to get my own wallpaper class. Without success I decided to re-use egmde classes and make it works in few minutes. I had issues trying to get wayland surface trough miral api. I tried to found a solution but api is quite opaque ...
A simple CMakelist, I added the miral module plus freetype, wayland_client and boost for the printer and wallpaper.
The main file is composed of a a MirRunner. An internal launcher allowing us to launch application from our mir compositor. An external launcher allowing us to handle external application inside our compositor, tested with :
WAYLAND_DISPLAY=wayland-99 xfce4-terminal.
A wallpaper class :
erwanTest::Wallpaper wallpaper; runner.add_stop_callback([&] { wallpaper.stop(); });\
At startup with a Configuration option gedit is launch.
auto run_startup_apps = [&](std::string const& apps)
The event filter allow us to launch applications and quit the current mir session.
AppendEventFilter event_filter{[&](MirEvent const* event)
MirRunner class is run with multiple options composed of what is describe above.
ErwanWindowManagement handle the behavior of windows and inputs. Inherit from CanonicalWindowManagerPolicy virtual class.
I removed the touch event because I don't need it.
I added events filter inside this function :
handle_keyboard_event
I tried to print and play with workspace and trees (removed) but AFAIK there is one session with one default workspace and I didn't succeed switching between multiple workspace even if they were created by myself.
Inside functions place_new_window
and handle_modify_window
I forced the fullscreen state for all windows.
Copied from [3]. Needed for the wallpaper.
Copied from [3]. Needed for the text on top of the wallpaper.
Copied from [3]. Needed for the wallpaper/printer. I simply removed a depency with xkb because I don't need it.