| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DWINDOWMANAGERHELPER_H |
| 6 |
#define DWINDOWMANAGERHELPER_H |
| 7 |
|
| 8 |
#include <dtkgui_global.h> |
| 9 |
#include <DObject> |
| 10 |
|
| 11 |
#include <QWindow> |
| 12 |
|
| 13 |
DGUI_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
class DForeignWindow; |
| 16 |
class DWindowManagerHelperPrivate; |
| 17 |
class DWindowManagerHelper : public QObject, public DTK_CORE_NAMESPACE::DObject |
| 18 |
{ |
| 19 |
Q_OBJECT |
| 20 |
|
| 21 |
Q_PROPERTY(bool hasBlurWindow READ hasBlurWindow NOTIFY hasBlurWindowChanged) |
| 22 |
Q_PROPERTY(bool hasComposite READ hasComposite NOTIFY hasCompositeChanged) |
| 23 |
Q_PROPERTY(bool hasNoTitlebar READ hasNoTitlebar NOTIFY hasNoTitlebarChanged) |
| 24 |
Q_PROPERTY(bool hasWallpaperEffect READ hasWallpaperEffect NOTIFY hasWallpaperEffectChanged) |
| 25 |
|
| 26 |
public: |
| 27 |
enum MotifFunction { |
| 28 |
FUNC_RESIZE = (1L << 1), |
| 29 |
FUNC_MOVE = (1L << 2), |
| 30 |
FUNC_MINIMIZE = (1L << 3), |
| 31 |
FUNC_MAXIMIZE = (1L << 4), |
| 32 |
FUNC_CLOSE = (1L << 5), |
| 33 |
FUNC_ALL = FUNC_RESIZE | FUNC_MOVE | FUNC_MINIMIZE | FUNC_MAXIMIZE | FUNC_CLOSE |
| 34 |
}; |
| 35 |
Q_ENUM(MotifFunction) |
| 36 |
Q_DECLARE_FLAGS(MotifFunctions, MotifFunction) |
| 37 |
Q_FLAG(MotifFunctions) |
| 38 |
|
| 39 |
enum MotifDecoration { |
| 40 |
DECOR_BORDER = (1L << 1), |
| 41 |
DECOR_RESIZEH = (1L << 2), |
| 42 |
DECOR_TITLE = (1L << 3), |
| 43 |
DECOR_MENU = (1L << 4), |
| 44 |
DECOR_MINIMIZE = (1L << 5), |
| 45 |
DECOR_MAXIMIZE = (1L << 6), |
| 46 |
DECOR_ALL = DECOR_BORDER | DECOR_RESIZEH | DECOR_TITLE | DECOR_MENU | DECOR_MINIMIZE | DECOR_MAXIMIZE |
| 47 |
}; |
| 48 |
Q_ENUM(MotifDecoration) |
| 49 |
Q_DECLARE_FLAGS(MotifDecorations, MotifDecoration) |
| 50 |
Q_FLAG(MotifDecorations) |
| 51 |
|
| 52 |
enum WMName { |
| 53 |
OtherWM, |
| 54 |
DeepinWM, |
| 55 |
KWinWM |
| 56 |
}; |
| 57 |
Q_ENUM(WMName) |
| 58 |
|
| 59 |
enum WmWindowType { |
| 60 |
UnknowWindowType = 0x000000, |
| 61 |
NormalType = 0x000001, |
| 62 |
DesktopType = 0x000002, |
| 63 |
DockType = 0x000004, |
| 64 |
ToolbarType = 0x000008, |
| 65 |
MenuType = 0x000010, |
| 66 |
UtilityType = 0x000020, |
| 67 |
SplashType = 0x000040, |
| 68 |
DialogType = 0x000080, |
| 69 |
DropDownMenuType = 0x000100, |
| 70 |
PopupMenuType = 0x000200, |
| 71 |
TooltipType = 0x000400, |
| 72 |
NotificationType = 0x000800, |
| 73 |
ComboType = 0x001000, |
| 74 |
DndType = 0x002000, |
| 75 |
KdeOverrideType = 0x004000 |
| 76 |
}; |
| 77 |
Q_ENUM(WmWindowType) |
| 78 |
Q_DECLARE_FLAGS(WmWindowTypes, WmWindowType) |
| 79 |
Q_FLAG(WmWindowTypes) |
| 80 |
|
| 81 |
~DWindowManagerHelper(); |
| 82 |
|
| 83 |
static DWindowManagerHelper *instance(); |
| 84 |
|
| 85 |
static void setMotifFunctions(const QWindow *window, MotifFunctions hints); |
| 86 |
static MotifFunctions setMotifFunctions(const QWindow *window, MotifFunctions hints, bool on); |
| 87 |
static MotifFunctions getMotifFunctions(const QWindow *window); |
| 88 |
static void setMotifDecorations(const QWindow *window, MotifDecorations hints); |
| 89 |
static MotifDecorations setMotifDecorations(const QWindow *window, MotifDecorations hints, bool on); |
| 90 |
static MotifDecorations getMotifDecorations(const QWindow *window); |
| 91 |
static void setWmWindowTypes(QWindow *window, WmWindowTypes types); |
| 92 |
static void setWmClassName(const QByteArray &name); |
| 93 |
|
| 94 |
static void popupSystemWindowMenu(const QWindow *window); |
| 95 |
|
| 96 |
bool hasBlurWindow() const; |
| 97 |
bool hasComposite() const; |
| 98 |
bool hasNoTitlebar() const; |
| 99 |
bool hasWallpaperEffect() const; |
| 100 |
QString windowManagerNameString() const; |
| 101 |
WMName windowManagerName() const; |
| 102 |
|
| 103 |
QVector<quint32> allWindowIdList() const; |
| 104 |
QVector<quint32> currentWorkspaceWindowIdList() const; |
| 105 |
QList<DForeignWindow*> currentWorkspaceWindows() const; |
| 106 |
quint32 windowFromPoint(const QPoint &p); |
| 107 |
|
| 108 |
Q_SIGNALS: |
| 109 |
void windowManagerChanged(); |
| 110 |
void hasBlurWindowChanged(); |
| 111 |
void hasCompositeChanged(); |
| 112 |
void hasNoTitlebarChanged(); |
| 113 |
void hasWallpaperEffectChanged(); |
| 114 |
void windowListChanged(); |
| 115 |
void windowMotifWMHintsChanged(quint32 winId); |
| 116 |
|
| 117 |
protected: |
| 118 |
explicit DWindowManagerHelper(QObject *parent = 0); |
| 119 |
|
| 120 |
private: |
| 121 |
D_DECLARE_PRIVATE(DWindowManagerHelper) |
| 122 |
}; |
| 123 |
|
| 124 |
DGUI_END_NAMESPACE |
| 125 |
|
| 126 |
Q_DECLARE_OPERATORS_FOR_FLAGS(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifFunctions) |
| 127 |
Q_DECLARE_OPERATORS_FOR_FLAGS(DTK_GUI_NAMESPACE::DWindowManagerHelper::MotifDecorations) |
| 128 |
Q_DECLARE_OPERATORS_FOR_FLAGS(DTK_GUI_NAMESPACE::DWindowManagerHelper::WmWindowTypes) |
| 129 |
|
| 130 |
#endif // DWINDOWMANAGERHELPER_H |