Add QHighDpiScaling support on Wayland via QPA API

This commit is contained in:
Ilya Fedin 2023-11-19 01:20:52 +04:00 committed by John Preston
parent d6133525dc
commit d86bd3f493

View file

@ -16,6 +16,7 @@
#include <QtCore/QPoint> #include <QtCore/QPoint>
#include <QtGui/QWindow> #include <QtGui/QWindow>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformwindow_p.h> #include <qpa/qplatformwindow_p.h>
extern "C" { extern "C" {
@ -561,9 +562,13 @@ bool WindowMarginsSupported() {
void SetWindowMargins(not_null<QWidget*> widget, const QMargins &margins) { void SetWindowMargins(not_null<QWidget*> widget, const QMargins &margins) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
using namespace QNativeInterface::Private; using namespace QNativeInterface::Private;
if (const auto native = not_null(widget->windowHandle()) const auto window = not_null(widget->windowHandle());
->nativeInterface<QWaylandWindow>()) { const auto platformWindow = not_null(window->handle());
native->setCustomMargins(margins); if (const auto native = window->nativeInterface<QWaylandWindow>()) {
native->setCustomMargins(
margins
* window->devicePixelRatio()
/ platformWindow->devicePixelRatio());
return; return;
} }
#endif // Qt >= 6.5.0 #endif // Qt >= 6.5.0