Implement QNativeInterface::QWaylandApplication

Task-number: QTBUG-94729
Change-Id: I84f080719c6364137368bdd1759947a6d6ef2e5b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
David Redondo 2022-07-28 10:09:57 +02:00
parent 9dd6cc1788
commit efdd7b5755
2 changed files with 71 additions and 4 deletions

View File

@ -12,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>
@ -68,6 +69,60 @@ void *QWaylandNativeInterface::nativeResourceForIntegration(const QByteArray &re
return nullptr;
}
wl_display *QtWaylandClient::QWaylandNativeInterface::display() const
{
return m_integration->display()->wl_display();
}
wl_compositor *QtWaylandClient::QWaylandNativeInterface::compositor() const
{
return const_cast<wl_compositor *>(m_integration->display()->wl_compositor());
}
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;
}
void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
QByteArray lowerCaseResource = resourceString.toLower();

View File

@ -1,8 +1,8 @@
// Copyright (C) 2020 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
#ifndef QWAYLANDNATIVEINTERFACE_H
#define QWAYLANDNATIVEINTERFACE_H
#ifndef QWAYLANDNATIVEINTERFACE_P_H
#define QWAYLANDNATIVEINTERFACE_P_H
//
// W A R N I N G
@ -21,6 +21,7 @@
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtCore/private/qglobal_p.h>
#include <QtCore/qhash.h>
#include <QtGui/qguiapplication_platform.h>
QT_BEGIN_NAMESPACE
@ -31,7 +32,8 @@ namespace QtWaylandClient {
class QWaylandIntegration;
class QWaylandScreen;
class Q_WAYLANDCLIENT_EXPORT QWaylandNativeInterface : public QPlatformNativeInterface
class Q_WAYLANDCLIENT_EXPORT QWaylandNativeInterface : public QPlatformNativeInterface,
public QNativeInterface::QWaylandApplication
{
public:
QWaylandNativeInterface(QWaylandIntegration *integration);
@ -51,6 +53,16 @@ public:
void emitWindowPropertyChanged(QPlatformWindow *window, const QString &name);
// QWaylandApplication interface
wl_display *display() const override;
wl_compositor *compositor() const override;
wl_seat *seat() const override;
wl_keyboard *keyboard() const override;
wl_pointer *pointer() const override;
wl_touch *touch() const override;
uint lastInputSerial() const override;
wl_seat *lastInputSeat() const override;
private:
static void setWindowMargins(QWindow *window, const QMargins &margins);
@ -62,4 +74,4 @@ private:
QT_END_NAMESPACE
#endif // QWAYLANDNATIVEINTERFACE_H
#endif // QWAYLANDNATIVEINTERFACE_P_H