mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
refactor: get window preview
The function provided by kwin should be used first, and xcb is second. Issue: Closed https://github.com/linuxdeepin/developer-center/issues/3137 Log: 重构获取窗口预览的方式
This commit is contained in:
parent
6c82bec3e3
commit
585b13bd7b
@ -210,6 +210,7 @@ void AppSnapshot::fetchSnapshot()
|
||||
uchar *image_data = nullptr;
|
||||
XImage *ximage = nullptr;
|
||||
|
||||
do {
|
||||
// 优先使用窗管进行窗口截图
|
||||
if (isKWinAvailable()) {
|
||||
QDBusInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QStringLiteral("org.kde.kwin.Screenshot"));
|
||||
@ -225,6 +226,7 @@ void AppSnapshot::fetchSnapshot()
|
||||
const QString tmpFile = reply.value();
|
||||
if (QFile::exists(tmpFile)) {
|
||||
m_snapshot.load(tmpFile);
|
||||
m_snapshotSrcRect = m_snapshot.rect();
|
||||
qDebug() << "reply: " << tmpFile;
|
||||
QFile::remove(tmpFile);
|
||||
} else {
|
||||
@ -233,9 +235,8 @@ void AppSnapshot::fetchSnapshot()
|
||||
} else {
|
||||
qDebug() << "get current workspace bckground error: "<< reply.error().message();
|
||||
}
|
||||
m_snapshotSrcRect = m_snapshot.rect();
|
||||
} else {
|
||||
do {
|
||||
}
|
||||
|
||||
// get window image from shm(only for deepin app)
|
||||
info = getImageDSHM();
|
||||
if (info) {
|
||||
@ -269,8 +270,7 @@ void AppSnapshot::fetchSnapshot()
|
||||
// remove shadow frame
|
||||
m_snapshotSrcRect = rectRemovedShadow(qimage, nullptr);
|
||||
m_snapshot = qimage;
|
||||
} while (false);
|
||||
}
|
||||
} while(false);
|
||||
|
||||
QSizeF size(rect().marginsRemoved(QMargins(8, 8, 8, 8)).size());
|
||||
const auto ratio = devicePixelRatioF();
|
||||
|
Loading…
x
Reference in New Issue
Block a user