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
23
24#include <memory>
25
26namespace mir
27{
28namespace client
29{
31class Window
32{
33public:
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
42private:
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".
48void mir_window_release_sync(Window const& window) = delete;
49void mir_surface_release_sync(Window const& window) = delete;
50}
51}
52
53#endif //MIR_CLIENT_WINDOW_H
Handle class for MirWindow - provides automatic reference counting.
Definition: window.h:32
void reset()
Definition: window.h:40
Window(MirWindow *spec)
Definition: window.h:35
struct MirSurface MirWindow
Definition: client_types.h:43
void mir_surface_release_sync(Window const &window)=delete
void mir_window_release_sync(Window const &window)=delete
Definition: splash_session.h:24

Copyright © 2012-2022 Canonical Ltd.
Generated on Sun Oct 9 06:13:38 UTC 2022
This documentation is licensed under the GPL version 2 or 3.