mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
fixed resizing of qml overlays when device pixel ratio changes
This commit is contained in:
parent
f0b78eae47
commit
78a1845afe
3 changed files with 6 additions and 11 deletions
|
@ -1459,13 +1459,7 @@ void Application::initializeUi() {
|
||||||
});
|
});
|
||||||
offscreenUi->resume();
|
offscreenUi->resume();
|
||||||
connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){
|
connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){
|
||||||
static qreal oldDevicePixelRatio = 0;
|
resizeGL();
|
||||||
qreal devicePixelRatio = getActiveDisplayPlugin()->devicePixelRatio();
|
|
||||||
if (devicePixelRatio != oldDevicePixelRatio) {
|
|
||||||
oldDevicePixelRatio = devicePixelRatio;
|
|
||||||
qDebug() << "Device pixel ratio changed, triggering GL resize";
|
|
||||||
resizeGL();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// This will set up the input plugins UI
|
// This will set up the input plugins UI
|
||||||
|
@ -1840,7 +1834,8 @@ void Application::resizeGL() {
|
||||||
static qreal lastDevicePixelRatio = 0;
|
static qreal lastDevicePixelRatio = 0;
|
||||||
qreal devicePixelRatio = _window->devicePixelRatio();
|
qreal devicePixelRatio = _window->devicePixelRatio();
|
||||||
if (offscreenUi->size() != fromGlm(uiSize) || devicePixelRatio != lastDevicePixelRatio) {
|
if (offscreenUi->size() != fromGlm(uiSize) || devicePixelRatio != lastDevicePixelRatio) {
|
||||||
offscreenUi->resize(fromGlm(uiSize));
|
qDebug() << "Device pixel ratio changed, triggering resize";
|
||||||
|
offscreenUi->resize(fromGlm(uiSize), true);
|
||||||
_offscreenContext->makeCurrent();
|
_offscreenContext->makeCurrent();
|
||||||
lastDevicePixelRatio = devicePixelRatio;
|
lastDevicePixelRatio = devicePixelRatio;
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,7 +414,7 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) {
|
||||||
_updateTimer.start();
|
_updateTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::resize(const QSize& newSize_) {
|
void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) {
|
||||||
|
|
||||||
if (!_renderer || !_renderer->_quickWindow) {
|
if (!_renderer || !_renderer->_quickWindow) {
|
||||||
return;
|
return;
|
||||||
|
@ -433,7 +433,7 @@ void OffscreenQmlSurface::resize(const QSize& newSize_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize currentSize = _renderer->_quickWindow->geometry().size();
|
QSize currentSize = _renderer->_quickWindow->geometry().size();
|
||||||
if (newSize == currentSize) {
|
if (newSize == currentSize && !forceResize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
using MouseTranslator = std::function<QPoint(const QPointF&)>;
|
using MouseTranslator = std::function<QPoint(const QPointF&)>;
|
||||||
|
|
||||||
virtual void create(QOpenGLContext* context);
|
virtual void create(QOpenGLContext* context);
|
||||||
void resize(const QSize& size);
|
void resize(const QSize& size, bool forceResize = false);
|
||||||
QSize size() const;
|
QSize size() const;
|
||||||
Q_INVOKABLE QObject* load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
Q_INVOKABLE QObject* load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
||||||
Q_INVOKABLE QObject* load(const QString& qmlSourceFile, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}) {
|
Q_INVOKABLE QObject* load(const QString& qmlSourceFile, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}) {
|
||||||
|
|
Loading…
Reference in a new issue