28
28
29
29
ProxyWindowBase::ProxyWindowBase (QObject* parent)
30
30
: Reloadable(parent)
31
- , mContentItem(new QQuickItem ()) {
31
+ , mContentItem(new ProxyWindowContentItem ()) {
32
32
QQmlEngine::setObjectOwnership (this ->mContentItem , QQmlEngine::CppOwnership);
33
33
this ->mContentItem ->setParent (this );
34
34
35
35
// clang-format off
36
+ QObject::connect (this ->mContentItem , &ProxyWindowContentItem::polished, this , &ProxyWindowBase::onPolished);
37
+
36
38
QObject::connect (this , &ProxyWindowBase::widthChanged, this , &ProxyWindowBase::onWidthChanged);
37
39
QObject::connect (this , &ProxyWindowBase::heightChanged, this , &ProxyWindowBase::onHeightChanged);
38
40
39
- QObject::connect (this , &ProxyWindowBase::maskChanged, this , &ProxyWindowBase::onMaskChanged);
40
41
QObject::connect (this , &ProxyWindowBase::widthChanged, this , &ProxyWindowBase::onMaskChanged);
41
42
QObject::connect (this , &ProxyWindowBase::heightChanged, this , &ProxyWindowBase::onMaskChanged);
42
43
@@ -264,6 +265,12 @@ void ProxyWindowBase::setVisibleDirect(bool visible) {
264
265
}
265
266
}
266
267
268
+ void ProxyWindowBase::schedulePolish () {
269
+ if (this ->isVisibleDirect ()) {
270
+ this ->mContentItem ->polish ();
271
+ }
272
+ }
273
+
267
274
void ProxyWindowBase::polishItems () {
268
275
// Due to QTBUG-126704, layouts in invisible windows don't update their dimensions.
269
276
// Usually this isn't an issue, but it is when the size of a window is based on the size
@@ -385,11 +392,11 @@ void ProxyWindowBase::setMask(PendingRegion* mask) {
385
392
this ->mMask = mask;
386
393
387
394
if (mask != nullptr ) {
388
- mask->setParent (this );
389
395
QObject::connect (mask, &QObject::destroyed, this , &ProxyWindowBase::onMaskDestroyed);
390
- QObject::connect (mask, &PendingRegion::changed, this , &ProxyWindowBase::maskChanged );
396
+ QObject::connect (mask, &PendingRegion::changed, this , &ProxyWindowBase::onMaskChanged );
391
397
}
392
398
399
+ this ->onMaskChanged ();
393
400
emit this ->maskChanged ();
394
401
}
395
402
@@ -410,23 +417,13 @@ void ProxyWindowBase::onMaskChanged() {
410
417
411
418
void ProxyWindowBase::onMaskDestroyed () {
412
419
this ->mMask = nullptr ;
420
+ this ->onMaskChanged ();
413
421
emit this ->maskChanged ();
414
422
}
415
423
416
424
void ProxyWindowBase::updateMask () {
417
- QRegion mask;
418
- if (this ->mMask != nullptr ) {
419
- // if left as the default, dont combine it with the whole window area, leave it as is.
420
- if (this ->mMask ->mIntersection == Intersection::Combine) {
421
- mask = this ->mMask ->build ();
422
- } else {
423
- auto windowRegion = QRegion (QRect (0 , 0 , this ->width (), this ->height ()));
424
- mask = this ->mMask ->applyTo (windowRegion);
425
- }
426
- }
427
-
428
- this ->window ->setFlag (Qt::WindowTransparentForInput, this ->mMask != nullptr && mask.isEmpty ());
429
- this ->window ->setMask (mask);
425
+ this ->pendingPolish .inputMask = true ;
426
+ this ->schedulePolish ();
430
427
}
431
428
432
429
QQmlListProperty<QObject> ProxyWindowBase::data () {
@@ -463,3 +460,21 @@ void ProxiedWindow::exposeEvent(QExposeEvent* event) {
463
460
this ->QQuickWindow ::exposeEvent (event);
464
461
emit this ->exposed ();
465
462
}
463
+
464
+ void ProxyWindowContentItem::updatePolish () { emit this ->polished (); }
465
+
466
+ void ProxyWindowBase::onPolished () {
467
+ if (this ->pendingPolish .inputMask ) {
468
+ QRegion mask;
469
+ if (this ->mMask != nullptr ) {
470
+ mask = this ->mMask ->applyTo (QRect (0 , 0 , this ->width (), this ->height ()));
471
+ }
472
+
473
+ this ->window ->setFlag (Qt::WindowTransparentForInput, this ->mMask != nullptr && mask.isEmpty ());
474
+ this ->window ->setMask (mask);
475
+
476
+ this ->pendingPolish .inputMask = false ;
477
+ }
478
+
479
+ emit this ->polished ();
480
+ }
0 commit comments