Mir
abstract_shell.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 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: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIR_SHELL_ABSTRACT_SHELL_H_
20 #define MIR_SHELL_ABSTRACT_SHELL_H_
21 
22 #include "mir/shell/shell.h"
25 
26 #include <mutex>
27 
28 namespace mir
29 {
30 namespace input
31 {
32 class Seat;
33 }
34 namespace shell
35 {
36 class ShellReport;
37 class WindowManager;
38 
40 class AbstractShell : public virtual Shell, public virtual FocusController
41 {
42 public:
44  std::shared_ptr<InputTargeter> const& input_targeter,
45  std::shared_ptr<SurfaceStack> const& surface_stack,
46  std::shared_ptr<scene::SessionCoordinator> const& session_coordinator,
47  std::shared_ptr<scene::PromptSessionManager> const& prompt_session_manager,
48  std::shared_ptr<ShellReport> const& report,
49  WindowManagerBuilder const& wm_builder,
50  std::shared_ptr<input::Seat> const& seat);
51 
52  ~AbstractShell() noexcept;
53 
54  std::shared_ptr<scene::Session> open_session(
55  pid_t client_pid,
56  std::string const& name,
57  std::shared_ptr<frontend::EventSink> const& sink) override;
58 
59  void close_session(std::shared_ptr<scene::Session> const& session) override;
60 
61  frontend::SurfaceId create_surface(
62  std::shared_ptr<scene::Session> const& session,
64  std::shared_ptr<frontend::EventSink> const& sink) override;
65 
66  void modify_surface(std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface, SurfaceSpecification const& modifications) override;
67 
68  void destroy_surface(std::shared_ptr<scene::Session> const& session, frontend::SurfaceId surface) override;
69 
70  int set_surface_attribute(
71  std::shared_ptr<scene::Session> const& session,
72  std::shared_ptr<scene::Surface> const& surface,
73  MirSurfaceAttrib attrib,
74  int value) override;
75 
76  int get_surface_attribute(
77  std::shared_ptr<scene::Surface> const& surface,
78  MirSurfaceAttrib attrib) override;
79 
80  void raise_surface(
81  std::shared_ptr<scene::Session> const& session,
82  std::shared_ptr<scene::Surface> const& surface,
83  uint64_t timestamp) override;
84 
85  std::shared_ptr<scene::PromptSession> start_prompt_session_for(
86  std::shared_ptr<scene::Session> const& session,
87  scene::PromptSessionCreationParameters const& params) override;
88 
89  void add_prompt_provider_for(
90  std::shared_ptr<scene::PromptSession> const& prompt_session,
91  std::shared_ptr<scene::Session> const& session) override;
92 
93  void stop_prompt_session(std::shared_ptr<scene::PromptSession> const& prompt_session) override;
94 
103  void focus_next_session() override;
104 
105  std::shared_ptr<scene::Session> focused_session() const override;
106 
107  // More useful than FocusController::set_focus_to()!
108  void set_focus_to(
109  std::shared_ptr<scene::Session> const& focus_session,
110  std::shared_ptr<scene::Surface> const& focus_surface) override;
111 
112  // The surface with focus
113  std::shared_ptr<scene::Surface> focused_surface() const override;
114 
115  auto surface_at(geometry::Point cursor) const -> std::shared_ptr<scene::Surface> override;
116 
117  void raise(SurfaceSet const& surfaces) override;
120  void add_display(geometry::Rectangle const& area) override;
121  void remove_display(geometry::Rectangle const& area) override;
122 
123  bool handle(MirEvent const& event) override;
124 
125  void update_focused_surface_confined_region();
126 
127 protected:
128  std::shared_ptr<InputTargeter> const input_targeter;
129  std::shared_ptr<SurfaceStack> const surface_stack;
130  std::shared_ptr<scene::SessionCoordinator> const session_coordinator;
131  std::shared_ptr<scene::PromptSessionManager> const prompt_session_manager;
132  std::shared_ptr<WindowManager> const window_manager;
133  std::shared_ptr<input::Seat> const seat;
134 
135 private:
136  std::shared_ptr<ShellReport> const report;
137 
138  std::mutex mutable focus_mutex;
139  std::weak_ptr<scene::Surface> focus_surface;
140  std::weak_ptr<scene::Session> focus_session;
141  std::shared_ptr<scene::SurfaceObserver> focus_surface_observer;
142 
143  void set_focus_to_locked(
144  std::unique_lock<std::mutex> const& lock,
145  std::shared_ptr<scene::Session> const& focus_session,
146  std::shared_ptr<scene::Surface> const& focus_surface);
147 };
148 }
149 }
150 
151 #endif /* MIR_SHELL_ABSTRACT_SHELL_H_ */
Definition: shell.h:51
Definition: as_render_target.h:27
Definition: point.h:30
std::set< std::weak_ptr< scene::Surface >, std::owner_less< std::weak_ptr< scene::Surface >>> SurfaceSet
Definition: focus_controller.h:32
std::shared_ptr< input::Seat > const seat
Definition: abstract_shell.h:133
std::shared_ptr< scene::SessionCoordinator > const session_coordinator
Definition: abstract_shell.h:130
std::shared_ptr< InputTargeter > const input_targeter
Definition: abstract_shell.h:128
Definition: focus_controller.h:38
struct MirEvent MirEvent
Definition: event.h:67
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire...
Definition: common.h:34
Definition: surface_creation_parameters.h:41
Definition: rectangle.h:33
std::shared_ptr< scene::PromptSessionManager > const prompt_session_manager
Definition: abstract_shell.h:131
Definition: prompt_session_creation_parameters.h:29
Specification of surface properties requested by client.
Definition: surface_specification.h:50
std::shared_ptr< SurfaceStack > const surface_stack
Definition: abstract_shell.h:129
std::shared_ptr< WindowManager > const window_manager
Definition: abstract_shell.h:132
Minimal Shell implementation with none of the necessary window management logic.
Definition: abstract_shell.h:40
std::function< std::shared_ptr< WindowManager >(FocusController *focus_controller)> WindowManagerBuilder
WindowManagers are built while initializing an AbstractShell, so a builder functor is needed...
Definition: window_manager_builder.h:34

Copyright © 2012-2016 Canonical Ltd.
Generated on Sat Dec 3 12:48:59 UTC 2016