Mir
window.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_H
18#define MIRAL_WINDOW_H
19
20#include "miral/application.h"
21
22#include <mir/geometry/point.h>
23#include <mir/geometry/size.h>
24
25#include <memory>
26
27namespace mir
28{
29namespace scene { class Surface; }
30}
31
32namespace miral
33{
34/// Handle class to manage a Mir surface. It may be null (e.g. default initialized)
35class Window
36{
37public:
39 Window(Application const& application, std::shared_ptr<mir::scene::Surface> const& surface);
41
42 /// The position of the top-left corner of the window frame
43 auto top_left() const -> mir::geometry::Point;
44 /// The size of the window frame. Units are logical screen coordinates (not necessarily device pixels). Any
45 /// decorations are included in the size.
46 auto size() const -> mir::geometry::Size;
47 /// The application that created this window
48 auto application() const -> Application;
49
50 /// Indicates that the Window isn't null
51 operator bool() const;
52
53 /// Not for external use, use WindowManagerTools::modify_window() instead
54 /// @{
55 void resize(mir::geometry::Size const& size);
56 void move_to(mir::geometry::Point top_left);
57 /// @}
58
59 /// Access to the underlying Mir surface
60 /// @{
61 operator std::weak_ptr<mir::scene::Surface>() const;
62 operator std::shared_ptr<mir::scene::Surface>() const;
63 /// @}
64
65private:
66 struct Self;
67 std::shared_ptr <Self> self;
68
69 friend bool operator==(Window const& lhs, Window const& rhs);
70 friend bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
71 friend bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
72 friend bool operator<(Window const& lhs, Window const& rhs);
73};
74
75bool operator==(Window const& lhs, Window const& rhs);
76bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
77bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
78bool operator<(Window const& lhs, Window const& rhs);
79
80inline bool operator!=(Window const& lhs, Window const& rhs) { return !(lhs == rhs); }
81inline bool operator!=(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs) { return !(lhs == rhs); }
82inline bool operator!=(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs) { return !(lhs == rhs); }
83inline bool operator>(Window const& lhs, Window const& rhs) { return rhs < lhs; }
84inline bool operator<=(Window const& lhs, Window const& rhs) { return !(lhs > rhs); }
85inline bool operator>=(Window const& lhs, Window const& rhs) { return !(lhs < rhs); }
86
87/// Customization for Google test (to print surface name in errors)
88/// \see https://github.com/google/googletest/blob/main/docs/advanced.md#teaching-googletest-how-to-print-your-values
89/// \remark Since MirAL 3.3
90void PrintTo(Window const& bar, std::ostream* os);
91}
92
93#endif //MIRAL_WINDOW_H
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:36
friend bool operator==(Window const &lhs, Window const &rhs)
auto top_left() const -> mir::geometry::Point
The position of the top-left corner of the window frame.
operator std::shared_ptr< mir::scene::Surface >() const
Window(Application const &application, std::shared_ptr< mir::scene::Surface > const &surface)
friend bool operator==(std::shared_ptr< mir::scene::Surface > const &lhs, Window const &rhs)
operator std::weak_ptr< mir::scene::Surface >() const
Access to the underlying Mir surface.
auto size() const -> mir::geometry::Size
The size of the window frame. Units are logical screen coordinates (not necessarily device pixels)....
void resize(mir::geometry::Size const &size)
Not for external use, use WindowManagerTools::modify_window() instead.
void move_to(mir::geometry::Point top_left)
operator bool() const
Indicates that the Window isn't null.
auto application() const -> Application
The application that created this window.
friend bool operator<(Window const &lhs, Window const &rhs)
friend bool operator==(Window const &lhs, std::shared_ptr< mir::scene::Surface > const &rhs)
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition: size.h:27
Definition: internal_client.h:24
Definition: runner.h:27
Mir Abstraction Layer.
Definition: runner.h:35
bool operator!=(Window const &lhs, std::shared_ptr< mir::scene::Surface > const &rhs)
Definition: window.h:82
bool operator!=(std::shared_ptr< mir::scene::Surface > const &lhs, Window const &rhs)
Definition: window.h:81
bool operator>(Window const &lhs, Window const &rhs)
Definition: window.h:83
bool operator<=(Window const &lhs, Window const &rhs)
Definition: window.h:84
bool operator!=(Window const &lhs, Window const &rhs)
Definition: window.h:80
void PrintTo(Window const &bar, std::ostream *os)
Customization for Google test (to print surface name in errors)
bool operator>=(Window const &lhs, Window const &rhs)
Definition: window.h:85

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.