Debian Codegraph @

kysdk-qtwidgets/src/xatom-helper.h

raw
1 /*
2 * KWin Style UKUI
3 *
4 * Copyright (C) 2020, KylinSoft Co., Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Yue Lan <[email protected]>
20 */
21
22 #ifndef XATOMHELPER_H
23 #define XATOMHELPER_H
24
25 #include <QObject>
26
27 #include <X11/Xlib.h>
28 // #include <NETWM>
29
30 /**
31 * @brief 窗口属性
32 * @since 1.0.0
33 */
34
35 struct UnityCorners
36 {
37 ulong topLeft = 0;
38 ulong topRight = 0;
39 ulong bottomLeft = 0;
40 ulong bottomRight = 0;
41 };
42
43 typedef struct
44 {
45 ulong flags = 0;
46 ulong functions = 0;
47 ulong decorations = 0;
48 long input_mode = 0;
49 ulong status = 0;
50 } MotifWmHints, MwmHints;
51
52 #define MWM_HINTS_FUNCTIONS (1L << 0)
53 #define MWM_HINTS_DECORATIONS (1L << 1)
54 #define MWM_HINTS_INPUT_MODE (1L << 2)
55 #define MWM_HINTS_STATUS (1L << 3)
56
57 #define MWM_FUNC_ALL (1L << 0)
58 #define MWM_FUNC_RESIZE (1L << 1)
59 #define MWM_FUNC_MOVE (1L << 2)
60 #define MWM_FUNC_MINIMIZE (1L << 3)
61 #define MWM_FUNC_MAXIMIZE (1L << 4)
62 #define MWM_FUNC_CLOSE (1L << 5)
63
64 #define MWM_DECOR_ALL (1L << 0)
65 #define MWM_DECOR_BORDER (1L << 1)
66 #define MWM_DECOR_RESIZEH (1L << 2)
67 #define MWM_DECOR_TITLE (1L << 3)
68 #define MWM_DECOR_MENU (1L << 4)
69 #define MWM_DECOR_MINIMIZE (1L << 5)
70 #define MWM_DECOR_MAXIMIZE (1L << 6)
71
72 #define MWM_INPUT_MODELESS 0
73 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
74 #define MWM_INPUT_SYSTEM_MODAL 2
75 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
76 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
77
78 #define MWM_TEAROFF_WINDOW (1L << 0)
79
80 namespace kdk
81 {
82 class Decoration;
83
84 class XAtomHelper : public QObject
85 {
86 // friend class UKUI::Decoration;
87 Q_OBJECT
88 public:
89 static XAtomHelper *getInstance();
90
91 static bool isFrameLessWindow(int winId);
92
93 static bool isWindowDecorateBorderOnly(int winId);
94 static bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint);
95 bool isUKUICsdSupported();
96 bool isUKUIDecorationWindow(int winId);
97
98 UnityCorners getWindowBorderRadius(int winId);
99 void setWindowBorderRadius(int winId, const UnityCorners &data);
100 void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight);
101 void setUKUIDecoraiontHint(int winId, bool set = true);
102
103 void setWindowMotifHint(int winId, const MotifWmHints &hints);
104 MotifWmHints getWindowMotifHint(int winId);
105
106 private:
107 explicit XAtomHelper(QObject *parent = nullptr);
108
109 Atom registerUKUICsdNetWmSupportAtom();
110 void unregisterUKUICsdNetWmSupportAtom();
111
112 Atom m_motifWMHintsAtom = None;
113 Atom m_unityBorderRadiusAtom = None;
114 Atom m_ukuiDecorationAtion = None;
115 };
116 }
117 #endif // XATOMHELPER_H