Skip to content

Commit

Permalink
Apply input config changes on server start
Browse files Browse the repository at this point in the history
Initially, the config file is loaded before the server starts. The
changes need some server components to be applied, so they aren't
applied at that stage.

The few lines added store the changes and apply them once the server
starts.
  • Loading branch information
tarek-y-ismail committed Jan 31, 2025
1 parent d484803 commit d64852c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions examples/mir_demo_server/server_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ try
miral::MirRunner runner{argc, argv, "mir/mir_demo_server.config"};

miral::InputConfiguration input_configuration;
auto mouse = input_configuration.mouse();
auto touchpad = input_configuration.touchpad();
auto keyboard = input_configuration.keyboard();

miral::ConfigFile test{runner, "mir_demo_server.input", miral::ConfigFile::Mode::reload_on_change,
[&input_configuration](auto& in, auto path)
[&](auto& in, auto path)
{
std::cout << "** Reloading: " << path << std::endl;

auto mouse = input_configuration.mouse();
auto touchpad = input_configuration.touchpad();
auto keyboard = input_configuration.keyboard();

for (std::string line; std::getline(in, line);)
{
Expand Down Expand Up @@ -190,6 +190,14 @@ try
input_configuration.keyboard(keyboard);
}};

runner.add_start_callback(
[&]
{
input_configuration.mouse(mouse);
input_configuration.touchpad(touchpad);
input_configuration.keyboard(keyboard);
});

runner.set_exception_handler(exception_handler);

std::function<void()> shutdown_hook{[]{}};
Expand Down

0 comments on commit d64852c

Please sign in to comment.