RazorAutostartEntry => LxQt::AutostartEntry
[lxde/liblxqt.git] / xfitman.h
1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2 * (c)LGPL2+
3 *
4 * Razor - a lightweight, Qt based, desktop toolset
5 * http://razor-qt.org
6 *
7 * Copyright: 2010-2011 Razor team
8 * Authors:
9 * Christopher "VdoP" Regali
10 * Alexander Sokoloff <sokoloff.a@gmail.com>
11 *
12 * This program or library is free software; you can redistribute it
13 * and/or modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21
22 * You should have received a copy of the GNU Lesser General
23 * Public License along with this library; if not, write to the
24 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301 USA
26 *
27 * END_COMMON_COPYRIGHT_HEADER */
28
29 #ifndef XFITMAN_H
30 #define XFITMAN_H
31
32 #include <QtCore/QList>
33 #include <QtGui/QPixmap>
34 #include <QtCore/QString>
35 #include <QtCore/QMap>
36 #include <X11/Xlib.h>
37
38 //some net_wm state-operations we need here
39 #define _NET_WM_STATE_TOGGLE 2
40 #define _NET_WM_STATE_ADD 1
41 #define _NET_WM_STATE_REMOVE 0
42
43 /**
44 * @file xfitman.h
45 * @author Christopher "VdoP" Regali
46 * @brief handles all of our xlib-calls.
47 */
48
49 typedef QList<Atom> AtomList;
50 typedef QList<Window> WindowList;
51
52 // A list of atoms indicating user operations that the Window Manager supports
53 // for this window.
54 // See http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569373
55 struct WindowAllowedActions
56 {
57 bool Move; // indicates that the window may be moved around the screen.
58 bool Resize; // indicates that the window may be resized.
59 bool Minimize; // indicates that the window may be iconified.
60 bool Shade; // indicates that the window may be shaded.
61 bool Stick; // indicates that the window may have its sticky state toggled.
62 bool MaximizeHoriz; // indicates that the window may be maximized horizontally.
63 bool MaximizeVert; // indicates that the window may be maximized vertically.
64 bool FullScreen; // indicates that the window may be brought to fullscreen state.
65 bool ChangeDesktop; // indicates that the window may be moved between desktops.
66 bool Close; // indicates that the window may be closed.
67 bool AboveLayer; // indicates that the window may placed in the "above" layer of windows
68 bool BelowLayer; // indicates that the window may placed in the "below" layer of windows
69 };
70
71 // A list of hints describing the window state.
72 // http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569140
73 struct WindowState
74 {
75 bool Modal; // indicates that this is a modal dialog box.
76 bool Sticky; // indicates that the Window Manager SHOULD keep the window's position
77 // fixed on the screen, even when the virtual desktop scrolls.
78 bool MaximizedVert; // indicates that the window is vertically maximized.
79 bool MaximizedHoriz;// indicates that the window is horizontally maximized.
80 bool Shaded; // indicates that the window is shaded.
81 bool SkipTaskBar; // indicates that the window should not be included on a taskbar.
82 bool SkipPager; // indicates that the window should not be included on a Pager.
83 bool Hidden; // indicates that a window would not be visible on the screen
84 bool FullScreen; // indicates that the window should fill the entire screen.
85 bool AboveLayer; // indicates that the window should be on top of most windows.
86 bool BelowLayer; // indicates that the window should be below most windows.
87 bool Attention; // indicates that some action in or with the window happened.
88 };
89
90
91 /**
92 * @brief manages the Xlib apicalls
93 */
94 class XfitMan
95 {
96 public:
97
98 enum Layer
99 {
100 LayerAbove,
101 LayerNormal,
102 LayerBelow
103 };
104
105 enum MaximizeDirection
106 {
107 MaximizeHoriz,
108 MaximizeVert,
109 MaximizeBoth
110 };
111
112 ~XfitMan();
113 XfitMan();
114 void moveWindow(Window _win, int _x, int _y) const;
115
116 // See
117 void setStrut(Window _wid,
118 int left, int right,
119 int top, int bottom,
120
121 int leftStartY, int leftEndY,
122 int rightStartY, int rightEndY,
123 int topStartX, int topEndX,
124 int bottomStartX, int bottomEndX
125 ) const;
126 WindowList getClientList() const;
127 bool getClientIcon(Window _wid, QPixmap& _pixreturn) const;
128 bool getClientIcon(Window _wid, QIcon *icon) const;
129 int getWindowDesktop(Window _wid) const;
130 void moveWindowToDesktop(Window _wid, int _display) const;
131
132 void raiseWindow(Window _wid) const;
133 void minimizeWindow(Window _wid) const;
134 void maximizeWindow(Window _wid, MaximizeDirection direction = MaximizeBoth) const;
135 void deMaximizeWindow(Window _wid) const;
136 void shadeWindow(Window _wid, bool shade) const;
137 void resizeWindow(Window _wid, int _width, int _height) const;
138 void closeWindow(Window _wid) const;
139 void setWindowLayer(Window _wid, Layer layer) const;
140
141 void setActiveDesktop(int _desktop) const;
142 bool isHidden(Window _wid) const;
143 WindowAllowedActions getAllowedActions(Window window) const;
144 WindowState getWindowState(Window window) const;
145 int getActiveDesktop() const;
146 Window getActiveAppWindow() const;
147 Window getActiveWindow() const;
148 int getNumDesktop() const;
149
150 /*!
151 * Returns the names of all virtual desktops. This is a list of UTF-8 encoding strings.
152 *
153 * Note: The number of names could be different from getNumDesktop(). If it is less
154 * than getNumDesktop(), then the desktops with high numbers are unnamed. If it is
155 * larger than getNumDesktop(), then the excess names outside of the getNumDesktop()
156 * are considered to be reserved in case the number of desktops is increased.
157 */
158 QStringList getDesktopNames() const;
159
160 /*!
161 * Returns the name of virtual desktop.
162 */
163 QString getDesktopName(int desktopNum, const QString &defaultName=QString()) const;
164
165 /*! Returns window title if available
166 *
167 */
168 QString getWindowTitle(Window _wid) const;
169
170 /*! Returns window title if available
171 *
172 */
173 QString getApplicationName(Window _wid) const;
174
175 bool acceptWindow(Window _wid) const;
176
177 AtomList getWindowType(Window window) const;
178 #ifdef DEBUG
179 static QString debugWindow(Window wnd);
180 #endif
181 static Atom atom(const char* atomName);
182
183 /*!
184 * QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
185 * This workaraund this problem.
186 */
187 const QRect availableGeometry(int screen = -1) const;
188
189 /*!
190 * QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
191 * This workaraund this problem.
192 */
193 const QRect availableGeometry(const QWidget *widget) const;
194
195 /*!
196 * QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
197 * This workaraund this problem.
198 */
199 const QRect availableGeometry(const QPoint &point) const;
200
201 int clientMessage(Window _wid, Atom _msg,
202 long unsigned int data0,
203 long unsigned int data1 = 0,
204 long unsigned int data2 = 0,
205 long unsigned int data3 = 0,
206 long unsigned int data4 = 0) const;
207
208 /*!
209 * Returns true if the Window Manager is running; otherwise returns false.
210 */
211 bool isWindowManagerActive() const;
212
213 private:
214
215 /** \warning Do not forget to XFree(result) after data are processed!
216 */
217 bool getWindowProperty(Window window,
218 Atom atom, // property
219 Atom reqType, // req_type
220 unsigned long* resultLen,// nitems_return
221 unsigned char** result // prop_return
222 ) const;
223
224 /** \warning Do not forget to XFree(result) after data are processed!
225 */
226 bool getRootWindowProperty(Atom atom, // property
227 Atom reqType, // req_type
228 unsigned long* resultLen,// nitems_return
229 unsigned char** result // prop_return
230 ) const;
231
232
233 Window root; //the actual root window on the used screen
234 };
235
236
237 const XfitMan& xfitMan();
238
239
240 #endif