fixed resizing of qml overlays when device pixel ratio changes

This commit is contained in:
SamGondelman 2016-06-21 18:13:11 -07:00
parent f0b78eae47
commit 78a1845afe
3 changed files with 6 additions and 11 deletions

View file

@ -1459,13 +1459,7 @@ void Application::initializeUi() {
});
offscreenUi->resume();
connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){
static qreal oldDevicePixelRatio = 0;
qreal devicePixelRatio = getActiveDisplayPlugin()->devicePixelRatio();
if (devicePixelRatio != oldDevicePixelRatio) {
oldDevicePixelRatio = devicePixelRatio;
qDebug() << "Device pixel ratio changed, triggering GL resize";
resizeGL();
}
resizeGL();
});
// This will set up the input plugins UI
@ -1840,7 +1834,8 @@ void Application::resizeGL() {
static qreal lastDevicePixelRatio = 0;
qreal devicePixelRatio = _window->devicePixelRatio();
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();
lastDevicePixelRatio = devicePixelRatio;
}

View file

@ -414,7 +414,7 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) {
_updateTimer.start();
}
void OffscreenQmlSurface::resize(const QSize& newSize_) {
void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) {
if (!_renderer || !_renderer->_quickWindow) {
return;
@ -433,7 +433,7 @@ void OffscreenQmlSurface::resize(const QSize& newSize_) {
}
QSize currentSize = _renderer->_quickWindow->geometry().size();
if (newSize == currentSize) {
if (newSize == currentSize && !forceResize) {
return;
}

View file

@ -38,7 +38,7 @@ public:
using MouseTranslator = std::function<QPoint(const QPointF&)>;
virtual void create(QOpenGLContext* context);
void resize(const QSize& size);
void resize(const QSize& size, bool forceResize = false);
QSize size() const;
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*) {}) {