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);
43 
45  auto top_left() const -> mir::geometry::Point;
48  auto size() const -> mir::geometry::Size;
50  auto application() const -> Application;
51 
53  operator bool() const;
54 
57  void resize(mir::geometry::Size const& size);
58  void move_to(mir::geometry::Point top_left);
60 
63  operator std::weak_ptr<mir::scene::Surface>() const;
64  operator std::shared_ptr<mir::scene::Surface>() const;
66 
67 private:
68  struct Self;
69  std::shared_ptr <Self> self;
70 
71  friend bool operator==(Window const& lhs, Window const& rhs);
72  friend bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
73  friend bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
74  friend bool operator<(Window const& lhs, Window const& rhs);
75 };
76 
77 bool operator==(Window const& lhs, Window const& rhs);
78 bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
79 bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
80 bool operator<(Window const& lhs, Window const& rhs);
81 
82 inline bool operator!=(Window const& lhs, Window const& rhs) { return !(lhs == rhs); }
83 inline bool operator!=(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs) { return !(lhs == rhs); }
84 inline bool operator!=(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs) { return !(lhs == rhs); }
85 inline bool operator>(Window const& lhs, Window const& rhs) { return rhs < lhs; }
86 inline bool operator<=(Window const& lhs, Window const& rhs) { return !(lhs > rhs); }
87 inline bool operator>=(Window const& lhs, Window const& rhs) { return !(lhs < rhs); }
88 }
89 
90 #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
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:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:31
std::shared_ptr< mir::scene::Session > Application
Definition: application.h:34
bool operator>(Window const &lhs, Window const &rhs)
Definition: window.h:85
bool operator!=(Output::PhysicalSizeMM const &lhs, Output::PhysicalSizeMM const &rhs)
Definition: output.h:116
bool operator<=(Window const &lhs, Window const &rhs)
Definition: window.h:86
bool operator>=(Window const &lhs, Window const &rhs)
Definition: window.h:87
Definition: point.h:31
Definition: size.h:32

Copyright © 2012-2021 Canonical Ltd.
Generated on Thu Feb 11 23:56:40 UTC 2021
This documentation is licensed under the GPL version 2 or 3.