optimize snapshots fetch

Change-Id: I56d2f74fdf0564dbfa973471dda979d794079a80
This commit is contained in:
石博文 2017-05-24 11:32:14 +08:00
parent a993d0454e
commit 32d87ca112
Notes: Deepin Code Review 2017-05-24 11:34:05 +08:00
Code-Review+2: 石博文 <sbw@sbw.so>
Verified+1: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Wed, 24 May 2017 11:34:00 +0800
Reviewed-on: https://cr.deepin.io/23372
Project: dde/dde-dock
Branch: refs/heads/master
5 changed files with 11 additions and 25 deletions

View File

@ -505,6 +505,7 @@ void AppItem::showPreview()
// }
m_appPreviewTips->setWindowInfos(m_titles);
m_appPreviewTips->updateSnapshots();
m_appPreviewTips->updateLayoutDirection(DockPosition);
showPopupWindow(m_appPreviewTips, true);

View File

@ -61,6 +61,12 @@ void _PreviewContainer::setWindowInfos(const WindowDict &infos)
}
}
void _PreviewContainer::updateSnapshots()
{
for (AppSnapshot *snap : m_snapshots)
snap->fetchSnapshot();
}
void _PreviewContainer::updateLayoutDirection(const Dock::Position dockPos)
{
if (m_wmHelper->hasComposite() && (dockPos == Dock::Top || dockPos == Dock::Bottom))

View File

@ -32,6 +32,7 @@ signals:
public:
void setWindowInfos(const WindowDict &infos);
void updateSnapshots();
public slots:
void updateLayoutDirection(const Dock::Position dockPos);

View File

@ -12,16 +12,9 @@
AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
: QWidget(parent),
m_wid(wid),
m_fetchSnapshotTimer(new QTimer(this))
m_wid(wid)
{
m_fetchSnapshotTimer->setSingleShot(true);
m_fetchSnapshotTimer->setInterval(10);
connect(m_fetchSnapshotTimer, &QTimer::timeout, this, &AppSnapshot::fetchSnapshot, Qt::QueuedConnection);
QTimer::singleShot(1, this, &AppSnapshot::fetchSnapshot);
// QTimer::singleShot(1, this, &AppSnapshot::fetchSnapshot);
}
void AppSnapshot::closeWindow() const
@ -49,9 +42,6 @@ void AppSnapshot::setWindowTitle(const QString &title)
void AppSnapshot::fetchSnapshot()
{
if (!isVisible())
return;
const auto display = QX11Info::display();
XWindowAttributes attrs;
@ -115,13 +105,6 @@ void AppSnapshot::paintEvent(QPaintEvent *e)
painter.drawImage(offset.x(), offset.y(), im);
}
void AppSnapshot::resizeEvent(QResizeEvent *e)
{
QWidget::resizeEvent(e);
m_fetchSnapshotTimer->start();
}
void AppSnapshot::mousePressEvent(QMouseEvent *e)
{
QWidget::mousePressEvent(e);

View File

@ -21,16 +21,13 @@ signals:
void clicked(const WId wid) const;
public slots:
void fetchSnapshot();
void closeWindow() const;
void setWindowTitle(const QString &title);
private slots:
void fetchSnapshot();
private:
void enterEvent(QEvent *e);
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);
void mousePressEvent(QMouseEvent *e);
private:
@ -38,8 +35,6 @@ private:
QString m_title;
QImage m_snapshot;
QTimer *m_fetchSnapshotTimer;
};
#endif // APPSNAPSHOT_H