Merge remote-tracking branch 'origin/5.15' into wip/cmake
Conflicts: src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp Change-Id: I6c6e05f76abcea8a315fe3ba471c4aa2139127b5
This commit is contained in:
commit
51bf0a1d2c
@ -5,6 +5,10 @@ QT += core-private gui-private
|
||||
QT_FOR_PRIVATE += service_support-private
|
||||
QT_PRIVATE += fontdatabase_support-private eventdispatcher_support-private theme_support-private
|
||||
|
||||
qtConfig(vulkan) {
|
||||
QT_PRIVATE += vulkan_support-private
|
||||
}
|
||||
|
||||
# We have a bunch of C code with casts, so we can't have this option
|
||||
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
|
||||
|
||||
@ -97,6 +101,16 @@ include(shellintegration/shellintegration.pri)
|
||||
include(inputdeviceintegration/inputdeviceintegration.pri)
|
||||
include(global/global.pri)
|
||||
|
||||
qtConfig(vulkan) {
|
||||
HEADERS += \
|
||||
qwaylandvulkaninstance_p.h \
|
||||
qwaylandvulkanwindow_p.h
|
||||
|
||||
SOURCES += \
|
||||
qwaylandvulkaninstance.cpp \
|
||||
qwaylandvulkanwindow.cpp
|
||||
}
|
||||
|
||||
qtConfig(cursor) {
|
||||
QMAKE_USE += wayland-cursor
|
||||
|
||||
|
@ -93,8 +93,10 @@ QMimeData *QWaylandClipboard::mimeData(QClipboard::Mode mode)
|
||||
void QWaylandClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
|
||||
{
|
||||
auto *seat = mDisplay->currentInputDevice();
|
||||
if (!seat)
|
||||
if (!seat) {
|
||||
qCWarning(lcQpaWayland) << "Can't set clipboard contents with no wl_seats available";
|
||||
return;
|
||||
}
|
||||
|
||||
static const QString plain = QStringLiteral("text/plain");
|
||||
static const QString utf8 = QStringLiteral("text/plain;charset=utf-8");
|
||||
@ -135,14 +137,20 @@ bool QWaylandClipboard::supportsMode(QClipboard::Mode mode) const
|
||||
|
||||
bool QWaylandClipboard::ownsMode(QClipboard::Mode mode) const
|
||||
{
|
||||
if (mode != QClipboard::Clipboard)
|
||||
QWaylandInputDevice *seat = mDisplay->currentInputDevice();
|
||||
if (!seat)
|
||||
return false;
|
||||
|
||||
QWaylandInputDevice *inputDevice = mDisplay->currentInputDevice();
|
||||
if (!inputDevice || !inputDevice->dataDevice())
|
||||
switch (mode) {
|
||||
case QClipboard::Clipboard:
|
||||
return seat->dataDevice() && seat->dataDevice()->selectionSource() != nullptr;
|
||||
#if QT_CONFIG(wayland_client_primary_selection)
|
||||
case QClipboard::Selection:
|
||||
return seat->primarySelectionDevice() && seat->primarySelectionDevice()->selectionSource() != nullptr;
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
|
||||
return inputDevice->dataDevice()->selectionSource() != nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,7 +81,14 @@ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
|
||||
|
||||
void QWaylandDataDevice::invalidateSelectionOffer()
|
||||
{
|
||||
if (m_selectionOffer.isNull())
|
||||
return;
|
||||
|
||||
m_selectionOffer.reset();
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Clipboard);
|
||||
#endif
|
||||
}
|
||||
|
||||
QWaylandDataSource *QWaylandDataDevice::selectionSource() const
|
||||
|
@ -94,6 +94,11 @@
|
||||
#include <QtXkbCommonSupport/private/qxkbcommon_p.h>
|
||||
#endif
|
||||
|
||||
#if QT_CONFIG(vulkan)
|
||||
#include "qwaylandvulkaninstance_p.h"
|
||||
#include "qwaylandvulkanwindow_p.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
@ -158,6 +163,11 @@ QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) cons
|
||||
&& mDisplay->clientBufferIntegration())
|
||||
return mDisplay->clientBufferIntegration()->createEglWindow(window);
|
||||
|
||||
#if QT_CONFIG(vulkan)
|
||||
if (window->surfaceType() == QSurface::VulkanSurface)
|
||||
return new QWaylandVulkanWindow(window);
|
||||
#endif // QT_CONFIG(vulkan)
|
||||
|
||||
return new QWaylandShmWindow(window);
|
||||
}
|
||||
|
||||
@ -278,6 +288,13 @@ QPlatformTheme *QWaylandIntegration::createPlatformTheme(const QString &name) co
|
||||
return QGenericUnixTheme::createUnixTheme(name);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(vulkan)
|
||||
QPlatformVulkanInstance *QWaylandIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
|
||||
{
|
||||
return new QWaylandVulkanInstance(instance);
|
||||
}
|
||||
#endif // QT_CONFIG(vulkan)
|
||||
|
||||
// May be called from non-GUI threads
|
||||
QWaylandClientBufferIntegration *QWaylandIntegration::clientBufferIntegration() const
|
||||
{
|
||||
|
@ -113,6 +113,10 @@ public:
|
||||
|
||||
QPlatformTheme *createPlatformTheme(const QString &name) const override;
|
||||
|
||||
#if QT_CONFIG(vulkan)
|
||||
QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
|
||||
#endif
|
||||
|
||||
QWaylandInputDevice *createInputDevice(QWaylandDisplay *display, int version, uint32_t id);
|
||||
|
||||
virtual QWaylandClientBufferIntegration *clientBufferIntegration() const;
|
||||
|
@ -51,6 +51,9 @@
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
|
||||
#if QT_CONFIG(vulkan)
|
||||
#include <QtWaylandClient/private/qwaylandvulkanwindow_p.h>
|
||||
#endif
|
||||
|
||||
#include <QtPlatformHeaders/qwaylandwindowfunctions.h>
|
||||
|
||||
@ -117,6 +120,15 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
|
||||
if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration())
|
||||
return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay);
|
||||
|
||||
#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())->surface();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (auto shellIntegration = m_integration->shellIntegration())
|
||||
return shellIntegration->nativeResourceForWindow(resourceString, window);
|
||||
|
||||
|
@ -96,6 +96,15 @@ QWaylandPrimarySelectionDeviceV1::~QWaylandPrimarySelectionDeviceV1()
|
||||
destroy();
|
||||
}
|
||||
|
||||
void QWaylandPrimarySelectionDeviceV1::invalidateSelectionOffer()
|
||||
{
|
||||
if (!m_selectionOffer)
|
||||
return;
|
||||
|
||||
m_selectionOffer.reset();
|
||||
QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Selection);
|
||||
}
|
||||
|
||||
void QWaylandPrimarySelectionDeviceV1::setSelectionSource(QWaylandPrimarySelectionSourceV1 *source)
|
||||
{
|
||||
if (source) {
|
||||
|
@ -125,7 +125,7 @@ class QWaylandPrimarySelectionDeviceV1 : public QObject, public QtWayland::zwp_p
|
||||
public:
|
||||
~QWaylandPrimarySelectionDeviceV1() override;
|
||||
QWaylandPrimarySelectionOfferV1 *selectionOffer() const { return m_selectionOffer.data(); }
|
||||
void invalidateSelectionOffer() { m_selectionOffer.reset(); }
|
||||
void invalidateSelectionOffer();
|
||||
QWaylandPrimarySelectionSourceV1 *selectionSource() const { return m_selectionSource.data(); }
|
||||
void setSelectionSource(QWaylandPrimarySelectionSourceV1 *source);
|
||||
|
||||
|
132
src/plugins/platforms/wayland/qwaylandvulkaninstance.cpp
Normal file
132
src/plugins/platforms/wayland/qwaylandvulkaninstance.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2019 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwaylandvulkaninstance_p.h"
|
||||
#include "qwaylandwindow_p.h"
|
||||
#include "qwaylandscreen_p.h"
|
||||
#include "qwaylanddisplay_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
QWaylandVulkanInstance::QWaylandVulkanInstance(QVulkanInstance *instance)
|
||||
: m_instance(instance)
|
||||
{
|
||||
loadVulkanLibrary(QStringLiteral("vulkan"));
|
||||
}
|
||||
|
||||
QWaylandVulkanInstance::~QWaylandVulkanInstance() = default;
|
||||
|
||||
void QWaylandVulkanInstance::createOrAdoptInstance()
|
||||
{
|
||||
QByteArrayList extraExtensions;
|
||||
extraExtensions << QByteArrayLiteral("VK_KHR_wayland_surface");
|
||||
initInstance(m_instance, extraExtensions);
|
||||
|
||||
if (!m_vkInst)
|
||||
return;
|
||||
|
||||
m_getPhysDevPresSupport = reinterpret_cast<PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR>(
|
||||
m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"));
|
||||
if (!m_getPhysDevPresSupport)
|
||||
qWarning() << "Failed to find vkGetPhysicalDeviceWaylandPresentationSupportKHR";
|
||||
}
|
||||
|
||||
bool QWaylandVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice,
|
||||
uint32_t queueFamilyIndex,
|
||||
QWindow *window)
|
||||
{
|
||||
if (!m_getPhysDevPresSupport || !m_getPhysDevSurfaceSupport)
|
||||
return true;
|
||||
|
||||
auto *w = static_cast<QWaylandWindow *>(window->handle());
|
||||
if (!w) {
|
||||
qWarning() << "Attempted to call supportsPresent() without a valid platform window";
|
||||
return false;
|
||||
}
|
||||
wl_display *display = w->display()->wl_display();
|
||||
bool ok = m_getPhysDevPresSupport(physicalDevice, queueFamilyIndex, display);
|
||||
|
||||
VkSurfaceKHR surface = QVulkanInstance::surfaceForWindow(window);
|
||||
VkBool32 supported = false;
|
||||
m_getPhysDevSurfaceSupport(physicalDevice, queueFamilyIndex, surface, &supported);
|
||||
ok &= bool(supported);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
VkSurfaceKHR QWaylandVulkanInstance::createSurface(QWaylandWindow *window)
|
||||
{
|
||||
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||
|
||||
if (!m_createSurface) {
|
||||
m_createSurface = reinterpret_cast<PFN_vkCreateWaylandSurfaceKHR>(
|
||||
m_vkGetInstanceProcAddr(m_vkInst, "vkCreateWaylandSurfaceKHR"));
|
||||
}
|
||||
if (!m_createSurface) {
|
||||
qWarning() << "Failed to find vkCreateWaylandSurfaceKHR";
|
||||
return surface;
|
||||
}
|
||||
|
||||
VkWaylandSurfaceCreateInfoKHR surfaceInfo;
|
||||
memset(&surfaceInfo, 0, sizeof(surfaceInfo));
|
||||
surfaceInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
||||
surfaceInfo.display = window->display()->wl_display();
|
||||
surfaceInfo.surface = window->wlSurface();
|
||||
VkResult err = m_createSurface(m_vkInst, &surfaceInfo, nullptr, &surface);
|
||||
if (err != VK_SUCCESS)
|
||||
qWarning("Failed to create Vulkan surface: %d", err);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
void QWaylandVulkanInstance::presentAboutToBeQueued(QWindow *window)
|
||||
{
|
||||
auto *w = static_cast<QWaylandWindow *>(window->handle());
|
||||
if (!w) {
|
||||
qWarning() << "Attempted to call presentAboutToBeQueued() without a valid platform window";
|
||||
return;
|
||||
}
|
||||
w->handleUpdate();
|
||||
}
|
||||
|
||||
} // namespace QtWaylandClient
|
||||
|
||||
QT_END_NAMESPACE
|
80
src/plugins/platforms/wayland/qwaylandvulkaninstance_p.h
Normal file
80
src/plugins/platforms/wayland/qwaylandvulkaninstance_p.h
Normal file
@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2019 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWAYLANDVULKANINSTANCE_P_H
|
||||
#define QWAYLANDVULKANINSTANCE_P_H
|
||||
|
||||
#if defined(VULKAN_H_) && !defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
#error "vulkan.h included without Wayland WSI"
|
||||
#endif
|
||||
|
||||
#define VK_USE_PLATFORM_WAYLAND_KHR
|
||||
|
||||
#include <QtVulkanSupport/private/qbasicvulkanplatforminstance_p.h>
|
||||
#include <QLibrary>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
class QWaylandWindow;
|
||||
|
||||
class QWaylandVulkanInstance : public QBasicPlatformVulkanInstance
|
||||
{
|
||||
public:
|
||||
explicit QWaylandVulkanInstance(QVulkanInstance *instance);
|
||||
~QWaylandVulkanInstance() override;
|
||||
|
||||
void createOrAdoptInstance() override;
|
||||
bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override;
|
||||
void presentAboutToBeQueued(QWindow *window) override;
|
||||
|
||||
VkSurfaceKHR createSurface(QWaylandWindow *window);
|
||||
|
||||
private:
|
||||
QVulkanInstance *m_instance = nullptr;
|
||||
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR m_getPhysDevPresSupport = nullptr;
|
||||
PFN_vkCreateWaylandSurfaceKHR m_createSurface = nullptr;
|
||||
};
|
||||
|
||||
} // namespace QtWaylandClient
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWAYLANDVULKANINSTANCE_P_H
|
84
src/plugins/platforms/wayland/qwaylandvulkanwindow.cpp
Normal file
84
src/plugins/platforms/wayland/qwaylandvulkanwindow.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2019 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwaylandvulkanwindow_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
QWaylandVulkanWindow::QWaylandVulkanWindow(QWindow *window)
|
||||
: QWaylandWindow(window)
|
||||
{
|
||||
}
|
||||
|
||||
QWaylandVulkanWindow::~QWaylandVulkanWindow()
|
||||
{
|
||||
if (m_surface) {
|
||||
QVulkanInstance *inst = window()->vulkanInstance();
|
||||
if (inst)
|
||||
static_cast<QWaylandVulkanInstance *>(inst->handle())->destroySurface(m_surface);
|
||||
}
|
||||
}
|
||||
|
||||
QWaylandWindow::WindowType QWaylandVulkanWindow::windowType() const
|
||||
{
|
||||
return QWaylandWindow::Vulkan;
|
||||
}
|
||||
|
||||
VkSurfaceKHR *QWaylandVulkanWindow::surface()
|
||||
{
|
||||
if (m_surface)
|
||||
return &m_surface;
|
||||
|
||||
QVulkanInstance *vulkanInstance = window()->vulkanInstance();
|
||||
if (!vulkanInstance) {
|
||||
qWarning() << "Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto *waylandVulkanInstance = static_cast<QWaylandVulkanInstance *>(vulkanInstance->handle());
|
||||
m_surface = waylandVulkanInstance->createSurface(this);
|
||||
|
||||
return &m_surface;
|
||||
}
|
||||
|
||||
} // namespace QtWaylandClient
|
||||
|
||||
QT_END_NAMESPACE
|
68
src/plugins/platforms/wayland/qwaylandvulkanwindow_p.h
Normal file
68
src/plugins/platforms/wayland/qwaylandvulkanwindow_p.h
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2019 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWAYLANDVULKANWINDOW_P_H
|
||||
#define QWAYLANDVULKANWINDOW_P_H
|
||||
|
||||
#include "qwaylandwindow_p.h"
|
||||
#include "qwaylandvulkaninstance_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
class QWaylandVulkanWindow : public QWaylandWindow
|
||||
{
|
||||
public:
|
||||
explicit QWaylandVulkanWindow(QWindow *window);
|
||||
~QWaylandVulkanWindow() override;
|
||||
|
||||
WindowType windowType() const override;
|
||||
|
||||
VkSurfaceKHR *surface();
|
||||
|
||||
private:
|
||||
VkSurfaceKHR m_surface = VK_NULL_HANDLE;
|
||||
};
|
||||
|
||||
} // namespace QtWaylandClient
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWAYLANDVULKANWINDOW_P_H
|
@ -303,8 +303,10 @@ void QWaylandWindow::setWindowTitle(const QString &title)
|
||||
const QString formatted = formatWindowTitle(title, separator);
|
||||
|
||||
const int libwaylandMaxBufferSize = 4096;
|
||||
// Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side
|
||||
const int maxLength = libwaylandMaxBufferSize - 100;
|
||||
// Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side.
|
||||
// Also, QString is in utf-16, which means that in the worst case each character will be
|
||||
// three bytes when converted to utf-8 (which is what libwayland uses), so divide by three.
|
||||
const int maxLength = libwaylandMaxBufferSize / 3 - 100;
|
||||
|
||||
auto truncated = QStringRef(&formatted).left(maxLength);
|
||||
if (truncated.length() < formatted.length()) {
|
||||
@ -1079,25 +1081,6 @@ QVariant QWaylandWindow::property(const QString &name, const QVariant &defaultVa
|
||||
|
||||
void QWaylandWindow::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (event->timerId() == mFallbackUpdateTimerId) {
|
||||
killTimer(mFallbackUpdateTimerId);
|
||||
mFallbackUpdateTimerId = -1;
|
||||
qCDebug(lcWaylandBackingstore) << "mFallbackUpdateTimer timed out";
|
||||
|
||||
if (!isExposed()) {
|
||||
qCDebug(lcWaylandBackingstore) << "Fallback update timer: Window not exposed,"
|
||||
<< "not delivering update request.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (mWaitingForUpdate && hasPendingUpdateRequest() && !mWaitingForFrameCallback) {
|
||||
qCWarning(lcWaylandBackingstore) << "Delivering update request through fallback timer,"
|
||||
<< "may not be in sync with display";
|
||||
deliverUpdateRequest();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mFrameCallbackTimerId.testAndSetOrdered(event->timerId(), -1)) {
|
||||
killTimer(event->timerId());
|
||||
qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
|
||||
@ -1109,6 +1092,7 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
|
||||
|
||||
void QWaylandWindow::requestUpdate()
|
||||
{
|
||||
qCDebug(lcWaylandBackingstore) << "requestUpdate";
|
||||
Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
|
||||
|
||||
// If we have a frame callback all is good and will be taken care of there
|
||||
@ -1116,20 +1100,17 @@ void QWaylandWindow::requestUpdate()
|
||||
return;
|
||||
|
||||
// If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
|
||||
if (mWaitingForUpdate) {
|
||||
// Ideally, we should just have returned here, but we're not guaranteed that the client
|
||||
// will actually update, so start this timer to deliver another request update after a while
|
||||
// *IF* the client doesn't update.
|
||||
int fallbackTimeout = 100;
|
||||
mFallbackUpdateTimerId = startTimer(fallbackTimeout);
|
||||
return;
|
||||
}
|
||||
// This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
|
||||
// here so we can get this information when debugging update/frame callback issues.
|
||||
// Continue as nothing happened, though.
|
||||
if (mWaitingForUpdate)
|
||||
qCDebug(lcWaylandBackingstore) << "requestUpdate called twice without committing anything";
|
||||
|
||||
// Some applications (such as Qt Quick) depend on updates being delivered asynchronously,
|
||||
// so use invokeMethod to delay the delivery a bit.
|
||||
QMetaObject::invokeMethod(this, [this] {
|
||||
// Things might have changed in the meantime
|
||||
if (hasPendingUpdateRequest() && !mWaitingForUpdate && !mWaitingForFrameCallback)
|
||||
if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
|
||||
deliverUpdateRequest();
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
@ -1139,6 +1120,7 @@ void QWaylandWindow::requestUpdate()
|
||||
// Can be called from the render thread (without locking anything) so make sure to not make races in this method.
|
||||
void QWaylandWindow::handleUpdate()
|
||||
{
|
||||
qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
|
||||
// TODO: Should sync subsurfaces avoid requesting frame callbacks?
|
||||
QReadLocker lock(&mSurfaceLock);
|
||||
if (!mSurface)
|
||||
@ -1149,15 +1131,6 @@ void QWaylandWindow::handleUpdate()
|
||||
mFrameCallback = nullptr;
|
||||
}
|
||||
|
||||
if (mFallbackUpdateTimerId != -1) {
|
||||
// Ideally, we would stop the fallback timer here, but since we're on another thread,
|
||||
// it's not allowed. Instead we set mFallbackUpdateTimer to -1 here, so we'll just
|
||||
// ignore it if it times out before it's cleaned up by the invokeMethod call.
|
||||
int id = mFallbackUpdateTimerId;
|
||||
mFallbackUpdateTimerId = -1;
|
||||
QMetaObject::invokeMethod(this, [this, id] { killTimer(id); }, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
mFrameCallback = mSurface->frame();
|
||||
wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
|
||||
mWaitingForFrameCallback = true;
|
||||
@ -1177,6 +1150,7 @@ void QWaylandWindow::handleUpdate()
|
||||
|
||||
void QWaylandWindow::deliverUpdateRequest()
|
||||
{
|
||||
qCDebug(lcWaylandBackingstore) << "deliverUpdateRequest";
|
||||
mWaitingForUpdate = true;
|
||||
QPlatformWindow::deliverUpdateRequest();
|
||||
}
|
||||
|
@ -89,7 +89,8 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandWindow : public QObject, public QPlatformW
|
||||
public:
|
||||
enum WindowType {
|
||||
Shm,
|
||||
Egl
|
||||
Egl,
|
||||
Vulkan
|
||||
};
|
||||
|
||||
QWaylandWindow(QWindow *window);
|
||||
@ -229,7 +230,6 @@ protected:
|
||||
|
||||
// True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
|
||||
bool mWaitingForUpdate = false;
|
||||
int mFallbackUpdateTimerId = -1; // Started when waiting for app to commit
|
||||
|
||||
QMutex mResizeLock;
|
||||
bool mWaitingToApplyConfigure = false;
|
||||
|
@ -110,13 +110,17 @@ void QWaylandWindowManagerIntegration::windowmanager_quit()
|
||||
void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url)
|
||||
{
|
||||
Q_ASSERT(isInitialized());
|
||||
QByteArray data = url.toString().toUtf8();
|
||||
QString data = url.toString();
|
||||
|
||||
static const int chunkSize = 128;
|
||||
while (!data.isEmpty()) {
|
||||
QByteArray chunk = data.left(chunkSize);
|
||||
QString chunk = data.left(chunkSize);
|
||||
data = data.mid(chunkSize);
|
||||
open_url(!data.isEmpty(), QString::fromUtf8(chunk));
|
||||
if (chunk.at(chunk.size() - 1).isHighSurrogate() && !data.isEmpty()) {
|
||||
chunk.append(data.at(0));
|
||||
data = data.mid(1);
|
||||
}
|
||||
open_url(!data.isEmpty(), chunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,7 @@ private slots:
|
||||
void glWindow();
|
||||
#endif // QT_CONFIG(opengl)
|
||||
void longWindowTitle();
|
||||
void longWindowTitleWithUtf16Characters();
|
||||
|
||||
private:
|
||||
MockCompositor *compositor = nullptr;
|
||||
@ -502,9 +503,20 @@ void tst_WaylandClient::longWindowTitle()
|
||||
QTRY_VERIFY(compositor->surface());
|
||||
}
|
||||
|
||||
void tst_WaylandClient::longWindowTitleWithUtf16Characters()
|
||||
{
|
||||
QWindow window;
|
||||
QString absurdlyLongTitle = QString("三").repeated(10000);
|
||||
Q_ASSERT(absurdlyLongTitle.length() == 10000); // just making sure the test isn't broken
|
||||
window.setTitle(absurdlyLongTitle);
|
||||
window.show();
|
||||
QTRY_VERIFY(compositor->surface());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setenv("XDG_RUNTIME_DIR", ".", 1);
|
||||
QTemporaryDir tmpRuntimeDir;
|
||||
setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1);
|
||||
setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
|
||||
|
||||
MockCompositor compositor;
|
||||
|
@ -59,6 +59,7 @@ private slots:
|
||||
void pasteUtf8();
|
||||
void destroysPreviousSelection();
|
||||
void destroysSelectionWithSurface();
|
||||
void destroysSelectionOnLeave();
|
||||
void dragWithoutFocus();
|
||||
};
|
||||
|
||||
@ -215,6 +216,35 @@ void tst_datadevicev1::destroysSelectionWithSurface()
|
||||
QCOMPOSITOR_TRY_COMPARE(dataDevice()->m_sentSelectionOffers.size(), 0);
|
||||
}
|
||||
|
||||
void tst_datadevicev1::destroysSelectionOnLeave()
|
||||
{
|
||||
QRasterWindow window;
|
||||
window.resize(64, 64);
|
||||
window.show();
|
||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||
|
||||
exec([&] {
|
||||
auto *offer = dataDevice()->sendDataOffer(client(), {"text/plain"});
|
||||
dataDevice()->sendSelection(offer);
|
||||
|
||||
auto *surface = xdgSurface()->m_surface;
|
||||
keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol
|
||||
});
|
||||
|
||||
QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard));
|
||||
QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)->hasText());
|
||||
|
||||
QSignalSpy dataChangedSpy(QGuiApplication::clipboard(), &QClipboard::dataChanged);
|
||||
|
||||
exec([&] {
|
||||
auto *surface = xdgSurface()->m_surface;
|
||||
keyboard()->sendLeave(surface);
|
||||
});
|
||||
|
||||
QTRY_COMPARE(dataChangedSpy.count(), 1);
|
||||
QVERIFY(!QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)->hasText());
|
||||
}
|
||||
|
||||
// The application should not crash if it attempts to start a drag operation
|
||||
// when it doesn't have input focus (QTBUG-76368)
|
||||
void tst_datadevicev1::dragWithoutFocus()
|
||||
|
@ -93,7 +93,8 @@ void tst_WaylandClientFullScreenShellV1::createDestroyWindow()
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setenv("XDG_RUNTIME_DIR", ".", 1);
|
||||
QTemporaryDir tmpRuntimeDir;
|
||||
setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1);
|
||||
setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
|
||||
setenv("QT_WAYLAND_SHELL_INTEGRATION", "fullscreen-shell-v1", 1);
|
||||
setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense here
|
||||
|
@ -171,7 +171,8 @@ void tst_inputcontext::inputContextReconfigurationWhenTogglingTextInputExtension
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qputenv("XDG_RUNTIME_DIR", ".");
|
||||
QTemporaryDir tmpRuntimeDir;
|
||||
qputenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit());
|
||||
qputenv("QT_QPA_PLATFORM", "wayland");
|
||||
|
||||
tst_inputcontext tc;
|
||||
|
@ -261,6 +261,7 @@ private slots:
|
||||
void pasteAscii();
|
||||
void pasteUtf8();
|
||||
void destroysPreviousSelection();
|
||||
void destroysSelectionOnLeave();
|
||||
void copy();
|
||||
};
|
||||
|
||||
@ -411,6 +412,35 @@ void tst_primaryselectionv1::destroysPreviousSelection()
|
||||
QCOMPOSITOR_TRY_COMPARE(primarySelectionDevice()->m_sentSelectionOffers.size(), 1);
|
||||
}
|
||||
|
||||
void tst_primaryselectionv1::destroysSelectionOnLeave()
|
||||
{
|
||||
QRasterWindow window;
|
||||
window.resize(64, 64);
|
||||
window.show();
|
||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||
|
||||
exec([&] {
|
||||
auto *surface = xdgSurface()->m_surface;
|
||||
keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol
|
||||
|
||||
auto *offer = primarySelectionDevice()->sendDataOffer({"text/plain"});
|
||||
primarySelectionDevice()->sendSelection(offer);
|
||||
});
|
||||
|
||||
QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Selection));
|
||||
QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Selection)->hasText());
|
||||
|
||||
QSignalSpy selectionChangedSpy(QGuiApplication::clipboard(), &QClipboard::selectionChanged);
|
||||
|
||||
exec([&] {
|
||||
auto *surface = xdgSurface()->m_surface;
|
||||
keyboard()->sendLeave(surface);
|
||||
});
|
||||
|
||||
QTRY_COMPARE(selectionChangedSpy.count(), 1);
|
||||
QVERIFY(!QGuiApplication::clipboard()->mimeData(QClipboard::Selection)->hasText());
|
||||
}
|
||||
|
||||
void tst_primaryselectionv1::copy()
|
||||
{
|
||||
class Window : public QRasterWindow {
|
||||
@ -442,6 +472,7 @@ void tst_primaryselectionv1::copy()
|
||||
});
|
||||
QCOMPOSITOR_TRY_VERIFY(primarySelectionDevice()->m_selectionSource);
|
||||
QCOMPOSITOR_TRY_VERIFY(mouseSerials.contains(primarySelectionDevice()->m_serial));
|
||||
QVERIFY(QGuiApplication::clipboard()->ownsSelection());
|
||||
QByteArray pastedBuf;
|
||||
exec([&](){
|
||||
auto *source = primarySelectionDevice()->m_selectionSource;
|
||||
|
@ -43,6 +43,7 @@ CoreCompositor::CoreCompositor()
|
||||
}
|
||||
})
|
||||
{
|
||||
qputenv("WAYLAND_DISPLAY", m_socketName);
|
||||
m_timer.start();
|
||||
Q_ASSERT(isClean());
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ public:
|
||||
~DataDevice() override;
|
||||
void send_data_offer(::wl_resource *resource) = delete;
|
||||
DataOffer *sendDataOffer(::wl_client *client, const QStringList &mimeTypes = {});
|
||||
DataOffer *sendDataOffer(const QStringList &mimeTypes = {});
|
||||
|
||||
void send_selection(::wl_resource *resource) = delete;
|
||||
void sendSelection(DataOffer *offer);
|
||||
|
@ -84,7 +84,8 @@ public:
|
||||
#define QCOMPOSITOR_TEST_MAIN(test) \
|
||||
int main(int argc, char **argv) \
|
||||
{ \
|
||||
setenv("XDG_RUNTIME_DIR", ".", 1); \
|
||||
QTemporaryDir tmpRuntimeDir; \
|
||||
setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1); \
|
||||
setenv("XDG_CURRENT_DESKTOP", "qtwaylandtests", 1); \
|
||||
setenv("QT_QPA_PLATFORM", "wayland", 1); \
|
||||
test tc; \
|
||||
|
@ -422,7 +422,8 @@ void tst_WaylandClientXdgShellV6::dontSpamExposeEvents()
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setenv("XDG_RUNTIME_DIR", ".", 1);
|
||||
QTemporaryDir tmpRuntimeDir;
|
||||
setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1);
|
||||
setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
|
||||
setenv("QT_WAYLAND_SHELL_INTEGRATION", "xdg-shell-v6", 1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user