MirAL
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 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 MIR_CLIENT_WINDOW_H
20 #define MIR_CLIENT_WINDOW_H
21 
23 
24 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
25 #include <mir_toolkit/mir_surface.h>
26 auto const mir_window_release_sync = mir_surface_release_sync;
27 auto const mir_window_release = mir_surface_release;
28 auto const mir_window_get_buffer_stream = mir_surface_get_buffer_stream;
29 auto const mir_window_is_valid = mir_surface_is_valid;
30 auto const mir_window_get_error_message = mir_surface_get_error_message;
31 auto const mir_window_set_state = mir_surface_set_state;
32 #else
33 #include <mir_toolkit/mir_window.h>
34 #endif
35 
36 #include <memory>
37 
38 namespace mir
39 {
40 namespace client
41 {
43 class Window
44 {
45 public:
46  Window() = default;
47  explicit Window(MirWindow* spec) : self{spec, deleter} {}
48 
49 
50  operator MirWindow*() const { return self.get(); }
51 
52  void reset() { self.reset(); }
53 
54 private:
55  static void deleter(MirWindow* window) { mir_window_release_sync(window); }
56  std::shared_ptr<MirWindow> self;
57 };
58 
59 // Provide a deleted overload to avoid double release "accidents".
60 void mir_window_release_sync(Window const& window) = delete;
61 void mir_surface_release_sync(Window const& window) = delete;
62 }
63 }
64 
65 #endif //MIR_CLIENT_WINDOW_H
Definition: blob.h:26

Copyright © 2016 Canonical Ltd.
Generated on Thu Mar 30 14:25:04 UTC 2017