7#include <qpa/qplatformwindow.h>
8#include <qpa/qplatformbackingstore.h>
9#include <qpa/qplatforminputcontextfactory_p.h>
10#include <qpa/qwindowsysteminterface.h>
12#include <QtGui/private/qguiapplication_p.h>
13#include <QtGui/private/qwindow_p.h>
14#include <QtGui/private/qgenericunixeventdispatcher_p.h>
15#include <QtGui/private/qgenericunixfontdatabase_p.h>
16#include <QtGui/private/qgenericunixtheme_p.h>
17#include <qpa/qplatformservices.h>
19#include <QtFbSupport/private/qfbvthandler_p.h>
21#if QT_CONFIG(libinput)
22#include <QtInputSupport/private/qlibinputhandler_p.h>
26#include <QtInputSupport/private/qevdevmousemanager_p.h>
27#include <QtInputSupport/private/qevdevkeyboardmanager_p.h>
28#include <QtInputSupport/private/qevdevtouchmanager_p.h>
32#include <QtInputSupport/private/qtslib_p.h>
37using namespace Qt::StringLiterals;
45 void setVk(QVkKhrDisplayVulkanInstance *inst);
48 QVkKhrDisplayVulkanInstance *m_vk =
nullptr;
58 m_geometry = QRect(QPoint(0, 0), m_vk->displaySize());
59 QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry, m_geometry);
60 qDebug() <<
"Screen will report geometry" << m_geometry;
64 QScreen *thisScreen = screen();
65 for (QWindow *window : QGuiApplication::allWindows()) {
66 if (window->isTopLevel() && window->screen() == thisScreen)
67 window->handle()->setGeometry(QRect());
88 QVulkanInstance *inst = window()->vulkanInstance();
90 static_cast<QVkKhrDisplayVulkanInstance *>(inst->handle())->destroySurface(m_surface);
99 QVulkanInstance *inst = window()->vulkanInstance();
101 qWarning(
"Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
104 QVkKhrDisplayVulkanInstance *vkdinst =
static_cast<QVkKhrDisplayVulkanInstance *>(inst->handle());
105 m_surface = vkdinst->createSurface(window());
113 QRect rect(screen()->availableGeometry());
114 QWindowSystemInterface::handleGeometryChange(window(), rect);
115 QPlatformWindow::setGeometry(rect);
117 const QRect lastReportedGeometry = qt_window_private(window())->geometry;
118 if (rect != lastReportedGeometry)
119 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), rect.size()));
129 void flush(QWindow *window,
const QRegion ®ion,
const QPoint &offset)
override {
134 void resize(
const QSize &size,
const QRegion &staticContents)
override {
135 Q_UNUSED(staticContents);
136 QImage::Format format = QGuiApplication::primaryScreen()->handle()->format();
137 if (m_image.size() != size)
138 m_image = QImage(size, format);
147 Q_UNUSED(parameters);
152 QWindowSystemInterface::handleScreenRemoved(m_primaryScreen);
154 delete m_fontDatabase;
161 case ThreadedPixmaps:
return true;
162 case WindowManagement:
return false;
163 default:
return QPlatformIntegration::hasCapability(cap);
173 m_primaryScreen->m_geometry = QRect(0, 0, 1920, 1080);
174 m_primaryScreen->m_depth = 32;
175 m_primaryScreen->m_format = QImage::Format_ARGB32_Premultiplied;
177 QWindowSystemInterface::handleScreenAdded(m_primaryScreen);
179 m_inputContext = QPlatformInputContextFactory::create();
181 m_vtHandler =
new QFbVtHandler;
183 if (!qEnvironmentVariableIntValue(
"QT_QPA_DISABLE_INPUT"))
184 createInputHandlers();
190 m_fontDatabase =
new QGenericUnixFontDatabase;
192 return m_fontDatabase;
198 m_services =
new QPlatformServices;
205 return m_inputContext;
210 return QGenericUnixTheme::createUnixTheme(name);
220 if (window->surfaceType() != QSurface::VulkanSurface) {
221 qWarning(
"vkkhrdisplay platform plugin only supports QWindow with surfaceType == VulkanSurface");
230 w->setGeometry(QRect());
231 w->requestActivateWindow();
242 return createUnixEventDispatcher();
253 QVkKhrDisplayVulkanInstance *inst =
new QVkKhrDisplayVulkanInstance(instance);
264 static const QByteArray names[] = {
265 QByteArrayLiteral(
"vksurface")
267 const QByteArray *end = names +
sizeof(names) /
sizeof(names[0]);
268 const QByteArray *result = std::find(names, end, key);
270 result = std::find(names, end, key.toLower());
271 return int(result - names);
276 void *result =
nullptr;
278 switch (resourceType(resource)) {
280 if (window && window->handle() && window->surfaceType() == QSurface::VulkanSurface)
292#if QT_CONFIG(libinput)
293 if (!qEnvironmentVariableIntValue(
"QT_QPA_NO_LIBINPUT")) {
294 new QLibInputHandler(
"libinput"_L1, QString());
300 bool useTslib = qEnvironmentVariableIntValue(
"QT_QPA_TSLIB");
302 new QTsLibMouseHandler(
"TsLib"_L1, QString());
306 new QEvdevKeyboardManager(
"EvdevKeyboard"_L1, QString(),
this);
307 new QEvdevMouseManager(
"EvdevMouse"_L1, QString(),
this);
311 new QEvdevTouchManager(
"EvdevTouch"_L1, QString() ,
this);
QVkKhrDisplayBackingStore(QWindow *window)
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override
Flushes the given region from the specified window.
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
void resize(const QSize &size, const QRegion &staticContents) override
bool hasCapability(QPlatformIntegration::Capability cap) const override
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
QPlatformTheme * createPlatformTheme(const QString &name) const override
QVkKhrDisplayIntegration(const QStringList ¶meters)
QPlatformVulkanInstance * createPlatformVulkanInstance(QVulkanInstance *instance) const override
~QVkKhrDisplayIntegration()
QPlatformServices * services() const override
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
QPlatformNativeInterface * nativeInterface() const override
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
void initialize() override
Performs initialization steps that depend on having an event dispatcher available.
void * nativeResourceForWindow(const QByteArray &resource, QWindow *window) override
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
void setVk(QVkKhrDisplayVulkanInstance *inst)
int depth() const override
Reimplement in subclass to return current depth of the screen.
void setGeometry(const QRect &r) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
void * vulkanSurfacePtr()
QVkKhrDisplayWindow(QWindow *window)
static int resourceType(const QByteArray &key)