Platforms are today represented as platform plugins in src/plugins/platforms, and we expose platform specific functionality in various ad-hock ways:
- QPlatformNativeInterface, a QPA-internal class with functions such as:
- void *nativeResourceForWindow(const QByteArray &resource, QWindow *window)
- QFunctionPointer platformFunction(const QByteArray &function)
- Plumbed out to QGuiApplication::platformFunction
- QtPlatformHeaders, a header-only module with no binary compatibility promise, only source compatibility
- QtMacExtras, QtX11Extras
All of these require plumbing and boilerplate to expose platform-specific functionality.
One way to improve on this situation is to move platforms into src/platforms, as libraries, with their own private headers. The plugins will then just be thin wrappers to dynamically load a platform, linking to the corresponding platform library.
Users who want to use platform-specific functionality can then do e.g. QT += macos-private, include the relevant headers such as qcocoawindow.h, and cast the QWindow's handle.