Mir
window.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 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIRAL_WINDOW_H
20#define MIRAL_WINDOW_H
21
22#include "miral/application.h"
23
24#include <mir/geometry/point.h>
25#include <mir/geometry/size.h>
26
27#include <memory>
28
29namespace mir
30{
31namespace scene { class Surface; }
32}
33
34namespace miral
35{
37class Window
38{
39public:
41 Window(Application const& application, std::shared_ptr<mir::scene::Surface> const& surface);
43
44 auto top_left() const -> mir::geometry::Point;
45 auto size() const -> mir::geometry::Size;
46 auto application() const -> Application;
47
48 // Indicates that the Window isn't null
49 operator bool() const;
50
51 void resize(mir::geometry::Size const& size);
52
53 void move_to(mir::geometry::Point top_left);
54
55 // Access to the underlying Mir surface
56 operator std::weak_ptr<mir::scene::Surface>() const;
57 operator std::shared_ptr<mir::scene::Surface>() const;
58
59private:
60 struct Self;
61 std::shared_ptr <Self> self;
62
63 friend bool operator==(Window const& lhs, Window const& rhs);
64 friend bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
65 friend bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
66 friend bool operator<(Window const& lhs, Window const& rhs);
67};
68
69bool operator==(Window const& lhs, Window const& rhs);
70bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
71bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
72bool operator<(Window const& lhs, Window const& rhs);
73
74inline bool operator!=(Window const& lhs, Window const& rhs) { return !(lhs == rhs); }
75inline bool operator!=(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs) { return !(lhs == rhs); }
76inline bool operator!=(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs) { return !(lhs == rhs); }
77inline bool operator>(Window const& lhs, Window const& rhs) { return rhs < lhs; }
78inline bool operator<=(Window const& lhs, Window const& rhs) { return !(lhs > rhs); }
79inline bool operator>=(Window const& lhs, Window const& rhs) { return !(lhs < rhs); }
80}
81
82#endif //MIRAL_WINDOW_H
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:38
auto top_left() const -> mir::geometry::Point
Window(Application const &application, std::shared_ptr< mir::scene::Surface > const &surface)
auto size() const -> mir::geometry::Size
void resize(mir::geometry::Size const &size)
void move_to(mir::geometry::Point top_left)
auto application() const -> Application
Definition: splash_session.h:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:29
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
bool operator>(Window const &lhs, Window const &rhs)
Definition: window.h:77
bool operator!=(Output::PhysicalSizeMM const &lhs, Output::PhysicalSizeMM const &rhs)
Definition: output.h:111
bool operator<=(Window const &lhs, Window const &rhs)
Definition: window.h:78
bool operator>=(Window const &lhs, Window const &rhs)
Definition: window.h:79
STL namespace.
Definition: point.h:31
Definition: size.h:32

Copyright © 2012-2022 Canonical Ltd.
Generated on Sun Oct 9 06:13:38 UTC 2022
This documentation is licensed under the GPL version 2 or 3.