File: windowmanager.h

package info (click to toggle)
ukui-panel 4.0.0.6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,148 kB
  • sloc: cpp: 28,423; xml: 476; sh: 51; makefile: 18
file content (345 lines) | stat: -rw-r--r-- 7,826 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
/*
 * libkysdk-waylandhelper's Library
 *
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library.  If not, see <https://www.gnu.org/licenses/>.
 *
 * Authors: Zhen Sun <sunzhen1@kylinos.cn>
 *
 */

#ifndef WINDOWMANAGER_H
#define WINDOWMANAGER_H

#include <QObject>
#include <QString>
#include <QIcon>
#include "windowinfo.h"
#include "wmregister.h"

namespace kdk
{
using WindowId = QVariant;
class WindowManager : public QObject
{
    Q_OBJECT

public:

    /**
     * @brief self
     * @return
     */
    static WindowManager* self();

    /**
      * @brief 获取窗口信息
      * @param windowId
      * @return
      */
    static WindowInfo getwindowInfo(const WindowId& windowId);

    /**
     * @brief 获取当前活动窗口
     * @return
     */
    static WindowId currentActiveWindow();

    /**
     * @brief 置顶窗口
     * @param windowId
     */
    static void keepWindowAbove(const WindowId& windowId);

    /**
     * @brief 获取窗口标题
     * @param windowId
     * @return
     */
     static QString getWindowTitle(const WindowId& windowId);

    /**
     * @brief 获取窗口图标
     * @param windowId
     * @return
     */
     static QIcon getWindowIcon(const WindowId& windowId);


     /**
      * @brief 获取窗口所在组的组名
      * @param windowId
      * @return
      */
     static QString getWindowGroup(const WindowId& windowId);


    /**
     * @brief 关闭窗口
     * @param windowId
     */
     static void closeWindow(const WindowId& windowId);

    /**
     * @brief 激活窗口
     * @param windowId
     */
     static void activateWindow(const WindowId& windowId);

    /**
     * @brief 最大化窗口
     * @param windowId
     */
     static void maximizeWindow(const WindowId& windowId);

    /**
     * @brief 最小化窗口
     * @param windowId
     */
     static void minimizeWindow(const WindowId& windowId);

     /**
      * @brief 获取窗口进程pid
      * @return
      */
     static quint32 getPid(const WindowId& windowId);

    /**
     * @brief 显示当前桌面
     */
     static void showDesktop();

    /**
     * @brief 取消显示当前桌面
     */
     static void hideDesktop();

     /**
     * @brief 获取当前桌面的名称
     * @return
     */
    static QString currentDesktop();

    /**
     * @brief 获取当前窗口列表
     * @return
     */
    static QList<WindowId> windows();

    /**
     * @brief 获取窗口类型,仅适用于X环境下,wayland下统一返回normal
     * @param windowId
     * @return
     */
    static NET::WindowType getWindowType(const WindowId& windowId);

    /**
     * @brief 设置窗口位置
     * @param window
     * @param rect
     */
    static void	setGeometry(QWindow *window,const QRect &rect);

    /**
     * @brief 设置是否跳过任务栏,since 2.0
     * @param window
     * @param skip
     */
    static void setSkipTaskBar(QWindow *window,bool skip);

    /**
     * @brief 设置是否跳过窗口选择,,since 2.0
     * @param window
     * @param skip
     */
    static  void setSkipSwitcher(QWindow *window,bool skip);

    /**
     * @brief 判断窗体是否跳过任务栏,since 2.0
     * @param windowId
     * @return
     */
    static bool skipTaskBar(const WindowId& windowId);

    /**
     * @brief 判断窗体是否跳过窗口选择,since 2.0
     * @param windowId
     * @return
     */
    static bool skipSwitcher(const WindowId& windowId);

    /**
     * @brief 判断桌面是否处于显示状态,,since 2.0
     * @return
     */
    static bool isShowingDesktop();

    /**
     * @brief 设置窗口在所有桌面中显示,since 2.0
     * @param wid
     */
    static void setOnAllDesktops(const WindowId &windowId);

    /**
     * @brief 判断窗口在所有桌面中显示,since 2.0
     * @param windowId
     * @return
     */
    static bool isOnAllDesktops(const WindowId &windowId);

    /**
     * @brief 判断窗口是否在当前桌面
     * @param 窗口id
     * @return
     */
    static bool isOnCurrentDesktop(const WindowId& id);

    /**
     * @brief 判断窗口是否在指定桌面
     * @param 窗口id
     * @param 桌面id
     * @return
     */
    static bool isOnDesktop(const WindowId &id, int desktop);


    /**
     * @brief 设置panel属性窗体是否获取焦点,仅wayland环境下生效,since 2.3
     * @param window
     * @param flag
     */
    static void setPanelTakefocus(QWindow *window, bool flag);
    
    /**
     * @brief 发送demandAttention状态,since 2.3
     * @param wid
     */
    static void demandAttention(const WindowId &wid, bool set = true);

Q_SIGNALS:
     /**
      * @brief 窗口添加信号
      * @param windowId
      */
     void windowAdded(const WindowId& windowId);

     /**
      * @brief 窗口删除信号
      * @param windowId
      */
     void windowRemoved(const WindowId& windowId);

     /**
      * @brief 活动窗口改变信号
      * @param wid
      */
     void activeWindowChanged(const WindowId& wid);

     /**
      * @brief 窗口改变信号
      * @param wid
      */
     void windowChanged(const WindowId& wid);

     /**
      * @brief 当前桌面改变信号
      * @param wid
      */
     void currentDesktopChanged();

     /**
      * @brief 桌面显示状态变化信号
      */
     void isShowingDesktopChanged();

     /**
      * @brief 窗口标题改变信号,since 2.3
      * @param wid
      */
     void titleChanged(const WindowId& wid);
     
     /**
      * @brief 窗口图标改变信号,since 2.3
      * @param wid
      */
     void iconChanged(const WindowId& wid);

     /**
      * @brief 窗口活动状态改变信号,since 2.3
      * @param wid
      */
     void activeChanged(const WindowId& wid);

     /**
      * @brief 窗口全屏状态改变信号,since 2.3
      * @param wid
      */
     void fullscreenChanged(const WindowId& wid);

     /**
      * @brief 窗口置顶状态改变信号,since 2.3
      * @param wid
      */
     void keepAboveChanged(const WindowId& wid);

     /**
      * @brief 窗口最小化状态改变信号,since 2.3
      * @param wid
      */
     void minimizedChanged(const WindowId& wid);

     /**
      * @brief 窗口最大化状态改变信号,since 2.3
      * @param wid
      */
     void maximizedChanged(const WindowId& wid);

     /**
      * @brief onAllDesktopsChanged,since 2.3
      * @param wid
      */
     void onAllDesktopsChanged(const WindowId& wid);

     /**
      * @brief demandsAttention状态改变信号,since 2.3
      * @param wid
      */
     void demandsAttentionChanged(const WindowId& wid);

     /**
      * @brief 跳过任务栏状态改变信号,since 2.3
      * @param wid
      */
     void skipTaskbarChanged(const WindowId& wid);

     /**
      * @brief 跳过窗口选择器状态改变信号,since 2.3
      * @param wid
      */
     void skipSwitcherChanged(const WindowId& wid);

     /**
      * @brief 窗口位置改变信号,since 2.3
      * @param wid
      */
     void geometryChanged(const WindowId& wid);

private:
     WindowManager(QObject *parent = nullptr);
};
}


#endif // WINDOWMANAGER_H