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 const auto windows = QGuiApplication::allWindows();
67 for (QWindow *window : windows) {
68 if (window->isTopLevel() && window->screen() == thisScreen)
69 window->handle()->setGeometry(QRect());
90 QVulkanInstance *inst = window()->vulkanInstance();
92 static_cast<QVkKhrDisplayVulkanInstance *>(inst->handle())->destroySurface(m_surface);
101 QVulkanInstance *inst = window()->vulkanInstance();
103 qWarning(
"Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
106 QVkKhrDisplayVulkanInstance *vkdinst =
static_cast<QVkKhrDisplayVulkanInstance *>(inst->handle());
107 m_surface = vkdinst->createSurface(window());
115 QRect rect(screen()->availableGeometry());
116 QWindowSystemInterface::handleGeometryChange(window(), rect);
117 QPlatformWindow::setGeometry(rect);
119 const QRect lastReportedGeometry = qt_window_private(window())->geometry;
120 if (rect != lastReportedGeometry)
121 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), rect.size()));
131 void flush(QWindow *window,
const QRegion ®ion,
const QPoint &offset)
override {
136 void resize(
const QSize &size,
const QRegion &staticContents)
override {
137 Q_UNUSED(staticContents);
138 QImage::Format format = QGuiApplication::primaryScreen()->handle()->format();
139 if (m_image.size() != size)
140 m_image = QImage(size, format);
149 Q_UNUSED(parameters);
154 QWindowSystemInterface::handleScreenRemoved(m_primaryScreen);
156 delete m_fontDatabase;
163 case ThreadedPixmaps:
return true;
164 case WindowManagement:
return false;
165 default:
return QPlatformIntegration::hasCapability(cap);
175 m_primaryScreen->m_geometry = QRect(0, 0, 1920, 1080);
176 m_primaryScreen->m_depth = 32;
177 m_primaryScreen->m_format = QImage::Format_ARGB32_Premultiplied;
179 QWindowSystemInterface::handleScreenAdded(m_primaryScreen);
181 m_inputContext = QPlatformInputContextFactory::create();
183 m_vtHandler =
new QFbVtHandler;
185 if (!qEnvironmentVariableIntValue(
"QT_QPA_DISABLE_INPUT"))
186 createInputHandlers();
192 m_fontDatabase =
new QGenericUnixFontDatabase;
194 return m_fontDatabase;
200 m_services =
new QPlatformServices;
207 return m_inputContext;
212 return QGenericUnixTheme::createUnixTheme(name);
222 if (window->surfaceType() != QSurface::VulkanSurface) {
223 qWarning(
"vkkhrdisplay platform plugin only supports QWindow with surfaceType == VulkanSurface");
232 w->setGeometry(QRect());
233 w->requestActivateWindow();
244 return createUnixEventDispatcher();
255 QVkKhrDisplayVulkanInstance *inst =
new QVkKhrDisplayVulkanInstance(instance);
266 static const QByteArray names[] = {
267 QByteArrayLiteral(
"vksurface")
269 const QByteArray *end = names +
sizeof(names) /
sizeof(names[0]);
270 const QByteArray *result = std::find(names, end, key);
272 result = std::find(names, end, key.toLower());
273 return int(result - names);
278 void *result =
nullptr;
280 switch (resourceType(resource)) {
282 if (window && window->handle() && window->surfaceType() == QSurface::VulkanSurface)
294#if QT_CONFIG(libinput)
295 if (!qEnvironmentVariableIntValue(
"QT_QPA_NO_LIBINPUT")) {
296 new QLibInputHandler(
"libinput"_L1, QString());
302 bool useTslib = qEnvironmentVariableIntValue(
"QT_QPA_TSLIB");
304 new QTsLibMouseHandler(
"TsLib"_L1, QString());
308 new QEvdevKeyboardManager(
"EvdevKeyboard"_L1, QString(),
this);
309 new QEvdevMouseManager(
"EvdevMouse"_L1, QString(),
this);
313 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)