1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief Provides access to window properties
10 #include "screeninfo.hh"
21 //! The atoms on the X server which this class will cache
24 Atom cardinal
; //!< The atom which represents the Cardinal data type
25 Atom window
; //!< The atom which represents window ids
26 Atom pixmap
; //!< The atom which represents pixmap ids
27 Atom atom
; //!< The atom which represents atom values
28 Atom string
; //!< The atom which represents ascii strings
29 Atom utf8
; //!< The atom which represents utf8-encoded strings
34 Atom wm_colormap_windows
;
37 Atom wm_delete_window
;
46 Atom openbox_show_root_menu
;
47 Atom openbox_show_workspace_menu
;
50 // root window properties
53 Atom net_client_list_stacking
;
54 Atom net_number_of_desktops
;
55 Atom net_desktop_geometry
;
56 Atom net_desktop_viewport
;
57 Atom net_current_desktop
;
58 Atom net_desktop_names
;
59 Atom net_active_window
;
61 Atom net_supporting_wm_check
;
62 // Atom net_virtual_roots;
63 Atom net_desktop_layout
;
64 Atom net_showing_desktop
;
65 // root window messages
66 Atom net_close_window
;
67 Atom net_wm_moveresize
;
68 // application window properties
69 // Atom net_properties;
71 Atom net_wm_visible_name
;
72 Atom net_wm_icon_name
;
73 Atom net_wm_visible_icon_name
;
75 Atom net_wm_window_type
;
78 // Atom net_wm_icon_geometry;
81 // Atom net_wm_handled_icons;
82 Atom net_wm_allowed_actions
;
83 // application protocols
84 // Atom Atom net_wm_ping;
86 Atom net_wm_window_type_desktop
;
87 Atom net_wm_window_type_dock
;
88 Atom net_wm_window_type_toolbar
;
89 Atom net_wm_window_type_menu
;
90 Atom net_wm_window_type_utility
;
91 Atom net_wm_window_type_splash
;
92 Atom net_wm_window_type_dialog
;
93 Atom net_wm_window_type_normal
;
95 Atom net_wm_moveresize_size_topleft
;
96 Atom net_wm_moveresize_size_topright
;
97 Atom net_wm_moveresize_size_bottomleft
;
98 Atom net_wm_moveresize_size_bottomright
;
99 Atom net_wm_moveresize_move
;
101 Atom net_wm_action_move
;
102 Atom net_wm_action_resize
;
103 Atom net_wm_action_minimize
;
104 Atom net_wm_action_shade
;
105 Atom net_wm_action_stick
;
106 Atom net_wm_action_maximize_horz
;
107 Atom net_wm_action_maximize_vert
;
108 Atom net_wm_action_fullscreen
;
109 Atom net_wm_action_change_desktop
;
110 Atom net_wm_action_close
;
112 Atom net_wm_state_modal
;
113 Atom net_wm_state_sticky
;
114 Atom net_wm_state_maximized_vert
;
115 Atom net_wm_state_maximized_horz
;
116 Atom net_wm_state_shaded
;
117 Atom net_wm_state_skip_taskbar
;
118 Atom net_wm_state_skip_pager
;
119 Atom net_wm_state_hidden
;
120 Atom net_wm_state_fullscreen
;
121 Atom net_wm_state_above
;
122 Atom net_wm_state_below
;
124 Atom kde_net_system_tray_windows
;
125 Atom kde_net_wm_system_tray_window_for
;
126 Atom kde_net_wm_window_type_override
;
132 Atom openbox_active_window
;
136 //! Provides easy access to window properties.
140 //! The possible types/encodings of strings
142 ascii
, //!< Standard 8-bit ascii string
143 utf8
, //!< Utf8-encoded string
144 #ifndef DOXYGEN_IGNORE
149 //! A list of ustrings
150 typedef std::vector
<ustring
> StringVect
;
152 //! The value of all atoms on the X server that exist in the
157 //! Sets a property on a window
158 static void set(Window win
, Atom atom
, Atom type
, unsigned char *data
,
159 int size
, int nelements
, bool append
);
160 //! Gets a property's value from a window
161 static bool get(Window win
, Atom atom
, Atom type
,
162 unsigned long *nelements
, unsigned char **value
,
166 //! Initializes the Property class.
168 CAUTION: This function uses otk::Display, so ensure that
169 otk::Display::initialize has been called before initializing this class!
171 static void initialize();
173 //! Sets a single-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 The value to set the property to
182 static void set(Window win
, Atom atom
, Atom type
, unsigned long value
);
183 //! Sets an multiple-value property on a window to a new value
185 @param win The window id of the window on which to set the property's value
186 @param atom The Atom value of the property to set. This can be found in the
187 struct returned by Property::atoms.
188 @param type The Atom value of the property type. This can be found in the
189 struct returned by Property::atoms.
190 @param value Any array of values to set the property to. The array must
191 contain <i>elements</i> number of elements
192 @param elements The number of elements in the <i>value</i> array
194 static void set(Window win
, Atom atom
, Atom type
,
195 unsigned long value
[], int elements
);
196 //! Sets a string property on a window to a new value
198 @param win The window id of the window on which to set the property's value
199 @param atom The Atom value of the property to set. This can be found in the
200 struct returned by Property::atoms.
201 @param type A member of the Property::StringType enum that specifies the
202 type of the string the property is being set to
203 @param value The string to set the property to
205 static void set(Window win
, Atom atom
, StringType type
,
206 const ustring
&value
);
207 //! Sets a string-array property on a window to a new value
209 @param win The window id of the window on which to set the property's value
210 @param atom The Atom value of the property to set. This can be found in the
211 struct returned by Property::atoms.
212 @param type A member of the Property::StringType enum that specifies the
213 type of the string the property is being set to
214 @param strings A list of strings to set the property to
216 static void set(Window win
, Atom atom
, StringType type
,
217 const StringVect
&strings
);
219 //! Gets the value of a property on a window
221 @param win The window id of the window to get the property value from
222 @param atom The Atom value of the property to set. This can be found in the
223 struct returned by Property::atoms.
224 @param type The Atom value of the property type. This can be found in the
225 struct returned by Property::atoms.
226 @param nelements The maximum number of elements to retrieve from the
227 property (assuming it has more than 1 value in it). To
228 retrieve all possible elements, use "(unsigned) -1".<br>
229 When the function returns, if it returns true, this will
230 contain the actual number of elements retrieved.<br>
231 @param value If the function returns true, then this contains an array of
232 retrieved values for the property.<br>
233 The <i>value</i> is allocated inside the function and
234 <b>delete[]</b> value needs to be called when you are done
236 The <i>value</i> array returned is null terminated, and has
237 <i>nelements</i> elements in it plus the terminating null.
238 @return true if retrieval of the specified property with the specified
239 type was successful; otherwise, false
241 static bool get(Window win
, Atom atom
, Atom type
,
242 unsigned long *nelements
, unsigned long **value
);
243 //! Gets a single element from the value of a property on a window
245 @param win The window id of the window to get the property value from
246 @param atom The Atom value of the property to set. This can be found in the
247 struct returned by Property::atoms.
248 @param type The Atom value of the property type. This can be found in the
249 struct returned by Property::atoms.
250 @param value If the function returns true, then this contains the first
251 (and possibly only) element in the value of the specified
253 @return true if retrieval of the specified property with the specified
254 type was successful; otherwise, false
256 static bool get(Window win
, Atom atom
, Atom type
, unsigned long *value
);
257 //! Gets a single string from the value of a property on a window
259 @param win The window id of the window to get the property value from
260 @param atom The Atom value of the property to set. This can be found in the
261 struct returned by Property::atoms.
262 @param type A member of the Property::StringType enum that specifies the
263 type of the string property to retrieve
264 @param value If the function returns true, then this contains the first
265 (and possibly only) string in the value of the specified
267 @return true if retrieval of the specified property with the specified
268 type was successful; otherwise, false
270 static bool get(Window win
, Atom atom
, StringType type
, ustring
*value
);
271 //! Gets strings from the value of a property on a window
273 @param win The window id of the window to get the property value from
274 @param atom The Atom value of the property to set. This can be found in the
275 struct returned by Property::atoms.
276 @param type A member of the Property::StringType enum that specifies the
277 type of the string property to retrieve
278 @param nelements The maximum number of strings to retrieve from the
279 property (assuming it has more than 1 string in it). To
280 retrieve all possible strings, use "(unsigned) -1".<br>
281 When the function returns, if it returns true, this will
282 contain the actual number of strings retrieved.<br>
283 @param strings If the function returns true, then this contains all of the
284 strings retrieved from the property's value.
285 @return true if retrieval of the specified property with the specified
286 type was successful; otherwise, false
288 static bool get(Window win
, Atom atom
, StringType type
,
289 unsigned long *nelements
, StringVect
*strings
);
291 //! Removes a property from a window
293 @param win The window id of the window to remove the property from
294 @param atom The Atom value of the property to set. This can be found in the
295 struct returned by Property::atoms.
297 static void erase(Window win
, Atom atom
);