Mir
window.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016-2017 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser 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 MIR_CLIENT_WINDOW_H
20 #define MIR_CLIENT_WINDOW_H
21 
22 #include <mir_toolkit/mir_window.h>
23 
24 #include <memory>
25 
26 namespace mir
27 {
28 namespace client
29 {
31 class Window
32 {
33 public:
34  Window() = default;
35  explicit Window(MirWindow* spec) : self{spec, deleter} {}
36 
37 
38  operator MirWindow*() const { return self.get(); }
39 
40  void reset() { self.reset(); }
41 
42 private:
43  static void deleter(MirWindow* window) { mir_window_release_sync(window); }
44  std::shared_ptr<MirWindow> self;
45 };
46 
47 // Provide a deleted overload to avoid double release "accidents".
48 void mir_window_release_sync(Window const& window) = delete;
49 void mir_surface_release_sync(Window const& window) = delete;
50 }
51 }
52 
53 #endif //MIR_CLIENT_WINDOW_H
mir::client::Window::reset
void reset()
Definition: window.h:40
mir::client::mir_window_release_sync
void mir_window_release_sync(Window const &window)=delete
mir::client::Window::Window
Window(MirWindow *spec)
Definition: window.h:35
MirWindow
struct MirSurface MirWindow
Definition: client_types.h:43
mir_window.h
mir::client::Window
Handle class for MirWindow - provides automatic reference counting.
Definition: window.h:32
mir
Definition: splash_session.h:24
mir::client::Window::Window
Window()=default
mir::client::mir_surface_release_sync
void mir_surface_release_sync(Window const &window)=delete

Copyright © 2012-2020 Canonical Ltd.
Generated on Sun Sep 27 19:03:53 UTC 2020
This documentation is licensed under the GPL version 2 or 3.