1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief Provides access to window properties
10 #include "screeninfo.hh"
22 //! The atoms on the X server which this class will cache
25 Atom cardinal
; //!< The atom which represents the Cardinal data type
26 Atom window
; //!< The atom which represents window ids
27 Atom pixmap
; //!< The atom which represents pixmap ids
28 Atom atom
; //!< The atom which represents atom values
29 Atom string
; //!< The atom which represents ascii strings
30 Atom utf8
; //!< The atom which represents utf8-encoded strings
35 Atom wm_colormap_windows
;
38 Atom wm_delete_window
;
47 Atom openbox_show_root_menu
;
48 Atom openbox_show_workspace_menu
;
51 // root window properties
54 Atom net_client_list_stacking
;
55 Atom net_number_of_desktops
;
56 Atom net_desktop_geometry
;
57 Atom net_desktop_viewport
;
58 Atom net_current_desktop
;
59 Atom net_desktop_names
;
60 Atom net_active_window
;
62 Atom net_supporting_wm_check
;
63 // Atom net_virtual_roots;
64 // root window messages
65 Atom net_close_window
;
66 Atom net_wm_moveresize
;
67 // application window properties
68 // Atom net_properties;
70 Atom net_wm_visible_name
;
71 Atom net_wm_icon_name
;
72 Atom net_wm_visible_icon_name
;
74 Atom net_wm_window_type
;
77 // Atom net_wm_icon_geometry;
80 // Atom net_wm_handled_icons;
81 Atom net_wm_allowed_actions
;
82 // application protocols
83 // Atom Atom net_wm_ping;
85 Atom net_wm_window_type_desktop
;
86 Atom net_wm_window_type_dock
;
87 Atom net_wm_window_type_toolbar
;
88 Atom net_wm_window_type_menu
;
89 Atom net_wm_window_type_utility
;
90 Atom net_wm_window_type_splash
;
91 Atom net_wm_window_type_dialog
;
92 Atom net_wm_window_type_normal
;
94 Atom net_wm_moveresize_size_topleft
;
95 Atom net_wm_moveresize_size_topright
;
96 Atom net_wm_moveresize_size_bottomleft
;
97 Atom net_wm_moveresize_size_bottomright
;
98 Atom net_wm_moveresize_move
;
100 Atom net_wm_action_move
;
101 Atom net_wm_action_resize
;
102 Atom net_wm_action_shade
;
103 Atom net_wm_action_maximize_horz
;
104 Atom net_wm_action_maximize_vert
;
105 Atom net_wm_action_change_desktop
;
106 Atom net_wm_action_close
;
108 Atom net_wm_state_modal
;
109 Atom net_wm_state_sticky
;
110 Atom net_wm_state_maximized_vert
;
111 Atom net_wm_state_maximized_horz
;
112 Atom net_wm_state_shaded
;
113 Atom net_wm_state_skip_taskbar
;
114 Atom net_wm_state_skip_pager
;
115 Atom net_wm_state_hidden
;
116 Atom net_wm_state_fullscreen
;
117 Atom net_wm_state_above
;
118 Atom net_wm_state_below
;
120 Atom kde_net_system_tray_windows
;
121 Atom kde_net_wm_system_tray_window_for
;
122 Atom kde_net_wm_window_type_override
;
126 //! Provides easy access to window properties.
130 //! The possible types/encodings of strings
132 ascii
, //!< Standard 8-bit ascii string
133 utf8
, //!< Utf8-encoded string
134 #ifndef DOXYGEN_IGNORE
139 //! A list of ustrings
140 typedef std::vector
<ustring
> StringVect
;
142 //! The value of all atoms on the X server that exist in the
147 //! Sets a property on a window
148 static void set(Window win
, Atom atom
, Atom type
, unsigned char *data
,
149 int size
, int nelements
, bool append
);
150 //! Gets a property's value from a window
151 static bool get(Window win
, Atom atom
, Atom type
,
152 unsigned long *nelements
, unsigned char **value
,
156 //! Initializes the Property class.
158 CAUTION: This function uses otk::Display, so ensure that
159 otk::Display::initialize has been called before initializing this class!
161 static void initialize();
163 //! Sets a single-value property on a window to a new value
165 @param win The window id of the window on which to set the property's value
166 @param atom The Atom value of the property to set. This can be found in the
167 struct returned by Property::atoms.
168 @param type The Atom value of the property type. This can be found in the
169 struct returned by Property::atoms.
170 @param value The value to set the property to
172 static void set(Window win
, Atom atom
, Atom type
, unsigned long value
);
173 //! Sets an multiple-value property on a window to a new value
175 @param win The window id of the window on which to set the property's value
176 @param atom The Atom value of the property to set. This can be found in the
177 struct returned by Property::atoms.
178 @param type The Atom value of the property type. This can be found in the
179 struct returned by Property::atoms.
180 @param value Any array of values to set the property to. The array must
181 contain <i>elements</i> number of elements
182 @param elements The number of elements in the <i>value</i> array
184 static void set(Window win
, Atom atom
, Atom type
,
185 unsigned long value
[], int elements
);
186 //! Sets a string property on a window to a new value
188 @param win The window id of the window on which to set the property's value
189 @param atom The Atom value of the property to set. This can be found in the
190 struct returned by Property::atoms.
191 @param type A member of the Property::StringType enum that specifies the
192 type of the string the property is being set to
193 @param value The string to set the property to
195 static void set(Window win
, Atom atom
, StringType type
,
196 const ustring
&value
);
197 //! Sets a string-array property on a window to a new value
199 @param win The window id of the window on which to set the property's value
200 @param atom The Atom value of the property to set. This can be found in the
201 struct returned by Property::atoms.
202 @param type A member of the Property::StringType enum that specifies the
203 type of the string the property is being set to
204 @param strings A list of strings to set the property to
206 static void set(Window win
, Atom atom
, StringType type
,
207 const StringVect
&strings
);
209 //! Gets the value of a property on a window
211 @param win The window id of the window to get the property value from
212 @param atom The Atom value of the property to set. This can be found in the
213 struct returned by Property::atoms.
214 @param type The Atom value of the property type. This can be found in the
215 struct returned by Property::atoms.
216 @param nelements The maximum number of elements to retrieve from the
217 property (assuming it has more than 1 value in it). To
218 retrieve all possible elements, use "(unsigned) -1".<br>
219 When the function returns, if it returns true, this will
220 contain the actual number of elements retrieved.<br>
221 @param value If the function returns true, then this contains an array of
222 retrieved values for the property.<br>
223 The <i>value</i> is allocated inside the function and
224 <b>delete[]</b> value needs to be called when you are done
226 The <i>value</i> array returned is null terminated, and has
227 <i>nelements</i> elements in it plus the terminating null.
228 @return true if retrieval of the specified property with the specified
229 type was successful; otherwise, false
231 static bool get(Window win
, Atom atom
, Atom type
,
232 unsigned long *nelements
, unsigned long **value
);
233 //! Gets a single element from the value of a property on a window
235 @param win The window id of the window to get the property value from
236 @param atom The Atom value of the property to set. This can be found in the
237 struct returned by Property::atoms.
238 @param type The Atom value of the property type. This can be found in the
239 struct returned by Property::atoms.
240 @param value If the function returns true, then this contains the first
241 (and possibly only) element in the value of the specified
243 @return true if retrieval of the specified property with the specified
244 type was successful; otherwise, false
246 static bool get(Window win
, Atom atom
, Atom type
, unsigned long *value
);
247 //! Gets a single string from the value of a property on a window
249 @param win The window id of the window to get the property value from
250 @param atom The Atom value of the property to set. This can be found in the
251 struct returned by Property::atoms.
252 @param type A member of the Property::StringType enum that specifies the
253 type of the string property to retrieve
254 @param value If the function returns true, then this contains the first
255 (and possibly only) string in the value of the specified
257 @return true if retrieval of the specified property with the specified
258 type was successful; otherwise, false
260 static bool get(Window win
, Atom atom
, StringType type
, ustring
*value
);
261 //! Gets strings from the value of a property on a window
263 @param win The window id of the window to get the property value from
264 @param atom The Atom value of the property to set. This can be found in the
265 struct returned by Property::atoms.
266 @param type A member of the Property::StringType enum that specifies the
267 type of the string property to retrieve
268 @param nelements The maximum number of strings to retrieve from the
269 property (assuming it has more than 1 string in it). To
270 retrieve all possible strings, use "(unsigned) -1".<br>
271 When the function returns, if it returns true, this will
272 contain the actual number of strings retrieved.<br>
273 @param strings If the function returns true, then this contains all of the
274 strings retrieved from the property's value.
275 @return true if retrieval of the specified property with the specified
276 type was successful; otherwise, false
278 static bool get(Window win
, Atom atom
, StringType type
,
279 unsigned long *nelements
, StringVect
*strings
);
281 //! Removes a property from a window
283 @param win The window id of the window to remove the property from
284 @param atom The Atom value of the property to set. This can be found in the
285 struct returned by Property::atoms.
287 static void erase(Window win
, Atom atom
);