2017-09-18 14:33:44 +08:00
|
|
|
/*
|
2018-02-07 11:52:47 +08:00
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
2017-09-18 14:33:44 +08:00
|
|
|
*
|
|
|
|
* Author: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-05-22 15:11:07 +08:00
|
|
|
#ifndef APPSNAPSHOT_H
|
|
|
|
#define APPSNAPSHOT_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2017-05-22 17:17:29 +08:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QTimer>
|
2018-09-07 11:16:40 +08:00
|
|
|
#include "../widgets/tipswidget.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>
|
|
|
|
|
2018-02-22 14:19:52 +08:00
|
|
|
#include <com_deepin_dde_daemon_dock_entry.h>
|
|
|
|
|
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
|
|
|
|
|
2018-07-30 11:22:56 +08:00
|
|
|
struct SHMInfo;
|
|
|
|
struct _XImage;
|
|
|
|
typedef _XImage XImage;
|
|
|
|
|
2017-05-22 15:11:07 +08:00
|
|
|
class AppSnapshot : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-05-22 17:17:29 +08:00
|
|
|
explicit AppSnapshot(const WId wid, QWidget *parent = 0);
|
|
|
|
|
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; }
|
|
|
|
inline const QImage snapshot() const { return m_snapshot; }
|
|
|
|
inline const QRectF snapshotGeometry() const { return m_snapshotSrcRect; }
|
|
|
|
inline const QString title() const { return m_windowInfo.title; }
|
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;
|
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 11:39:32 +08:00
|
|
|
void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
void enterEvent(QEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
void leaveEvent(QEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
bool eventFilter(QObject *watched, QEvent *e) Q_DECL_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);
|
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;
|
|
|
|
|
2017-05-22 17:17:29 +08:00
|
|
|
QImage m_snapshot;
|
2018-07-30 11:22:56 +08:00
|
|
|
QRectF m_snapshotSrcRect;
|
|
|
|
|
2018-09-07 11:16:40 +08:00
|
|
|
TipsWidget *m_title;
|
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
|