qt: Compatibility improvements

* Patch to build with Qt 5.11 and later by jriwanek
* Attempt to fix viewport on hardware renderers
This commit is contained in:
Cacodemon345
2022-02-11 13:49:45 +06:00
parent 15bc29aef8
commit bfebbd05d3
5 changed files with 12 additions and 9 deletions

View File

@@ -32,7 +32,7 @@ extern "C" {
void HardwareRenderer::resizeGL(int w, int h) 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 #define PROGRAM_VERTEX_ATTRIBUTE 0
@@ -141,11 +141,11 @@ void HardwareRenderer::paintGL() {
QVector<QVector2D> verts, texcoords; QVector<QVector2D> verts, texcoords;
QMatrix4x4 mat; QMatrix4x4 mat;
mat.setToIdentity(); 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()));
verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + destination.height())); verts.push_back(QVector2D((float)destination.x(), (float)destination.y() + (float)destination.height()));
verts.push_back(QVector2D((float)destination.x() + destination.width(), (float)destination.y() + 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() + destination.width(), (float)destination.y())); 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()) / 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() / 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)); texcoords.push_back(QVector2D((float)(source.x() + source.width()) / 2048.f, (float)(source.y() + source.height()) / 2048.f));

View File

@@ -134,7 +134,9 @@ int main(int argc, char* argv[]) {
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif #endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
QApplication app(argc, argv); QApplication app(argc, argv);
qt_set_sequence_auto_mnemonic(false); qt_set_sequence_auto_mnemonic(false);
Q_INIT_RESOURCE(qt_resources); Q_INIT_RESOURCE(qt_resources);

View File

@@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include <tuple> #include <tuple>
#include <atomic> #include <atomic>
#include <memory>
class QWidget; class QWidget;

View File

@@ -138,10 +138,6 @@ void RendererStack::mousePressEvent(QMouseEvent *event)
{ {
mousedata.mousebuttons |= event->button(); mousedata.mousebuttons |= event->button();
} }
if (main_window->frameGeometry().contains(event->pos()) && !geometry().contains(event->pos()))
{
main_window->windowHandle()->startSystemMove();
}
event->accept(); event->accept();
} }
void RendererStack::wheelEvent(QWheelEvent *event) void RendererStack::wheelEvent(QWheelEvent *event)

View File

@@ -76,7 +76,11 @@ void SoftwareRenderer::onPaint(QPaintDevice* device) {
QPainter painter(device); QPainter painter(device);
painter.setRenderHint(QPainter::SmoothPixmapTransform, video_filter_method > 0 ? true : false); 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); 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.setCompositionMode(QPainter::CompositionMode_Plus);
painter.drawImage(destination, *images[cur_image], source); painter.drawImage(destination, *images[cur_image], source);
} }