avoid ascii control characters in strings
[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 ascii strings */
35     OBT_PROP_UTF8,     /*!< The atom which represents utf8-encoded strings */
36
37     /* selection stuff */
38     OBT_PROP_MANAGER,
39
40     /* window hints */
41     OBT_PROP_WM_COLORMAP_WINDOWS,
42     OBT_PROP_WM_PROTOCOLS,
43     OBT_PROP_WM_STATE,
44     OBT_PROP_WM_DELETE_WINDOW,
45     OBT_PROP_WM_TAKE_FOCUS,
46     OBT_PROP_WM_CHANGE_STATE,
47     OBT_PROP_WM_NAME,
48     OBT_PROP_WM_ICON_NAME,
49     OBT_PROP_WM_CLASS,
50     OBT_PROP_WM_WINDOW_ROLE,
51     OBT_PROP_WM_CLIENT_MACHINE,
52     OBT_PROP_WM_COMMAND,
53     OBT_PROP_WM_CLIENT_LEADER,
54     OBT_PROP_WM_TRANSIENT_FOR,
55     OBT_PROP_MOTIF_WM_HINTS,
56     OBT_PROP_MOTIF_WM_INFO,
57
58     /* SM atoms */
59     OBT_PROP_SM_CLIENT_ID,
60
61     /* NETWM atoms */
62
63     /* Atoms that are used inside messages - these don't go in net_supported */
64
65     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT,
66     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP,
67     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT,
68     OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT,
69     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT,
70     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM,
71     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT,
72     OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT,
73     OBT_PROP_NET_WM_MOVERESIZE_MOVE,
74     OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD,
75     OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD,
76     OBT_PROP_NET_WM_MOVERESIZE_CANCEL,
77
78     OBT_PROP_NET_WM_STATE_ADD,
79     OBT_PROP_NET_WM_STATE_REMOVE,
80     OBT_PROP_NET_WM_STATE_TOGGLE,
81
82     OBT_PROP_NET_WM_ORIENTATION_HORZ,
83     OBT_PROP_NET_WM_ORIENTATION_VERT,
84     OBT_PROP_NET_WM_TOPLEFT,
85     OBT_PROP_NET_WM_TOPRIGHT,
86     OBT_PROP_NET_WM_BOTTOMRIGHT,
87     OBT_PROP_NET_WM_BOTTOMLEFT,
88
89     OBT_PROP_NET_WM_WINDOW_TYPE_POPUP_MENU,
90
91     OBT_PROP_PRIVATE_PADDING1,
92     OBT_PROP_PRIVATE_PADDING2,
93     OBT_PROP_PRIVATE_PADDING3,
94     OBT_PROP_PRIVATE_PADDING4,
95     OBT_PROP_PRIVATE_PADDING5,
96     OBT_PROP_PRIVATE_PADDING6,
97     OBT_PROP_PRIVATE_PADDING7,
98     OBT_PROP_PRIVATE_PADDING8,
99     OBT_PROP_PRIVATE_PADDING9,
100     OBT_PROP_PRIVATE_PADDING10,
101     OBT_PROP_PRIVATE_PADDING11,
102     OBT_PROP_PRIVATE_PADDING12,
103
104     /* Everything below here must go in net_supported on the root window */
105
106     /* root window properties */
107     OBT_PROP_NET_SUPPORTED,
108     OBT_PROP_NET_CLIENT_LIST,
109     OBT_PROP_NET_CLIENT_LIST_STACKING,
110     OBT_PROP_NET_NUMBER_OF_DESKTOPS,
111     OBT_PROP_NET_DESKTOP_GEOMETRY,
112     OBT_PROP_NET_DESKTOP_VIEWPORT,
113     OBT_PROP_NET_CURRENT_DESKTOP,
114     OBT_PROP_NET_DESKTOP_NAMES,
115     OBT_PROP_NET_ACTIVE_WINDOW,
116 /*    Atom net_restack_window;*/
117     OBT_PROP_NET_WORKAREA,
118     OBT_PROP_NET_SUPPORTING_WM_CHECK,
119     OBT_PROP_NET_DESKTOP_LAYOUT,
120     OBT_PROP_NET_SHOWING_DESKTOP,
121
122     /* root window messages */
123     OBT_PROP_NET_CLOSE_WINDOW,
124     OBT_PROP_NET_WM_MOVERESIZE,
125     OBT_PROP_NET_MOVERESIZE_WINDOW,
126     OBT_PROP_NET_REQUEST_FRAME_EXTENTS,
127     OBT_PROP_NET_RESTACK_WINDOW,
128
129     /* helpful hints to apps that aren't used for anything */
130     OBT_PROP_NET_WM_FULL_PLACEMENT,
131
132     /* startup-notification extension */
133     OBT_PROP_NET_STARTUP_ID,
134
135     /* application window properties */
136     OBT_PROP_NET_WM_NAME,
137     OBT_PROP_NET_WM_VISIBLE_NAME,
138     OBT_PROP_NET_WM_ICON_NAME,
139     OBT_PROP_NET_WM_VISIBLE_ICON_NAME,
140     OBT_PROP_NET_WM_DESKTOP,
141     OBT_PROP_NET_WM_WINDOW_TYPE,
142     OBT_PROP_NET_WM_STATE,
143     OBT_PROP_NET_WM_STRUT,
144     OBT_PROP_NET_WM_STRUT_PARTIAL,
145     OBT_PROP_NET_WM_ICON,
146     OBT_PROP_NET_WM_ICON_GEOMETRY,
147     OBT_PROP_NET_WM_PID,
148     OBT_PROP_NET_WM_ALLOWED_ACTIONS,
149     OBT_PROP_NET_WM_USER_TIME,
150 /*  OBT_PROP_NET_WM_USER_TIME_WINDOW, */
151     OBT_PROP_NET_FRAME_EXTENTS,
152
153     /* application protocols */
154     OBT_PROP_NET_WM_PING,
155 #ifdef SYNC
156     OBT_PROP_NET_WM_SYNC_REQUEST,
157     OBT_PROP_NET_WM_SYNC_REQUEST_COUNTER,
158 #endif
159
160     OBT_PROP_NET_WM_WINDOW_TYPE_DESKTOP,
161     OBT_PROP_NET_WM_WINDOW_TYPE_DOCK,
162     OBT_PROP_NET_WM_WINDOW_TYPE_TOOLBAR,
163     OBT_PROP_NET_WM_WINDOW_TYPE_MENU,
164     OBT_PROP_NET_WM_WINDOW_TYPE_UTILITY,
165     OBT_PROP_NET_WM_WINDOW_TYPE_SPLASH,
166     OBT_PROP_NET_WM_WINDOW_TYPE_DIALOG,
167     OBT_PROP_NET_WM_WINDOW_TYPE_NORMAL,
168
169     OBT_PROP_NET_WM_ACTION_MOVE,
170     OBT_PROP_NET_WM_ACTION_RESIZE,
171     OBT_PROP_NET_WM_ACTION_MINIMIZE,
172     OBT_PROP_NET_WM_ACTION_SHADE,
173 /*    OBT_PROP_NET_WM_ACTION_STICK,*/
174     OBT_PROP_NET_WM_ACTION_MAXIMIZE_HORZ,
175     OBT_PROP_NET_WM_ACTION_MAXIMIZE_VERT,
176     OBT_PROP_NET_WM_ACTION_FULLSCREEN,
177     OBT_PROP_NET_WM_ACTION_CHANGE_DESKTOP,
178     OBT_PROP_NET_WM_ACTION_CLOSE,
179     OBT_PROP_NET_WM_ACTION_ABOVE,
180     OBT_PROP_NET_WM_ACTION_BELOW,
181
182     OBT_PROP_NET_WM_STATE_MODAL,
183 /*    OBT_PROP_NET_WM_STATE_STICKY,*/
184     OBT_PROP_NET_WM_STATE_MAXIMIZED_VERT,
185     OBT_PROP_NET_WM_STATE_MAXIMIZED_HORZ,
186     OBT_PROP_NET_WM_STATE_SHADED,
187     OBT_PROP_NET_WM_STATE_SKIP_TASKBAR,
188     OBT_PROP_NET_WM_STATE_SKIP_PAGER,
189     OBT_PROP_NET_WM_STATE_HIDDEN,
190     OBT_PROP_NET_WM_STATE_FULLSCREEN,
191     OBT_PROP_NET_WM_STATE_ABOVE,
192     OBT_PROP_NET_WM_STATE_BELOW,
193     OBT_PROP_NET_WM_STATE_DEMANDS_ATTENTION,
194
195     /* KDE atoms */
196
197     OBT_PROP_KDE_WM_CHANGE_STATE,
198     OBT_PROP_KDE_NET_WM_FRAME_STRUT,
199     OBT_PROP_KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
200
201 /*
202     OBT_PROP_ROOTPMAPID,
203     OBT_PROP_ESETROOTID,
204 */
205
206     /* Openbox specific atoms */
207
208     OBT_PROP_OB_WM_ACTION_UNDECORATE,
209     OBT_PROP_OB_WM_STATE_UNDECORATED,
210     OBT_PROP_OPENBOX_PID, /* this is depreecated in favour of ob_control */
211     OBT_PROP_OB_THEME,
212     OBT_PROP_OB_CONFIG_FILE,
213     OBT_PROP_OB_CONTROL,
214     OBT_PROP_OB_VERSION,
215     OBT_PROP_OB_APP_ROLE,
216     OBT_PROP_OB_APP_TITLE,
217     OBT_PROP_OB_APP_NAME,
218     OBT_PROP_OB_APP_CLASS,
219     OBT_PROP_OB_APP_TYPE,
220
221     OBT_PROP_NUM_ATOMS
222 } ObtPropAtom;
223
224 Atom obt_prop_atom(ObtPropAtom a);
225
226 gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret);
227 gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
228                               guint *nret);
229 gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret);
230 gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret);
231 gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret);
232 gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret);
233
234 void obt_prop_set32(Window win, Atom prop, Atom type, gulong val);
235 void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
236                           guint num);
237 void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val);
238 void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val);
239 void obt_prop_set_strings_locale(Window win, Atom prop, const gchar **strs);
240 void obt_prop_set_strings_utf8(Window win, Atom prop, const gchar **strs);
241
242 void obt_prop_erase(Window win, Atom prop);
243
244 void obt_prop_message(gint screen, Window about, Atom messagetype,
245                       glong data0, glong data1, glong data2, glong data3,
246                       glong data4, glong mask);
247 void obt_prop_message_to(Window to, Window about, Atom messagetype,
248                          glong data0, glong data1, glong data2, glong data3,
249                          glong data4, glong mask);
250
251 #define OBT_PROP_ATOM(prop) obt_prop_atom(OBT_PROP_##prop)
252
253 #define OBT_PROP_GET32(win, prop, type, ret) \
254     (obt_prop_get32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), ret))
255 #define OBT_PROP_GETA32(win, prop, type, ret, nret) \
256     (obt_prop_get_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
257                           ret, nret))
258 #define OBT_PROP_GETS(win, prop, type, ret) \
259     (obt_prop_get_string_##type(win, OBT_PROP_ATOM(prop), ret))
260 #define OBT_PROP_GETSS(win, prop, type, ret) \
261     (obt_prop_get_strings_##type(win, OBT_PROP_ATOM(prop), ret))
262
263 #define OBT_PROP_SET32(win, prop, type, val) \
264     (obt_prop_set32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), val))
265 #define OBT_PROP_SETA32(win, prop, type, val, num) \
266     (obt_prop_set_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \
267                           val, num))
268 #define OBT_PROP_SETS(win, prop, type, val) \
269     (obt_prop_set_string_##type(win, OBT_PROP_ATOM(prop), val))
270 #define OBT_PROP_SETSS(win, prop, type, strs) \
271     (obt_prop_set_strings_##type(win, OBT_PROP_ATOM(prop), strs))
272
273 #define OBT_PROP_ERASE(win, prop) (obt_prop_erase(win, OBT_PROP_ATOM(prop)))
274
275 #define OBT_PROP_MSG(screen, about, msgtype, data0, data1, data2, data3, \
276                      data4) \
277     (obt_prop_message(screen, about, OBT_PROP_ATOM(msgtype), \
278                       data0, data1, data2, data3, data4, \
279                       SubstructureNotifyMask | SubstructureRedirectMask))
280
281 #define OBT_PROP_MSG_TO(to, about, msgtype, data0, data1, data2, data3, \
282                         data4, mask) \
283     (obt_prop_message_to(to, about, OBT_PROP_ATOM(msgtype), \
284                          data0, data1, data2, data3, data4, mask))
285
286 G_END_DECLS
287
288 #endif /* __obt_prop_h */