2
* Copyright © 2016-2017 Canonical Ltd.
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.
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.
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/>.
16
* Authored by: Alan Griffiths <alan@octopull.co.uk>
19
#ifndef MIR_CLIENT_WINDOW_H
20
#define MIR_CLIENT_WINDOW_H
22
#include <mir_toolkit/mir_window.h>
30
/// Handle class for MirWindow - provides automatic reference counting.
35
explicit Window(MirWindow* spec) : self{spec, deleter} {}
38
operator MirWindow*() const { return self.get(); }
40
void reset() { self.reset(); }
43
static void deleter(MirWindow* window) { mir_window_release_sync(window); }
44
std::shared_ptr<MirWindow> self;
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;
53
#endif //MIR_CLIENT_WINDOW_H