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 "qwaylandwlshellintegration_p.h" |
5 | #include "qwaylandwlshellsurface_p.h" |
6 | |
7 | #include <QtWaylandClient/private/qwaylandwindow_p.h> |
8 | #include <QtWaylandClient/private/qwaylanddisplay_p.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | namespace QtWaylandClient { |
13 | |
14 | QWaylandWlShellIntegration::QWaylandWlShellIntegration() : QWaylandShellIntegrationTemplate(1) |
15 | { |
16 | qCWarning(lcQpaWayland) << "\"wl-shell\" is a deprecated shell extension, prefer using" |
17 | << "\"xdg-shell\" if supported by the compositor" |
18 | << "by setting the environment variable QT_WAYLAND_SHELL_INTEGRATION"; |
19 | } |
20 | |
21 | QWaylandWlShellIntegration::~QWaylandWlShellIntegration() |
22 | { |
23 | if (object()) |
24 | wl_shell_destroy(object()); |
25 | } |
26 | |
27 | QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window) |
28 | { |
29 | return new QWaylandWlShellSurface(get_shell_surface(window->wlSurface()), window); |
30 | } |
31 | |
32 | void *QWaylandWlShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) |
33 | { |
34 | QByteArray lowerCaseResource = resource.toLower(); |
35 | if (lowerCaseResource == "wl_shell_surface") { |
36 | if (auto waylandWindow = static_cast<QWaylandWindow *>(window->handle())) { |
37 | if (auto shellSurface = qobject_cast<QWaylandWlShellSurface *>(object: waylandWindow->shellSurface())) { |
38 | return shellSurface->object(); |
39 | } |
40 | } |
41 | } |
42 | return nullptr; |
43 | } |
44 | |
45 | } // namespace QtWaylandClient |
46 | |
47 | QT_END_NAMESPACE |
48 |