Mir
window_info.h
Go to the documentation of this file.
1/*
2 * Copyright © 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_INFO_H
18#define MIRAL_WINDOW_INFO_H
19
20#include "miral/window.h"
21#include "miral/window_specification.h"
22
23#include <mir/geometry/rectangles.h>
24#include <mir/optional_value.h>
25
26#include <algorithm>
27
28namespace miral
29{
31{
32 using AspectRatio = WindowSpecification::AspectRatio;
33
35 WindowInfo(Window const& window, WindowSpecification const& params);
37 explicit WindowInfo(WindowInfo const& that);
39
40 bool can_be_active() const;
41
42 bool can_morph_to(MirWindowType new_type) const;
43
44 bool must_have_parent() const;
45
47
48 bool is_visible() const;
49
50 static bool needs_titlebar(MirWindowType type);
51
52 void constrain_resize(mir::geometry::Point& requested_pos, mir::geometry::Size& requested_size) const;
53
54 auto window() const -> Window&;
55
56 auto name() const -> std::string;
57
58 auto type() const -> MirWindowType;
59
60 auto state() const -> MirWindowState;
61
62 auto restore_rect() const -> mir::geometry::Rectangle;
63
64 auto parent() const -> Window;
65
66 auto children() const -> std::vector <Window> const&;
67
68 /// These constrain the sizes a window may be resized to (both interactively and pragmatically). Clients can request
69 /// a min/max size, but it can be overridden by the window management policy. By default, minimum values are 0 and
70 /// maximum values are `std::numeric_limits<int>::max()`.
71 /// @{
72 auto min_width() const -> mir::geometry::Width;
73 auto min_height() const -> mir::geometry::Height;
74 auto max_width() const -> mir::geometry::Width;
75 auto max_height() const -> mir::geometry::Height;
76 /// @}
77
78 /// These control the size increments of the window. This is used in cases like a terminal that can only be resized
79 /// character-by-character. Current Wayland protocols do not support this property, so it generally wont be
80 /// requested by clients. By default, both are 1.
81 /// @{
82 auto width_inc() const -> mir::geometry::DeltaX;
83 auto height_inc() const -> mir::geometry::DeltaY;
84 /// @}
85
86 /// These constrain the possible aspect ratio of the window. Current Wayland protocols to not support this property,
87 /// so it generally wont be requested by clients. By default, min_aspect is
88 /// `{0U, std::numeric_limits<unsigned>::max()}` and max_aspect is `{std::numeric_limits<unsigned>::max(), 0U}`.
89 /// @{
90 auto min_aspect() const -> AspectRatio;
91 auto max_aspect() const -> AspectRatio;
92 /// @}
93
94 bool has_output_id() const;
95 auto output_id() const -> int;
96
97 auto preferred_orientation() const -> MirOrientationMode;
98
99 auto confine_pointer() const -> MirPointerConfinementState;
100
101 auto shell_chrome() const -> MirShellChrome;
102
103 /// This can be used by client code to store window manager specific information
104 auto userdata() const -> std::shared_ptr<void>;
105 void userdata(std::shared_ptr<void> userdata);
106
107 void swap(WindowInfo& rhs) { std::swap(self, rhs.self); }
108
109 auto depth_layer() const -> MirDepthLayer;
110
111 /// Get the edges of the output that the window is attached to
112 /// (only meaningful for windows in state mir_window_state_attached)
113 auto attached_edges() const -> MirPlacementGravity;
114
115 /// Mir will try to avoid occluding the area covered by this rectangle (relative to the window)
116 /// (only meaningful when the window is attached to an edge)
117 auto exclusive_rect() const -> mir::optional_value<mir::geometry::Rectangle>;
118
119 /// Mir will not render anything outside this rectangle
120 auto clip_area() const -> mir::optional_value<mir::geometry::Rectangle>;
121 void clip_area(mir::optional_value<mir::geometry::Rectangle> const& area);
122
123 /// The D-bus service name and basename of the app's .desktop file
124 /// See http://standards.freedesktop.org/desktop-entry-spec/
125 /// \remark Since MirAL 2.8
126 ///@{
127 auto application_id() const -> std::string;
128 ///@}
129
130 /// How the window should gain and lose focus
131 /// \remark Since MirAL 3.3
132 auto focus_mode() const -> MirFocusMode;
133
134private:
135 friend class BasicWindowManager;
136 void name(std::string const& name);
137 void type(MirWindowType type);
138 void state(MirWindowState state);
139 void restore_rect(mir::geometry::Rectangle const& restore_rect);
140 void parent(Window const& parent);
141 void add_child(Window const& child);
142 void remove_child(Window const& child);
143 void min_width(mir::geometry::Width min_width);
144 void min_height(mir::geometry::Height min_height);
145 void max_width(mir::geometry::Width max_width);
146 void max_height(mir::geometry::Height max_height);
147 void width_inc(mir::geometry::DeltaX width_inc);
148 void height_inc(mir::geometry::DeltaY height_inc);
149 void min_aspect(AspectRatio min_aspect);
150 void max_aspect(AspectRatio max_aspect);
151 void output_id(mir::optional_value<int> output_id);
152 void preferred_orientation(MirOrientationMode preferred_orientation);
153 void confine_pointer(MirPointerConfinementState confinement);
154 void shell_chrome(MirShellChrome chrome);
155 void depth_layer(MirDepthLayer depth_layer);
156 void attached_edges(MirPlacementGravity edges);
157 void exclusive_rect(mir::optional_value<mir::geometry::Rectangle> const& rect);
158 void application_id(std::string const& application_id);
159 void focus_mode(MirFocusMode focus_mode);
160
161 struct Self;
162 std::unique_ptr<Self> self;
163};
164}
165
166namespace std
167{
168template<> inline void swap(miral::WindowInfo& lhs, miral::WindowInfo& rhs) { lhs.swap(rhs); }
169}
170
171#endif //MIRAL_WINDOW_INFO_H
Definition: optional_value.h:27
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:36
Definition: window_specification.h:42
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition: size.h:27
Definition: runner.h:27
Mir Abstraction Layer.
Definition: runner.h:35
Definition: window_info.h:31
auto min_height() const -> mir::geometry::Height
auto name() const -> std::string
bool can_be_active() const
auto type() const -> MirWindowType
static bool needs_titlebar(MirWindowType type)
auto depth_layer() const -> MirDepthLayer
void swap(WindowInfo &rhs)
Definition: window_info.h:107
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 &
WindowInfo & operator=(WindowInfo const &that)
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...
void clip_area(mir::optional_value< mir::geometry::Rectangle > const &area)
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_...
void userdata(std::shared_ptr< void > userdata)
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:50

Copyright © 2012-2023 Canonical Ltd.
Generated on Tue 2 May 10:01:24 UTC 2023
This documentation is licensed under the GPL version 2 or 3.