mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 开始预览时获取所有应用窗口的最小化状态,退出预览时根据应用窗口的最小化状态设置窗口是否被最小化到任务栏
在预览应用时,由于预览会展开应用窗口,将应用由最小化还原为显示状态,而退出预览时又没有重新将应用窗口最小化,修改后在预览时,先获取应用窗口是否已 被最小化到任务栏,然后在退出预览时,根据是否最小化条件,将应用窗口最小化到任务栏 Log: 修复3D模式下任务栏,鼠标划过应用图标上方预览窗口时,应用显示在桌面,鼠标移开时,应用没有退回最小化状态问题 Bug: https://pms.uniontech.com/zentao/bug-view-42002.html Change-Id: I60b5dbdbfc102d6541acc326f713fe2e220ba3fc Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/2854 Reviewed-by: <mailman@uniontech.com> Reviewed-by: lizhongming <lizhongming@uniontech.com> Tested-by: <mailman@uniontech.com>
This commit is contained in:
parent
b342f6f884
commit
76d0acd6d5
@ -57,10 +57,12 @@ using namespace Dock;
|
|||||||
AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_wid(wid)
|
, m_wid(wid)
|
||||||
|
, m_isWidowHidden(false)
|
||||||
, m_title(new TipsWidget)
|
, m_title(new TipsWidget)
|
||||||
, m_waitLeaveTimer(new QTimer(this))
|
, m_waitLeaveTimer(new QTimer(this))
|
||||||
, m_closeBtn2D(new DIconButton(this))
|
, m_closeBtn2D(new DIconButton(this))
|
||||||
, m_wmHelper(DWindowManagerHelper::instance())
|
, m_wmHelper(DWindowManagerHelper::instance())
|
||||||
|
, m_dockDaemonInter(new DockDaemonInter("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this))
|
||||||
{
|
{
|
||||||
m_closeBtn2D->setFixedSize(24, 24);
|
m_closeBtn2D->setFixedSize(24, 24);
|
||||||
m_closeBtn2D->setIconSize(QSize(24, 24));
|
m_closeBtn2D->setIconSize(QSize(24, 24));
|
||||||
@ -85,6 +87,13 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
|||||||
QTimer::singleShot(1, this, &AppSnapshot::compositeChanged);
|
QTimer::singleShot(1, this, &AppSnapshot::compositeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppSnapshot::setWindowState()
|
||||||
|
{
|
||||||
|
if (m_isWidowHidden) {
|
||||||
|
m_dockDaemonInter->MinimizeWindow(m_wid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AppSnapshot::closeWindow() const
|
void AppSnapshot::closeWindow() const
|
||||||
{
|
{
|
||||||
const auto display = QX11Info::display();
|
const auto display = QX11Info::display();
|
||||||
@ -118,6 +127,7 @@ void AppSnapshot::setWindowInfo(const WindowInfo &info)
|
|||||||
QFontMetrics fm(m_title->font());
|
QFontMetrics fm(m_title->font());
|
||||||
QString strTtile = m_title->fontMetrics().elidedText(m_windowInfo.title, Qt::ElideRight, width());
|
QString strTtile = m_title->fontMetrics().elidedText(m_windowInfo.title, Qt::ElideRight, width());
|
||||||
m_title->setText(strTtile);
|
m_title->setText(strTtile);
|
||||||
|
getWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppSnapshot::dragEnterEvent(QDragEnterEvent *e)
|
void AppSnapshot::dragEnterEvent(QDragEnterEvent *e)
|
||||||
@ -348,3 +358,39 @@ QRect AppSnapshot::rectRemovedShadow(const QImage &qimage, unsigned char *prop_t
|
|||||||
return QRect(0, 0, qimage.width(), qimage.height());
|
return QRect(0, 0, qimage.width(), qimage.height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppSnapshot::getWindowState()
|
||||||
|
{
|
||||||
|
Atom actual_type;
|
||||||
|
int actual_format;
|
||||||
|
unsigned long i, num_items, bytes_after;
|
||||||
|
unsigned char *properties = nullptr;
|
||||||
|
|
||||||
|
m_isWidowHidden = false;
|
||||||
|
|
||||||
|
const auto display = QX11Info::display();
|
||||||
|
Atom atom_prop = XInternAtom(display, "_NET_WM_STATE", true);
|
||||||
|
if (!atom_prop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status status = XGetWindowProperty(display, m_wid, atom_prop, 0, LONG_MAX, False, AnyPropertyType, &actual_type, &actual_format, &num_items, &bytes_after, &properties);
|
||||||
|
if (status != Success) {
|
||||||
|
qDebug() << "Fail to get window state";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Atom *atoms = reinterpret_cast<Atom *>(properties);
|
||||||
|
for(i = 0; i < num_items; ++i) {
|
||||||
|
const char *atomName = XGetAtomName(display, atoms[i]);
|
||||||
|
|
||||||
|
if (strcmp(atomName, "_NET_WM_STATE_HIDDEN") == 0) {
|
||||||
|
m_isWidowHidden = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties) {
|
||||||
|
XFree(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <DIconButton>
|
#include <DIconButton>
|
||||||
#include <DWindowManagerHelper>
|
#include <DWindowManagerHelper>
|
||||||
|
|
||||||
|
#include <com_deepin_dde_daemon_dock.h>
|
||||||
#include <com_deepin_dde_daemon_dock_entry.h>
|
#include <com_deepin_dde_daemon_dock_entry.h>
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
@ -41,6 +42,8 @@ struct SHMInfo;
|
|||||||
struct _XImage;
|
struct _XImage;
|
||||||
typedef _XImage XImage;
|
typedef _XImage XImage;
|
||||||
|
|
||||||
|
using DockDaemonInter = com::deepin::dde::daemon::Dock;
|
||||||
|
|
||||||
namespace Dock {
|
namespace Dock {
|
||||||
class TipsWidget;
|
class TipsWidget;
|
||||||
}
|
}
|
||||||
@ -59,6 +62,7 @@ public:
|
|||||||
inline const QImage snapshot() const { return m_snapshot; }
|
inline const QImage snapshot() const { return m_snapshot; }
|
||||||
inline const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
inline const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
||||||
inline const QString title() const { return m_windowInfo.title; }
|
inline const QString title() const { return m_windowInfo.title; }
|
||||||
|
void setWindowState();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void entered(const WId wid) const;
|
void entered(const WId wid) const;
|
||||||
@ -82,13 +86,14 @@ private:
|
|||||||
SHMInfo *getImageDSHM();
|
SHMInfo *getImageDSHM();
|
||||||
XImage *getImageXlib();
|
XImage *getImageXlib();
|
||||||
QRect rectRemovedShadow(const QImage &qimage, unsigned char *prop_to_return_gtk);
|
QRect rectRemovedShadow(const QImage &qimage, unsigned char *prop_to_return_gtk);
|
||||||
|
void getWindowState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const WId m_wid;
|
const WId m_wid;
|
||||||
WindowInfo m_windowInfo;
|
WindowInfo m_windowInfo;
|
||||||
|
|
||||||
bool m_closeAble;
|
bool m_closeAble;
|
||||||
|
bool m_isWidowHidden;
|
||||||
QImage m_snapshot;
|
QImage m_snapshot;
|
||||||
QRectF m_snapshotSrcRect;
|
QRectF m_snapshotSrcRect;
|
||||||
|
|
||||||
@ -96,6 +101,7 @@ private:
|
|||||||
QTimer *m_waitLeaveTimer;
|
QTimer *m_waitLeaveTimer;
|
||||||
DIconButton *m_closeBtn2D;
|
DIconButton *m_closeBtn2D;
|
||||||
DWindowManagerHelper *m_wmHelper;
|
DWindowManagerHelper *m_wmHelper;
|
||||||
|
DockDaemonInter *m_dockDaemonInter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPSNAPSHOT_H
|
#endif // APPSNAPSHOT_H
|
||||||
|
@ -186,6 +186,7 @@ void FloatingPreview::hideEvent(QHideEvent *event)
|
|||||||
{
|
{
|
||||||
if (m_tracked) {
|
if (m_tracked) {
|
||||||
m_tracked->setContentsMargins(0, 0, 0, 0);
|
m_tracked->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_tracked->setWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget::hideEvent(event);
|
QWidget::hideEvent(event);
|
||||||
|
@ -241,6 +241,7 @@ void PreviewContainer::previewEntered(const WId wid)
|
|||||||
AppSnapshot *preSnap = m_floatingPreview->trackedWindow();
|
AppSnapshot *preSnap = m_floatingPreview->trackedWindow();
|
||||||
if (preSnap && preSnap != snap) {
|
if (preSnap && preSnap != snap) {
|
||||||
preSnap->setContentsMargins(0, 0, 0, 0);
|
preSnap->setContentsMargins(0, 0, 0, 0);
|
||||||
|
preSnap->setWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentWId = wid;
|
m_currentWId = wid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user