1 /**
2  * @file hint.h
3  * @author Joe Wingbermuehle
4  * @date 2004-2006
5  *
6  * @brief Header for reading and writing X properties.
7  *
8  */
9 
10 #ifndef HINT_H
11 #define HINT_H
12 
13 struct ClientNode;
14 
15 /** Enumeration of atoms. */
16 typedef enum {
17 
18    /* Misc */
19    ATOM_COMPOUND_TEXT,
20    ATOM_UTF8_STRING,
21    ATOM_XROOTPMAP_ID,
22    ATOM_MANAGER,
23 
24    /* Standard atoms */
25    ATOM_WM_STATE,
26    ATOM_WM_PROTOCOLS,
27    ATOM_WM_DELETE_WINDOW,
28    ATOM_WM_TAKE_FOCUS,
29    ATOM_WM_CHANGE_STATE,
30    ATOM_WM_COLORMAP_WINDOWS,
31 
32    /* WM Spec atoms */
33    ATOM_NET_SUPPORTED,
34    ATOM_NET_NUMBER_OF_DESKTOPS,
35    ATOM_NET_DESKTOP_NAMES,
36    ATOM_NET_DESKTOP_GEOMETRY,
37    ATOM_NET_DESKTOP_VIEWPORT,
38    ATOM_NET_CURRENT_DESKTOP,
39    ATOM_NET_ACTIVE_WINDOW,
40    ATOM_NET_WORKAREA,
41    ATOM_NET_SUPPORTING_WM_CHECK,
42    ATOM_NET_SHOWING_DESKTOP,
43    ATOM_NET_FRAME_EXTENTS,
44    ATOM_NET_WM_DESKTOP,
45 
46    ATOM_NET_WM_STATE,
47    ATOM_NET_WM_STATE_STICKY,
48    ATOM_NET_WM_STATE_MAXIMIZED_VERT,
49    ATOM_NET_WM_STATE_MAXIMIZED_HORZ,
50    ATOM_NET_WM_STATE_SHADED,
51    ATOM_NET_WM_STATE_FULLSCREEN,
52    ATOM_NET_WM_STATE_HIDDEN,
53    ATOM_NET_WM_STATE_SKIP_TASKBAR,
54    ATOM_NET_WM_STATE_SKIP_PAGER,
55    ATOM_NET_WM_STATE_BELOW,
56    ATOM_NET_WM_STATE_ABOVE,
57    ATOM_NET_WM_STATE_DEMANDS_ATTENTION,
58    ATOM_NET_WM_STATE_FOCUSED,
59 
60    ATOM_NET_WM_ALLOWED_ACTIONS,
61    ATOM_NET_WM_ACTION_MOVE,
62    ATOM_NET_WM_ACTION_RESIZE,
63    ATOM_NET_WM_ACTION_MINIMIZE,
64    ATOM_NET_WM_ACTION_SHADE,
65    ATOM_NET_WM_ACTION_STICK,
66    ATOM_NET_WM_ACTION_FULLSCREEN,
67    ATOM_NET_WM_ACTION_MAXIMIZE_HORZ,
68    ATOM_NET_WM_ACTION_MAXIMIZE_VERT,
69    ATOM_NET_WM_ACTION_CHANGE_DESKTOP,
70    ATOM_NET_WM_ACTION_CLOSE,
71    ATOM_NET_WM_ACTION_BELOW,
72    ATOM_NET_WM_ACTION_ABOVE,
73 
74    ATOM_NET_CLOSE_WINDOW,
75    ATOM_NET_MOVERESIZE_WINDOW,
76    ATOM_NET_RESTACK_WINDOW,
77    ATOM_NET_REQUEST_FRAME_EXTENTS,
78 
79    ATOM_NET_WM_PID,
80    ATOM_NET_WM_NAME,
81    ATOM_NET_WM_VISIBLE_NAME,
82    ATOM_NET_WM_HANDLED_ICONS,
83    ATOM_NET_WM_ICON,
84    ATOM_NET_WM_ICON_NAME,
85    ATOM_NET_WM_USER_TIME,
86    ATOM_NET_WM_USER_TIME_WINDOW,
87    ATOM_NET_WM_VISIBLE_ICON_NAME,
88    ATOM_NET_WM_WINDOW_TYPE,
89    ATOM_NET_WM_WINDOW_TYPE_DESKTOP,
90    ATOM_NET_WM_WINDOW_TYPE_DOCK,
91    ATOM_NET_WM_WINDOW_TYPE_SPLASH,
92    ATOM_NET_WM_WINDOW_TYPE_DIALOG,
93    ATOM_NET_WM_WINDOW_TYPE_NORMAL,
94    ATOM_NET_WM_WINDOW_TYPE_MENU,
95    ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION,
96    ATOM_NET_WM_WINDOW_TYPE_TOOLBAR,
97    ATOM_NET_WM_WINDOW_TYPE_UTILITY,
98 
99    ATOM_NET_CLIENT_LIST,
100    ATOM_NET_CLIENT_LIST_STACKING,
101 
102    ATOM_NET_WM_STRUT_PARTIAL,
103    ATOM_NET_WM_WINDOW_OPACITY,
104    ATOM_NET_WM_STRUT,
105    ATOM_NET_WM_MOVERESIZE,
106 
107    ATOM_NET_SYSTEM_TRAY_OPCODE,
108    ATOM_NET_SYSTEM_TRAY_ORIENTATION,
109 
110    /* MWM atoms */
111    ATOM_MOTIF_WM_HINTS,
112 
113    /* JWM-specific atoms. */
114    ATOM_JWM_RESTART,
115    ATOM_JWM_EXIT,
116    ATOM_JWM_RELOAD,
117    ATOM_JWM_WM_STATE_MAXIMIZED_TOP,
118    ATOM_JWM_WM_STATE_MAXIMIZED_BOTTOM,
119    ATOM_JWM_WM_STATE_MAXIMIZED_LEFT,
120    ATOM_JWM_WM_STATE_MAXIMIZED_RIGHT,
121 
122    ATOM_COUNT
123 } AtomType;
124 
125 extern const char jwmRestart[];
126 extern const char jwmExit[];
127 extern const char jwmReload[];
128 extern const char managerProperty[];
129 
130 #define FIRST_NET_ATOM ATOM_NET_SUPPORTED
131 #define LAST_NET_ATOM  ATOM_NET_WM_STRUT
132 
133 #define FIRST_MWM_ATOM ATOM_MOTIF_WM_HINTS
134 #define LAST_MWM_ATOM  ATOM_MOTIF_WM_HINTS
135 
136 /** Enumeration of window layers. */
137 typedef unsigned char WinLayerType;
138 #define LAYER_DESKTOP   0
139 #define LAYER_BELOW     1
140 #define LAYER_NORMAL    2
141 #define LAYER_ABOVE     3
142 #define LAYER_COUNT     4
143 
144 #define FIRST_LAYER        LAYER_DESKTOP
145 #define LAST_LAYER         LAYER_ABOVE
146 #define DEFAULT_TRAY_LAYER LAYER_ABOVE
147 
148 /** Client state information. */
149 typedef struct ClientState {
150    unsigned int status;          /**< Status bit mask. */
151    unsigned int opacity;         /**< Opacity (0 - 0xFFFFFFFF). */
152    unsigned short border;        /**< Border bit mask. */
153    unsigned short desktop;       /**< Desktop. */
154    unsigned char maxFlags;       /**< Maximization status. */
155    unsigned char layer;          /**< Current window layer. */
156    unsigned char defaultLayer;   /**< Default window layer. */
157 } ClientState;
158 
159 extern Atom atoms[ATOM_COUNT];
160 
161 /*@{*/
162 #define InitializeHints()  (void)(0)
163 void StartupHints(void);
164 #define ShutdownHints()    (void)(0)
165 #define DestroyHints()     (void)(0)
166 /*@}*/
167 
168 /** Determine the current desktop. */
169 void ReadCurrentDesktop(void);
170 
171 /** Read client info.
172  * @param np The client.
173  * @param alreadyMapped Set if the client is already mapped.
174  */
175 void ReadClientInfo(struct ClientNode *np, char alreadyMapped);
176 
177 /** Read a client's name.
178  * @param np The client.
179  */
180 void ReadWMName(struct ClientNode *np);
181 
182 /** Read a client's class.
183  * @param np The client.
184  */
185 void ReadWMClass(struct ClientNode *np);
186 
187 /** Read normal hints for a client.
188  * @param np The client.
189  */
190 void ReadWMNormalHints(struct ClientNode *np);
191 
192 /** Read the WM_PROTOCOLS property for a window.
193  * @param w The window.
194  * @param state The client state to update.
195  */
196 void ReadWMProtocols(Window w, ClientState *state);
197 
198 /** Read colormap information for a client.
199  * @param np The client.
200  */
201 void ReadWMColormaps(struct ClientNode *np);
202 
203 /** Determine the layer of a client.
204  * @param np The client.
205  */
206 void ReadWinLayer(struct ClientNode *np);
207 
208 /** Read the current state of a window.
209  * @param win The window.
210  * @param alreadyMapped Set if the window is already mapped.
211  * @return The window state.
212  */
213 ClientState ReadWindowState(Window win, char alreadyMapped);
214 
215 /** Read WM hints.
216  * @param win The window.
217  * @param state The state hints to update.
218  * @param alreadyMapped Set if the window is already mapped.
219  */
220 void ReadWMHints(Window win, ClientState *state, char alreadyMapped);
221 
222 /** Read opacity.
223  * @param win The window.
224  * @param opacity The opacity to update.
225  */
226 void ReadWMOpacity(Window win, unsigned *opacity);
227 
228 /** Set the state of a client window.
229  * Note that this will call WriteNetState.
230  * @param np The client.
231  */
232 void WriteState(struct ClientNode *np);
233 
234 /** Set _NET_WM_STATE.
235  * @param np The client.
236  */
237 void WriteNetState(struct ClientNode *np);
238 
239 /** Set the opacity of a client window.
240  * @param np The client.
241  * @param opacity The opacity to set.
242  * @param force Set the opacity even if it hasn't changed.
243  */
244 void SetOpacity(struct ClientNode *np, unsigned int opacity, char force);
245 
246 /** Set the frame extents of a window.
247  * @param win The window.
248  * @param state The client state.
249  */
250 void WriteFrameExtents(Window win, const ClientState *state);
251 
252 /** Read a cardinal atom.
253  * @param window The window.
254  * @param atom The atom to read.
255  * @param value A pointer to the location to save the atom.
256  * @return 1 on success, 0 on failure.
257  */
258 char GetCardinalAtom(Window window, AtomType atom, unsigned long *value);
259 
260 /** Set a cardinal atom.
261  * @param window The window.
262  * @param atom The atom to set.
263  * @param value The value.
264  */
265 void SetCardinalAtom(Window window, AtomType atom, unsigned long value);
266 
267 /** Read a window atom.
268  * @param window The window.
269  * @param atom The atom to read.
270  * @param value A pointer to the location to save the atom.
271  * @return 1 on success, 0 on failure.
272  */
273 char GetWindowAtom(Window window, AtomType atom, Window *value);
274 
275 /** Set a window atom.
276  * @param window The window.
277  * @param atom The atom to set.
278  * @param value The value.
279  */
280 void SetWindowAtom(Window window, AtomType atom, unsigned long value);
281 
282 /** Set a pixmap atom.
283  * @param window The window.
284  * @param atom The atom to set.
285  * @param value The value.
286  */
287 void SetPixmapAtom(Window window, AtomType atom, Pixmap value);
288 
289 /** Set an atom atom.
290  * @param window The window.
291  * @param atom The atom to set.
292  * @param value The value.
293  */
294 void SetAtomAtom(Window window, AtomType atom, AtomType value);
295 
296 #endif /* HINT_H */
297 
298