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 
29 namespace mir
30 {
31 namespace scene { class Surface; }
32 }
33 
34 namespace miral
35 {
37 class Window
38 {
39 public:
40  Window();
41  Window(Application const& application, std::shared_ptr<mir::scene::Surface> const& surface);
42  ~Window();
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 
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 
59 private:
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 
69 bool operator==(Window const& lhs, Window const& rhs);
70 bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
71 bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
72 bool operator<(Window const& lhs, Window const& rhs);
73 
74 inline bool operator!=(Window const& lhs, Window const& rhs) { return !(lhs == rhs); }
75 inline bool operator!=(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs) { return !(lhs == rhs); }
76 inline bool operator!=(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs) { return !(lhs == rhs); }
77 inline bool operator>(Window const& lhs, Window const& rhs) { return rhs < lhs; }
78 inline bool operator<=(Window const& lhs, Window const& rhs) { return !(lhs > rhs); }
79 inline bool operator>=(Window const& lhs, Window const& rhs) { return !(lhs < rhs); }
80 }
81 
82 #endif //MIRAL_WINDOW_H
miral::Window::move_to
void move_to(mir::geometry::Point top_left)
point.h
miral
Mir Abstraction Layer.
Definition: floating_window_manager.h:29
miral::operator!=
bool operator!=(Output::PhysicalSizeMM const &lhs, Output::PhysicalSizeMM const &rhs)
Definition: output.h:111
miral::Window::operator<
friend bool operator<(Window const &lhs, Window const &rhs)
miral::operator>
bool operator>(Window const &lhs, Window const &rhs)
Definition: window.h:77
miral::Window::size
auto size() const -> mir::geometry::Size
miral::operator<
bool operator<(Window const &lhs, Window const &rhs)
miral::Application
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
miral::operator>=
bool operator>=(Window const &lhs, Window const &rhs)
Definition: window.h:79
miral::Window
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:37
mir
Definition: splash_session.h:24
miral::Window::Window
Window()
miral::Window::resize
void resize(mir::geometry::Size const &size)
miral::Window::~Window
~Window()
miral::Window::application
auto application() const -> Application
miral::Window::top_left
auto top_left() const -> mir::geometry::Point
mir::geometry::Point
Definition: point.h:30
miral::operator<=
bool operator<=(Window const &lhs, Window const &rhs)
Definition: window.h:78
miral::operator==
bool operator==(Output::PhysicalSizeMM const &lhs, Output::PhysicalSizeMM const &rhs)
mir::geometry::Size
Definition: size.h:31
size.h
miral::Window::operator==
friend bool operator==(Window const &lhs, Window const &rhs)
application.h

Copyright © 2012-2020 Canonical Ltd.
Generated on Mon Jun 29 21:51:46 UTC 2020
This documentation is licensed under the GPL version 2 or 3.