Allow window matching based on the group leader's name and class (Fix bug 5721)
[dana/openbox.git] / obt / prop.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    obt/prop.h for the Openbox window manager
4    Copyright (c) 2006        Mikael Magnusson
5    Copyright (c) 2003-2007   Dana Jansens
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #ifndef __obt_prop_h
21 #define __obt_prop_h
22
23 #include <X11/Xlib.h>
24 #include <glib.h>
25
26 G_BEGIN_DECLS
27
28 typedef enum {
29     /* types */
30     OBT_PROP_CARDINAL, /*!< The atom which represents the Cardinal data type */
31     OBT_PROP_WINDOW, /*!< The atom which represents window ids */
32     OBT_PROP_PIXMAP, /*!< The atom which represents pixmap ids */
33     OBT_PROP_ATOM, /*!< The atom which represents atom values */
34     OBT_PROP_STRING, /*!< The atom which represents latin1 strings */
35     OBT_PROP_COMPOUND_TEXT, /*!< The atom which represents locale-encoded
36                               strings */
37     OBT_PROP_UTF8_STRING, /*!< The atom which represents utf8-encoded strings*/
38
39     /* selection stuff */
40     OBT_PROP_MANAGER,
41
42     /* window hints */
43     OBT_PROP_WM_COLORMAP_WINDOWS,
44     OBT_PROP_WM_PROTOCOLS,
45     OBT_PROP_WM_STATE,
46     OBT_PROP_WM_DELETE_WINDOW,
47     OBT_PROP_WM_TAKE_FOCUS,
48     OBT_PROP_WM_CHANGE_STATE,
49     OBT_PROP_WM_NAME,
50     OBT_PROP_WM_ICON_NAME,
51     OBT_PROP_WM_CLASS,
52     OBT_PROP_WM_WINDOW_ROLE,
53     OBT_PROP_WM_CLIENT_MACHINE,
54     OBT_PROP_WM_COMMAND,
55     OBT_PROP_WM_CLIENT_LEADER,
56     OBT_PROP_WM_TRANSIENT_FOR,
57     OBT_PROP_MOTIF_WM_HINTS,
58     OBT_PROP_MOTIF_WM_INFO,
59
60     /* SM atoms */
61     OBT_PROP_SM_CLIENT_ID,
62
63     /* NETWM atoms */
64
65     /* Atoms that are used inside messages - these don't go in net_supported */
66
67     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT,
68     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP,
69     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT,
70     OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT,
71     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT,
72     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM,
73     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT,
74     OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT,
75     OBT_PROP_NET_WM_MOVERESIZE_MOVE,
76     OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD,
77     OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD,
78     OBT_PROP_NET_WM_MOVERESIZE_CANCEL,
79
80     OBT_PROP_NET_WM_STATE_ADD,
81     OBT_PROP_NET_WM_STATE_REMOVE,
82     OBT_PROP_NET_WM_STATE_TOGGLE,
83
84     OBT_PROP_NET_WM_ORIENTATION_HORZ,
85     OBT_PROP_NET_WM_ORIENTATION_VERT,
86     OBT_PROP_NET_WM_TOPLEFT,
87     OBT_PROP_NET_WM_TOPRIGHT,
88     OBT_PROP_NET_WM_BOTTOMRIGHT,
89     OBT_PROP_NET_WM_BOTTOMLEFT,
90
91     OBT_PROP_NET_WM_WINDOW_TYPE_POPUP_MENU,
92
93     OBT_PROP_PRIVATE_PADDING1,
94     OBT_PROP_PRIVATE_PADDING2,
95     OBT_PROP_PRIVATE_PADDING3,
96     OBT_PROP_PRIVATE_PADDING4,
97     OBT_PROP_PRIVATE_PADDING5,
98     OBT_PROP_PRIVATE_PADDING6,
99     OBT_PROP_PRIVATE_PADDING7,
100     OBT_PROP_PRIVATE_PADDING8,
101     OBT_PROP_PRIVATE_PADDING9,
102     OBT_PROP_PRIVATE_PADDING10,
103     OBT_PROP_PRIVATE_PADDING11,
104     OBT_PROP_PRIVATE_PADDING12,
105
106     /* Everything below here must go in net_supported on the root window */
107
108     /* root window properties */
109     OBT_PROP_NET_SUPPORTED,
110     OBT_PROP_NET_CLIENT_LIST,
111     OBT_PROP_NET_CLIENT_LIST_STACKING,
112     OBT_PROP_NET_NUMBER_OF_DESKTOPS,
113     OBT_PROP_NET_DESKTOP_GEOMETRY,
114     OBT_PROP_NET_DESKTOP_VIEWPORT,
115     OBT_PROP_NET_CURRENT_DESKTOP,
116     OBT_PROP_NET_DESKTOP_NAMES,
117     OBT_PROP_NET_ACTIVE_WINDOW,
118 /*    Atom net_restack_window;*/
119     OBT_PROP_NET_WORKAREA,
120     OBT_PROP_NET_SUPPORTING_WM_CHECK,
121     OBT_PROP_NET_DESKTOP_LAYOUT,
122     OBT_PROP_NET_SHOWING_DESKTOP,
123
124     /* root window messages */
125     OBT_PROP_NET_CLOSE_WINDOW,
126     OBT_PROP_NET_WM_MOVERESIZE,
127     OBT_PROP_NET_MOVERESIZE_WINDOW,
128     OBT_PROP_NET_REQUEST_FRAME_EXTENTS,
129     OBT_PROP_NET_RESTACK_WINDOW,
130
131     /* helpful hints to apps that aren't used for anything */
132     OBT_PROP_NET_WM_FULL_PLACEMENT,
133
134     /* startup-notification extension */
135     OBT_PROP_NET_STARTUP_ID,
136
137     /* application window properties */
138     OBT_PROP_NET_WM_NAME,
139     OBT_PROP_NET_WM_VISIBLE_NAME,
140     OBT_PROP_NET_WM_ICON_NAME,
141     OBT_PROP_NET_WM_VISIBLE_ICON_NAME,
142     OBT_PROP_NET_WM_DESKTOP,
143     OBT_PROP_NET_WM_WINDOW_TYPE,
144     OBT_PROP_NET_WM_STATE,
145     OBT_PROP_NET_WM_STRUT,
146     OBT_PROP_NET_WM_STRUT_PARTIAL,
147     OBT_PROP_NET_WM_ICON,
148     OBT_PROP_NET_WM_ICON_GEOMETRY,
149     OBT_PROP_NET_WM_PID,
150     OBT_PROP_NET_WM_ALLOWED_ACTIONS,
151     OBT_PROP_NET_WM_WINDOW_OPACITY,
152     OBT_PROP_NET_WM_USER_TIME,
153 /*  OBT_PROP_NET_WM_USER_TIME_WINDOW, */
154     OBT_PROP_NET_FRAME_EXTENTS,
155
156     /* application protocols */
157     OBT_PROP_NET_WM_PING,
158 #ifdef SYNC
159     OBT_PROP_NET_WM_SYNC_REQUEST,
160     OBT_PROP_NET_WM_SYNC_REQUEST_COUNTER,
161 #endif
162
163     OBT_PROP_NET_WM_WINDOW_TYPE_DESKTOP,
164     OBT_PROP_NET_WM_WINDOW_TYPE_DOCK,
165     OBT_PROP_NET_WM_WINDOW_TYPE_TOOLBAR,
166     OBT_PROP_NET_WM_WINDOW_TYPE_MENU,
167     OBT_PROP_NET_WM_WINDOW_TYPE_UTILITY,
168     OBT_PROP_NET_WM_WINDOW_TYPE_SPLASH,
169     OBT_PROP_NET_WM_WINDOW_TYPE_DIALOG,
170     OBT_PROP_NET_WM_WINDOW_TYPE_NORMAL,
171
172     OBT_PROP_NET_WM_ACTION_MOVE,
173     OBT_PROP_NET_WM_ACTION_RESIZE,
174     OBT_PROP_NET_WM_ACTION_MINIMIZE,
175     OBT_PROP_NET_WM_ACTION_SHADE,
176 /*    OBT_PROP_NET_WM_ACTION_STICK,*/
177     OBT_PROP_NET_WM_ACTION_MAXIMIZE_HORZ,
178     OBT_PROP_NET_WM_ACTION_MAXIMIZE_VERT,
179     OBT_PROP_NET_WM_ACTION_FULLSCREEN,
180     OBT_PROP_NET_WM_ACTION_CHANGE_DESKTOP,
181     OBT_PROP_NET_WM_ACTION_CLOSE,
182     OBT_PROP_NET_WM_ACTION_ABOVE,
183     OBT_PROP_NET_WM_ACTION_BELOW,
184
185     OBT_PROP_NET_WM_STATE_MODAL,
186 /*    OBT_PROP_NET_WM_STATE_STICKY,*/
187     OBT_PROP_NET_WM_STATE_MAXIMIZED_VERT,
188     OBT_PROP_NET_WM_STATE_MAXIMIZED_HORZ,
189     OBT_PROP_NET_WM_STATE_SHADED,
190     OBT_PROP_NET_WM_STATE_SKIP_TASKBAR,
191     OBT_PROP_NET_WM_STATE_SKIP_PAGER,
192     OBT_PROP_NET_WM_STATE_HIDDEN,
193     OBT_PROP_NET_WM_STATE_FULLSCREEN,
194     OBT_PROP_NET_WM_STATE_ABOVE,
195     OBT_PROP_NET_WM_STATE_BELOW,
196     OBT_PROP_NET_WM_STATE_DEMANDS_ATTENTION,
197
198     /* KDE atoms */
199
200     OBT_PROP_KDE_WM_CHANGE_STATE,
201     OBT_PROP_KDE_NET_WM_FRAME_STRUT,
202     OBT_PROP_KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
203
204 /*
205     OBT_PROP_ROOTPMAPID,
206     OBT_PROP_ESETROOTID,
207 */
208
209     /* Openbox specific atoms */
210
211     OBT_PROP_OB_WM_ACTION_UNDECORATE,
212     OBT_PROP_OB_WM_STATE_UNDECORATED,
213     OBT_PROP_OPENBOX_PID, /* this is depreecated in favour of ob_control */
214     OBT_PROP_OB_THEME,
215     OBT_PROP_OB_CONFIG_FILE,
216     OBT_PROP_OB_CONTROL,
217     OBT_PROP_OB_VERSION,
218     OBT_PROP_OB_APP_ROLE,
219     OBT_PROP_OB_APP_TITLE,
220     OBT_PROP_OB_APP_NAME,
221     OBT_PROP_OB_APP_CLASS,
222     OBT_PROP_OB_APP_GROUP_NAME,
223     OBT_PROP_OB_APP_GROUP_CLASS,
224     OBT_PROP_OB_APP_TYPE,
225
226     OBT_PROP_NUM_ATOMS
227 } ObtPropAtom;
228
229 Atom obt_prop_atom(ObtPropAtom a);
230
231 typedef enum {
232     /*! STRING is latin1 encoded.  It cannot contain control characters except
233        for tab and line-feed. */
234     OBT_PROP_TEXT_STRING = 1,
235     /*! STRING text restricted to characters in the X Portable Character
236       Set, which is a subset of latin1.
237       http://static.cray-cyber.org/Documentation/NEC_SX_R10_1/G1AE02E/CHAP1.HTML
238     */
239     OBT_PROP_TEXT_STRING_XPCS = 2,
240     /*! STRING text restricted to not allow any control characters to be
241       present. */
242     OBT_PROP_TEXT_STRING_NO_CC = 3,
243     /* COMPOUND_TEXT is encoded in the current locale setting. */
244     OBT_PROP_TEXT_COMPOUND_TEXT = 4,
245     /* UTF8_STRING is encoded as utf-8. */
246     OBT_PROP_TEXT_UTF8_STRING = 5,
247 } ObtPropTextType;
248
249 gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret);
250 gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
251                               guint *nret);
252
253 gboolean obt_prop_get_text(Window win, Atom prop, ObtPropTextType type,
254                            gchar **ret);
255 gboolean obt_prop_get_array_text(Window win, Atom prop,
256                                  ObtPropTextType type,
257                                  gchar ***ret);
258
259 void obt_prop_set32(Window win, Atom prop, Atom type, gulong val);
260 void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
261                           guint num);
262 void obt_prop_set_text(Window win, Atom prop, const gchar *str);
263 void obt_prop_set_array_text(Window win, Atom prop, const gchar *const *strs);
264
265 void obt_prop_erase(Window win, Atom prop);
266
267 void obt_prop_message(gint screen, Window about, Atom messagetype,
268                       glong data0, glong data1, glong data2, glong data3,
269                       glong data4, glong mask);
270 void obt_prop_message_to(Window to, Window about, Atom messagetype,
271                          glong data0, glong data1, glong data2, glong data3,
272                          glong data4, glong mask);
273
274 #define OBT_PROP_ATOM(prop) obt_prop_atom(OBT_PROP_##prop)
275
276 #define OBT_PROP_GET32(win, prop, type, ret) \
277     (obt_prop_get32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), ret))
278 #define OBT_PROP_GETA32(win, prop, type, ret, nret) \
279     (obt_prop_get_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
280                           ret, nret))
281 #define OBT_PROP_GETS(win, prop, ret) \
282     (obt_prop_get_text(win, OBT_PROP_ATOM(prop), 0, ret))
283 #define OBT_PROP_GETSS(win, prop, ret) \
284     (obt_prop_get_array_text(win, OBT_PROP_ATOM(prop), 0, ret))
285
286 #define OBT_PROP_GETS_TYPE(win, prop, type, ret) \
287     (obt_prop_get_text(win, OBT_PROP_ATOM(prop), OBT_PROP_TEXT_##type, ret))
288 #define OBT_PROP_GETSS_TYPE(win, prop, type, ret) \
289     (obt_prop_get_array_text(win, OBT_PROP_ATOM(prop), \
290                              OBT_PROP_TEXT_##type, ret))
291
292 #define OBT_PROP_GETS_UTF8(win, prop, ret) \
293     OBT_PROP_GETS_TYPE(win, prop, UTF8_STRING, ret)
294 #define OBT_PROP_GETSS_UTF8(win, prop, ret) \
295     OBT_PROP_GETSS_TYPE(win, prop, UTF8_STRING, ret)
296 #define OBT_PROP_GETS_XPCS(win, prop, ret) \
297     OBT_PROP_GETS_TYPE(win, prop, STRING_XPCS, ret)
298
299 #define OBT_PROP_SET32(win, prop, type, val) \
300     (obt_prop_set32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), val))
301 #define OBT_PROP_SETA32(win, prop, type, val, num) \
302     (obt_prop_set_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
303                           val, num))
304 #define OBT_PROP_SETS(win, prop, val) \
305     (obt_prop_set_text(win, OBT_PROP_ATOM(prop), val))
306 #define OBT_PROP_SETSS(win, prop, strs) \
307     (obt_prop_set_array_text(win, OBT_PROP_ATOM(prop), strs))
308
309 #define OBT_PROP_ERASE(win, prop) (obt_prop_erase(win, OBT_PROP_ATOM(prop)))
310
311 #define OBT_PROP_MSG(screen, about, msgtype, data0, data1, data2, data3, \
312                      data4) \
313     (obt_prop_message(screen, about, OBT_PROP_ATOM(msgtype), \
314                       data0, data1, data2, data3, data4, \
315                       SubstructureNotifyMask | SubstructureRedirectMask))
316
317 #define OBT_PROP_MSG_TO(to, about, msgtype, data0, data1, data2, data3, \
318                         data4, mask) \
319     (obt_prop_message_to(to, about, OBT_PROP_ATOM(msgtype), \
320                          data0, data1, data2, data3, data4, mask))
321
322 G_END_DECLS
323
324 #endif /* __obt_prop_h */