1 // -*- mode: C++; indent-tabs-mode: nil; -*-
6 @brief Provides access to window properties
11 #include <X11/Xatom.h>
19 #include "screeninfo.hh"
23 //! Provides easy access to window properties.
26 //! The atoms on the X server which this class will cache
29 Atom_Cardinal
, //!< The atom which represents the Cardinal data type
30 Atom_Window
, //!< The atom which represents window ids
31 Atom_Pixmap
, //!< The atom which represents pixmap ids
32 Atom_Atom
, //!< The atom which represents atom values
33 Atom_String
, //!< The atom which represents ascii strings
34 Atom_Utf8
, //!< The atom which represents utf8-encoded strings
52 blackbox_change_attributes
,
55 // blackbox-protocol atoms (wm -> client)
56 blackbox_structure_messages
,
57 blackbox_notify_startup
,
58 blackbox_notify_window_add
,
59 blackbox_notify_window_del
,
60 blackbox_notify_window_focus
,
61 blackbox_notify_current_workspace
,
62 blackbox_notify_workspace_count
,
63 blackbox_notify_window_raise
,
64 blackbox_notify_window_lower
,
65 // blackbox-protocol atoms (client -> wm)
66 blackbox_change_workspace
,
67 blackbox_change_window_focus
,
68 blackbox_cycle_window_focus
,
70 openbox_show_root_menu
,
71 openbox_show_workspace_menu
,
74 // root window properties
77 net_client_list_stacking
,
78 net_number_of_desktops
,
85 net_supporting_wm_check
,
87 // root window messages
90 // application window properties
95 net_wm_visible_icon_name
,
100 // net_wm_icon_geometry,
103 // net_wm_handled_icons,
104 net_wm_allowed_actions
,
105 // application protocols
108 net_wm_window_type_desktop
,
109 net_wm_window_type_dock
,
110 net_wm_window_type_toolbar
,
111 net_wm_window_type_menu
,
112 net_wm_window_type_utility
,
113 net_wm_window_type_splash
,
114 net_wm_window_type_dialog
,
115 net_wm_window_type_normal
,
117 net_wm_moveresize_size_topleft
,
118 net_wm_moveresize_size_topright
,
119 net_wm_moveresize_size_bottomleft
,
120 net_wm_moveresize_size_bottomright
,
121 net_wm_moveresize_move
,
124 net_wm_action_resize
,
126 net_wm_action_maximize_horz
,
127 net_wm_action_maximize_vert
,
128 net_wm_action_change_desktop
,
132 net_wm_state_maximized_vert
,
133 net_wm_state_maximized_horz
,
135 net_wm_state_skip_taskbar
,
136 net_wm_state_skip_pager
,
138 net_wm_state_fullscreen
,
140 kde_net_system_tray_windows
,
141 kde_net_wm_system_tray_window_for
,
142 kde_net_wm_window_type_override
,
144 #ifndef DOXYGEN_IGNORE
145 // constant for how many atoms exist in the enumerator
150 //! The possible types/encodings of strings
152 ascii
, //!< Standard 8-bit ascii string
153 utf8
, //!< Utf8-encoded string
154 #ifndef DOXYGEN_IGNORE
160 //! The value of all atoms on the X server that exist in the
161 //! OBProperty::Atoms enum
162 Atom _atoms
[NUM_ATOMS
];
164 //! Gets the value of an Atom from the X server, creating it if nessesary
165 Atom
create(const char *name
) const;
167 //! Sets a property on a window
168 void set(Window win
, Atom atom
, Atom type
, unsigned char *data
,
169 int size
, int nelements
, bool append
) const;
170 //! Gets a property's value from a window
171 bool get(Window win
, Atom atom
, Atom type
,
172 unsigned long *nelements
, unsigned char **value
,
176 //! A list of strings
177 typedef std::vector
<std::string
> StringVect
;
179 //! Constructs a new OBAtom object
181 CAUTION: This constructor uses OBDisplay::display, so ensure that it is
182 initialized before initializing this class!
185 //! Destroys the OBAtom object
186 virtual ~OBProperty();
188 //! Sets a single-value property on a window to a new value
190 @param win The window id of the window on which to set the property's value
191 @param atom A member of the OBProperty::Atoms enum that specifies which
193 @param type A member of the OBProperty::Atoms enum that specifies the type
194 of the property to set
195 @param value The value to set the property to
197 void set(Window win
, Atoms atom
, Atoms type
, unsigned long value
) const;
198 //! Sets an multiple-value property on a window to a new value
200 @param win The window id of the window on which to set the property's value
201 @param atom A member of the OBProperty::Atoms enum that specifies which
203 @param type A member of the OBProperty::Atoms enum that specifies the type
204 of the property to set
205 @param value Any array of values to set the property to. The array must
206 contain <i>elements</i> number of elements
207 @param elements The number of elements in the <i>value</i> array
209 void set(Window win
, Atoms atom
, Atoms type
,
210 unsigned long value
[], int elements
) const;
211 //! Sets a string property on a window to a new value
213 @param win The window id of the window on which to set the property's value
214 @param atom A member of the OBProperty::Atoms enum that specifies which
216 @param type A member of the OBProperty::StringType enum that specifies the
217 type of the string the property is being set to
218 @param value The string to set the property to
220 void set(Window win
, Atoms atom
, StringType type
,
221 const std::string
&value
) const;
222 //! Sets a string-array property on a window to a new value
224 @param win The window id of the window on which to set the property's value
225 @param atom A member of the OBProperty::Atoms enum that specifies which
227 @param type A member of the OBProperty::StringType enum that specifies the
228 type of the string the property is being set to
229 @param strings A list of strings to set the property to
231 void set(Window win
, Atoms atom
, StringType type
,
232 const StringVect
&strings
) const;
234 //! Gets the value of a property on a window
236 @param win The window id of the window to get the property value from
237 @param atom A member of the OBProperty::Atoms enum that specifies which
239 @param type A member of the OBProperty::Atoms enum that specifies the type
240 of the property to retrieve
241 @param nelements The maximum number of elements to retrieve from the
242 property (assuming it has more than 1 value in it). To
243 retrieve all possible elements, use "(unsigned) -1".<br>
244 When the function returns, if it returns true, this will
245 contain the actual number of elements retrieved.<br>
246 @param value If the function returns true, then this contains an array of
247 retrieved values for the property.<br>
248 The <i>value</i> is allocated inside the function and
249 <b>delete[]</b> value needs to be called when you are done
251 The <i>value</i> array returned is null terminated, and has
252 <i>nelements</i> elements in it plus the terminating null.
253 @return true if retrieval of the specified property with the specified
254 type was successful; otherwise, false
256 bool get(Window win
, Atoms atom
, Atoms type
,
257 unsigned long *nelements
, unsigned long **value
) const;
258 //! Gets a single element from the value of a property on a window
260 @param win The window id of the window to get the property value from
261 @param atom A member of the OBProperty::Atoms enum that specifies which
263 @param type A member of the OBProperty::Atoms enum that specifies the type
264 of the property to retrieve
265 @param value If the function returns true, then this contains the first
266 (and possibly only) element in the value of the specified
268 @return true if retrieval of the specified property with the specified
269 type was successful; otherwise, false
271 bool get(Window win
, Atoms atom
, Atoms type
, unsigned long *value
) const;
272 //! Gets a single string from the value of a property on a window
274 @param win The window id of the window to get the property value from
275 @param atom A member of the OBProperty::Atoms enum that specifies which
277 @param type A member of the OBProperty::StringType enum that specifies the
278 type of the string property to retrieve
279 @param value If the function returns true, then this contains the first
280 (and possibly only) string in the value of the specified
282 @return true if retrieval of the specified property with the specified
283 type was successful; otherwise, false
285 bool get(Window win
, Atoms atom
, StringType type
, std::string
*value
) const;
286 //! Gets strings from the value of a property on a window
288 @param win The window id of the window to get the property value from
289 @param atom A member of the OBProperty::Atoms enum that specifies which
291 @param type A member of the OBProperty::StringType enum that specifies the
292 type of the string property to retrieve
293 @param nelements The maximum number of strings to retrieve from the
294 property (assuming it has more than 1 string in it). To
295 retrieve all possible strings, use "(unsigned) -1".<br>
296 When the function returns, if it returns true, this will
297 contain the actual number of strings retrieved.<br>
298 @param strings If the function returns true, then this contains all of the
299 strings retrieved from the property's value.
300 @return true if retrieval of the specified property with the specified
301 type was successful; otherwise, false
303 bool get(Window win
, Atoms atom
, StringType type
,
304 unsigned long *nelements
, StringVect
*strings
) const;
306 //! Removes a property from a window
308 @param win The window id of the window to remove the property from
309 @param atom A member of the OBProperty::Atoms enum that specifies which
310 property to remove from the window
312 void erase(Window win
, Atoms atom
) const;
314 //! Gets the value of an atom on the X server
316 @param a A member of the OBProperty::Atoms enum that specifies which Atom's
318 @return The value of the specified Atom
320 inline Atom
atom(Atoms a
) {
321 assert(a
>= 0 && a
< NUM_ATOMS
); Atom ret
= _atoms
[a
]; assert(ret
!= 0);