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 shell
30 {
31 class WindowManager;
32 
34 class AbstractShell : public virtual Shell, public virtual FocusController
35 {
36 public:
38  std::shared_ptr<InputTargeter> const& input_targeter,
39  std::shared_ptr<scene::SurfaceCoordinator> const& surface_coordinator,
40  std::shared_ptr<scene::SessionCoordinator> const& session_coordinator,
41  std::shared_ptr<scene::PromptSessionManager> const& prompt_session_manager,
42  WindowManagerBuilder const& wm_builder);
43 
44  ~AbstractShell() noexcept;
45 
46  std::shared_ptr<scene::Session> open_session(
47  pid_t client_pid,
48  std::string const& name,
49  std::shared_ptr<frontend::EventSink> const& sink) override;
50 
51  void close_session(std::shared_ptr<scene::Session> const& session) override;
52 
54  std::shared_ptr<scene::Session> const& session,
56  std::shared_ptr<frontend::EventSink> const& sink) override;
57 
58  void modify_surface(std::shared_ptr<scene::Session> const& session, std::shared_ptr<scene::Surface> const& surface, SurfaceSpecification const& modifications) override;
59 
60  void destroy_surface(std::shared_ptr<scene::Session> const& session, frontend::SurfaceId surface) override;
61 
63  std::shared_ptr<scene::Session> const& session,
64  std::shared_ptr<scene::Surface> const& surface,
65  MirSurfaceAttrib attrib,
66  int value) override;
67 
69  std::shared_ptr<scene::Surface> const& surface,
70  MirSurfaceAttrib attrib) override;
71 
72  std::shared_ptr<scene::PromptSession> start_prompt_session_for(
73  std::shared_ptr<scene::Session> const& session,
74  scene::PromptSessionCreationParameters const& params) override;
75 
77  std::shared_ptr<scene::PromptSession> const& prompt_session,
78  std::shared_ptr<scene::Session> const& session) override;
79 
80  void stop_prompt_session(std::shared_ptr<scene::PromptSession> const& prompt_session) override;
81 
90  void focus_next_session() override;
91 
92  std::shared_ptr<scene::Session> focused_session() const override;
93 
94  // More useful than FocusController::set_focus_to()!
95  void set_focus_to(
96  std::shared_ptr<scene::Session> const& focus_session,
97  std::shared_ptr<scene::Surface> const& focus_surface) override;
98 
99  // The surface with focus
100  std::shared_ptr<scene::Surface> focused_surface() const override;
101 
102  auto surface_at(geometry::Point cursor) const -> std::shared_ptr<scene::Surface> override;
103 
104  void raise(SurfaceSet const& surfaces) override;
107  void add_display(geometry::Rectangle const& area) override;
108  void remove_display(geometry::Rectangle const& area) override;
109 
110  bool handle(MirEvent const& event) override;
111 
112 protected:
113  std::shared_ptr<InputTargeter> const input_targeter;
114  std::shared_ptr<scene::SurfaceCoordinator> const surface_coordinator;
115  std::shared_ptr<scene::SessionCoordinator> const session_coordinator;
116  std::shared_ptr<scene::PromptSessionManager> const prompt_session_manager;
117  std::shared_ptr<WindowManager> const window_manager;
118 
119 private:
120  std::mutex mutable focus_mutex;
121  std::weak_ptr<scene::Surface> focus_surface;
122  std::weak_ptr<scene::Session> focus_session;
123 
124  void set_focus_to_locked(
125  std::unique_lock<std::mutex> const& lock,
126  std::shared_ptr<scene::Session> const& focus_session,
127  std::shared_ptr<scene::Surface> const& focus_surface);
128 };
129 }
130 }
131 
132 #endif /* MIR_SHELL_ABSTRACT_SHELL_H_ */
Definition: shell.h:51
All things Mir.
Definition: atomic_callback.h:25
std::shared_ptr< scene::Session > focused_session() const override
Definition: abstract_shell.cpp:147
void add_display(geometry::Rectangle const &area) override
Definition: abstract_shell.cpp:211
void add_prompt_provider_for(std::shared_ptr< scene::PromptSession > const &prompt_session, std::shared_ptr< scene::Session > const &session) override
Definition: abstract_shell.cpp:102
~AbstractShell() noexcept
Definition: abstract_shell.cpp:47
std::shared_ptr< scene::SurfaceCoordinator > const surface_coordinator
Definition: abstract_shell.h:114
Definition: point.h:30
std::shared_ptr< scene::Surface > focused_surface() const override
Definition: abstract_shell.cpp:153
frontend::SurfaceId create_surface(std::shared_ptr< scene::Session > const &session, scene::SurfaceCreationParameters const &params, std::shared_ptr< frontend::EventSink > const &sink) override
Definition: abstract_shell.cpp:69
void close_session(std::shared_ptr< scene::Session > const &session) override
Definition: abstract_shell.cpp:61
void modify_surface(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface, SurfaceSpecification const &modifications) override
Definition: abstract_shell.cpp:82
std::set< std::weak_ptr< scene::Surface >, std::owner_less< std::weak_ptr< scene::Surface >>> SurfaceSet
Definition: focus_controller.h:32
int set_surface_attribute(std::shared_ptr< scene::Session > const &session, std::shared_ptr< scene::Surface > const &surface, MirSurfaceAttrib attrib, int value) override
Definition: abstract_shell.cpp:115
std::shared_ptr< scene::SessionCoordinator > const session_coordinator
Definition: abstract_shell.h:115
std::shared_ptr< InputTargeter > const input_targeter
Definition: abstract_shell.h:113
Definition: focus_controller.h:38
int get_surface_attribute(std::shared_ptr< scene::Surface > const &surface, MirSurfaceAttrib attrib) override
Definition: abstract_shell.cpp:124
AbstractShell(std::shared_ptr< InputTargeter > const &input_targeter, std::shared_ptr< scene::SurfaceCoordinator > const &surface_coordinator, std::shared_ptr< scene::SessionCoordinator > const &session_coordinator, std::shared_ptr< scene::PromptSessionManager > const &prompt_session_manager, WindowManagerBuilder const &wm_builder)
Definition: abstract_shell.cpp:33
void set_focus_to(std::shared_ptr< scene::Session > const &focus_session, std::shared_ptr< scene::Surface > const &focus_surface) override
Definition: abstract_shell.cpp:159
void stop_prompt_session(std::shared_ptr< scene::PromptSession > const &prompt_session) override
Definition: abstract_shell.cpp:109
auto surface_at(geometry::Point cursor) const -> std::shared_ptr< scene::Surface > override
Definition: abstract_shell.cpp:243
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire...
Definition: common.h:34
void focus_next_session() override
Definition: abstract_shell.cpp:132
Definition: surface_creation_parameters.h:42
std::shared_ptr< scene::PromptSession > start_prompt_session_for(std::shared_ptr< scene::Session > const &session, scene::PromptSessionCreationParameters const &params) override
Definition: abstract_shell.cpp:95
Definition: rectangle.h:33
std::shared_ptr< scene::PromptSessionManager > const prompt_session_manager
Definition: abstract_shell.h:116
bool handle(MirEvent const &event) override
Definition: abstract_shell.cpp:221
void remove_display(geometry::Rectangle const &area) override
Definition: abstract_shell.cpp:216
Definition: prompt_session_creation_parameters.h:29
void destroy_surface(std::shared_ptr< scene::Session > const &session, frontend::SurfaceId surface) override
Definition: abstract_shell.cpp:87
Definition: event_private.h:178
Specification of surface properties requested by client.
Definition: surface_specification.h:50
std::shared_ptr< WindowManager > const window_manager
Definition: abstract_shell.h:117
Minimal Shell implementation with none of the necessary window management logic.
Definition: abstract_shell.h:34
std::shared_ptr< scene::Session > open_session(pid_t client_pid, std::string const &name, std::shared_ptr< frontend::EventSink > const &sink) override
Definition: abstract_shell.cpp:51
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-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015