2023-02-16 13:51:55 +08:00
|
|
|
// Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
2022-09-06 11:36:55 +08:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2017-09-18 14:33:44 +08:00
|
|
|
|
2017-05-22 15:11:07 +08:00
|
|
|
#ifndef APPSNAPSHOT_H
|
|
|
|
#define APPSNAPSHOT_H
|
|
|
|
|
2022-06-21 17:43:19 +08:00
|
|
|
#include "dbusutil.h"
|
2023-06-13 15:05:44 +08:00
|
|
|
#include "taskmanager/windowinfomap.h"
|
2017-05-24 14:12:50 +08:00
|
|
|
|
2020-06-13 11:39:32 +08:00
|
|
|
#include <DIconButton>
|
2017-05-24 14:12:50 +08:00
|
|
|
#include <DWindowManagerHelper>
|
2021-09-14 17:08:36 +08:00
|
|
|
#include <DPushButton>
|
2017-05-24 14:12:50 +08:00
|
|
|
|
2022-06-21 17:43:19 +08:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QTimer>
|
2018-02-22 14:19:52 +08:00
|
|
|
|
2017-05-24 14:12:50 +08:00
|
|
|
DWIDGET_USE_NAMESPACE
|
2019-08-28 21:31:03 +08:00
|
|
|
DGUI_USE_NAMESPACE
|
2017-05-22 15:11:07 +08:00
|
|
|
|
2017-12-28 15:41:47 +08:00
|
|
|
#define SNAP_WIDTH 200
|
|
|
|
#define SNAP_HEIGHT 130
|
|
|
|
|
2021-02-07 17:38:19 +08:00
|
|
|
#define SNAP_CLOSE_BTN_WIDTH (24)
|
|
|
|
#define SNAP_CLOSE_BTN_MARGIN (5)
|
2021-09-14 17:08:36 +08:00
|
|
|
// 标题到左右两边的距离
|
|
|
|
#define TITLE_MARGIN (20)
|
|
|
|
|
|
|
|
// 标题的文本到标题背景两边的距离
|
|
|
|
#define BTN_TITLE_MARGIN (6)
|
|
|
|
|
|
|
|
// 高亮框边距
|
|
|
|
#define BORDER_MARGIN (8)
|
2021-02-07 17:38:19 +08:00
|
|
|
|
2018-07-30 11:22:56 +08:00
|
|
|
struct SHMInfo;
|
|
|
|
struct _XImage;
|
|
|
|
typedef _XImage XImage;
|
|
|
|
|
2020-06-29 15:35:51 +08:00
|
|
|
namespace Dock {
|
|
|
|
class TipsWidget;
|
|
|
|
}
|
|
|
|
|
2017-05-22 15:11:07 +08:00
|
|
|
class AppSnapshot : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-06-21 17:43:19 +08:00
|
|
|
explicit AppSnapshot(const WId wid, QWidget *parent = Q_NULLPTR);
|
2017-05-22 17:17:29 +08:00
|
|
|
|
2018-08-13 14:17:45 +08:00
|
|
|
inline WId wid() const { return m_wid; }
|
|
|
|
inline bool attentioned() const { return m_windowInfo.attention; }
|
|
|
|
inline bool closeAble() const { return m_closeAble; }
|
|
|
|
inline void setCloseAble(const bool value) { m_closeAble = value; }
|
2022-10-11 08:29:02 +00:00
|
|
|
inline const QPixmap snapshot() const { return m_pixmap; }
|
2018-08-13 14:17:45 +08:00
|
|
|
inline const QString title() const { return m_windowInfo.title; }
|
2020-08-28 10:39:24 +08:00
|
|
|
void setWindowState();
|
2021-09-14 17:08:36 +08:00
|
|
|
void setTitleVisible(bool bVisible);
|
|
|
|
QString appTitle() { return m_3DtitleBtn ? m_3DtitleBtn->text() : QString(); }
|
2021-11-05 21:53:23 +08:00
|
|
|
bool isKWinAvailable();
|
2017-05-23 15:32:03 +08:00
|
|
|
|
2017-05-22 17:54:59 +08:00
|
|
|
signals:
|
|
|
|
void entered(const WId wid) const;
|
|
|
|
void clicked(const WId wid) const;
|
2017-06-09 16:18:15 +08:00
|
|
|
void requestCheckWindow() const;
|
2020-10-24 11:03:03 +08:00
|
|
|
void requestCloseAppSnapshot() const;
|
2017-05-22 17:54:59 +08:00
|
|
|
|
2017-05-23 15:32:03 +08:00
|
|
|
public slots:
|
2017-05-24 11:32:14 +08:00
|
|
|
void fetchSnapshot();
|
2017-05-23 15:32:03 +08:00
|
|
|
void closeWindow() const;
|
2017-05-24 14:12:50 +08:00
|
|
|
void compositeChanged() const;
|
2018-02-22 14:19:52 +08:00
|
|
|
void setWindowInfo(const WindowInfo &info);
|
2017-05-23 15:32:03 +08:00
|
|
|
|
2017-05-22 17:17:29 +08:00
|
|
|
private:
|
2020-06-13 19:19:30 +08:00
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void enterEvent(QEvent *e) override;
|
|
|
|
void leaveEvent(QEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
bool eventFilter(QObject *watched, QEvent *e) override;
|
2022-01-25 10:22:59 +08:00
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
2018-07-30 11:22:56 +08:00
|
|
|
SHMInfo *getImageDSHM();
|
2020-06-13 11:39:32 +08:00
|
|
|
XImage *getImageXlib();
|
2018-07-30 11:22:56 +08:00
|
|
|
QRect rectRemovedShadow(const QImage &qimage, unsigned char *prop_to_return_gtk);
|
2020-08-28 10:39:24 +08:00
|
|
|
void getWindowState();
|
2021-09-14 17:08:36 +08:00
|
|
|
void updateTitle();
|
2017-05-22 17:17:29 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
const WId m_wid;
|
2018-02-22 14:19:52 +08:00
|
|
|
WindowInfo m_windowInfo;
|
2018-08-13 14:17:45 +08:00
|
|
|
|
|
|
|
bool m_closeAble;
|
2020-08-28 10:39:24 +08:00
|
|
|
bool m_isWidowHidden;
|
2022-10-11 08:29:02 +00:00
|
|
|
QPixmap m_pixmap;
|
2018-07-30 11:22:56 +08:00
|
|
|
|
2020-06-29 15:35:51 +08:00
|
|
|
Dock::TipsWidget *m_title;
|
2021-09-14 17:08:36 +08:00
|
|
|
DPushButton *m_3DtitleBtn;
|
|
|
|
|
2018-11-07 15:26:56 +08:00
|
|
|
QTimer *m_waitLeaveTimer;
|
2020-06-13 11:39:32 +08:00
|
|
|
DIconButton *m_closeBtn2D;
|
2017-05-24 14:12:50 +08:00
|
|
|
DWindowManagerHelper *m_wmHelper;
|
2017-05-22 15:11:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // APPSNAPSHOT_H
|