Mir
window_info.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016-2020 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  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIRAL_WINDOW_INFO_H
20 #define MIRAL_WINDOW_INFO_H
21 
22 #include "miral/window.h"
24 
26 #include <mir/optional_value.h>
27 
28 #include <algorithm>
29 
30 namespace miral
31 {
32 struct WindowInfo
33 {
35 
37  WindowInfo(Window const& window, WindowSpecification const& params);
39  explicit WindowInfo(WindowInfo const& that);
41 
42  bool can_be_active() const;
43 
44  bool can_morph_to(MirWindowType new_type) const;
45 
46  bool must_have_parent() const;
47 
48  bool must_not_have_parent() const;
49 
50  bool is_visible() const;
51 
53 
54  void constrain_resize(mir::geometry::Point& requested_pos, mir::geometry::Size& requested_size) const;
55 
56  auto window() const -> Window&;
57 
58  auto name() const -> std::string;
59 
60  auto type() const -> MirWindowType;
61 
62  auto state() const -> MirWindowState;
63 
64  auto restore_rect() const -> mir::geometry::Rectangle;
65 
66  auto parent() const -> Window;
67 
68  auto children() const -> std::vector <Window> const&;
69 
74  auto min_width() const -> mir::geometry::Width;
75  auto min_height() const -> mir::geometry::Height;
76  auto max_width() const -> mir::geometry::Width;
77  auto max_height() const -> mir::geometry::Height;
79 
84  auto width_inc() const -> mir::geometry::DeltaX;
85  auto height_inc() const -> mir::geometry::DeltaY;
87 
92  auto min_aspect() const -> AspectRatio;
93  auto max_aspect() const -> AspectRatio;
95 
96  bool has_output_id() const;
97  auto output_id() const -> int;
98 
100 
102 
103  auto shell_chrome() const -> MirShellChrome;
104 
106  auto userdata() const -> std::shared_ptr<void>;
107  void userdata(std::shared_ptr<void> userdata);
108 
109  void swap(WindowInfo& rhs) { std::swap(self, rhs.self); }
110 
111  auto depth_layer() const -> MirDepthLayer;
112 
116 
119  auto exclusive_rect() const -> mir::optional_value<mir::geometry::Rectangle>;
120 
122  auto clip_area() const -> mir::optional_value<mir::geometry::Rectangle>;
123  void clip_area(mir::optional_value<mir::geometry::Rectangle> const& area);
124 
129  auto application_id() const -> std::string;
131 
134  auto focus_mode() const -> MirFocusMode;
135 
136 private:
137  friend class BasicWindowManager;
138  void name(std::string const& name);
139  void type(MirWindowType type);
140  void state(MirWindowState state);
141  void restore_rect(mir::geometry::Rectangle const& restore_rect);
142  void parent(Window const& parent);
143  void add_child(Window const& child);
144  void remove_child(Window const& child);
145  void min_width(mir::geometry::Width min_width);
146  void min_height(mir::geometry::Height min_height);
147  void max_width(mir::geometry::Width max_width);
148  void max_height(mir::geometry::Height max_height);
149  void width_inc(mir::geometry::DeltaX width_inc);
150  void height_inc(mir::geometry::DeltaY height_inc);
153  void output_id(mir::optional_value<int> output_id);
156  void shell_chrome(MirShellChrome chrome);
159  void exclusive_rect(mir::optional_value<mir::geometry::Rectangle> const& rect);
160  void application_id(std::string const& application_id);
162 
163  struct Self;
164  std::unique_ptr<Self> self;
165 };
166 }
167 
168 namespace std
169 {
170 template<> inline void swap(miral::WindowInfo& lhs, miral::WindowInfo& rhs) { lhs.swap(rhs); }
171 }
172 
173 #endif //MIRAL_WINDOW_INFO_H
Definition: dimensions.h:36
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:38
Definition: window_specification.h:44
MirFocusMode
Focus mode controls how a surface gains and loses focus.
Definition: common.h:425
MirPointerConfinementState
Pointer Confinement.
Definition: common.h:387
MirWindowType
Definition: common.h:58
MirShellChrome
Shell chrome.
Definition: common.h:378
MirWindowState
Definition: common.h:73
MirPlacementGravity
Reference point for aligning a surface relative to a rectangle.
Definition: common.h:238
MirDepthLayer
Depth layer controls Z ordering of surfaces.
Definition: common.h:412
MirOrientationMode
Definition: common.h:211
Definition: splash_session.h:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:31
Definition: point.h:32
Definition: rectangle.h:34
Definition: size.h:32
Definition: window_info.h:33
auto min_height() const -> mir::geometry::Height
auto name() const -> std::string
bool can_be_active() const
auto type() const -> MirWindowType
WindowInfo & operator=(WindowInfo const &that)
static bool needs_titlebar(MirWindowType type)
auto depth_layer() const -> MirDepthLayer
void swap(WindowInfo &rhs)
Definition: window_info.h:109
auto height_inc() const -> mir::geometry::DeltaY
auto shell_chrome() const -> MirShellChrome
bool can_morph_to(MirWindowType new_type) const
auto userdata() const -> std::shared_ptr< void >
This can be used by client code to store window manager specific information.
bool must_not_have_parent() const
auto confine_pointer() const -> MirPointerConfinementState
bool has_output_id() const
auto output_id() const -> int
auto state() const -> MirWindowState
auto parent() const -> Window
auto max_width() const -> mir::geometry::Width
auto restore_rect() const -> mir::geometry::Rectangle
auto width_inc() const -> mir::geometry::DeltaX
These control the size increments of the window. This is used in cases like a terminal that can only ...
auto clip_area() const -> mir::optional_value< mir::geometry::Rectangle >
Mir will not render anything outside this rectangle.
auto min_width() const -> mir::geometry::Width
These constrain the sizes a window may be resized to (both interactively and pragmatically)....
auto window() const -> Window &
void constrain_resize(mir::geometry::Point &requested_pos, mir::geometry::Size &requested_size) const
WindowInfo(WindowInfo const &that)
auto children() const -> std::vector< Window > const &
friend class BasicWindowManager
Definition: window_info.h:137
auto min_aspect() const -> AspectRatio
These constrain the possible aspect ratio of the window. Current Wayland protocols to not support thi...
auto focus_mode() const -> MirFocusMode
How the window should gain and lose focus.
auto exclusive_rect() const -> mir::optional_value< mir::geometry::Rectangle >
Mir will try to avoid occluding the area covered by this rectangle (relative to the window) (only mea...
auto max_aspect() const -> AspectRatio
bool is_visible() const
WindowInfo(Window const &window, WindowSpecification const &params)
bool must_have_parent() const
auto max_height() const -> mir::geometry::Height
auto attached_edges() const -> MirPlacementGravity
Get the edges of the output that the window is attached to (only meaningful for windows in state mir_...
auto application_id() const -> std::string
The D-bus service name and basename of the app's .desktop file See http://standards....
auto preferred_orientation() const -> MirOrientationMode
Definition: window_specification.h:52

Copyright © 2012-2022 Canonical Ltd.
Generated on Fri Feb 25 18:01:44 UTC 2022
This documentation is licensed under the GPL version 2 or 3.