summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandnativeinterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/qwaylandnativeinterface.cpp')
-rw-r--r--src/client/qwaylandnativeinterface.cpp181
1 files changed, 99 insertions, 82 deletions
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp
index b4ecc0090..601f833aa 100644
--- a/src/client/qwaylandnativeinterface.cpp
+++ b/src/client/qwaylandnativeinterface.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qwaylandnativeinterface_p.h"
#include "qwaylanddisplay_p.h"
@@ -48,11 +12,13 @@
#include "qwaylandwindowmanagerintegration_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandinputdevice_p.h"
+#include <QtCore/private/qnativeinterface_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QScreen>
#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
-
-#include <QtPlatformHeaders/qwaylandwindowfunctions.h>
+#if QT_CONFIG(vulkan)
+#include <QtWaylandClient/private/qwaylandvulkanwindow_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -69,8 +35,10 @@ void *QWaylandNativeInterface::nativeResourceForIntegration(const QByteArray &re
if (lowerCaseResource == "display" || lowerCaseResource == "wl_display" || lowerCaseResource == "nativedisplay")
return m_integration->display()->wl_display();
- if (lowerCaseResource == "compositor")
- return const_cast<wl_compositor *>(m_integration->display()->wl_compositor());
+ if (lowerCaseResource == "compositor") {
+ if (auto compositor = m_integration->display()->compositor())
+ return compositor->object();
+ }
if (lowerCaseResource == "server_buffer_integration")
return m_integration->serverBufferIntegration();
@@ -97,7 +65,65 @@ void *QWaylandNativeInterface::nativeResourceForIntegration(const QByteArray &re
return touch->wl_touch();
return nullptr;
}
+ if (lowerCaseResource == "serial")
+ return reinterpret_cast<void *>(quintptr(m_integration->display()->defaultInputDevice()->serial()));
+
+ return nullptr;
+}
+
+wl_display *QtWaylandClient::QWaylandNativeInterface::display() const
+{
+ return m_integration->display()->wl_display();
+}
+
+wl_compositor *QtWaylandClient::QWaylandNativeInterface::compositor() const
+{
+ if (auto compositor = m_integration->display()->compositor())
+ return compositor->object();
+ return nullptr;
+}
+
+wl_seat *QtWaylandClient::QWaylandNativeInterface::seat() const
+{
+ if (auto inputDevice = m_integration->display()->defaultInputDevice()) {
+ return inputDevice->wl_seat();
+ }
+ return nullptr;
+}
+
+wl_keyboard *QtWaylandClient::QWaylandNativeInterface::keyboard() const
+{
+ if (auto inputDevice = m_integration->display()->defaultInputDevice())
+ if (auto keyboard = inputDevice->keyboard())
+ return keyboard->wl_keyboard();
+ return nullptr;
+}
+
+wl_pointer *QtWaylandClient::QWaylandNativeInterface::pointer() const
+{
+ if (auto inputDevice = m_integration->display()->defaultInputDevice())
+ if (auto pointer = inputDevice->pointer())
+ return pointer->wl_pointer();
+ return nullptr;
+}
+
+wl_touch *QtWaylandClient::QWaylandNativeInterface::touch() const
+{
+ if (auto inputDevice = m_integration->display()->defaultInputDevice())
+ if (auto touch = inputDevice->touch())
+ return touch->wl_touch();
+ return nullptr;
+}
+
+uint QtWaylandClient::QWaylandNativeInterface::lastInputSerial() const
+{
+ return m_integration->display()->lastInputSerial();
+}
+wl_seat *QtWaylandClient::QWaylandNativeInterface::lastInputSeat() const
+{
+ if (auto inputDevice = m_integration->display()->lastInputDevice())
+ return inputDevice->wl_seat();
return nullptr;
}
@@ -107,8 +133,10 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
if (lowerCaseResource == "display")
return m_integration->display()->wl_display();
- if (lowerCaseResource == "compositor")
- return const_cast<wl_compositor *>(m_integration->display()->wl_compositor());
+ if (lowerCaseResource == "compositor") {
+ if (auto compositor = m_integration->display()->compositor())
+ return compositor->object();
+ }
if (lowerCaseResource == "surface") {
QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle());
return w ? w->wlSurface() : nullptr;
@@ -117,8 +145,18 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration())
return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay);
- if (auto shellIntegration = m_integration->shellIntegration())
- return shellIntegration->nativeResourceForWindow(resourceString, window);
+#if QT_CONFIG(vulkan)
+ if (lowerCaseResource == "vksurface") {
+ if (window->surfaceType() == QSurface::VulkanSurface && window->handle()) {
+ // return a pointer to the VkSurfaceKHR value, not the value itself
+ return static_cast<QWaylandVulkanWindow *>(window->handle())->vkSurface();
+ }
+ }
+#endif
+
+ QWaylandWindow *platformWindow = static_cast<QWaylandWindow *>(window->handle());
+ if (platformWindow && platformWindow->shellIntegration())
+ return platformWindow->shellIntegration()->nativeResourceForWindow(resourceString, window);
return nullptr;
}
@@ -127,7 +165,7 @@ void *QWaylandNativeInterface::nativeResourceForScreen(const QByteArray &resourc
{
QByteArray lowerCaseResource = resourceString.toLower();
- if (lowerCaseResource == "output")
+ if (lowerCaseResource == "output" && !screen->handle()->isPlaceholder())
return ((QWaylandScreen *) screen->handle())->output();
return nullptr;
@@ -153,6 +191,17 @@ void *QWaylandNativeInterface::nativeResourceForContext(const QByteArray &resour
}
#endif // opengl
+QPlatformNativeInterface::NativeResourceForWindowFunction QWaylandNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource)
+{
+ QByteArray lowerCaseResource = resource.toLower();
+
+ if (lowerCaseResource == "setmargins") {
+ return NativeResourceForWindowFunction(reinterpret_cast<void *>(setWindowMargins));
+ }
+
+ return nullptr;
+}
+
QVariantMap QWaylandNativeInterface::windowProperties(QPlatformWindow *window) const
{
QWaylandWindow *waylandWindow = static_cast<QWaylandWindow *>(window);
@@ -182,42 +231,10 @@ void QWaylandNativeInterface::emitWindowPropertyChanged(QPlatformWindow *window,
emit windowPropertyChanged(window,name);
}
-QFunctionPointer QWaylandNativeInterface::platformFunction(const QByteArray &resource) const
-{
- if (resource == QWaylandWindowFunctions::setSyncIdentifier()) {
- return QFunctionPointer(setSync);
- } else if (resource == QWaylandWindowFunctions::setDeSyncIdentifier()) {
- return QFunctionPointer(setDeSync);
- } else if (resource == QWaylandWindowFunctions::isSyncIdentifier()) {
- return QFunctionPointer(isSync);
- }
- return nullptr;
-}
-
-
-void QWaylandNativeInterface::setSync(QWindow *window)
-{
- QWaylandWindow *ww = static_cast<QWaylandWindow*>(window->handle());
- if (ww->subSurfaceWindow()) {
- ww->subSurfaceWindow()->setSync();
- }
-}
-
-void QWaylandNativeInterface::setDeSync(QWindow *window)
-{
- QWaylandWindow *ww = static_cast<QWaylandWindow*>(window->handle());
- if (ww->subSurfaceWindow()) {
- ww->subSurfaceWindow()->setDeSync();
- }
-}
-
-bool QWaylandNativeInterface::isSync(QWindow *window)
+void QWaylandNativeInterface::setWindowMargins(QWindow *window, const QMargins &margins)
{
- QWaylandWindow *ww = static_cast<QWaylandWindow*>(window->handle());
- if (ww->subSurfaceWindow()) {
- return ww->subSurfaceWindow()->isSync();
- }
- return false;
+ QWaylandWindow *wlWindow = static_cast<QWaylandWindow*>(window->handle());
+ wlWindow->setCustomMargins(margins);
}
}