]> icculus.org git repositories - dana/openbox.git/blob - openbox/prop.h
resize resistance. size incs will fuck with it yet though.
[dana/openbox.git] / openbox / prop.h
1 #ifndef __atoms_h
2 #define __atoms_h
3
4 #include <X11/Xlib.h>
5 #include <glib.h>
6 #ifdef HAVE_STRING_H
7 #  include <string.h>
8 #endif
9
10 #include "openbox.h"
11
12 /*! The atoms on the X server which this class will cache */
13 typedef struct Atoms {
14     /* types */
15     Atom cardinal; /*!< The atom which represents the Cardinal data type */
16     Atom window;   /*!< The atom which represents window ids */
17     Atom pixmap;   /*!< The atom which represents pixmap ids */
18     Atom atom;     /*!< The atom which represents atom values */
19     Atom string;   /*!< The atom which represents ascii strings */
20     Atom utf8;     /*!< The atom which represents utf8-encoded strings */
21
22     /* window hints */
23     Atom wm_colormap_windows;
24     Atom wm_protocols;
25     Atom wm_state;
26     Atom wm_delete_window;
27     Atom wm_take_focus;
28     Atom wm_change_state;
29     Atom wm_name;
30     Atom wm_icon_name;
31     Atom wm_class;
32     Atom wm_window_role;
33     Atom motif_wm_hints;
34
35     /* NETWM atoms */
36      
37     /* root window properties */
38     Atom net_supported;
39     Atom net_client_list;
40     Atom net_client_list_stacking;
41     Atom net_number_of_desktops;
42     Atom net_desktop_geometry;
43     Atom net_desktop_viewport;
44     Atom net_current_desktop;
45     Atom net_desktop_names;
46     Atom net_active_window;
47     Atom net_workarea;
48     Atom net_supporting_wm_check;
49 /*  Atom net_virtual_roots; */
50     Atom net_desktop_layout;
51     Atom net_showing_desktop;
52     /* root window messages */
53     Atom net_close_window;
54     Atom net_wm_moveresize;
55     /* application window properties */
56 /*  Atom net_properties; */
57     Atom net_wm_name;
58     Atom net_wm_visible_name;
59     Atom net_wm_icon_name;
60     Atom net_wm_visible_icon_name;
61     Atom net_wm_desktop;
62     Atom net_wm_window_type;
63     Atom net_wm_state;
64     Atom net_wm_strut;
65 /*  Atom net_wm_icon_geometry; */
66     Atom net_wm_icon;
67 /*  Atom net_wm_pid; */
68 /*  Atom net_wm_handled_icons; */
69     Atom net_wm_allowed_actions;
70     /* application protocols */
71 /*  Atom   Atom net_wm_ping; */
72
73     Atom net_wm_window_type_desktop;
74     Atom net_wm_window_type_dock;
75     Atom net_wm_window_type_toolbar;
76     Atom net_wm_window_type_menu;
77     Atom net_wm_window_type_utility;
78     Atom net_wm_window_type_splash;
79     Atom net_wm_window_type_dialog;
80     Atom net_wm_window_type_normal;
81
82     Atom net_wm_moveresize_size_topleft;
83     Atom net_wm_moveresize_size_topright;
84     Atom net_wm_moveresize_size_bottomleft;
85     Atom net_wm_moveresize_size_bottomright;
86     Atom net_wm_moveresize_move;
87
88     Atom net_wm_action_move;
89     Atom net_wm_action_resize;
90     Atom net_wm_action_minimize;
91     Atom net_wm_action_shade;
92     Atom net_wm_action_stick;
93     Atom net_wm_action_maximize_horz;
94     Atom net_wm_action_maximize_vert;
95     Atom net_wm_action_fullscreen;
96     Atom net_wm_action_change_desktop;
97     Atom net_wm_action_close;
98
99     Atom net_wm_state_modal;
100     Atom net_wm_state_sticky;
101     Atom net_wm_state_maximized_vert;
102     Atom net_wm_state_maximized_horz;
103     Atom net_wm_state_shaded;
104     Atom net_wm_state_skip_taskbar;
105     Atom net_wm_state_skip_pager;
106     Atom net_wm_state_hidden;
107     Atom net_wm_state_fullscreen;
108     Atom net_wm_state_above;
109     Atom net_wm_state_below;
110
111     Atom net_wm_state_add;
112     Atom net_wm_state_remove;
113     Atom net_wm_state_toggle;
114
115     Atom net_wm_orientation_horz;
116     Atom net_wm_orientation_vert;
117     Atom net_wm_topleft;
118     Atom net_wm_topright;
119     Atom net_wm_bottomright;
120     Atom net_wm_bottomleft;
121
122     /* Extra atoms */
123
124     Atom kde_net_system_tray_windows;
125     Atom kde_net_wm_system_tray_window_for;
126     Atom kde_net_wm_window_type_override;
127
128     Atom kwm_win_icon;
129
130     Atom rootpmapid;
131     Atom esetrootid;
132
133     /* Openbox specific atoms */
134      
135     Atom openbox_pid;
136     Atom openbox_premax;
137 } Atoms;
138 Atoms prop_atoms;
139
140 void prop_startup();
141
142 gboolean prop_get(Window win, Atom prop, Atom type, int size,
143                         guchar **data, gulong num);
144
145 gboolean prop_get_prealloc(Window win, Atom prop, Atom type, int size,
146                            guchar *data, gulong num);
147
148 gboolean prop_get_all(Window win, Atom prop, Atom type, int size,
149                       guchar **data, gulong *num);
150
151 gboolean prop_get_string(Window win, Atom prop, Atom type, guchar **data);
152 gboolean prop_get_strings(Window win, Atom prop, Atom type,
153                           GPtrArray *data);
154
155 void prop_set_strings(Window win, Atom prop, Atom type, GPtrArray *data);
156
157 void prop_erase(Window win, Atom prop);
158
159 void prop_message(Window about, Atom messagetype, long data0, long data1,
160                   long data2, long data3);
161
162 #define PROP_MSG(about, msgtype, data0, data1, data2, data3) \
163   (prop_message(about, prop_atoms.msgtype, data0, data1, data2, data3))
164
165 /* Set an 8-bit property from a string */
166 #define PROP_SETS(win, prop, type, value) \
167   (XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 8, \
168                    PropModeReplace, (guchar*)value, strlen(value)))
169 /* Set an 8-bit property array from a GPtrArray of strings */
170 #define PROP_SETSA(win, prop, type, value) \
171   (prop_set_strings(win, prop_atoms.prop, prop_atoms.type, value))
172
173 /* Set a 32-bit property from a single value */
174 #define PROP_SET32(win, prop, type, value) \
175   (XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
176                    PropModeReplace, (guchar*)&value, 1))
177 /* Set a 32-bit property from an array */
178 #define PROP_SET32A(win, prop, type, value, num) \
179   (XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
180                    PropModeReplace, (guchar*)value, num))
181
182 /* Get an 8-bit property into a string */
183 #define PROP_GETS(win, prop, type, value) \
184   (prop_get_string(win, prop_atoms.prop, prop_atoms.type, \
185                    (guchar**)&value))
186 /* Get an 8-bit property into a GPtrArray of strings
187    (The strings must be freed, the GPtrArray must already be created.) */
188 #define PROP_GETSA(win, prop, type, value) \
189   (prop_get_strings(win, prop_atoms.prop, prop_atoms.type, \
190                     value))
191
192 /* Get an entire 8-bit property into an array (which must be freed) */
193 #define PROP_GET8U(win, prop, type, value, num) \
194   (prop_get_all(win, prop_atoms.prop, prop_atoms.type, 8, \
195                 (guchar**)&value, &num))
196
197 /* Get 1 element of a 32-bit property into a given variable */
198 #define PROP_GET32(win, prop, type, value) \
199   (prop_get_prealloc(win, prop_atoms.prop, prop_atoms.type, 32, \
200                      (guchar*)&value, 1))
201
202 /* Get an amount of a 32-bit property into an array (which must be freed) */
203 #define PROP_GET32A(win, prop, type, value, num) \
204   (prop_get(win, prop_atoms.prop, prop_atoms.type, 32, \
205             (guchar**)&value, num))
206
207 /* Get an entire 32-bit property into an array (which must be freed) */
208 #define PROP_GET32U(win, prop, type, value, num) \
209   (prop_get_all(win, prop_atoms.prop, prop_atoms.type, 32, \
210                 (guchar**)&value, &num))
211
212 #define PROP_ERASE(win, prop) (prop_erase(win, prop_atoms.prop))
213
214 #endif