MirAL
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 3,
6  * as 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 
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 
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 };
67 
68 bool operator==(Window const& lhs, Window const& rhs);
69 bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
70 bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
71 
72 inline bool operator!=(Window const& lhs, Window const& rhs) { return !(lhs == rhs); }
73 inline bool operator!=(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs) { return !(lhs == rhs); }
74 inline bool operator!=(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs) { return !(lhs == rhs); }
75 }
76 
77 #endif //MIRAL_WINDOW_H
Definition: active_outputs.h:25
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:37
bool operator!=(Window const &lhs, std::shared_ptr< mir::scene::Surface > const &rhs)
Definition: window.h:74
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:31
bool operator==(Window const &lhs, std::shared_ptr< mir::scene::Surface > const &rhs)
Mir Abstraction Layer.
Definition: active_outputs.h:27

Copyright © 2016 Canonical Ltd.
Generated on Fri Sep 30 13:21:55 UTC 2016