Mir
basic_surface.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012-2014 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: Thomas Voss <thomas.voss@canonical.com>
17  */
18 
19 #ifndef MIR_SCENE_BASIC_SURFACE_H_
20 #define MIR_SCENE_BASIC_SURFACE_H_
21 
22 #include "mir/scene/surface.h"
23 #include "mir/basic_observers.h"
25 #include "mir/input/validator.h"
26 
27 #include "mir/geometry/rectangle.h"
28 
29 #include "mir_toolkit/common.h"
30 
31 #include <glm/glm.hpp>
32 #include <vector>
33 #include <list>
34 #include <memory>
35 #include <mutex>
36 #include <string>
37 
38 namespace mir
39 {
40 namespace compositor
41 {
42 struct BufferIPCPackage;
43 class BufferStream;
44 }
45 namespace frontend { class EventSink; }
46 namespace graphics
47 {
48 class Buffer;
49 }
50 namespace input
51 {
52 class InputChannel;
53 class InputSender;
54 class Surface;
55 }
56 namespace scene
57 {
58 class SceneReport;
59 class CursorStreamImageAdapter;
60 
61 class BasicSurface : public Surface
62 {
63 public:
65  std::string const& name,
68  bool nonrectangular,
69  std::list<scene::StreamInfo> const& streams,
70  std::shared_ptr<input::InputChannel> const& input_channel,
71  std::shared_ptr<input::InputSender> const& sender,
72  std::shared_ptr<graphics::CursorImage> const& cursor_image,
73  std::shared_ptr<SceneReport> const& report);
74 
76  std::string const& name,
78  std::weak_ptr<Surface> const& parent,
80  bool nonrectangular,
81  std::list<scene::StreamInfo> const& streams,
82  std::shared_ptr<input::InputChannel> const& input_channel,
83  std::shared_ptr<input::InputSender> const& sender,
84  std::shared_ptr<graphics::CursorImage> const& cursor_image,
85  std::shared_ptr<SceneReport> const& report);
86 
87  ~BasicSurface() noexcept;
88 
89  std::string name() const override;
90  void move_to(geometry::Point const& top_left) override;
91  float alpha() const override;
92  void set_hidden(bool is_hidden);
93 
94  geometry::Size size() const override;
95  geometry::Size client_size() const override;
96 
97  std::shared_ptr<frontend::BufferStream> primary_buffer_stream() const override;
98  void set_streams(std::list<scene::StreamInfo> const& streams) override;
99 
100  bool supports_input() const override;
101  int client_input_fd() const override;
102  std::shared_ptr<input::InputChannel> input_channel() const override;
103  input::InputReceptionMode reception_mode() const override;
104  void set_reception_mode(input::InputReceptionMode mode) override;
105 
106  void set_input_region(std::vector<geometry::Rectangle> const& input_rectangles) override;
107 
108  std::shared_ptr<compositor::BufferStream> buffer_stream() const;
109 
110  void resize(geometry::Size const& size) override;
111  geometry::Point top_left() const override;
112  geometry::Rectangle input_bounds() const override;
113  bool input_area_contains(geometry::Point const& point) const override;
114  void consume(MirEvent const* event) override;
115  void set_alpha(float alpha) override;
116  void set_orientation(MirOrientation orientation) override;
117  void set_transformation(glm::mat4 const&) override;
118 
119  bool visible() const override;
120 
121  graphics::RenderableList generate_renderables(compositor::CompositorID id) const override;
122  int buffers_ready_for_compositor(void const* compositor_id) const override;
123 
124  MirSurfaceType type() const override;
125  MirSurfaceState state() const override;
126  int configure(MirSurfaceAttrib attrib, int value) override;
127  int query(MirSurfaceAttrib attrib) const override;
128  void hide() override;
129  void show() override;
130 
131  void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) override;
132  std::shared_ptr<graphics::CursorImage> cursor_image() const override;
133 
134  void set_cursor_stream(std::shared_ptr<frontend::BufferStream> const& stream,
135  geometry::Displacement const& hotspot) override;
136  void set_cursor_from_buffer(graphics::Buffer& buffer,
137  geometry::Displacement const& hotspot);
138 
139  void request_client_surface_close() override;
140 
141  std::shared_ptr<Surface> parent() const override;
142 
143  void add_observer(std::shared_ptr<SurfaceObserver> const& observer) override;
144  void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) override;
145 
146  int dpi() const;
147 
148  void set_keymap(MirInputDeviceId id, std::string const& model, std::string const& layout,
149  std::string const& variant, std::string const& options) override;
150 
151  void rename(std::string const& title) override;
152 
153  void set_confine_pointer_state(MirPointerConfinementState state) override;
154  MirPointerConfinementState confine_pointer_state() const override;
155 
156 private:
157  bool visible(std::unique_lock<std::mutex>&) const;
158  MirSurfaceType set_type(MirSurfaceType t); // Use configure() to make public changes
159  MirSurfaceState set_state(MirSurfaceState s);
160  int set_dpi(int);
161  MirSurfaceVisibility set_visibility(MirSurfaceVisibility v);
162  int set_swap_interval(int);
163  MirSurfaceFocusState set_focus_state(MirSurfaceFocusState f);
164  MirOrientationMode set_preferred_orientation(MirOrientationMode mode);
165 
166  SurfaceObservers observers;
167  std::mutex mutable guard;
168  std::string surface_name;
169  geometry::Rectangle surface_rect;
170  glm::mat4 transformation_matrix;
171  float surface_alpha;
172  bool hidden;
173  input::InputReceptionMode input_mode;
174  const bool nonrectangular;
175  std::vector<geometry::Rectangle> custom_input_rectangles;
176  std::shared_ptr<compositor::BufferStream> const surface_buffer_stream;
177  std::shared_ptr<input::InputChannel> const server_input_channel;
178  std::shared_ptr<input::InputSender> const input_sender;
179  std::shared_ptr<graphics::CursorImage> cursor_image_;
180  std::shared_ptr<SceneReport> const report;
181  std::weak_ptr<Surface> const parent_;
182 
183  std::list<StreamInfo> layers;
184  // Surface attributes:
187  int swapinterval_ = 1;
189  int dpi_ = 0;
191  MirOrientationMode pref_orientation_mode = mir_orientation_mode_any;
192  MirPointerConfinementState confine_pointer_state_ = mir_pointer_unconfined;
193 
194  std::unique_ptr<CursorStreamImageAdapter> const cursor_stream_adapter;
195 
196  input::Validator input_validator;
197 };
198 
199 }
200 }
201 
202 #endif // MIR_SCENE_BASIC_SURFACE_H_
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
Definition: common.h:90
Definition: point.h:30
Definition: common.h:230
MirPointerConfinementState
Pointer Confinement.
Definition: common.h:228
Definition: common.h:84
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
Definition: validator.h:32
MirSurfaceState
Definition: common.h:64
int64_t MirInputDeviceId
Definition: input_event.h:35
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire...
Definition: common.h:34
MirSurfaceType
Definition: common.h:48
Definition: basic_surface.h:61
Definition: displacement.h:32
MirSurfaceFocusState
Definition: common.h:82
MirSurfaceVisibility
Definition: common.h:88
void const * CompositorID
Definition: compositor_id.h:27
std::vector< std::shared_ptr< Renderable > > RenderableList
Definition: renderable.h:79
Definition: rectangle.h:33
Definition: surface_observers.h:30
Definition: common.h:67
Definition: common.h:190
Definition: buffer.h:44
MirOrientationMode
Definition: common.h:180
InputReceptionMode
Definition: input_reception_mode.h:27
Definition: surface.h:49
AKA "regular".
Definition: common.h:50
int const size
Definition: make_socket_rpc_channel.cpp:51
Definition: event.h:30
char const * consume(char const *pos, Data &data)
Definition: event.h:83

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