~unity-system-compositor-team/unity-system-compositor/trunk

« back to all changes in this revision

Viewing changes to src/server.cpp

  • Committer: Tarmac
  • Author(s): Alexandros Frantzis
  • Date: 2015-04-28 06:59:14 UTC
  • mfrom: (203.2.7 powerd-mediator)
  • Revision ID: tarmac-20150428065914-y1hs68oib8m0nzpy
Reimplement PowerdMediator without Qt. Fixes: https://bugs.launchpad.net/bugs/1389187.

Approved by Alberto Aguirre, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "asio_dm_connection.h"
22
22
#include "session_switcher.h"
23
23
#include "window_manager.h"
 
24
#include "mir_screen.h"
 
25
#include "screen_event_handler.h"
24
26
#include "powerd_mediator.h"
 
27
#include "unity_screen_service.h"
25
28
 
26
29
#include <mir/input/cursor_listener.h>
27
30
#include <mir/server_status_listener.h>
28
31
#include <mir/shell/focus_controller.h>
29
32
#include <mir/scene/session.h>
 
33
#include <mir/main_loop.h>
30
34
 
31
35
#include <iostream>
32
36
 
179
183
        });
180
184
}
181
185
 
 
186
std::shared_ptr<usc::Screen> usc::Server::the_screen()
 
187
{
 
188
    return screen(
 
189
        [this]
 
190
        {
 
191
            return std::make_shared<MirScreen>(
 
192
                the_screen_hardware(),
 
193
                the_compositor(),
 
194
                the_display(),
 
195
                the_touch_visualizer(),
 
196
                the_main_loop(),
 
197
                inactivity_display_off_timeout(),
 
198
                inactivity_display_dim_timeout());
 
199
        });
 
200
}
 
201
 
 
202
std::shared_ptr<mi::EventFilter> usc::Server::the_screen_event_handler()
 
203
{
 
204
    return screen_event_handler(
 
205
        [this]
 
206
        {
 
207
            return std::make_shared<ScreenEventHandler>(
 
208
                the_screen(),
 
209
                the_main_loop(),
 
210
                power_key_ignore_timeout(),
 
211
                shutdown_timeout(),
 
212
                [] { if (system("shutdown -P now")); }); // ignore warning
 
213
        });
 
214
}
 
215
 
182
216
std::shared_ptr<usc::ScreenHardware> usc::Server::the_screen_hardware()
183
217
{
184
218
    return screen_hardware(
185
219
        [this]
186
220
        {
187
 
            return std::make_shared<PowerdMediator>();
188
 
        });
 
221
            return std::make_shared<usc::PowerdMediator>(dbus_bus_address());
 
222
        });
 
223
}
 
224
 
 
225
std::shared_ptr<usc::UnityScreenService> usc::Server::the_unity_screen_service()
 
226
{
 
227
    return unity_screen_service(
 
228
        [this]
 
229
        {
 
230
            return std::make_shared<UnityScreenService>(
 
231
                    dbus_bus_address(),
 
232
                    the_screen());
 
233
        });
 
234
}
 
235
 
 
236
std::string usc::Server::dbus_bus_address()
 
237
{
 
238
    static char const* const default_bus_address{"unix:path=/var/run/dbus/system_bus_socket"};
 
239
 
 
240
    char const* bus = getenv("DBUS_SYSTEM_BUS_ADDRESS");
 
241
    if (!bus)
 
242
        bus = default_bus_address;
 
243
 
 
244
    return std::string{bus};
189
245
}