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 #include "mir/input/input_region.h"
26 
27 #include <mutex>
28 #include <map>
30 
31 namespace mir
32 {
33 class ServerActionQueue;
34 
35 namespace time
36 {
37 class Alarm;
38 class AlarmFactory;
39 }
40 
41 namespace graphics
42 {
43  class Display;
44  class DisplayConfigurationPolicy;
45  class DisplayConfigurationReport;
46 }
47 namespace compositor { class Compositor; }
48 namespace input
49 {
50 class InputRegion;
51 }
52 namespace scene
53 {
54 class SessionEventHandlerRegister;
55 class SessionContainer;
56 class Session;
57 
59  public mir::DisplayChanger,
61 {
62 public:
64  std::shared_ptr<graphics::Display> const& display,
65  std::shared_ptr<compositor::Compositor> const& compositor,
66  std::shared_ptr<graphics::DisplayConfigurationPolicy> const& display_configuration_policy,
67  std::shared_ptr<SessionContainer> const& session_container,
68  std::shared_ptr<SessionEventHandlerRegister> const& session_event_handler_register,
69  std::shared_ptr<ServerActionQueue> const& server_action_queue,
70  std::shared_ptr<graphics::DisplayConfigurationReport> const& report,
71  std::shared_ptr<input::InputRegion> const& region,
72  std::shared_ptr<time::AlarmFactory> const& alarm_factory);
73 
74  /* From mir::frontend::DisplayChanger */
75  std::shared_ptr<graphics::DisplayConfiguration> base_configuration() override;
76  void configure(std::shared_ptr<frontend::Session> const& session,
77  std::shared_ptr<graphics::DisplayConfiguration> const& conf) override;
78  void preview_base_configuration(
79  std::weak_ptr<frontend::Session> const& session,
80  std::shared_ptr<graphics::DisplayConfiguration> const& conf,
81  std::chrono::seconds timeout) override;
82  void confirm_base_configuration(
83  std::shared_ptr<frontend::Session> const& session,
84  std::shared_ptr<graphics::DisplayConfiguration> const& confirmed_conf) override;
85 
86  /* From mir::DisplayChanger */
87  void configure_for_hardware_change(
88  std::shared_ptr<graphics::DisplayConfiguration> const& conf,
89  SystemStateHandling pause_resume_system) override;
90 
91  void pause_display_config_processing() override;
92  void resume_display_config_processing() override;
93 
94  /* From shell::DisplayConfigurationController */
95  void set_base_configuration(std::shared_ptr<graphics::DisplayConfiguration> const &conf) override;
96 
97 private:
98  void focus_change_handler(std::shared_ptr<Session> const& session);
99  void no_focus_handler();
100  void session_stopping_handler(std::shared_ptr<Session> const& session);
101 
102  void apply_config(std::shared_ptr<graphics::DisplayConfiguration> const& conf,
103  SystemStateHandling pause_resume_system);
104  void apply_base_config(SystemStateHandling pause_resume_system);
105  void send_config_to_all_sessions(
106  std::shared_ptr<graphics::DisplayConfiguration> const& conf);
107  void update_input_rectangles(graphics::DisplayConfiguration const& conf);
108 
109  std::shared_ptr<graphics::Display> const display;
110  std::shared_ptr<compositor::Compositor> const compositor;
111  std::shared_ptr<graphics::DisplayConfigurationPolicy> const display_configuration_policy;
112  std::shared_ptr<SessionContainer> const session_container;
113  std::shared_ptr<SessionEventHandlerRegister> const session_event_handler_register;
114  std::shared_ptr<ServerActionQueue> const server_action_queue;
115  std::shared_ptr<graphics::DisplayConfigurationReport> const report;
116  std::mutex configuration_mutex;
117  std::map<std::weak_ptr<frontend::Session>,
118  std::shared_ptr<graphics::DisplayConfiguration>,
119  std::owner_less<std::weak_ptr<frontend::Session>>> config_map;
120  std::weak_ptr<frontend::Session> focused_session;
121  std::shared_ptr<graphics::DisplayConfiguration> base_configuration_;
122  bool base_configuration_applied;
123  std::shared_ptr<input::InputRegion> const region;
124  std::shared_ptr<time::AlarmFactory> const alarm_factory;
125  std::unique_ptr<time::Alarm> preview_configuration_timeout;
126 };
127 
128 }
129 }
130 
131 #endif /* MIR_SCENE_MEDIATING_DISPLAY_CHANGER_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: display_changer.h:31
Definition: display_changer.h:35
Definition: mediating_display_changer.h:58
SystemStateHandling
Definition: display_changer.h:36
Definition: display_configuration_controller.h:33
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:168

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016