Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandqtwindowmanager.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:critical reason:network-protocol
5
6#include <QtCore/QObject>
7#include <QtCore/QUrl>
8
9#include <QtWaylandCompositor/QWaylandCompositor>
10#include <QtWaylandCompositor/QWaylandClient>
11
14
16
17QWaylandQtWindowManagerPrivate::QWaylandQtWindowManagerPrivate()
18{
19}
20
21void QWaylandQtWindowManagerPrivate::windowmanager_bind_resource(Resource *resource)
22{
23 send_hints(resource->handle, static_cast<int32_t>(showIsFullScreen));
24}
25
26void QWaylandQtWindowManagerPrivate::windowmanager_destroy_resource(Resource *resource)
27{
28 urls.remove(resource);
29}
30
31void QWaylandQtWindowManagerPrivate::windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &newUrl)
32{
33 Q_Q(QWaylandQtWindowManager);
34
35 QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer());
36 if (!compositor) {
37 qWarning() << "Failed to find QWaylandCompositor from QWaylandQtWindowManager::windowmanager_open_url()";
38 return;
39 }
40
41 QString url = urls.value(resource, QString());
42
43 url.append(newUrl);
44
45 if (remaining)
46 urls.insert(resource, url);
47 else {
48 urls.remove(resource);
49 q->openUrl(QWaylandClient::fromWlClient(compositor, resource->client()), QUrl(url));
50 }
51}
52
53QWaylandQtWindowManager::QWaylandQtWindowManager()
54 : QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager>(*new QWaylandQtWindowManagerPrivate())
55{
56}
57
58QWaylandQtWindowManager::QWaylandQtWindowManager(QWaylandCompositor *compositor)
59 : QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager>(compositor, *new QWaylandQtWindowManagerPrivate())
60{
61}
62
63/*!
64 * \property QWaylandQtWindowManager::showIsFullScreen
65 *
66 * This property holds whether the window manager should indicate to clients
67 * that the "show" window state is equivalent to fullscreen mode.
68 *
69 * When \c true, clients will treat the show state as fullscreen; when \c false,
70 * the show state represents a normal window state.
71 */
72bool QWaylandQtWindowManager::showIsFullScreen() const
73{
74 Q_D(const QWaylandQtWindowManager);
75 return d->showIsFullScreen;
76}
77
78void QWaylandQtWindowManager::setShowIsFullScreen(bool value)
79{
80 Q_D(QWaylandQtWindowManager);
81
82 if (d->showIsFullScreen == value)
83 return;
84
85 d->showIsFullScreen = value;
86 const auto resMap = d->resourceMap();
87 for (QWaylandQtWindowManagerPrivate::Resource *resource : resMap) {
88 d->send_hints(resource->handle, static_cast<int32_t>(d->showIsFullScreen));
89 }
90 Q_EMIT showIsFullScreenChanged();
91}
92
93void QWaylandQtWindowManager::sendQuitMessage(QWaylandClient *client)
94{
95 Q_D(QWaylandQtWindowManager);
96 QWaylandQtWindowManagerPrivate::Resource *resource = d->resourceMap().value(client->client());
97
98 if (resource)
99 d->send_quit(resource->handle);
100}
101
102void QWaylandQtWindowManager::initialize()
103{
104 Q_D(QWaylandQtWindowManager);
105
106 QWaylandCompositorExtensionTemplate::initialize();
107 QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
108 if (!compositor) {
109 qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandQtWindowManager";
110 return;
111 }
112 d->init(compositor->display(), 1);
113}
114
115const struct wl_interface *QWaylandQtWindowManager::interface()
116{
117 return QWaylandQtWindowManagerPrivate::interface();
118}
119
120QByteArray QWaylandQtWindowManager::interfaceName()
121{
122 return QWaylandQtWindowManagerPrivate::interfaceName();
123}
124
125QT_END_NAMESPACE
126
127#include "moc_qwaylandqtwindowmanager.cpp"
Combined button and popup list for selecting options.