• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. The KDE Frameworks
  3. KWayland
  • KDE Home
  • Contact Us

Quick Links

Skip menu "KWayland"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Modules
  • Dependencies
  • Related Pages

Class Picker

About

Qt-style API to interact with the wayland-client and wayland-server API

Maintainer
Martin Flöser
Supported platforms
FreeBSD, Linux
Community
IRC: #kde-devel on Freenode
Mailing list: kde-frameworks-devel
Use with CMake
find_package(KF5Wayland)
target_link_libraries(yourapp KF5::WaylandClient KF5::WaylandServer)
Use with QMake
QT += KWaylandClient KWaylandServer 
Clone
git clone git://anongit.kde.org/kwayland.git
Browse source
KWayland on cgit.kde.org

KWayland

  • frameworks
  • frameworks
  • kwayland
  • src
  • client
xdgforeign_v2.cpp
1 /****************************************************************************
2 Copyright 2017 Marco Martin <[email protected]>
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), which shall
10 act as a proxy defined in Section 6 of version 3 of the license.
11 
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 ****************************************************************************/
20 #include "xdgforeign_v2.h"
21 #include "xdgforeign_p.h"
22 #include "event_queue.h"
23 #include "wayland_pointer_p.h"
24 
25 #include <wayland-xdg-foreign-unstable-v2-client-protocol.h>
26 
27 #include <QDebug>
28 
29 namespace KWayland
30 {
31 namespace Client
32 {
33 
34 class Q_DECL_HIDDEN XdgExporterUnstableV2::Private : public XdgExporter::Private
35 {
36 public:
37  Private();
38 
39  XdgExported *exportTopLevelV2(Surface *surface, QObject *parent) override;
40  void setupV2(zxdg_exporter_v2 *arg) override;
41  zxdg_exporter_v2 *exporterV2() override;
42 
43  void release() override;
44  void destroy() override;
45  bool isValid() override;
46 
47  WaylandPointer<zxdg_exporter_v2, zxdg_exporter_v2_destroy> exporter;
48 };
49 
50 XdgExporterUnstableV2::Private::Private()
51  : XdgExporter::Private()
52 {}
53 
54 zxdg_exporter_v2 *XdgExporterUnstableV2::Private::exporterV2()
55 {
56  return exporter;
57 }
58 
59 void XdgExporterUnstableV2::Private::release()
60 {
61  exporter.release();
62 }
63 
64 void XdgExporterUnstableV2::Private::destroy()
65 {
66  exporter.destroy();
67 }
68 
69 bool XdgExporterUnstableV2::Private::isValid()
70 {
71  return exporter.isValid();
72 }
73 
74 XdgExported *XdgExporterUnstableV2::Private::exportTopLevelV2(Surface *surface, QObject *parent)
75 {
76  Q_ASSERT(isValid());
77  auto p = new XdgExportedUnstableV2(parent);
78  auto w = zxdg_exporter_v2_export_toplevel(exporter, *surface);
79  if (queue) {
80  queue->addProxy(w);
81  }
82  p->setup(w);
83  return p;
84 }
85 
86 
87 XdgExporterUnstableV2::XdgExporterUnstableV2(QObject *parent)
88  : XdgExporter(new Private, parent)
89 {
90 }
91 
92 void XdgExporterUnstableV2::Private::setupV2(zxdg_exporter_v2 *arg)
93 {
94  Q_ASSERT(arg);
95  Q_ASSERT(!exporter);
96  exporter.setup(arg);
97 }
98 
99 XdgExporterUnstableV2::~XdgExporterUnstableV2()
100 {
101 }
102 
103 class Q_DECL_HIDDEN XdgImporterUnstableV2::Private : public XdgImporter::Private
104 {
105 public:
106  Private();
107 
108  XdgImported *importTopLevelV2(const QString & handle, QObject *parent) override;
109  void setupV2(zxdg_importer_v2 *arg) override;
110  zxdg_importer_v2 *importerV2() override;
111 
112  void release() override;
113  void destroy() override;
114  bool isValid() override;
115 
116  WaylandPointer<zxdg_importer_v2, zxdg_importer_v2_destroy> importer;
117  EventQueue *queue = nullptr;
118 };
119 
120 XdgImporterUnstableV2::Private::Private()
121  : XdgImporter::Private()
122 {}
123 
124 zxdg_importer_v2 *XdgImporterUnstableV2::Private::importerV2()
125 {
126  return importer;
127 }
128 
129 void XdgImporterUnstableV2::Private::release()
130 {
131  importer.release();
132 }
133 
134 void XdgImporterUnstableV2::Private::destroy()
135 {
136  importer.destroy();
137 }
138 
139 bool XdgImporterUnstableV2::Private::isValid()
140 {
141  return importer.isValid();
142 }
143 
144 XdgImported *XdgImporterUnstableV2::Private::importTopLevelV2(const QString & handle, QObject *parent)
145 {
146  Q_ASSERT(isValid());
147  auto p = new XdgImportedUnstableV2(parent);
148  auto w = zxdg_importer_v2_import_toplevel(importer, handle.toUtf8());
149  if (queue) {
150  queue->addProxy(w);
151  }
152  p->setup(w);
153  return p;
154 }
155 
156 
157 XdgImporterUnstableV2::XdgImporterUnstableV2(QObject *parent)
158  : XdgImporter(new Private, parent)
159 {
160 }
161 
162 void XdgImporterUnstableV2::Private::setupV2(zxdg_importer_v2 *arg)
163 {
164  Q_ASSERT(arg);
165  Q_ASSERT(!importer);
166  importer.setup(arg);
167 }
168 
169 XdgImporterUnstableV2::~XdgImporterUnstableV2()
170 {
171 }
172 
173 
174 class Q_DECL_HIDDEN XdgExportedUnstableV2::Private : public XdgExported::Private
175 {
176 public:
177  Private(XdgExportedUnstableV2 *q);
178 
179  void setupV2(zxdg_exported_v2 *arg) override;
180  zxdg_exported_v2 *exportedV2() override;
181 
182  void release() override;
183  void destroy() override;
184  bool isValid() override;
185 
186  WaylandPointer<zxdg_exported_v2, zxdg_exported_v2_destroy> exported;
187 
188 private:
189  static void handleCallback(void *data, zxdg_exported_v2 *zxdg_exported_v2, const char * handle);
190 
191  static const zxdg_exported_v2_listener s_listener;
192 };
193 
194 zxdg_exported_v2 *XdgExportedUnstableV2::Private::exportedV2()
195 {
196  return exported;
197 }
198 
199 void XdgExportedUnstableV2::Private::release()
200 {
201  exported.release();
202 }
203 
204 void XdgExportedUnstableV2::Private::destroy()
205 {
206  exported.destroy();
207 }
208 
209 bool XdgExportedUnstableV2::Private::isValid()
210 {
211  return exported.isValid();
212 }
213 
214 
215 const zxdg_exported_v2_listener XdgExportedUnstableV2::Private::s_listener = {
216  handleCallback
217 };
218 
219 void XdgExportedUnstableV2::Private::handleCallback(void *data, zxdg_exported_v2 *zxdg_exported_v2, const char * handle)
220 {
221  auto p = reinterpret_cast<XdgExportedUnstableV2::Private*>(data);
222  Q_ASSERT(p->exported == zxdg_exported_v2);
223 
224  p->handle = handle;
225  emit p->q->done();
226 }
227 
228 XdgExportedUnstableV2::XdgExportedUnstableV2(QObject *parent)
229  : XdgExported(new Private(this), parent)
230 {
231 }
232 
233 void XdgExportedUnstableV2::Private::setupV2(zxdg_exported_v2 *arg)
234 {
235  Q_ASSERT(arg);
236  Q_ASSERT(!exported);
237  exported.setup(arg);
238  zxdg_exported_v2_add_listener(exported, &s_listener, this);
239 }
240 
241 XdgExportedUnstableV2::Private::Private(XdgExportedUnstableV2 *q)
242  : XdgExported::Private::Private(q)
243 {
244 }
245 
246 XdgExportedUnstableV2::~XdgExportedUnstableV2()
247 {
248 }
249 
250 class Q_DECL_HIDDEN XdgImportedUnstableV2::Private : public XdgImported::Private
251 {
252 public:
253  Private(XdgImportedUnstableV2 *q);
254 
255  void setupV2(zxdg_imported_v2 *arg) override;
256  zxdg_imported_v2 *importedV2() override;
257 
258  void setParentOf(Surface *surface) override;
259  void release() override;
260  void destroy() override;
261  bool isValid() override;
262 
263  WaylandPointer<zxdg_imported_v2, zxdg_imported_v2_destroy> imported;
264 
265 private:
266  static void destroyedCallback(void *data, zxdg_imported_v2 *zxdg_imported_v2);
267 
268  static const zxdg_imported_v2_listener s_listener;
269 };
270 
271 XdgImportedUnstableV2::Private::Private(XdgImportedUnstableV2 *q)
272  : XdgImported::Private::Private(q)
273 {
274 }
275 
276 zxdg_imported_v2 *XdgImportedUnstableV2::Private::importedV2()
277 {
278  return imported;
279 }
280 
281 void XdgImportedUnstableV2::Private::release()
282 {
283  imported.release();
284 }
285 
286 void XdgImportedUnstableV2::Private::destroy()
287 {
288  imported.destroy();
289 }
290 
291 bool XdgImportedUnstableV2::Private::isValid()
292 {
293  return imported.isValid();
294 }
295 
296 void XdgImportedUnstableV2::Private::setParentOf(Surface *surface)
297 {
298  Q_ASSERT(isValid());
299  zxdg_imported_v2_set_parent_of(imported, *surface);
300 }
301 
302 const zxdg_imported_v2_listener XdgImportedUnstableV2::Private::s_listener = {
303  destroyedCallback
304 };
305 
306 void XdgImportedUnstableV2::Private::destroyedCallback(void *data, zxdg_imported_v2 *zxdg_imported_v2)
307 {
308  auto p = reinterpret_cast<XdgImportedUnstableV2::Private*>(data);
309  Q_ASSERT(p->imported == zxdg_imported_v2);
310 
311  p->q->release();
312  emit p->q->importedDestroyed();
313 }
314 
315 
316 
317 XdgImportedUnstableV2::XdgImportedUnstableV2(QObject *parent)
318  : XdgImported(new Private(this), parent)
319 {
320 }
321 
322 void XdgImportedUnstableV2::Private::setupV2(zxdg_imported_v2 *arg)
323 {
324  Q_ASSERT(arg);
325  Q_ASSERT(!imported);
326  imported.setup(arg);
327  zxdg_imported_v2_add_listener(imported, &s_listener, this);
328 }
329 
330 XdgImportedUnstableV2::~XdgImportedUnstableV2()
331 {
332 }
333 
334 
335 }
336 }
337 
KWayland::Client::XdgExporter
Wrapper for the zxdg_exporter_v2 interface.
Definition: xdgforeign.h:67
KWayland::Client::XdgExporter::isValid
bool isValid() const
Definition: xdgforeign.cpp:76
KWayland::Client::XdgImporter::destroy
void destroy()
Destroys the data held by this .
Definition: xdgforeign.cpp:127
KWayland::Client::EventQueue
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:69
KWayland::Client::XdgImporter
Wrapper for the zxdg_importer_v2 interface.
Definition: xdgforeign.h:167
KWayland::Client::Surface
Wrapper for the wl_surface interface.
Definition: surface.h:58
QObject
QString
KWayland::Client::XdgExporter::release
void release()
Releases the zxdg_exporter_v2 interface.
Definition: xdgforeign.cpp:58
KWayland::Client::XdgImporterUnstableV2::XdgImporterUnstableV2
XdgImporterUnstableV2(QObject *parent=nullptr)
Creates a new .
Definition: xdgforeign_v2.cpp:157
KWayland::Client::XdgImporter::isValid
bool isValid() const
Definition: xdgforeign.cpp:140
KWayland
Definition: appmenu.cpp:27
KWayland::Client::XdgExporter::destroy
void destroy()
Destroys the data held by this .
Definition: xdgforeign.cpp:63
QObject::parent
QObject * parent() const
KWayland::Server::XdgForeignInterface::isValid
bool isValid()
Definition: xdgforeign_interface.cpp:67
KWayland::Client::XdgImporter::release
void release()
Releases the zxdg_importer_v2 interface.
Definition: xdgforeign.cpp:122
QString::toUtf8
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Wed Dec 11 2019 06:39:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal