MirAL
window_id.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 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_ID_H
20 #define MIR_CLIENT_WINDOW_ID_H
21 
23 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
24 #include <mir_toolkit/mir_surface.h>
25 auto const mir_window_request_window_id_sync = mir_surface_request_persistent_id_sync;
26 #else
27 #include <mir_toolkit/mir_window.h>
28 #endif
29 
30 #if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 26, 1)
31 #if MIR_CLIENT_VERSION == MIR_VERSION_NUMBER(3, 5, 0)
32 #include <mir_toolkit/mir_persistent_id.h>
33 auto const mir_window_request_window_id_sync = mir_window_request_persistent_id_sync;
34 #endif
35 auto const mir_window_id_as_string = mir_persistent_id_as_string;
36 auto const mir_window_id_release = mir_persistent_id_release;
37 typedef struct MirPersistentId MirWindowId;
38 #else
39 #include <mir_toolkit/mir_window_id.h>
40 #endif
41 
42 #include <memory>
43 
44 namespace mir
45 {
46 namespace client
47 {
49 class WindowId
50 {
51 public:
52  explicit WindowId(MirWindowId* id) : self{id, deleter} {}
53 
54  explicit WindowId(MirWindow* window) : WindowId{mir_window_request_window_id_sync(window)} {}
55 
56  auto c_str() const -> char const* { return mir_window_id_as_string(self.get()); }
57 
58 private:
59  static void deleter(MirWindowId* id) { mir_window_id_release(id); }
60  std::shared_ptr<MirWindowId> self;
61 };
62 }
63 }
64 
65 #endif //MIR_CLIENT_WINDOW_ID_H
Definition: connection.h:26

Copyright © 2016 Canonical Ltd.
Generated on Fri Mar 3 10:22:14 UTC 2017