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;
54 QSizeF m_physicalSize;
64 if (m_physicalSize.isEmpty())
65 return QPlatformScreen::physicalSize();
66 return m_physicalSize;
72 m_name = m_vk->displayName();
73 m_physicalSize = m_vk->physicalSize();
74 m_geometry = QRect(QPoint(0, 0), m_vk->displaySize());
75 QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry, m_geometry);
76 qCDebug(qLcVkKhrDisplay) <<
"Screen will report name" << m_name <<
"geometry" << m_geometry
77 <<
"physical size" << m_physicalSize;
81 QScreen *thisScreen = screen();
82 const auto windows = QGuiApplication::allWindows();
83 for (QWindow *window : windows) {
84 if (window->isTopLevel() && window->screen() == thisScreen)
85 window->handle()->setGeometry(QRect());
106 QVulkanInstance *inst = window()->vulkanInstance();
117 QVulkanInstance *inst = window()->vulkanInstance();
119 qWarning(
"Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
123 m_surface = vkdinst->createSurface(window());
131 QRect rect(screen()->availableGeometry());
132 QWindowSystemInterface::handleGeometryChange(window(), rect);
133 QPlatformWindow::setGeometry(rect);
135 const QRect lastReportedGeometry = qt_window_private(window())->geometry;
136 if (rect != lastReportedGeometry)
137 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), rect.size()));
147 void flush(QWindow *window,
const QRegion ®ion,
const QPoint &offset)
override {
152 void resize(
const QSize &size,
const QRegion &staticContents)
override {
153 Q_UNUSED(staticContents);
154 QImage::Format format = QGuiApplication::primaryScreen()->handle()->format();
155 if (m_image.size() != size)
156 m_image = QImage(size, format);
165 Q_UNUSED(parameters);
170 QWindowSystemInterface::handleScreenRemoved(m_primaryScreen);
172 delete m_fontDatabase;
179 case ThreadedPixmaps:
return true;
180 case WindowManagement:
return false;
181 default:
return QPlatformIntegration::hasCapability(cap);
191 m_primaryScreen->m_geometry = QRect(0, 0, 1920, 1080);
192 m_primaryScreen->m_depth = 32;
193 m_primaryScreen->m_format = QImage::Format_ARGB32_Premultiplied;
195 QWindowSystemInterface::handleScreenAdded(m_primaryScreen);
197 m_inputContext = QPlatformInputContextFactory::create();
199 m_vtHandler =
new QFbVtHandler;
201 if (!qEnvironmentVariableIntValue(
"QT_QPA_DISABLE_INPUT"))
202 createInputHandlers();
208 m_fontDatabase =
new QGenericUnixFontDatabase;
210 return m_fontDatabase;
216 m_services =
new QPlatformServices;
223 return m_inputContext;
228 return QGenericUnixTheme::createUnixTheme(name);
238 if (window->surfaceType() != QSurface::VulkanSurface) {
239 qWarning(
"vkkhrdisplay platform plugin only supports QWindow with surfaceType == VulkanSurface");
248 w->setGeometry(QRect());
249 w->requestActivateWindow();
260 return createUnixEventDispatcher();
282 static const QByteArray names[] = {
283 QByteArrayLiteral(
"vksurface")
285 const QByteArray *end = names +
sizeof(names) /
sizeof(names[0]);
286 const QByteArray *result = std::find(names, end, key);
288 result = std::find(names, end, key.toLower());
289 return int(result - names);
294 void *result =
nullptr;
296 switch (resourceType(resource)) {
298 if (window && window->handle() && window->surfaceType() == QSurface::VulkanSurface)
310#if QT_CONFIG(libinput)
311 if (!qEnvironmentVariableIntValue(
"QT_QPA_NO_LIBINPUT")) {
312 new QLibInputHandler(
"libinput"_L1, QString());
318 bool useTslib = qEnvironmentVariableIntValue(
"QT_QPA_TSLIB");
320 new QTsLibMouseHandler(
"TsLib"_L1, QString());
324 new QEvdevKeyboardManager(
"EvdevKeyboard"_L1, QString(),
this);
325 new QEvdevMouseManager(
"EvdevMouse"_L1, QString(),
this);
329 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.
QSizeF physicalSize() const override
Reimplement this function in subclass to return the physical size of the screen, in millimeters.
QString name() const override
void setCreatedCallback(CreatedCallback callback, void *userData)
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)