From bfebbd05d33a59a2c1c6d5f5d8afbdcb00928210 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 11 Feb 2022 13:49:45 +0600 Subject: [PATCH] qt: Compatibility improvements * Patch to build with Qt 5.11 and later by jriwanek * Attempt to fix viewport on hardware renderers --- src/qt/qt_hardwarerenderer.cpp | 10 +++++----- src/qt/qt_main.cpp | 2 ++ src/qt/qt_renderercommon.hpp | 1 + src/qt/qt_rendererstack.cpp | 4 ---- src/qt/qt_softwarerenderer.cpp | 4 ++++ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index b322cbaf2..1a89b93be 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -32,7 +32,7 @@ extern "C" { void HardwareRenderer::resizeGL(int w, int h) { - glViewport(0, 0, w * devicePixelRatio(), h * devicePixelRatio()); + glViewport(0, 0, qRound(w * devicePixelRatio()), qRound(h * devicePixelRatio())); } #define PROGRAM_VERTEX_ATTRIBUTE 0 @@ -141,11 +141,11 @@ void HardwareRenderer::paintGL() { QVector verts, texcoords; QMatrix4x4 mat; mat.setToIdentity(); - mat.ortho(QRect(0, 0, width(), height())); + mat.ortho(QRectF(0, 0, (qreal)width(), (qreal)height())); verts.push_back(QVector2D((float)destination.x(), (float)destination.y())); - verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + destination.height())); - verts.push_back(QVector2D((float)destination.x() + destination.width(), (float)destination.y() + destination.height())); - verts.push_back(QVector2D((float)destination.x() + destination.width(), (float)destination.y())); + verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + (float)destination.height())); + verts.push_back(QVector2D((float)destination.x() + (float)destination.width(), (float)destination.y() + (float)destination.height())); + verts.push_back(QVector2D((float)destination.x() + (float)destination.width(), (float)destination.y())); texcoords.push_back(QVector2D((float)source.x() / 2048.f, (float)(source.y()) / 2048.f)); texcoords.push_back(QVector2D((float)source.x() / 2048.f, (float)(source.y() + source.height()) / 2048.f)); texcoords.push_back(QVector2D((float)(source.x() + source.width()) / 2048.f, (float)(source.y() + source.height()) / 2048.f)); diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 51412dab7..78a0fc33f 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -134,7 +134,9 @@ int main(int argc, char* argv[]) { QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); +#endif QApplication app(argc, argv); qt_set_sequence_auto_mnemonic(false); Q_INIT_RESOURCE(qt_resources); diff --git a/src/qt/qt_renderercommon.hpp b/src/qt/qt_renderercommon.hpp index a62aa9aa2..f55f3ee03 100644 --- a/src/qt/qt_renderercommon.hpp +++ b/src/qt/qt_renderercommon.hpp @@ -7,6 +7,7 @@ #include #include #include +#include class QWidget; diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 52d82fc92..16987099f 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -138,10 +138,6 @@ void RendererStack::mousePressEvent(QMouseEvent *event) { mousedata.mousebuttons |= event->button(); } - if (main_window->frameGeometry().contains(event->pos()) && !geometry().contains(event->pos())) - { - main_window->windowHandle()->startSystemMove(); - } event->accept(); } void RendererStack::wheelEvent(QWheelEvent *event) diff --git a/src/qt/qt_softwarerenderer.cpp b/src/qt/qt_softwarerenderer.cpp index 1245fd70a..13d727e83 100644 --- a/src/qt/qt_softwarerenderer.cpp +++ b/src/qt/qt_softwarerenderer.cpp @@ -76,7 +76,11 @@ void SoftwareRenderer::onPaint(QPaintDevice* device) { QPainter painter(device); painter.setRenderHint(QPainter::SmoothPixmapTransform, video_filter_method > 0 ? true : false); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) painter.fillRect(0, 0, device->width(), device->height(), QColorConstants::Black); +#else + painter.fillRect(0,0, device->width(), device->height(), Qt::black); +#endif painter.setCompositionMode(QPainter::CompositionMode_Plus); painter.drawImage(destination, *images[cur_image], source); }