~ps-jenkins/unity-system-compositor/trusty-proposed

« back to all changes in this revision

Viewing changes to src/system_compositor.cpp

  • Committer: Kevin Gunn
  • Date: 2014-03-05 17:43:17 UTC
  • mfrom: (115.3.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 116.
  • Revision ID: kevin.gunn@canonical.com-20140305174317-duh4i2ua1jssrhbc
bring option file parsing back

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <mir/run_mir.h>
23
23
#include <mir/abnormal_exit.h>
24
24
#include <mir/default_server_configuration.h>
 
25
#include <mir/options/default_configuration.h>
25
26
#include <mir/frontend/shell.h>
26
27
#include <mir/server_status_listener.h>
27
28
#include <mir/shell/session.h>
40
41
namespace msh = mir::shell;
41
42
namespace mf = mir::frontend;
42
43
namespace mi = mir::input;
 
44
namespace mo = mir::options;
43
45
namespace po = boost::program_options;
44
46
 
45
47
class SystemCompositorShell : public mf::Shell
85
87
    std::map<std::string, std::shared_ptr<mf::Session>> sessions;
86
88
};
87
89
 
88
 
class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
 
90
class SystemCompositorConfiguration : public mo::DefaultConfiguration
89
91
{
90
92
public:
91
 
    SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char **argv)
92
 
        : mir::DefaultServerConfiguration(argc, (char const **)argv), compositor{compositor}
 
93
    SystemCompositorConfiguration(int argc, char **argv)
 
94
        : mo::DefaultConfiguration(argc, const_cast<const char **>(argv))
93
95
    {
94
96
        add_options()
95
97
            ("from-dm-fd", po::value<int>(),  "File descriptor of read end of pipe from display manager [int]")
100
102
            ("power-off-delay", po::value<int>(), "Delay in milliseconds before powering off screen [int]");
101
103
    }
102
104
 
 
105
private:
 
106
    void parse_config_file(po::options_description& desc, mo::ProgramOption& options) const
 
107
    {
 
108
        setenv("MIR_SERVER_STANDALONE", "true", 0); // Default to standalone
 
109
        options.parse_file(desc, "unity-system-compositor.conf");
 
110
    }
 
111
};
 
112
 
 
113
class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
 
114
{
 
115
public:
 
116
    SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char **argv)
 
117
        : mir::DefaultServerConfiguration(std::make_shared<SystemCompositorConfiguration>(argc, argv)),
 
118
          compositor{compositor}
 
119
    {
 
120
    }
 
121
 
103
122
    int from_dm_fd()
104
123
    {
105
124
        return the_options()->get("from-dm-fd", -1);
112
131
 
113
132
    bool show_version()
114
133
    {
115
 
        return the_options()->is_set ("version");
 
134
        return the_options()->is_set("version");
116
135
    }
117
136
 
118
137
    int power_off_delay()
122
141
 
123
142
    std::string blacklist()
124
143
    {
125
 
        auto x = the_options()->get ("blacklist", "");
 
144
        auto x = the_options()->get("blacklist", "");
126
145
        boost::trim(x);
127
146
        return x;
128
147
    }
132
151
        return !the_options()->is_set("no-file") && the_options()->get("public-socket", true);
133
152
    }
134
153
 
135
 
    void parse_options(boost::program_options::options_description& options_description, mir::options::ProgramOption& options) const override
136
 
    {
137
 
        setenv("MIR_SERVER_STANDALONE", "true", 0); // Default to standalone
138
 
        mir::DefaultServerConfiguration::parse_options(options_description, options);
139
 
        options.parse_file(options_description, "unity-system-compositor.conf");
140
 
    }
141
 
 
142
154
    std::shared_ptr<mi::CursorListener> the_cursor_listener() override
143
155
    {
144
156
        struct NullCursorListener : public mi::CursorListener
237
249
void SystemCompositor::run(int argc, char **argv)
238
250
{
239
251
    config = std::make_shared<SystemCompositorServerConfiguration>(this, argc, argv);
240
 
  
 
252
 
241
253
    if (config->show_version())
242
254
    {
243
255
        std::cerr << "unity-system-compositor " << USC_VERSION << std::endl;