Mir
Loading...
Searching...
No Matches
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{
35class Window
36{
37public:
39 Window(Application const& application, std::shared_ptr<mir::scene::Surface> const& surface);
41
43 auto top_left() const -> mir::geometry::Point;
46 auto size() const -> mir::geometry::Size;
48 auto application() const -> Application;
49
51 operator bool() const;
52
55 void resize(mir::geometry::Size const& size);
56 void move_to(mir::geometry::Point top_left);
58
61 operator std::weak_ptr<mir::scene::Surface>() const;
62 operator std::shared_ptr<mir::scene::Surface>() const;
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
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
auto top_left() const -> mir::geometry::Point
The position of the top-left corner of the window frame.
Window(Application const &application, std::shared_ptr< mir::scene::Surface > const &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)
auto application() const -> Application
The application that created this window.
Definition splash_session.h:22
Mir Abstraction Layer.
Definition floating_window_manager.h:29
std::shared_ptr< mir::scene::Session > Application
Definition application.h:32
bool operator>(Window const &lhs, Window const &rhs)
Definition window.h:83
bool operator!=(Output::PhysicalSizeMM const &lhs, Output::PhysicalSizeMM const &rhs)
Definition output.h:127
bool operator<=(Window const &lhs, Window const &rhs)
Definition window.h:84
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
STL namespace.
Definition point.h:37
Definition size.h:37

Copyright © 2012-2025 Canonical Ltd.
Generated on Mon Jan 20 23:24:07 UTC 2025
This documentation is licensed under the GPL version 2 or 3.