forked from lxqt/liblxqt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lxqtxfitman.h
283 lines (241 loc) · 9.63 KB
/
lxqtxfitman.h
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
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2010-2011 Razor team
* Authors:
* Christopher "VdoP" Regali
* Alexander Sokoloff <[email protected]>
*
* This program or 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 2.1 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 Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef LXQTXFITMAN_H
#define LXQTXFITMAN_H
#include "lxqtglobals.h"
#include <QList>
#include <QPixmap>
#include <QString>
#include <QMap>
#include <QIcon>
#include <X11/Xlib.h>
//some net_wm state-operations we need here
#define _NET_WM_STATE_TOGGLE 2
#define _NET_WM_STATE_ADD 1
#define _NET_WM_STATE_REMOVE 0
/**
* @file xfitman.h
* @author Christopher "VdoP" Regali
* @brief handles all of our xlib-calls.
*/
namespace LxQt
{
typedef QList<Atom> AtomList;
typedef QList<Window> WindowList;
// A list of atoms indicating user operations that the Window Manager supports
// for this window.
// See http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569373
struct WindowAllowedActions
{
bool Move; // indicates that the window may be moved around the screen.
bool Resize; // indicates that the window may be resized.
bool Minimize; // indicates that the window may be iconified.
bool Shade; // indicates that the window may be shaded.
bool Stick; // indicates that the window may have its sticky state toggled.
bool MaximizeHoriz; // indicates that the window may be maximized horizontally.
bool MaximizeVert; // indicates that the window may be maximized vertically.
bool FullScreen; // indicates that the window may be brought to fullscreen state.
bool ChangeDesktop; // indicates that the window may be moved between desktops.
bool Close; // indicates that the window may be closed.
bool AboveLayer; // indicates that the window may placed in the "above" layer of windows
bool BelowLayer; // indicates that the window may placed in the "below" layer of windows
};
// A list of hints describing the window state.
// http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569140
struct WindowState
{
bool Modal; // indicates that this is a modal dialog box.
bool Sticky; // indicates that the Window Manager SHOULD keep the window's position
// fixed on the screen, even when the virtual desktop scrolls.
bool MaximizedVert; // indicates that the window is vertically maximized.
bool MaximizedHoriz;// indicates that the window is horizontally maximized.
bool Shaded; // indicates that the window is shaded.
bool SkipTaskBar; // indicates that the window should not be included on a taskbar.
bool SkipPager; // indicates that the window should not be included on a Pager.
bool Hidden; // indicates that a window would not be visible on the screen
bool FullScreen; // indicates that the window should fill the entire screen.
bool AboveLayer; // indicates that the window should be on top of most windows.
bool BelowLayer; // indicates that the window should be below most windows.
bool Attention; // indicates that some action in or with the window happened.
};
// A list of hints to the window manager
// http://tronche.com/gui/x/xlib/ICC/client-to-window-manager/wm-hints.html
enum WMHintsFlag
{
WMInputHint = (1L << 0),
WMStateHint = (1L << 1),
WMIconPixmapHint = (1L << 2),
WMIconWindowHint = (1L << 3),
WMIconPositionHint = (1L << 4),
WMIconMaskHint = (1L << 5),
WMWindowGroupHint = (1L << 6),
WMAllHints = (WMInputHint | WMStateHint | WMIconPixmapHint | WMIconWindowHint
| WMIconPositionHint | WMIconMaskHint | WMWindowGroupHint),
WMUrgencyHint = (1L << 8)
};
typedef long WMHintsFlags;
/**
* @brief manages the Xlib apicalls
*/
class LXQT_API XfitMan
{
public:
enum Layer
{
LayerAbove,
LayerNormal,
LayerBelow
};
enum MaximizeDirection
{
MaximizeHoriz,
MaximizeVert,
MaximizeBoth
};
enum WMState
{
WMStateWithdrawn = 0,
WMStateNormal = 1,
WMStateIconic = 3
};
~XfitMan();
XfitMan();
void moveWindow(Window _win, int _x, int _y) const;
// See
void setStrut(Window _wid,
int left, int right,
int top, int bottom,
int leftStartY, int leftEndY,
int rightStartY, int rightEndY,
int topStartX, int topEndX,
int bottomStartX, int bottomEndX
) const;
WindowList getClientList() const;
bool getClientIcon(Window _wid, QPixmap& _pixreturn) const;
bool getClientIcon(Window _wid, QIcon *icon) const;
int getWindowDesktop(Window _wid) const;
void moveWindowToDesktop(Window _wid, int _display) const;
void raiseWindow(Window _wid) const;
void minimizeWindow(Window _wid) const;
void maximizeWindow(Window _wid, MaximizeDirection direction = MaximizeBoth) const;
void deMaximizeWindow(Window _wid) const;
void shadeWindow(Window _wid, bool shade) const;
void resizeWindow(Window _wid, int _width, int _height) const;
void closeWindow(Window _wid) const;
void setWindowLayer(Window _wid, Layer layer) const;
void setActiveDesktop(int _desktop) const;
bool isHidden(Window _wid) const;
WindowAllowedActions getAllowedActions(Window window) const;
WindowState getWindowState(Window window) const;
int getActiveDesktop() const;
Window getActiveAppWindow() const;
Window getActiveWindow() const;
int getNumDesktop() const;
bool getShowingDesktop() const;
void setShowingDesktop(bool show) const;
void setIconGeometry(Window _wid, QRect* rect = 0) const;
/*!
* Returns ICCCM WM_STATE
*/
WMState getWMState(Window _wid) const;
/*!
* Returns the window's hints' flags
*/
WMHintsFlags getWMHintsFlags(Window _wid) const;
/*!
* Returns the names of all virtual desktops. This is a list of UTF-8 encoding strings.
*
* Note: The number of names could be different from getNumDesktop(). If it is less
* than getNumDesktop(), then the desktops with high numbers are unnamed. If it is
* larger than getNumDesktop(), then the excess names outside of the getNumDesktop()
* are considered to be reserved in case the number of desktops is increased.
*/
QStringList getDesktopNames() const;
/*!
* Returns the name of virtual desktop.
*/
QString getDesktopName(int desktopNum, const QString &defaultName=QString()) const;
/*! Returns window title if available
*
*/
QString getWindowTitle(Window _wid) const;
/*! Returns window title if available
*
*/
QString getApplicationName(Window _wid) const;
bool acceptWindow(Window _wid) const;
AtomList getWindowType(Window window) const;
#ifdef DEBUG
static QString debugWindow(Window wnd);
#endif
static Atom atom(const char* atomName);
/*!
* QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
* This workaraund this problem.
*/
const QRect availableGeometry(int screen = -1) const;
/*!
* QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
* This workaraund this problem.
*/
const QRect availableGeometry(const QWidget *widget) const;
/*!
* QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
* This workaraund this problem.
*/
const QRect availableGeometry(const QPoint &point) const;
int clientMessage(Window _wid, Atom _msg,
long unsigned int data0,
long unsigned int data1 = 0,
long unsigned int data2 = 0,
long unsigned int data3 = 0,
long unsigned int data4 = 0) const;
/*!
* Returns true if the Window Manager is running; otherwise returns false.
*/
bool isWindowManagerActive() const;
private:
/** \warning Do not forget to XFree(result) after data are processed!
*/
bool getWindowProperty(Window window,
Atom atom, // property
Atom reqType, // req_type
unsigned long* resultLen,// nitems_return
unsigned char** result // prop_return
) const;
/** \warning Do not forget to XFree(result) after data are processed!
*/
bool getRootWindowProperty(Atom atom, // property
Atom reqType, // req_type
unsigned long* resultLen,// nitems_return
unsigned char** result // prop_return
) const;
Window root; //the actual root window on the used screen
};
LXQT_API const XfitMan& xfitMan();
} //namespace LxQt
#endif // LXQTXFITMAN_H