93821c87887bba57143406ef22b89dbf62d4dbdf
[mikachu/openbox.git] / openbox / prop.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    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 __atoms_h
21 #define __atoms_h
22
23 #include <X11/Xlib.h>
24 #include <glib.h>
25 #ifdef HAVE_STRING_H
26 #  include <string.h>
27 #endif
28
29 /*! The atoms on the X server which this class will cache */
30 typedef struct Atoms {
31     /* types */
32     Atom cardinal; /*!< The atom which represents the Cardinal data type */
33     Atom window;   /*!< The atom which represents window ids */
34     Atom pixmap;   /*!< The atom which represents pixmap ids */
35     Atom atom;     /*!< The atom which represents atom values */
36     Atom string;   /*!< The atom which represents ascii strings */
37     Atom utf8;     /*!< The atom which represents utf8-encoded strings */
38
39     /* selection stuff */
40     Atom manager;
41
42     /* window hints */
43     Atom wm_colormap_windows;
44     Atom wm_protocols;
45     Atom wm_state;
46     Atom wm_delete_window;
47     Atom wm_take_focus;
48     Atom wm_change_state;
49     Atom wm_name;
50     Atom wm_icon_name;
51     Atom wm_class;
52     Atom wm_window_role;
53     Atom wm_client_machine;
54     Atom wm_command;
55     Atom wm_client_leader;
56     Atom motif_wm_hints;
57
58     /* SM atoms */
59     Atom sm_client_id;
60
61     /* NETWM atoms */
62
63     /* Atoms that are used inside messages - these don't go in net_supported */
64
65     Atom net_wm_moveresize_size_topleft; 
66     Atom net_wm_moveresize_size_top;
67     Atom net_wm_moveresize_size_topright;
68     Atom net_wm_moveresize_size_right;
69     Atom net_wm_moveresize_size_bottomright;
70     Atom net_wm_moveresize_size_bottom;
71     Atom net_wm_moveresize_size_bottomleft;
72     Atom net_wm_moveresize_size_left;
73     Atom net_wm_moveresize_move;
74     Atom net_wm_moveresize_size_keyboard;
75     Atom net_wm_moveresize_move_keyboard;
76     Atom net_wm_moveresize_cancel;
77
78     Atom net_wm_state_add;
79     Atom net_wm_state_remove;
80     Atom net_wm_state_toggle;
81
82     Atom net_wm_orientation_horz;
83     Atom net_wm_orientation_vert;
84     Atom net_wm_topleft;
85     Atom net_wm_topright;
86     Atom net_wm_bottomright;
87     Atom net_wm_bottomleft;
88
89     /* Everything below here must go in net_supported on the root window */
90
91     /* root window properties */
92     Atom net_supported;
93     Atom net_client_list;
94     Atom net_client_list_stacking;
95     Atom net_number_of_desktops;
96     Atom net_desktop_geometry;
97     Atom net_desktop_viewport;
98     Atom net_current_desktop;
99     Atom net_desktop_names;
100     Atom net_active_window;
101 /*    Atom net_restack_window;*/
102     Atom net_workarea;
103     Atom net_supporting_wm_check;
104     Atom net_desktop_layout;
105     Atom net_showing_desktop;
106
107     /* root window messages */
108     Atom net_close_window;
109     Atom net_wm_moveresize;
110     Atom net_moveresize_window;
111     Atom net_request_frame_extents;
112     Atom net_restack_window;
113
114     /* helpful hints to apps that aren't used for anything */
115     Atom net_wm_full_placement;
116
117     /* startup-notification extension */
118     Atom net_startup_id;
119
120     /* application window properties */
121     Atom net_wm_name;
122     Atom net_wm_visible_name;
123     Atom net_wm_icon_name;
124     Atom net_wm_visible_icon_name;
125     Atom net_wm_desktop;
126     Atom net_wm_window_type;
127     Atom net_wm_state;
128     Atom net_wm_strut;
129     Atom net_wm_strut_partial;
130     Atom net_wm_icon;
131     Atom net_wm_icon_geometry;
132 /*  Atom net_wm_pid; */
133     Atom net_wm_allowed_actions;
134     Atom net_wm_user_time;
135     Atom net_wm_user_time_window;
136     Atom net_frame_extents;
137
138     /* application protocols */
139 /*  Atom net_wm_ping; */
140 #ifdef SYNC
141     Atom net_wm_sync_request;
142     Atom net_wm_sync_request_counter;
143 #endif
144
145     Atom net_wm_window_type_desktop;
146     Atom net_wm_window_type_dock;
147     Atom net_wm_window_type_toolbar;
148     Atom net_wm_window_type_menu;
149     Atom net_wm_window_type_utility;
150     Atom net_wm_window_type_splash;
151     Atom net_wm_window_type_dialog;
152     Atom net_wm_window_type_normal;
153
154     Atom net_wm_action_move;
155     Atom net_wm_action_resize;
156     Atom net_wm_action_minimize;
157     Atom net_wm_action_shade;
158 /*    Atom net_wm_action_stick;*/
159     Atom net_wm_action_maximize_horz;
160     Atom net_wm_action_maximize_vert;
161     Atom net_wm_action_fullscreen;
162     Atom net_wm_action_change_desktop;
163     Atom net_wm_action_close;
164     Atom net_wm_action_above;
165     Atom net_wm_action_below;
166
167     Atom net_wm_state_modal;
168 /*    Atom net_wm_state_sticky;*/
169     Atom net_wm_state_maximized_vert;
170     Atom net_wm_state_maximized_horz;
171     Atom net_wm_state_shaded;
172     Atom net_wm_state_skip_taskbar;
173     Atom net_wm_state_skip_pager;
174     Atom net_wm_state_hidden;
175     Atom net_wm_state_fullscreen;
176     Atom net_wm_state_above;
177     Atom net_wm_state_below;
178     Atom net_wm_state_demands_attention;
179
180     /* KDE atoms */
181
182     Atom kde_wm_change_state;
183     Atom kde_net_wm_frame_strut;
184     Atom kde_net_wm_window_type_override;
185
186 /*
187     Atom rootpmapid;
188     Atom esetrootid;
189 */
190
191     /* Openbox specific atoms */
192      
193     Atom ob_wm_action_undecorate;
194     Atom ob_wm_state_undecorated;
195     Atom openbox_pid; /* this is depreecated in favour of ob_control */
196     Atom ob_control;
197 } Atoms;
198 Atoms prop_atoms;
199
200 void prop_startup();
201
202 gboolean prop_get32(Window win, Atom prop, Atom type, guint32 *ret);
203 gboolean prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
204                           guint *nret);
205 gboolean prop_get_string_locale(Window win, Atom prop, gchar **ret);
206 gboolean prop_get_string_utf8(Window win, Atom prop, gchar **ret);
207 gboolean prop_get_strings_locale(Window win, Atom prop, gchar ***ret);
208 gboolean prop_get_strings_utf8(Window win, Atom prop, gchar ***ret);
209
210 void prop_set32(Window win, Atom prop, Atom type, gulong val);
211 void prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
212                       guint num);
213 void prop_set_string_utf8(Window win, Atom prop, const gchar *val);
214 void prop_set_strings_utf8(Window win, Atom prop, gchar **strs);
215
216 void prop_erase(Window win, Atom prop);
217
218 void prop_message(Window about, Atom messagetype, glong data0, glong data1,
219                   glong data2, glong data3, glong mask);
220
221 #define PROP_GET32(win, prop, type, ret) \
222     (prop_get32(win, prop_atoms.prop, prop_atoms.type, ret))
223 #define PROP_GETA32(win, prop, type, ret, nret) \
224     (prop_get_array32(win, prop_atoms.prop, prop_atoms.type, ret, \
225                       nret))
226 #define PROP_GETS(win, prop, type, ret) \
227     (prop_get_string_##type(win, prop_atoms.prop, ret))
228 #define PROP_GETSS(win, prop, type, ret) \
229     (prop_get_strings_##type(win, prop_atoms.prop, ret))
230
231 #define PROP_SET32(win, prop, type, val) \
232     prop_set32(win, prop_atoms.prop, prop_atoms.type, val)
233 #define PROP_SETA32(win, prop, type, val, num) \
234     prop_set_array32(win, prop_atoms.prop, prop_atoms.type, val, num)
235 #define PROP_SETS(win, prop, val) \
236     prop_set_string_utf8(win, prop_atoms.prop, val)
237 #define PROP_SETSS(win, prop, strs) \
238     prop_set_strings_utf8(win, prop_atoms.prop, strs)
239
240 #define PROP_ERASE(win, prop) prop_erase(win, prop_atoms.prop)
241
242 #define PROP_MSG(about, msgtype, data0, data1, data2, data3) \
243   (prop_message(about, prop_atoms.msgtype, data0, data1, data2, data3, \
244                 SubstructureNotifyMask | SubstructureRedirectMask))
245
246 #endif