Mir
mediating_display_changer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_SCENE_MEDIATING_DISPLAY_CHANGER_H_
20 #define MIR_SCENE_MEDIATING_DISPLAY_CHANGER_H_
21 
23 #include "mir/display_changer.h"
25 
26 #include <mutex>
27 #include <map>
28 
29 namespace mir
30 {
31 class ServerActionQueue;
32 
33 namespace graphics
34 {
35  class Display;
36  class DisplayConfigurationPolicy;
37  class DisplayConfigurationReport;
38 }
39 namespace compositor { class Compositor; }
40 namespace scene
41 {
42 class SessionEventHandlerRegister;
43 class SessionContainer;
44 class Session;
45 
47  public mir::DisplayChanger,
49 {
50 public:
52  std::shared_ptr<graphics::Display> const& display,
53  std::shared_ptr<compositor::Compositor> const& compositor,
54  std::shared_ptr<graphics::DisplayConfigurationPolicy> const& display_configuration_policy,
55  std::shared_ptr<SessionContainer> const& session_container,
56  std::shared_ptr<SessionEventHandlerRegister> const& session_event_handler_register,
57  std::shared_ptr<ServerActionQueue> const& server_action_queue,
58  std::shared_ptr<graphics::DisplayConfigurationReport> const& report);
59 
60  /* From mir::frontend::DisplayChanger */
61  std::shared_ptr<graphics::DisplayConfiguration> active_configuration() override;
62  void configure(std::shared_ptr<frontend::Session> const& session,
63  std::shared_ptr<graphics::DisplayConfiguration> const& conf) override;
64 
65  /* From mir::DisplayChanger */
67  std::shared_ptr<graphics::DisplayConfiguration> const& conf,
68  SystemStateHandling pause_resume_system) override;
69 
70  void pause_display_config_processing() override;
71  void resume_display_config_processing() override;
72 
73  /* From shell::DisplayConfigurationController */
74  std::future<void> set_default_display_configuration(
75  std::shared_ptr<graphics::DisplayConfiguration> const &conf) override;
76 
77 private:
78  void focus_change_handler(std::shared_ptr<Session> const& session);
79  void no_focus_handler();
80  void session_stopping_handler(std::shared_ptr<Session> const& session);
81 
82  void apply_config(std::shared_ptr<graphics::DisplayConfiguration> const& conf,
83  SystemStateHandling pause_resume_system);
84  void apply_base_config(SystemStateHandling pause_resume_system);
85  void send_config_to_all_sessions(
86  std::shared_ptr<graphics::DisplayConfiguration> const& conf);
87 
88  std::shared_ptr<graphics::Display> const display;
89  std::shared_ptr<compositor::Compositor> const compositor;
90  std::shared_ptr<graphics::DisplayConfigurationPolicy> const display_configuration_policy;
91  std::shared_ptr<SessionContainer> const session_container;
92  std::shared_ptr<SessionEventHandlerRegister> const session_event_handler_register;
93  std::shared_ptr<ServerActionQueue> const server_action_queue;
94  std::shared_ptr<graphics::DisplayConfigurationReport> const report;
95  std::mutex configuration_mutex;
96  std::map<std::weak_ptr<frontend::Session>,
97  std::shared_ptr<graphics::DisplayConfiguration>,
98  std::owner_less<std::weak_ptr<frontend::Session>>> config_map;
99  std::weak_ptr<frontend::Session> focused_session;
100  std::shared_ptr<graphics::DisplayConfiguration> base_configuration;
101  bool base_configuration_applied;
102 };
103 
104 }
105 }
106 
107 #endif /* MIR_SCENE_MEDIATING_DISPLAY_CHANGER_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: display_changer.h:31
std::future< void > set_default_display_configuration(std::shared_ptr< graphics::DisplayConfiguration > const &conf) override
Set the base display configuration.
Definition: mediating_display_changer.cpp:282
void pause_display_config_processing() override
Definition: mediating_display_changer.cpp:190
void configure_for_hardware_change(std::shared_ptr< graphics::DisplayConfiguration > const &conf, SystemStateHandling pause_resume_system) override
Definition: mediating_display_changer.cpp:164
MediatingDisplayChanger(std::shared_ptr< graphics::Display > const &display, std::shared_ptr< compositor::Compositor > const &compositor, std::shared_ptr< graphics::DisplayConfigurationPolicy > const &display_configuration_policy, std::shared_ptr< SessionContainer > const &session_container, std::shared_ptr< SessionEventHandlerRegister > const &session_event_handler_register, std::shared_ptr< ServerActionQueue > const &server_action_queue, std::shared_ptr< graphics::DisplayConfigurationReport > const &report)
Definition: mediating_display_changer.cpp:62
void configure(std::shared_ptr< frontend::Session > const &session, std::shared_ptr< graphics::DisplayConfiguration > const &conf) override
Definition: mediating_display_changer.cpp:117
Definition: display_changer.h:34
void resume_display_config_processing() override
Definition: mediating_display_changer.cpp:195
Definition: mediating_display_changer.h:46
std::shared_ptr< graphics::DisplayConfiguration > active_configuration() override
Definition: mediating_display_changer.cpp:157
SystemStateHandling
Definition: display_changer.h:36
Definition: display_configuration_controller.h:34

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015