8#include <qpa/qplatformwindow.h>
9#include <qpa/qplatformbackingstore.h>
10#include <qpa/qplatforminputcontextfactory_p.h>
11#include <qpa/qwindowsysteminterface.h>
13#include <QtGui/private/qguiapplication_p.h>
14#include <QtGui/private/qwindow_p.h>
15#include <QtGui/private/qgenericunixeventdispatcher_p.h>
16#include <QtGui/private/qgenericunixfontdatabase_p.h>
17#include <QtGui/private/qgenericunixtheme_p.h>
18#include <qpa/qplatformservices.h>
20#include <QtFbSupport/private/qfbvthandler_p.h>
22#if QT_CONFIG(libinput)
23#include <QtInputSupport/private/qlibinputhandler_p.h>
27#include <QtInputSupport/private/qevdevmousemanager_p.h>
28#include <QtInputSupport/private/qevdevkeyboardmanager_p.h>
29#include <QtInputSupport/private/qevdevtouchmanager_p.h>
33#include <QtInputSupport/private/qtslib_p.h>
38using namespace Qt::StringLiterals;
46 void setVk(QVkKhrDisplayVulkanInstance *inst);
49 QVkKhrDisplayVulkanInstance *m_vk =
nullptr;
59 m_geometry = QRect(QPoint(0, 0), m_vk->displaySize());
60 QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry, m_geometry);
61 qDebug() <<
"Screen will report geometry" << m_geometry;
65 QScreen *thisScreen = screen();
66 for (QWindow *window : QGuiApplication::allWindows()) {
67 if (window->isTopLevel() && window->screen() == thisScreen)
68 window->handle()->setGeometry(QRect());
89 QVulkanInstance *inst = window()->vulkanInstance();
91 static_cast<QVkKhrDisplayVulkanInstance *>(inst->handle())->destroySurface(m_surface);
100 QVulkanInstance *inst = window()->vulkanInstance();
102 qWarning(
"Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
105 QVkKhrDisplayVulkanInstance *vkdinst =
static_cast<QVkKhrDisplayVulkanInstance *>(inst->handle());
106 m_surface = vkdinst->createSurface(window());
114 QRect rect(screen()->availableGeometry());
115 QWindowSystemInterface::handleGeometryChange(window(), rect);
116 QPlatformWindow::setGeometry(rect);
118 const QRect lastReportedGeometry = qt_window_private(window())->geometry;
119 if (rect != lastReportedGeometry)
120 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), rect.size()));
130 void flush(QWindow *window,
const QRegion ®ion,
const QPoint &offset)
override {
135 void resize(
const QSize &size,
const QRegion &staticContents)
override {
136 Q_UNUSED(staticContents);
137 QImage::Format format = QGuiApplication::primaryScreen()->handle()->format();
138 if (m_image.size() != size)
139 m_image = QImage(size, format);
148 Q_UNUSED(parameters);
153 QWindowSystemInterface::handleScreenRemoved(m_primaryScreen);
155 delete m_fontDatabase;
162 case ThreadedPixmaps:
return true;
163 case WindowManagement:
return false;
164 default:
return QPlatformIntegration::hasCapability(cap);
174 m_primaryScreen->m_geometry = QRect(0, 0, 1920, 1080);
175 m_primaryScreen->m_depth = 32;
176 m_primaryScreen->m_format = QImage::Format_ARGB32_Premultiplied;
178 QWindowSystemInterface::handleScreenAdded(m_primaryScreen);
180 m_inputContext = QPlatformInputContextFactory::create();
182 m_vtHandler =
new QFbVtHandler;
184 if (!qEnvironmentVariableIntValue(
"QT_QPA_DISABLE_INPUT"))
185 createInputHandlers();
191 m_fontDatabase =
new QGenericUnixFontDatabase;
193 return m_fontDatabase;
199 m_services =
new QPlatformServices;
206 return m_inputContext;
211 return QGenericUnixTheme::createUnixTheme(name);
221 if (window->surfaceType() != QSurface::VulkanSurface) {
222 qWarning(
"vkkhrdisplay platform plugin only supports QWindow with surfaceType == VulkanSurface");
231 w->setGeometry(QRect());
232 w->requestActivateWindow();
243 return createUnixEventDispatcher();
254 QVkKhrDisplayVulkanInstance *inst =
new QVkKhrDisplayVulkanInstance(instance);
265 static const QByteArray names[] = {
266 QByteArrayLiteral(
"vksurface")
268 const QByteArray *end = names +
sizeof(names) /
sizeof(names[0]);
269 const QByteArray *result = std::find(names, end, key);
271 result = std::find(names, end, key.toLower());
272 return int(result - names);
277 void *result =
nullptr;
279 switch (resourceType(resource)) {
281 if (window && window->handle() && window->surfaceType() == QSurface::VulkanSurface)
293#if QT_CONFIG(libinput)
294 if (!qEnvironmentVariableIntValue(
"QT_QPA_NO_LIBINPUT")) {
295 new QLibInputHandler(
"libinput"_L1, QString());
301 bool useTslib = qEnvironmentVariableIntValue(
"QT_QPA_TSLIB");
303 new QTsLibMouseHandler(
"TsLib"_L1, QString());
307 new QEvdevKeyboardManager(
"EvdevKeyboard"_L1, QString(),
this);
308 new QEvdevMouseManager(
"EvdevMouse"_L1, QString(),
this);
312 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)
Combined button and popup list for selecting options.
static int resourceType(const QByteArray &key)