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
5#include <QtCore/QObject>
6#include <QtCore/QUrl>
7
8#include <QtWaylandCompositor/QWaylandCompositor>
9#include <QtWaylandCompositor/QWaylandClient>
10
13
15
16QWaylandQtWindowManagerPrivate::QWaylandQtWindowManagerPrivate()
17{
18}
19
20void QWaylandQtWindowManagerPrivate::windowmanager_bind_resource(Resource *resource)
21{
22 send_hints(resource->handle, static_cast<int32_t>(showIsFullScreen));
23}
24
25void QWaylandQtWindowManagerPrivate::windowmanager_destroy_resource(Resource *resource)
26{
27 urls.remove(resource);
28}
29
30void QWaylandQtWindowManagerPrivate::windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &newUrl)
31{
32 Q_Q(QWaylandQtWindowManager);
33
34 QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer());
35 if (!compositor) {
36 qWarning() << "Failed to find QWaylandCompositor from QWaylandQtWindowManager::windowmanager_open_url()";
37 return;
38 }
39
40 QString url = urls.value(resource, QString());
41
42 url.append(newUrl);
43
44 if (remaining)
45 urls.insert(resource, url);
46 else {
47 urls.remove(resource);
48 q->openUrl(QWaylandClient::fromWlClient(compositor, resource->client()), QUrl(url));
49 }
50}
51
52QWaylandQtWindowManager::QWaylandQtWindowManager()
53 : QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager>(*new QWaylandQtWindowManagerPrivate())
54{
55}
56
57QWaylandQtWindowManager::QWaylandQtWindowManager(QWaylandCompositor *compositor)
58 : QWaylandCompositorExtensionTemplate<QWaylandQtWindowManager>(compositor, *new QWaylandQtWindowManagerPrivate())
59{
60}
61
62/*!
63 * \property QWaylandQtWindowManager::showIsFullScreen
64 *
65 * This property holds whether the window manager should indicate to clients
66 * that the "show" window state is equivalent to fullscreen mode.
67 *
68 * When \c true, clients will treat the show state as fullscreen; when \c false,
69 * the show state represents a normal window state.
70 */
71bool QWaylandQtWindowManager::showIsFullScreen() const
72{
73 Q_D(const QWaylandQtWindowManager);
74 return d->showIsFullScreen;
75}
76
77void QWaylandQtWindowManager::setShowIsFullScreen(bool value)
78{
79 Q_D(QWaylandQtWindowManager);
80
81 if (d->showIsFullScreen == value)
82 return;
83
84 d->showIsFullScreen = value;
85 const auto resMap = d->resourceMap();
86 for (QWaylandQtWindowManagerPrivate::Resource *resource : resMap) {
87 d->send_hints(resource->handle, static_cast<int32_t>(d->showIsFullScreen));
88 }
89 Q_EMIT showIsFullScreenChanged();
90}
91
92void QWaylandQtWindowManager::sendQuitMessage(QWaylandClient *client)
93{
94 Q_D(QWaylandQtWindowManager);
95 QWaylandQtWindowManagerPrivate::Resource *resource = d->resourceMap().value(client->client());
96
97 if (resource)
98 d->send_quit(resource->handle);
99}
100
101void QWaylandQtWindowManager::initialize()
102{
103 Q_D(QWaylandQtWindowManager);
104
105 QWaylandCompositorExtensionTemplate::initialize();
106 QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
107 if (!compositor) {
108 qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandQtWindowManager";
109 return;
110 }
111 d->init(compositor->display(), 1);
112}
113
114const struct wl_interface *QWaylandQtWindowManager::interface()
115{
116 return QWaylandQtWindowManagerPrivate::interface();
117}
118
119QByteArray QWaylandQtWindowManager::interfaceName()
120{
121 return QWaylandQtWindowManagerPrivate::interfaceName();
122}
123
124QT_END_NAMESPACE
125
126#include "moc_qwaylandqtwindowmanager.cpp"
Combined button and popup list for selecting options.