add prop.[ch] to the libobt, but they are not used yet. add a global obt_display...
[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_MOTIF_WM_HINTS,
55
56     /* SM atoms */
57     OBT_PROP_SM_CLIENT_ID,
58
59     /* NETWM atoms */
60
61     /* Atoms that are used inside messages - these don't go in net_supported */
62
63     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT,
64     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP,
65     OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT,
66     OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT,
67     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT,
68     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM,
69     OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT,
70     OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT,
71     OBT_PROP_NET_WM_MOVERESIZE_MOVE,
72     OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD,
73     OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD,
74     OBT_PROP_NET_WM_MOVERESIZE_CANCEL,
75
76     OBT_PROP_NET_WM_STATE_ADD,
77     OBT_PROP_NET_WM_STATE_REMOVE,
78     OBT_PROP_NET_WM_STATE_TOGGLE,
79
80     OBT_PROP_NET_WM_ORIENTATION_HORZ,
81     OBT_PROP_NET_WM_ORIENTATION_VERT,
82     OBT_PROP_NET_WM_TOPLEFT,
83     OBT_PROP_NET_WM_TOPRIGHT,
84     OBT_PROP_NET_WM_BOTTOMRIGHT,
85     OBT_PROP_NET_WM_BOTTOMLEFT,
86
87     /* Everything below here must go in net_supported on the root window */
88
89     /* root window properties */
90     OBT_PROP_NET_SUPPORTED,
91     OBT_PROP_NET_CLIENT_LIST,
92     OBT_PROP_NET_CLIENT_LIST_STACKING,
93     OBT_PROP_NET_NUMBER_OF_DESKTOPS,
94     OBT_PROP_NET_DESKTOP_GEOMETRY,
95     OBT_PROP_NET_DESKTOP_VIEWPORT,
96     OBT_PROP_NET_CURRENT_DESKTOP,
97     OBT_PROP_NET_DESKTOP_NAMES,
98     OBT_PROP_NET_ACTIVE_WINDOW,
99 /*    Atom net_restack_window;*/
100     OBT_PROP_NET_WORKAREA,
101     OBT_PROP_NET_SUPPORTING_WM_CHECK,
102     OBT_PROP_NET_DESKTOP_LAYOUT,
103     OBT_PROP_NET_SHOWING_DESKTOP,
104
105     /* root window messages */
106     OBT_PROP_NET_CLOSE_WINDOW,
107     OBT_PROP_NET_WM_MOVERESIZE,
108     OBT_PROP_NET_MOVERESIZE_WINDOW,
109     OBT_PROP_NET_REQUEST_FRAME_EXTENTS,
110     OBT_PROP_NET_RESTACK_WINDOW,
111
112     /* helpful hints to apps that aren't used for anything */
113     OBT_PROP_NET_WM_FULL_PLACEMENT,
114
115     /* startup-notification extension */
116     OBT_PROP_NET_STARTUP_ID,
117
118     /* application window properties */
119     OBT_PROP_NET_WM_NAME,
120     OBT_PROP_NET_WM_VISIBLE_NAME,
121     OBT_PROP_NET_WM_ICON_NAME,
122     OBT_PROP_NET_WM_VISIBLE_ICON_NAME,
123     OBT_PROP_NET_WM_DESKTOP,
124     OBT_PROP_NET_WM_WINDOW_TYPE,
125     OBT_PROP_NET_WM_STATE,
126     OBT_PROP_NET_WM_STRUT,
127     OBT_PROP_NET_WM_STRUT_PARTIAL,
128     OBT_PROP_NET_WM_ICON,
129     OBT_PROP_NET_WM_ICON_GEOMETRY,
130 /*  OBT_PROP_NET_WM_PID, */
131     OBT_PROP_NET_WM_ALLOWED_ACTIONS,
132     OBT_PROP_NET_WM_USER_TIME,
133     OBT_PROP_NET_WM_USER_TIME_WINDOW,
134     OBT_PROP_NET_FRAME_EXTENTS,
135
136     /* application protocols */
137 /*  OBT_PROP_NET_WM_PING, */
138 #ifdef SYNC
139     OBT_PROP_NET_WM_SYNC_REQUEST,
140     OBT_PROP_NET_WM_SYNC_REQUEST_COUNTER,
141 #endif
142
143     OBT_PROP_NET_WM_WINDOW_TYPE_DESKTOP,
144     OBT_PROP_NET_WM_WINDOW_TYPE_DOCK,
145     OBT_PROP_NET_WM_WINDOW_TYPE_TOOLBAR,
146     OBT_PROP_NET_WM_WINDOW_TYPE_MENU,
147     OBT_PROP_NET_WM_WINDOW_TYPE_UTILITY,
148     OBT_PROP_NET_WM_WINDOW_TYPE_SPLASH,
149     OBT_PROP_NET_WM_WINDOW_TYPE_DIALOG,
150     OBT_PROP_NET_WM_WINDOW_TYPE_NORMAL,
151
152     OBT_PROP_NET_WM_ACTION_MOVE,
153     OBT_PROP_NET_WM_ACTION_RESIZE,
154     OBT_PROP_NET_WM_ACTION_MINIMIZE,
155     OBT_PROP_NET_WM_ACTION_SHADE,
156 /*    OBT_PROP_NET_WM_ACTION_STICK,*/
157     OBT_PROP_NET_WM_ACTION_MAXIMIZE_HORZ,
158     OBT_PROP_NET_WM_ACTION_MAXIMIZE_VERT,
159     OBT_PROP_NET_WM_ACTION_FULLSCREEN,
160     OBT_PROP_NET_WM_ACTION_CHANGE_DESKTOP,
161     OBT_PROP_NET_WM_ACTION_CLOSE,
162     OBT_PROP_NET_WM_ACTION_ABOVE,
163     OBT_PROP_NET_WM_ACTION_BELOW,
164
165     OBT_PROP_NET_WM_STATE_MODAL,
166 /*    OBT_PROP_NET_WM_STATE_STICKY,*/
167     OBT_PROP_NET_WM_STATE_MAXIMIZED_VERT,
168     OBT_PROP_NET_WM_STATE_MAXIMIZED_HORZ,
169     OBT_PROP_NET_WM_STATE_SHADED,
170     OBT_PROP_NET_WM_STATE_SKIP_TASKBAR,
171     OBT_PROP_NET_WM_STATE_SKIP_PAGER,
172     OBT_PROP_NET_WM_STATE_HIDDEN,
173     OBT_PROP_NET_WM_STATE_FULLSCREEN,
174     OBT_PROP_NET_WM_STATE_ABOVE,
175     OBT_PROP_NET_WM_STATE_BELOW,
176     OBT_PROP_NET_WM_STATE_DEMANDS_ATTENTION,
177
178     /* KDE atoms */
179
180     OBT_PROP_KDE_WM_CHANGE_STATE,
181     OBT_PROP_KDE_NET_WM_FRAME_STRUT,
182     OBT_PROP_KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
183
184 /*
185     OBT_PROP_ROOTPMAPID,
186     OBT_PROP_ESETROOTID,
187 */
188
189     /* Openbox specific atoms */
190
191     OBT_PROP_OB_WM_ACTION_UNDECORATE,
192     OBT_PROP_OB_WM_STATE_UNDECORATED,
193     OBT_PROP_OPENBOX_PID, /* this is depreecated in favour of ob_control */
194     OBT_PROP_OB_THEME,
195     OBT_PROP_OB_CONTROL,
196
197     OBT_PROP_NUM_ATOMS
198 } ObtPropAtom;
199
200 #define OB_PROP_NUM_PUBLIC_ATOMS (OB_PROP_NUM_ATOMS - OB_PROP_NET_SUPPORTED)
201
202 void obt_prop_startup();
203
204 Atom obt_prop_atom(ObtPropAtom a);
205
206 gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret);
207 gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
208                               guint *nret);
209 gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret);
210 gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret);
211 gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret);
212 gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret);
213
214 void obt_prop_set32(Window win, Atom prop, Atom type, gulong val);
215 void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
216                           guint num);
217 void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val);
218 void obt_prop_set_strings_utf8(Window win, Atom prop, gchar **strs);
219
220 void obt_prop_erase(Window win, Atom prop);
221
222 void obt_prop_message(gint screen, Window about, Atom messagetype,
223                       glong data0, glong data1, glong data2, glong data3,
224                       glong data4, glong mask);
225
226 #define PROP_GET32(win, prop, type, ret) \
227     (prop_get32(win, obt_prop_atom(OB_PROP_##prop), prop_atoms.type, ret))
228 #define PROP_GETA32(win, prop, type, ret, nret) \
229     (prop_get_array32(win, obt_prop_atom(OB_PROP_##prop), prop_atoms.type, \
230                       ret, nret))
231 #define PROP_GETS(win, prop, type, ret) \
232     (prop_get_string_##type(win, obt_prop_atom(OB_PROP_##prop), ret))
233 #define PROP_GETSS(win, prop, type, ret) \
234     (prop_get_strings_##type(win, obt_prop_atom(OB_PROP_##prop), ret))
235
236 #define PROP_SET32(win, prop, type, val) \
237     prop_set32(win, obt_prop_atom(OB_PROP_##prop), \
238                obt_prop_atom(OB_PROP_##type), val)
239 #define PROP_SETA32(win, prop, type, val, num) \
240     prop_set_array32(win, obt_prop_atom(OB_PROP_##prop), \
241                      obt_prop_atom(OB_PROP_##type), val, num)
242 #define PROP_SETS(win, prop, val) \
243     prop_set_string_utf8(win, obt_prop_atom(OB_PROP_##prop), val)
244 #define PROP_SETSS(win, prop, strs) \
245     prop_set_strings_utf8(win, obt_prop_atom(OB_PROP_##prop), strs)
246
247 #define PROP_ERASE(win, prop) prop_erase(win, obt_prop_atom(OB_PROP_##prop))
248
249 #define PROP_MSG(screen, about, msgtype, data0, data1, data2, data3, data4) \
250   (prop_message(screen, about, obt_prop_atom(OB_PROP_##msgtype), \
251                 data0, data1, data2, data3, data4, \
252                 SubstructureNotifyMask | SubstructureRedirectMask))
253
254 G_END_DECLS
255
256 #endif /* __obt_prop_h */