Mir
window_specification.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 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 2 or 3 as
6  * 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 
17 #ifndef MIRAL_WINDOW_SPECIFICATION_H
18 #define MIRAL_WINDOW_SPECIFICATION_H
19 
20 #include <mir_toolkit/common.h>
21 
22 #include <mir/geometry/displacement.h>
23 #include <mir/geometry/rectangles.h>
24 #include <mir/optional_value.h>
25 #include <mir/int_wrapper.h>
26 
27 #include <memory>
28 
29 namespace mir
30 {
31 namespace scene { class Surface; }
32 namespace shell { struct SurfaceSpecification; }
33 }
34 
35 namespace miral
36 {
37 using namespace mir::geometry;
38 namespace detail { struct SessionsBufferStreamIdTag; }
40 
42 {
43 public:
44  enum class InputReceptionMode
45  {
46  normal,
48  };
49 
50  struct AspectRatio { unsigned width; unsigned height; };
51 
55 
56  WindowSpecification(mir::shell::SurfaceSpecification const& spec);
57 
59 
60  auto top_left() const -> mir::optional_value<Point> const&;
61  auto size() const -> mir::optional_value<Size> const&;
62  auto name() const -> mir::optional_value<std::string> const&;
63  auto output_id() const -> mir::optional_value<int> const&;
64  auto type() const -> mir::optional_value<MirWindowType> const&;
65  auto state() const -> mir::optional_value<MirWindowState> const&;
66  auto preferred_orientation() const -> mir::optional_value<MirOrientationMode> const&;
67  auto aux_rect() const -> mir::optional_value<Rectangle> const&;
68  auto placement_hints() const -> mir::optional_value<MirPlacementHints> const&;
69  auto window_placement_gravity() const -> mir::optional_value<MirPlacementGravity> const&;
70  auto aux_rect_placement_gravity() const -> mir::optional_value<MirPlacementGravity> const&;
71  auto aux_rect_placement_offset() const -> mir::optional_value<Displacement> const&;
72  auto min_width() const -> mir::optional_value<Width> const&;
73  auto min_height() const -> mir::optional_value<Height> const&;
74  auto max_width() const -> mir::optional_value<Width> const&;
75  auto max_height() const -> mir::optional_value<Height> const&;
76  auto width_inc() const -> mir::optional_value<DeltaX> const&;
77  auto height_inc() const -> mir::optional_value<DeltaY> const&;
78  auto min_aspect() const -> mir::optional_value<AspectRatio> const&;
79  auto max_aspect() const -> mir::optional_value<AspectRatio> const&;
80 
81  auto parent() const -> mir::optional_value<std::weak_ptr<mir::scene::Surface>> const&;
82  auto input_shape() const -> mir::optional_value<std::vector<Rectangle>> const&;
83  auto input_mode() const -> mir::optional_value<InputReceptionMode> const&;
84  auto shell_chrome() const -> mir::optional_value<MirShellChrome> const&;
85  auto confine_pointer() const -> mir::optional_value<MirPointerConfinementState> const&;
86  auto userdata() const -> mir::optional_value<std::shared_ptr<void>> const&;
87 
88  auto top_left() -> mir::optional_value<Point>&;
89  /// The new size of the window frame (including any decorations). Will be adjusted based on min_width(),
90  /// WindowInfo::max_width(), WindowInfo::min_height(), WindowInfo::max_height(), WindowInfo::min_aspect(),
91  /// WindowInfo::max_aspect(), WindowInfo::width_inc() and WindowInfo::height_inc(). Set these to properties to their
92  /// default values if they should be ignored.
93  auto size() -> mir::optional_value<Size>&;
94  auto name() -> mir::optional_value<std::string>&;
95  auto output_id() -> mir::optional_value<int>&;
96  auto type() -> mir::optional_value<MirWindowType>&;
97  auto state() -> mir::optional_value<MirWindowState>&;
98  auto preferred_orientation() -> mir::optional_value<MirOrientationMode>&;
99  /// Relative to window's surface's CONTENT offset and size
100  /// (not equal to the top_left and size exposed by this interface if server-side decorations are in use)
101  auto aux_rect() -> mir::optional_value<Rectangle>&;
102  auto placement_hints() -> mir::optional_value<MirPlacementHints>&;
103  auto window_placement_gravity() -> mir::optional_value<MirPlacementGravity>&;
104  auto aux_rect_placement_gravity() -> mir::optional_value<MirPlacementGravity>&;
105  auto aux_rect_placement_offset() -> mir::optional_value<Displacement>&;
106 
107  /// Constrains how a window can be resized, see the corresponding properties on WindowInfo for details.
108  /// @{
109  auto min_width() -> mir::optional_value<Width>&;
110  auto min_height() -> mir::optional_value<Height>&;
111  auto max_width() -> mir::optional_value<Width>&;
112  auto max_height() -> mir::optional_value<Height>&;
113  auto width_inc() -> mir::optional_value<DeltaX>&;
114  auto height_inc() -> mir::optional_value<DeltaY>&;
117  /// @}
118 
119  auto parent() -> mir::optional_value<std::weak_ptr<mir::scene::Surface>>&;
122  auto shell_chrome() -> mir::optional_value<MirShellChrome>&;
123  auto confine_pointer() -> mir::optional_value<MirPointerConfinementState>&;
124  auto userdata() -> mir::optional_value<std::shared_ptr<void>>&;
125 
126  /// The depth layer of a child window is updated with the depth layer of its parent, but can be overridden
127  ///@{
128  auto depth_layer() const -> mir::optional_value<MirDepthLayer> const&;
129  auto depth_layer() -> mir::optional_value<MirDepthLayer>&;
130  ///@}
131 
132  /// The set of window eges that are attched to edges of the output
133  /// If attached to perpendicular edges, it is attached to the corner where the two edges intersect
134  /// If attached to oposite edges (eg left and right), it is stretched across the output in that direction
135  /// If all edges are specified, it takes up the entire output
136  ///@{
137  auto attached_edges() const -> mir::optional_value<MirPlacementGravity> const&;
138  auto attached_edges() -> mir::optional_value<MirPlacementGravity>&;
139  ///@}
140 
141  /// The area over which the window should not be occluded
142  /// Only meaningful for windows attached to an edge
143  /// If the outer optional is unset (the default), the window's exclusive rect is not changed by this spec
144  /// If the outer optional is set but the inner is not, the window's exclusive rect is cleared
145  ///@{
146  auto exclusive_rect() const -> mir::optional_value<mir::optional_value<mir::geometry::Rectangle>> const&;
148  ///@}
149 
150  /// The D-bus service name and basename of the app's .desktop file
151  /// See http://standards.freedesktop.org/desktop-entry-spec/
152  ///@{
153  auto application_id() const -> mir::optional_value<std::string> const&;
154  auto application_id() -> mir::optional_value<std::string>&;
155  ///@}
156 
157  /// If this window should have server-side decorations provided by Mir
158  /// Currently, Mir only respects this value during surface construction
159  ///@{
160  auto server_side_decorated() const -> mir::optional_value<bool> const&;
162  ///@}
163 
164  /// How the window should gain and lose focus
165  /// \remark Since MirAL 3.3
166  ///@{
167  auto focus_mode() const -> mir::optional_value<MirFocusMode> const&;
168  auto focus_mode() -> mir::optional_value<MirFocusMode>&;
169  ///@}
170 
171 private:
172  friend auto make_surface_spec(WindowSpecification const& miral_spec) -> mir::shell::SurfaceSpecification;
173  struct Self;
174  std::unique_ptr<Self> self;
175 };
176 }
177 
178 #endif //MIRAL_WINDOW_SPECIFICATION_H

Copyright © 2012-2022 Canonical Ltd.
Generated on Tue Sep 13 03:20:30 UTC 2022
This documentation is licensed under the GPL version 2 or 3.