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 
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 
27 namespace mir
28 {
29 namespace scene { class Surface; }
30 }
31 
32 namespace miral
33 {
35 class Window
36 {
37 public:
38  Window();
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 
65 private:
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 
75 bool operator==(Window const& lhs, Window const& rhs);
76 bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs);
77 bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs);
78 bool operator<(Window const& lhs, Window const& rhs);
79 
80 inline bool operator!=(Window const& lhs, Window const& rhs) { return !(lhs == rhs); }
81 inline bool operator!=(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs) { return !(lhs == rhs); }
82 inline bool operator!=(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs) { return !(lhs == rhs); }
83 inline bool operator>(Window const& lhs, Window const& rhs) { return rhs < lhs; }
84 inline bool operator<=(Window const& lhs, Window const& rhs) { return !(lhs > rhs); }
85 inline bool operator>=(Window const& lhs, Window const& rhs) { return !(lhs < rhs); }
86 
90 void 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:114
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
Definition: point.h:30
Definition: size.h:30

Copyright © 2012-2022 Canonical Ltd.
Generated on Tue May 24 14:35:34 UTC 2022
This documentation is licensed under the GPL version 2 or 3.