diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index 39e5b0113..1428ac5bf 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -654,9 +654,8 @@ void AppItem::showPreview() m_appPreviewTips = new PreviewContainer; - m_appPreviewTips->setWindowInfos(m_windowInfos, m_itemEntryInter->GetAllowedCloseWindows().value()); - m_appPreviewTips->updateSnapshots(); m_appPreviewTips->updateLayoutDirection(DockPosition); + m_appPreviewTips->setWindowInfos(m_windowInfos, m_itemEntryInter->GetAllowedCloseWindows().value()); connect(m_appPreviewTips, &PreviewContainer::requestActivateWindow, this, &AppItem::requestActivateWindow, Qt::QueuedConnection); connect(m_appPreviewTips, &PreviewContainer::requestPreviewWindow, this, &AppItem::requestPreviewWindow, Qt::QueuedConnection); diff --git a/frame/item/components/appsnapshot.cpp b/frame/item/components/appsnapshot.cpp index d48f63fb4..9fcf0f016 100644 --- a/frame/item/components/appsnapshot.cpp +++ b/frame/item/components/appsnapshot.cpp @@ -372,6 +372,12 @@ bool AppSnapshot::eventFilter(QObject *watched, QEvent *e) return false; } +void AppSnapshot::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + fetchSnapshot(); +} + SHMInfo *AppSnapshot::getImageDSHM() { const auto display = Utils::IS_WAYLAND_DISPLAY ? XOpenDisplay(nullptr) : QX11Info::display(); diff --git a/frame/item/components/appsnapshot.h b/frame/item/components/appsnapshot.h index 2942b166d..2f7bca737 100644 --- a/frame/item/components/appsnapshot.h +++ b/frame/item/components/appsnapshot.h @@ -98,6 +98,7 @@ private: void paintEvent(QPaintEvent *e) override; void mousePressEvent(QMouseEvent *e) override; bool eventFilter(QObject *watched, QEvent *e) override; + void resizeEvent(QResizeEvent *event) override; SHMInfo *getImageDSHM(); XImage *getImageXlib(); QRect rectRemovedShadow(const QImage &qimage, unsigned char *prop_to_return_gtk); diff --git a/frame/item/components/previewcontainer.cpp b/frame/item/components/previewcontainer.cpp index 43f0721be..833f48a6d 100644 --- a/frame/item/components/previewcontainer.cpp +++ b/frame/item/components/previewcontainer.cpp @@ -95,12 +95,6 @@ void PreviewContainer::setWindowInfos(const WindowInfoMap &infos, const WindowLi adjustSize(m_wmHelper->hasComposite()); } -void PreviewContainer::updateSnapshots() -{ - for (AppSnapshot *snap : m_snapshots) - snap->fetchSnapshot(); -} - void PreviewContainer::setTitleDisplayMode(int mode) { m_titleMode = static_cast(mode); @@ -164,7 +158,7 @@ void PreviewContainer::adjustSize(bool composite) const int padding = 20; const bool horizontal = m_windowListLayout->direction() == QBoxLayout::LeftToRight; if (horizontal) { - count = qMin(count, screenWidth *2 / SNAP_WIDTH); + count = qMin(count, screenWidth * 2 / SNAP_WIDTH); const int h = SNAP_HEIGHT + MARGIN * 2; const int w = SNAP_WIDTH * count + MARGIN * 2 + SPACING * (count - 1); @@ -172,7 +166,7 @@ void PreviewContainer::adjustSize(bool composite) setFixedHeight(h); setFixedWidth(qMin(w, screenWidth - padding)); } else { - count = qMin(count, screenWidth *2 / SNAP_HEIGHT); + count = qMin(count, screenWidth * 2 / SNAP_HEIGHT); const int w = SNAP_WIDTH + MARGIN * 2; const int h = SNAP_HEIGHT * count + MARGIN * 2 + SPACING * (count - 1); diff --git a/frame/item/components/previewcontainer.h b/frame/item/components/previewcontainer.h index 6aebb1700..1e48cb8b7 100644 --- a/frame/item/components/previewcontainer.h +++ b/frame/item/components/previewcontainer.h @@ -58,7 +58,6 @@ signals: public: void setWindowInfos(const WindowInfoMap &infos, const WindowList &allowClose); - void updateSnapshots(); void setTitleDisplayMode(int mode); public slots: diff --git a/tests/item/components/ut_previewcontainer.cpp b/tests/item/components/ut_previewcontainer.cpp index bf4b40c58..ba8029591 100644 --- a/tests/item/components/ut_previewcontainer.cpp +++ b/tests/item/components/ut_previewcontainer.cpp @@ -57,7 +57,6 @@ TEST_F(Test_PreviewContainer, coverage_test) container->previewEntered(id); container->m_waitForShowPreviewTimer->start(); - container->updateSnapshots(); container->updateLayoutDirection(Dock::Position::Bottom); ASSERT_EQ(container->m_windowListLayout->direction(), container->m_wmHelper->hasComposite() ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom); container->updateLayoutDirection(Dock::Position::Top);