diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -157,7 +157,7 @@ dlg->setVisualParent(this); dlg->setMainItem(mainItem()); dlg->setInteractive(m_interactive); - dlg->show(); + dlg->setVisible(true); } QString ToolTip::mainText() const diff --git a/src/plasmaquick/dialog.h b/src/plasmaquick/dialog.h --- a/src/plasmaquick/dialog.h +++ b/src/plasmaquick/dialog.h @@ -197,6 +197,9 @@ void setBackgroundHints(BackgroundHints hints); bool isVisible() const; + /** + * Note: in order for aboutToShow to be correctly emitted, this needs to be used instead of show() + */ void setVisible(bool visible); /** @@ -221,6 +224,11 @@ * window that is neither a parent dialog to nor a child dialog of this dialog. */ void windowDeactivated(); + /** + * Emitted when the popup is about to show + * it's still not visible, but geometry already adjusted + */ + void aboutToShow(); protected: /** diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -298,11 +298,10 @@ cachedGeometry = QRect(); } - if (mainItem) { - syncToMainItemSize(); - } - if (mainItemLayout) { - updateLayoutParameters(); + //if is a wayland window that was hidden, we need + //to set its position again as there won't be any move event to sync QWindow::position and shellsurface::position + if (shellSurface) { + shellSurface->setPosition(q->position()); } } } @@ -447,7 +446,7 @@ void DialogPrivate::getSizeHints(QSize &min, QSize &max) const { - if (!componentComplete || !mainItem || !q->isVisible() || !mainItemLayout) { + if (!componentComplete || !mainItem || !mainItemLayout) { return; } Q_ASSERT(mainItem); @@ -481,7 +480,7 @@ void DialogPrivate::updateLayoutParameters() { - if (!componentComplete || !mainItem || !q->isVisible() || !mainItemLayout) { + if (!componentComplete || !mainItem || !mainItemLayout) { return; } @@ -598,7 +597,7 @@ { Q_ASSERT(mainItem); - if (!componentComplete || !q->isVisible()) { + if (!componentComplete) { return; } if (mainItem->width() <= 0 || mainItem->height() <= 0) { @@ -1164,10 +1163,13 @@ * see https://phabricator.kde.org/T6064 */ #if HAVE_KWAYLAND - if (!d->shellSurface) { + //sometimes non null regions arrive even for non visible windows + //for which surface creation would fail + if (!d->shellSurface && isVisible()) { KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager); d->setupWaylandIntegration(); d->updateVisibility(true); + d->updateTheme(); } #endif #if (QT_VERSION > QT_VERSION_CHECK(5, 5, 0)) @@ -1304,21 +1306,24 @@ void Dialog::componentComplete() { d->componentComplete = true; + if (d->visible) { + if (d->mainItem) { + d->mainItem->setVisible(true); + d->syncToMainItemSize(); + } + + if (d->mainItemLayout) { + d->updateLayoutParameters(); + } + emit aboutToShow(); + } QQuickWindow::setVisible(d->visible); if (d->visible) { // FIXME TODO: We can remove this once we depend on Qt 5.6.1+. // See: https://bugreports.qt.io/browse/QTBUG-26978 KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager); } d->updateTheme(); - - if (d->mainItem) { - d->syncToMainItemSize(); - } - - if (d->mainItemLayout) { - d->updateLayoutParameters(); - } } bool Dialog::hideOnWindowDeactivate() const @@ -1356,6 +1361,17 @@ d->visible = visible; if (d->componentComplete) { + if (visible) { + if (d->mainItem) { + d->mainItem->setVisible(true); + d->syncToMainItemSize(); + } + if (d->mainItemLayout) { + d->updateLayoutParameters(); + } + + emit aboutToShow(); + } if (visible && d->visualParent) { setPosition(popupPosition(d->visualParent, size())); }