2020-08-05 19:46:15 +08:00
|
|
|
|
/*
|
2021-06-18 17:36:06 +08:00
|
|
|
|
* Copyright (C) 2018 ~ 2020 Deepin Technology Co., Ltd.
|
2020-08-05 19:46:15 +08:00
|
|
|
|
*
|
|
|
|
|
* Author: fanpengcheng <fanpengcheng_cm@deepin.com>
|
|
|
|
|
*
|
|
|
|
|
* Maintainer: fanpengcheng <fanpengcheng_cm@deepin.com>
|
|
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef MULTISCREENWORKER_H
|
|
|
|
|
#define MULTISCREENWORKER_H
|
2020-12-16 17:38:41 +08:00
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
#include "constants.h"
|
|
|
|
|
#include "utils.h"
|
2020-12-16 17:38:41 +08:00
|
|
|
|
#include "dockitem.h"
|
|
|
|
|
#include "xcb_misc.h"
|
2022-06-22 11:18:29 +08:00
|
|
|
|
#include "dbusutil.h"
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
|
#include "org_deepin_dde_xeventmonitor1.h"
|
|
|
|
|
#include "org_deepin_dde_launcher1.h"
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
#include <DWindowManagerHelper>
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-05-31 17:37:21 +08:00
|
|
|
|
#include <QFlag>
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
#define WINDOWMARGIN ((m_displayMode == Dock::Efficient) ? 0 : 10)
|
|
|
|
|
#define ANIMATIONTIME 300
|
2020-09-08 19:34:53 +08:00
|
|
|
|
#define FREE_POINT(p) if (p) {\
|
2020-09-15 19:54:47 +08:00
|
|
|
|
delete p;\
|
|
|
|
|
p = nullptr;\
|
|
|
|
|
}\
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
DGUI_USE_NAMESPACE
|
|
|
|
|
/**
|
|
|
|
|
* 多屏功能这部分看着很复杂,其实只需要把握住一个核心:及时更新数据!
|
|
|
|
|
* 之前测试出的诸多问题都是在切换任务栏位置,切换屏幕,主屏更改,分辨率更改等情况发生后
|
|
|
|
|
* 任务栏的鼠标唤醒区域或任务栏的大小没更新或者更新时的大小还是按照原来的屏幕信息计算而来的,
|
|
|
|
|
*/
|
2022-06-22 11:18:29 +08:00
|
|
|
|
|
2022-08-25 19:31:31 +00:00
|
|
|
|
#define DRAG_AREA_SIZE (5)
|
|
|
|
|
#define DOCKSPACE (WINDOWMARGIN * 2)
|
|
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
|
using XEventMonitor = ::org::deepin::dde::XEventMonitor1;
|
2022-09-16 20:12:52 +00:00
|
|
|
|
using DBusLuncher = ::org::deepin::dde::Launcher1;
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
using namespace Dock;
|
|
|
|
|
class QVariantAnimation;
|
|
|
|
|
class QWidget;
|
|
|
|
|
class QTimer;
|
|
|
|
|
class MainWindow;
|
2020-09-15 19:54:47 +08:00
|
|
|
|
class QGSettings;
|
2022-08-25 19:31:31 +00:00
|
|
|
|
class TrayMainWindow;
|
|
|
|
|
class MenuWorker;
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
class MultiScreenWorker : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2022-08-25 19:31:31 +00:00
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
public:
|
|
|
|
|
enum Flag {
|
|
|
|
|
Motion = 1 << 0,
|
|
|
|
|
Button = 1 << 1,
|
|
|
|
|
Key = 1 << 2
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-14 17:44:50 +08:00
|
|
|
|
enum RunState {
|
|
|
|
|
ShowAnimationStart = 0x1, // 单次显示动画正在运行状态
|
|
|
|
|
HideAnimationStart = 0x2, // 单次隐藏动画正在运行状态
|
|
|
|
|
ChangePositionAnimationStart = 0x4, // 任务栏切换位置动画运行状态
|
|
|
|
|
AutoHide = 0x8, // 和MenuWorker保持一致,未设置此state时表示菜单已经打开
|
|
|
|
|
MousePress = 0x10, // 当前鼠标是否被按下
|
|
|
|
|
TouchPress = 0x20, // 当前触摸屏下是否按下
|
2021-04-16 11:19:56 +08:00
|
|
|
|
LauncherDisplay = 0x40, // 启动器是否显示
|
2022-08-25 19:31:31 +00:00
|
|
|
|
DockIsDraging = 0x80, // 任务栏正在拖拽
|
2021-04-14 17:44:50 +08:00
|
|
|
|
|
|
|
|
|
// 如果要添加新的状态,可以在上面添加
|
|
|
|
|
RunState_Mask = 0xffffffff,
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-31 17:37:21 +08:00
|
|
|
|
typedef QFlags<RunState> RunStates;
|
2021-04-14 17:44:50 +08:00
|
|
|
|
|
2022-08-25 19:31:31 +00:00
|
|
|
|
explicit MultiScreenWorker(QObject *parent = Q_NULLPTR);
|
|
|
|
|
~MultiScreenWorker() override;
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
2022-06-22 11:18:29 +08:00
|
|
|
|
DockInter *dockInter() { return m_dockInter; }
|
2022-08-25 19:31:31 +00:00
|
|
|
|
void updateDaemonDockSize(const int &dockSize);
|
2021-03-20 12:10:45 +08:00
|
|
|
|
|
2021-04-14 17:44:50 +08:00
|
|
|
|
inline bool testState(RunState state) { return (m_state & state); }
|
|
|
|
|
void setStates(RunStates state, bool on = true);
|
|
|
|
|
|
2021-03-20 12:10:45 +08:00
|
|
|
|
inline const Position &position() { return m_position; }
|
|
|
|
|
inline const DisplayMode &displayMode() { return m_displayMode; }
|
|
|
|
|
inline const HideMode &hideMode() { return m_hideMode; }
|
|
|
|
|
inline const HideState &hideState() { return m_hideState; }
|
|
|
|
|
inline quint8 opacity() { return m_opacity * 255; }
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void opacityChanged(const quint8 value) const;
|
2022-08-25 19:31:31 +00:00
|
|
|
|
void displayModeChanged(const Dock::DisplayMode &);
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
// 更新监视区域
|
2020-09-08 13:06:32 +08:00
|
|
|
|
void requestUpdateRegionMonitor(); // 更新监听区域
|
2020-08-08 00:55:02 +08:00
|
|
|
|
void requestUpdateFrontendGeometry(); //!!! 给后端的区域不能为是或宽度为0的区域,否则会带来HideState死循环切换的bug
|
2020-08-05 19:46:15 +08:00
|
|
|
|
void requestNotifyWindowManager();
|
|
|
|
|
void requestUpdatePosition(const Position &fromPos, const Position &toPos);
|
2020-08-08 00:55:02 +08:00
|
|
|
|
void requestUpdateMonitorInfo(); // 屏幕信息发生变化,需要更新任务栏大小,拖拽区域,所在屏幕,监控区域,通知窗管,通知后端,
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
2022-08-25 19:31:31 +00:00
|
|
|
|
// 用来通知WindowManager的信号
|
|
|
|
|
void requestUpdateDockGeometry(const Dock::HideMode &hideMode);
|
|
|
|
|
void positionChanged(const Dock::Position &position);
|
2020-09-29 17:22:23 +08:00
|
|
|
|
|
2022-08-25 19:31:31 +00:00
|
|
|
|
void requestPlayAnimation(const QString &screenName, const Position &position, const Dock::AniAction &animation, bool containMouse = false, bool updatePos = false);
|
|
|
|
|
void requestChangeDockPosition(const QString &fromScreen, const QString &toScreen, const Position &fromPos, const Position &toPos);
|
2020-10-29 18:08:30 +08:00
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
public slots:
|
2022-08-25 19:31:31 +00:00
|
|
|
|
void onAutoHideChanged(const bool autoHide);
|
2021-04-12 16:53:03 +08:00
|
|
|
|
void onRequestUpdateRegionMonitor();
|
2022-06-22 11:18:29 +08:00
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
private slots:
|
|
|
|
|
// Region Monitor
|
|
|
|
|
void onRegionMonitorChanged(int x, int y, const QString &key);
|
2020-08-07 23:03:41 +08:00
|
|
|
|
void onExtralRegionMonitorChanged(int x, int y, const QString &key);
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
2021-08-25 21:03:30 +08:00
|
|
|
|
void updateDisplay();
|
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
void onWindowSizeChanged(uint value);
|
2022-08-25 19:31:31 +00:00
|
|
|
|
void onPrimaryScreenChanged();
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
// 任务栏属性变化
|
2022-06-22 11:18:29 +08:00
|
|
|
|
void onPositionChanged(int position);
|
|
|
|
|
void onDisplayModeChanged(int displayMode);
|
|
|
|
|
void onHideModeChanged(int hideMode);
|
|
|
|
|
void onHideStateChanged(int state);
|
2020-08-05 19:46:15 +08:00
|
|
|
|
void onOpacityChanged(const double value);
|
|
|
|
|
|
|
|
|
|
void onRequestUpdatePosition(const Position &fromPos, const Position &toPos);
|
|
|
|
|
void onRequestUpdateMonitorInfo();
|
2021-04-16 11:19:56 +08:00
|
|
|
|
void onRequestDelayShowDock();
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
2021-08-25 21:03:30 +08:00
|
|
|
|
// 触摸手势操作
|
2020-08-18 10:41:14 +08:00
|
|
|
|
void onTouchPress(int type, int x, int y, const QString &key);
|
|
|
|
|
void onTouchRelease(int type, int x, int y, const QString &key);
|
|
|
|
|
|
2021-08-25 21:03:30 +08:00
|
|
|
|
void onDelayAutoHideChanged();
|
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
private:
|
|
|
|
|
// 初始化数据信息
|
|
|
|
|
void initMembers();
|
2022-05-12 16:24:54 +08:00
|
|
|
|
void initDockMode();
|
2020-08-05 19:46:15 +08:00
|
|
|
|
void initConnection();
|
|
|
|
|
void initUI();
|
2022-08-25 19:31:31 +00:00
|
|
|
|
|
2020-09-08 19:34:53 +08:00
|
|
|
|
void initDisplayData();
|
|
|
|
|
void reInitDisplayData();
|
2020-09-29 17:22:23 +08:00
|
|
|
|
|
2020-08-18 10:41:14 +08:00
|
|
|
|
void tryToShowDock(int eventX, int eventY);
|
2021-10-18 11:45:51 +08:00
|
|
|
|
void changeDockPosition(QString fromScreen, QString toScreen, const Position &fromPos, const Position &toPos);
|
2021-03-20 12:10:45 +08:00
|
|
|
|
|
2020-09-08 19:34:53 +08:00
|
|
|
|
void resetDockScreen();
|
2021-03-20 12:10:45 +08:00
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
void checkDaemonDockService();
|
2020-09-08 19:34:53 +08:00
|
|
|
|
void checkXEventMonitorService();
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
2022-08-25 19:31:31 +00:00
|
|
|
|
QString getValidScreen(const Position &pos);
|
2021-04-16 11:19:56 +08:00
|
|
|
|
|
2021-12-31 15:52:15 +08:00
|
|
|
|
bool isCursorOut(int x, int y);
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
bool onScreenEdge(const QString &screenName, const QPoint &point);
|
|
|
|
|
const QPoint rawXPosition(const QPoint &scaledPos);
|
2021-08-25 21:03:30 +08:00
|
|
|
|
static bool isCopyMode();
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// monitor screen
|
|
|
|
|
XEventMonitor *m_eventInter;
|
2020-08-07 23:03:41 +08:00
|
|
|
|
XEventMonitor *m_extralEventInter;
|
2020-08-18 10:41:14 +08:00
|
|
|
|
XEventMonitor *m_touchEventInter;
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
// DBus interface
|
2022-06-22 11:18:29 +08:00
|
|
|
|
DockInter *m_dockInter;
|
2020-09-08 13:06:32 +08:00
|
|
|
|
DBusLuncher *m_launcherInter;
|
2020-08-05 19:46:15 +08:00
|
|
|
|
|
|
|
|
|
// update monitor info
|
|
|
|
|
QTimer *m_monitorUpdateTimer;
|
2021-03-20 12:10:45 +08:00
|
|
|
|
QTimer *m_delayWakeTimer; // sp3需求,切换屏幕显示延时,默认2秒唤起任务栏
|
2020-09-15 19:54:47 +08:00
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
// 任务栏属性
|
|
|
|
|
double m_opacity;
|
|
|
|
|
Position m_position;
|
|
|
|
|
HideMode m_hideMode;
|
|
|
|
|
HideState m_hideState;
|
|
|
|
|
DisplayMode m_displayMode;
|
2020-09-08 13:06:32 +08:00
|
|
|
|
|
2020-08-05 19:46:15 +08:00
|
|
|
|
/***************不和其他流程产生交互,尽量不要动这里的变量***************/
|
|
|
|
|
QString m_registerKey;
|
2020-08-07 23:03:41 +08:00
|
|
|
|
QString m_extralRegisterKey;
|
2020-08-18 10:41:14 +08:00
|
|
|
|
QString m_touchRegisterKey; // 触控屏唤起任务栏监控区域key
|
2020-09-08 13:06:32 +08:00
|
|
|
|
QPoint m_touchPos; // 触屏按下坐标
|
2020-08-05 19:46:15 +08:00
|
|
|
|
QList<MonitRect> m_monitorRectList; // 监听唤起任务栏区域
|
2020-08-07 23:03:41 +08:00
|
|
|
|
QList<MonitRect> m_extralRectList; // 任务栏外部区域,随m_monitorRectList一起更新
|
2020-08-18 10:41:14 +08:00
|
|
|
|
QList<MonitRect> m_touchRectList; // 监听触屏唤起任务栏区域
|
2020-08-12 13:57:33 +08:00
|
|
|
|
QString m_delayScreen; // 任务栏将要切换到的屏幕名
|
2021-04-14 17:44:50 +08:00
|
|
|
|
RunStates m_state;
|
2020-08-05 19:46:15 +08:00
|
|
|
|
/*****************************************************************/
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // MULTISCREENWORKER_H
|