~ubuntu-branches/ubuntu/wily/mir/wily-proposed

« back to all changes in this revision

Viewing changes to examples/server_example.cpp

  • Committer: Package Import Robot
  • Author(s): CI Train Bot
  • Date: 2015-05-12 13:12:55 UTC
  • mto: This revision was merged to the branch mainline in revision 96.
  • Revision ID: package-import@ubuntu.com-20150512131255-y7z12i8n4pbvo70x
Tags: upstream-0.13.0+15.10.20150512
Import upstream version 0.13.0+15.10.20150512

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright © 2012-2014 Canonical Ltd.
 
2
 * Copyright © 2012-2015 Canonical Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License version 3 as
19
19
#include "server_example_log_options.h"
20
20
#include "server_example_input_event_filter.h"
21
21
#include "server_example_input_filter.h"
22
 
#include "server_example_fullscreen_placement_strategy.h"
23
22
#include "server_example_display_configuration_policy.h"
24
23
#include "server_example_host_lifecycle_event_listener.h"
25
 
#include "server_example_window_manager.h"
 
24
#include "server_example_window_management.h"
 
25
#include "server_example_custom_compositor.h"
26
26
#include "server_example_test_client.h"
27
27
 
28
28
#include "mir/server.h"
65
65
 
66
66
    server.add_configuration_option(timeout_opt, timeout_descr, mir::OptionType::integer);
67
67
 
68
 
    server.add_init_callback([&]
 
68
    server.add_init_callback([&server]
69
69
    {
70
70
        const auto options = server.get_options();
71
71
        if (options->is_set(timeout_opt))
72
72
        {
73
 
            static auto const exit_action = server.the_main_loop()->notify_in(
74
 
                std::chrono::seconds(options->get<int>(timeout_opt)),
75
 
                [&] { server.stop(); });
 
73
            static auto const exit_action = server.the_main_loop()->create_alarm([&server] { server.stop(); });
 
74
            exit_action->reschedule_in(std::chrono::seconds(options->get<int>(timeout_opt)));
76
75
        }
77
76
    });
78
77
}
83
82
{
84
83
    mir::Server server;
85
84
 
 
85
    // Use config options file in e.g. ~/.config/mir/mir_demo_server.config
 
86
    server.set_config_filename("mir/mir_demo_server.config");
 
87
 
86
88
    // Add example options for display layout, logging, launching clients and timeout
87
89
    me::add_display_configuration_options_to(server);
88
90
    me::add_log_host_lifecycle_option_to(server);
89
91
    me::add_glog_options_to(server);
90
92
    me::add_window_manager_option_to(server);
 
93
    me::add_custom_compositor_option_to(server);
91
94
    add_launcher_option_to(server);
92
95
    add_timeout_option_to(server);
93
96
 
97
100
    // Create some input filters (we need to keep them or they deactivate)
98
101
    auto const quit_filter = me::make_quit_filter_for(server);
99
102
    auto const printing_filter = me::make_printing_input_filter_for(server);
 
103
    auto const screen_rotation_filter = me::make_screen_rotation_filter_for(server);
100
104
 
101
105
    // Provide the command line and run the server
102
106
    server.set_command_line(argc, argv);