diff options
Diffstat (limited to 'src/client/qwaylandnativeinterface.cpp')
-rw-r--r-- | src/client/qwaylandnativeinterface.cpp | 137 |
1 files changed, 91 insertions, 46 deletions
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp index 2c9ba899f..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,6 +12,7 @@ #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> @@ -70,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(); @@ -98,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; } @@ -108,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; @@ -122,13 +149,14 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc 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(); + return static_cast<QWaylandVulkanWindow *>(window->handle())->vkSurface(); } } #endif - if (auto shellIntegration = m_integration->shellIntegration()) - return shellIntegration->nativeResourceForWindow(resourceString, window); + QWaylandWindow *platformWindow = static_cast<QWaylandWindow *>(window->handle()); + if (platformWindow && platformWindow->shellIntegration()) + return platformWindow->shellIntegration()->nativeResourceForWindow(resourceString, window); return nullptr; } @@ -137,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; @@ -163,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); @@ -192,6 +231,12 @@ void QWaylandNativeInterface::emitWindowPropertyChanged(QPlatformWindow *window, emit windowPropertyChanged(window,name); } +void QWaylandNativeInterface::setWindowMargins(QWindow *window, const QMargins &margins) +{ + QWaylandWindow *wlWindow = static_cast<QWaylandWindow*>(window->handle()); + wlWindow->setCustomMargins(margins); +} + } QT_END_NAMESPACE |