Class MirRunner¶
Defined in File runner.h
Class Documentation¶
-
class MirRunner¶
This class is responsible for managing the lifetime of the core engine of a Mir compositor.
This is a core class to the lifetime of any Mir-based compositor. Compositor authors will often initialize a single instance of this object at the beginning of their program. They will then use MirRunner::run_with to begin their server with their desired list of arguments.
Public Functions
-
MirRunner(int argc, char const *argv[])¶
Construct a new runner with arguments provided from the commandline.
- Parameters:
argc – number of arguments
argv – array of arguments
-
MirRunner(int argc, char const *argv[], char const *config_file)¶
Construct a new runner with arguments provided from the commandline as well as a path to a Mir config file.
- Parameters:
argc – number of arguments
argv – array of arguments
config_file – path to a config file
-
~MirRunner()¶
-
void add_start_callback(std::function<void()> const &start_callback)¶
Add a callback to be invoked when the server has started.
If multiple callbacks are added, they will be invoked in the sequence added.
- Parameters:
start_callback – callback to be invoked
-
void add_stop_callback(std::function<void()> const &stop_callback)¶
Add a callback to be invoked when the server is about to stop.
If multiple callbacks are added they will be invoked in the reverse sequence added.
- Parameters:
stop_callback – callback to be invoked
-
void register_signal_handler(std::initializer_list<int> signals, std::function<void(int)> const &handler)¶
Add signal handler to the server’s main loop.
- Parameters:
signals – a list of signals to listen on
handler – a handler function called when a signal occurs
-
auto register_fd_handler(mir::Fd fd, std::function<void(int)> const &handler) -> std::unique_ptr<miral::FdHandle>¶
Add a watch on a file descriptor to the server’s main loop.
The handler will be triggered when there is data to read on
fd
.- Parameters:
fd – the file descriptor to wait on
handler – a handler function called when data is available
- Returns:
a handle
-
void set_exception_handler(std::function<void()> const &handler)¶
Set a handler for exceptions caught in MirRunner::run_with().
run_with() invokes
handler
incatch (...)
blocks before returningEXIT_FAILURE
. Hence, the exception can be re-thrown to retrieve type information.The default action is to call
mir::report_exception(std::cerr)
.- Parameters:
handler – the handler
-
auto run_with(std::initializer_list<std::function<void(::mir::Server&)>> options) -> int¶
Apply the supplied initialization options and run the Mir server.
This method blocks until the server exits.
The supplied
options
parameter is an initializer list of functions that take a #mir::Server as an argument. Throughout themiral
namespace, you will see classes implementvoid operator()(mir::Server&)
so that they may be implicitly passed to this method.- Parameters:
options – an initializer list of functions that take a #mir::Server as an argument
- Returns:
EXIT_SUCCESS
orEXIT_FAILURE
according to whether the server ran successfully
-
void stop()¶
Tell the Mir server to exit.
-
auto config_file() const -> std::string¶
Name of the .config file.
The .config file is located via the XDG Base Directory Specification:
$XDG_CONFIG_HOME
or$HOME/.config
followed by$XDG_CONFIG_DIRS
Config file entries are long form (e.g. “x11-output=1200x720”).
- Returns:
name of the config file
-
auto display_config_file() const -> std::string¶
Name of the .display configuration file.
The .display file is located via the XDG Base Directory Specification:
$XDG_CONFIG_HOME
or$HOME/.config
followed by$XDG_CONFIG_DIRS
Config file entries are long form (e.g. “x11-output=1200x720”)
- Returns:
name of the display config file
-
auto wayland_display() const -> mir::optional_value<std::string>¶
Get the Wayland socket name.
This value is usable as a
$WAYLAND_DISPLAY
value.This will be an empty optional if the server has not yet started.
- Returns:
the wayland socket, if any
-
auto x11_display() const -> mir::optional_value<std::string>¶
Get the X11 socket name.
This is usable as a
$DISPLAY
value.This will be an empty optional if the server has not yet started or X11 is not enabled for the server.
See also
miral::X11Support - provides X11 support to a Mir server
- Returns:
the X11 socket, if any
-
MirRunner(int argc, char const *argv[])¶