| 1 | // Copyright (C) 2017 The Qt Company Ltd. | 
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | 
| 3 | |
| 4 | #include "qwaylandxdgshell_p.h" | 
| 5 | #include "qwaylandxdgshellintegration_p.h" | 
| 6 | #include "qwaylandxdgdecorationv1_p.h" | 
| 7 | |
| 8 | #include <QtWaylandClient/private/qwaylandwindow_p.h> | 
| 9 | #include <QtWaylandClient/private/qwaylanddisplay_p.h> | 
| 10 | |
| 11 | QT_BEGIN_NAMESPACE | 
| 12 | |
| 13 | namespace QtWaylandClient { | 
| 14 | |
| 15 | QWaylandXdgShellIntegration::QWaylandXdgShellIntegration() : QWaylandShellIntegrationTemplate(6) | 
| 16 | { | 
| 17 | connect(sender: this, signal: &QWaylandShellIntegrationTemplate::activeChanged, context: this, slot: [this] { | 
| 18 | if (isActive()) { | 
| 19 | mXdgShell.reset(new QWaylandXdgShell(mDisplay, this)); | 
| 20 | } else { | 
| 21 | mXdgShell.reset(other: nullptr); | 
| 22 | destroy(); | 
| 23 | } | 
| 24 | }); | 
| 25 | } | 
| 26 | |
| 27 | QWaylandXdgShellIntegration::~QWaylandXdgShellIntegration() | 
| 28 | { | 
| 29 | if (isActive()) | 
| 30 | destroy(); | 
| 31 | } | 
| 32 | |
| 33 | bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display) | 
| 34 | { | 
| 35 | mDisplay = display; | 
| 36 | return QWaylandShellIntegrationTemplate::initialize(display); | 
| 37 | } | 
| 38 | |
| 39 | void QWaylandXdgShellIntegration::xdg_wm_base_ping(uint32_t serial) | 
| 40 | { | 
| 41 | pong(serial); | 
| 42 | } | 
| 43 | |
| 44 | QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window) | 
| 45 | { | 
| 46 | return new QWaylandXdgSurface(mXdgShell.get(), get_xdg_surface(window->wlSurface()), window); | 
| 47 | } | 
| 48 | |
| 49 | void *QWaylandXdgShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) | 
| 50 | { | 
| 51 | if (auto waylandWindow = static_cast<QWaylandWindow *>(window->handle())) { | 
| 52 | if (auto xdgSurface = qobject_cast<QWaylandXdgSurface *>(object: waylandWindow->shellSurface())) { | 
| 53 | return xdgSurface->nativeResource(resource); | 
| 54 | } | 
| 55 | } | 
| 56 | return nullptr; | 
| 57 | } | 
| 58 | |
| 59 | } | 
| 60 | |
| 61 | QT_END_NAMESPACE | 
| 62 | 
