11#include " proxywindow.hpp"
22
33#include < private/qquickwindow_p.h>
4+ #include < qcoreevent.h>
45#include < qevent.h>
56#include < qnamespace.h>
67#include < qobject.h>
@@ -191,6 +192,7 @@ void ProxyWindowBase::connectWindow() {
191192 QObject::connect (this ->window , &QWindow::screenChanged, this , &ProxyWindowBase::screenChanged);
192193 QObject::connect (this ->window , &QQuickWindow::colorChanged, this , &ProxyWindowBase::colorChanged);
193194 QObject::connect (this ->window , &ProxiedWindow::exposed, this , &ProxyWindowBase::runLints);
195+ QObject::connect (this ->window , &ProxiedWindow::devicePixelRatioChanged, this , &ProxyWindowBase::devicePixelRatioChanged);
194196 // clang-format on
195197}
196198
@@ -213,6 +215,7 @@ void ProxyWindowBase::completeWindow() {
213215 emit this ->yChanged ();
214216 emit this ->widthChanged ();
215217 emit this ->heightChanged ();
218+ emit this ->devicePixelRatioChanged ();
216219
217220 this ->mContentItem ->setParentItem (this ->window ->contentItem ());
218221 this ->mContentItem ->setWidth (this ->width ());
@@ -411,6 +414,12 @@ void ProxyWindowBase::setSurfaceFormat(QsSurfaceFormat format) {
411414 emit this ->surfaceFormatChanged ();
412415}
413416
417+ qreal ProxyWindowBase::devicePixelRatio () const {
418+ if (this ->window != nullptr ) return this ->window ->devicePixelRatio ();
419+ if (this ->mScreen != nullptr ) return this ->mScreen ->devicePixelRatio ();
420+ return 1.0 ;
421+ }
422+
414423void ProxyWindowBase::onMaskChanged () {
415424 if (this ->window != nullptr ) this ->updateMask ();
416425}
@@ -456,6 +465,14 @@ void ProxyWindowAttached::setWindow(ProxyWindowBase* window) {
456465 emit this ->windowChanged ();
457466}
458467
468+ bool ProxiedWindow::event (QEvent* event) {
469+ if (event->type () == QEvent::DevicePixelRatioChange) {
470+ emit this ->devicePixelRatioChanged ();
471+ }
472+
473+ return this ->QQuickWindow ::event (event);
474+ }
475+
459476void ProxiedWindow::exposeEvent (QExposeEvent* event) {
460477 this ->QQuickWindow ::exposeEvent (event);
461478 emit this ->exposed ();
0 commit comments