2
* Copyright © 2013 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Kevin DuBois <kevin.dubois@canonical.com>
19
#ifndef MIR_SHELL_MEDIATING_DISPLAY_CHANGER_H_
20
#define MIR_SHELL_MEDIATING_DISPLAY_CHANGER_H_
22
#include "mir/frontend/display_changer.h"
23
#include "mir/display_changer.h"
34
class DisplayConfigurationPolicy;
36
namespace compositor { class Compositor; }
41
class SessionContainer;
42
class SessionEventHandlerRegister;
44
class MediatingDisplayChanger : public frontend::DisplayChanger,
45
public mir::DisplayChanger
48
MediatingDisplayChanger(
49
std::shared_ptr<graphics::Display> const& display,
50
std::shared_ptr<compositor::Compositor> const& compositor,
51
std::shared_ptr<graphics::DisplayConfigurationPolicy> const& display_configuration_policy,
52
std::shared_ptr<SessionContainer> const& session_container,
53
std::shared_ptr<SessionEventHandlerRegister> const& session_event_handler_register);
55
/* From mir::frontend::DisplayChanger */
56
std::shared_ptr<graphics::DisplayConfiguration> active_configuration();
57
void configure(std::shared_ptr<frontend::Session> const& session,
58
std::shared_ptr<graphics::DisplayConfiguration> const& conf);
60
void ensure_display_powered(std::shared_ptr<frontend::Session> const& session);
62
/* From mir::DisplayChanger */
63
void configure_for_hardware_change(
64
std::shared_ptr<graphics::DisplayConfiguration> const& conf,
65
SystemStateHandling pause_resume_system);
68
void apply_config(std::shared_ptr<graphics::DisplayConfiguration> const& conf,
69
SystemStateHandling pause_resume_system);
70
void apply_base_config(SystemStateHandling pause_resume_system);
71
void send_config_to_all_sessions(
72
std::shared_ptr<graphics::DisplayConfiguration> const& conf);
74
std::shared_ptr<graphics::Display> const display;
75
std::shared_ptr<compositor::Compositor> const compositor;
76
std::shared_ptr<graphics::DisplayConfigurationPolicy> const display_configuration_policy;
77
std::shared_ptr<shell::SessionContainer> const session_container;
78
std::shared_ptr<SessionEventHandlerRegister> const session_event_handler_register;
79
std::mutex configuration_mutex;
80
std::map<std::weak_ptr<frontend::Session>,
81
std::shared_ptr<graphics::DisplayConfiguration>,
82
std::owner_less<std::weak_ptr<frontend::Session>>> config_map;
83
std::weak_ptr<frontend::Session> focused_session;
84
std::shared_ptr<graphics::DisplayConfiguration> base_configuration;
85
bool base_configuration_applied;
91
#endif /* MIR_SHELL_MEDIATING_DISPLAY_CHANGER_H_ */