~raof/mir/lots-of-unused-lambda-captures

« back to all changes in this revision

Viewing changes to include/miral/mir/client/window.h

  • Committer: Tarmac
  • Author(s): Alan Griffiths
  • Date: 2017-08-30 15:19:51 UTC
  • mfrom: (4232.2.18 mir2)
  • Revision ID: tarmac-20170830151951-jizxlto07otfslu1
Incorporate miral project into mir source tree - part 1.

Approved by mir-ci-bot, Gerry Boland, Brandon Schaefer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
{
 
30
/// Handle class for MirWindow - provides automatic reference counting.
 
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