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"
24 
25 #include <mutex>
26 
27 namespace mir
28 {
29 namespace input
30 {
31 class Seat;
32 }
33 namespace shell
34 {
35 class ShellReport;
36 class WindowManager;
37 
39 class AbstractShell : public virtual Shell, public virtual FocusController
40 {
41 public:
43  std::shared_ptr<InputTargeter> const& input_targeter,
44  std::shared_ptr<SurfaceStack> const& surface_stack,
45  std::shared_ptr<scene::SessionCoordinator> const& session_coordinator,
46  std::shared_ptr<scene::PromptSessionManager> const& prompt_session_manager,
47  std::shared_ptr<ShellReport> const& report,
48  WindowManagerBuilder const& wm_builder,
49  std::shared_ptr<input::Seat> const& seat);
50 
51  ~AbstractShell() noexcept;
52 
53  std::shared_ptr<scene::Session> open_session(
54  pid_t client_pid,
55  std::string const& name,
56  std::shared_ptr<frontend::EventSink> const& sink) override;
57 
58  void close_session(std::shared_ptr<scene::Session> const& session) override;
59 
60  frontend::SurfaceId create_surface(
61  std::shared_ptr<scene::Session> const& session,
63  std::shared_ptr<frontend::EventSink> const& sink) override;
64 
65  void modify_surface(std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface, SurfaceSpecification const& modifications) override;
66 
67  void destroy_surface(std::shared_ptr<scene::Session> const& session, frontend::SurfaceId surface) override;
68 
69  int set_surface_attribute(
70  std::shared_ptr<scene::Session> const& session,
71  std::shared_ptr<scene::Surface> const& surface,
72  MirSurfaceAttrib attrib,
73  int value) override;
74 
75  int get_surface_attribute(
76  std::shared_ptr<scene::Surface> const& surface,
77  MirSurfaceAttrib attrib) override;
78 
79  void raise_surface(
80  std::shared_ptr<scene::Session> const& session,
81  std::shared_ptr<scene::Surface> const& surface,
82  uint64_t timestamp) override;
83 
84  std::shared_ptr<scene::PromptSession> start_prompt_session_for(
85  std::shared_ptr<scene::Session> const& session,
86  scene::PromptSessionCreationParameters const& params) override;
87 
88  void add_prompt_provider_for(
89  std::shared_ptr<scene::PromptSession> const& prompt_session,
90  std::shared_ptr<scene::Session> const& session) override;
91 
92  void stop_prompt_session(std::shared_ptr<scene::PromptSession> const& prompt_session) override;
93 
102  void focus_next_session() override;
103 
104  std::shared_ptr<scene::Session> focused_session() const override;
105 
106  // More useful than FocusController::set_focus_to()!
107  void set_focus_to(
108  std::shared_ptr<scene::Session> const& focus_session,
109  std::shared_ptr<scene::Surface> const& focus_surface) override;
110 
111  // The surface with focus
112  std::shared_ptr<scene::Surface> focused_surface() const override;
113 
114  auto surface_at(geometry::Point cursor) const -> std::shared_ptr<scene::Surface> override;
115 
116  void raise(SurfaceSet const& surfaces) override;
119  void add_display(geometry::Rectangle const& area) override;
120  void remove_display(geometry::Rectangle const& area) override;
121 
122  bool handle(MirEvent const& event) override;
123 
124 protected:
125  std::shared_ptr<InputTargeter> const input_targeter;
126  std::shared_ptr<SurfaceStack> const surface_stack;
127  std::shared_ptr<scene::SessionCoordinator> const session_coordinator;
128  std::shared_ptr<scene::PromptSessionManager> const prompt_session_manager;
129  std::shared_ptr<WindowManager> const window_manager;
130  std::shared_ptr<input::Seat> const seat;
131 
132 private:
133  std::shared_ptr<ShellReport> const report;
134 
135  std::mutex mutable focus_mutex;
136  std::weak_ptr<scene::Surface> focus_surface;
137  std::weak_ptr<scene::Session> focus_session;
138 
139  void set_focus_to_locked(
140  std::unique_lock<std::mutex> const& lock,
141  std::shared_ptr<scene::Session> const& focus_session,
142  std::shared_ptr<scene::Surface> const& focus_surface);
143 };
144 }
145 }
146 
147 #endif /* MIR_SHELL_ABSTRACT_SHELL_H_ */
Definition: shell.h:51
All things Mir.
Definition: atomic_callback.h:25
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:130
std::shared_ptr< scene::SessionCoordinator > const session_coordinator
Definition: abstract_shell.h:127
std::shared_ptr< InputTargeter > const input_targeter
Definition: abstract_shell.h:125
Definition: focus_controller.h:38
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:128
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:126
std::shared_ptr< WindowManager > const window_manager
Definition: abstract_shell.h:129
Minimal Shell implementation with none of the necessary window management logic.
Definition: abstract_shell.h:39
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
Definition: event.h:30

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