]> Dogcows Code - chaz/openbox/blob - src/xatom.hh
updated doxygen documentation
[chaz/openbox] / src / xatom.hh
1 // XAtom.h for Openbox
2 #ifndef __XAtom_h
3 #define __XAtom_h
4
5 /*! @file xatom.hh
6 @brief Provides access to atoms on the display
7 */
8
9 extern "C" {
10 #include <X11/Xlib.h>
11 #include <X11/Xatom.h>
12
13 #include <assert.h>
14 }
15
16 #include <vector>
17 #include <string>
18
19 #include "otk/screeninfo.hh"
20
21 namespace ob {
22
23 class XAtom {
24 public:
25 enum Atoms {
26 // types
27 cardinal,
28 window,
29 pixmap,
30 atom,
31 string,
32 utf8_string,
33
34 #ifdef HAVE_GETPID
35 blackbox_pid,
36 #endif // HAVE_GETPID
37
38 // window hints
39 wm_colormap_windows,
40 wm_protocols,
41 wm_state,
42 wm_delete_window,
43 wm_take_focus,
44 wm_change_state,
45 wm_name,
46 wm_icon_name,
47 wm_class,
48 motif_wm_hints,
49 blackbox_attributes,
50 blackbox_change_attributes,
51 blackbox_hints,
52
53 // blackbox-protocol atoms (wm -> client)
54 blackbox_structure_messages,
55 blackbox_notify_startup,
56 blackbox_notify_window_add,
57 blackbox_notify_window_del,
58 blackbox_notify_window_focus,
59 blackbox_notify_current_workspace,
60 blackbox_notify_workspace_count,
61 blackbox_notify_window_raise,
62 blackbox_notify_window_lower,
63 // blackbox-protocol atoms (client -> wm)
64 blackbox_change_workspace,
65 blackbox_change_window_focus,
66 blackbox_cycle_window_focus,
67
68 openbox_show_root_menu,
69 openbox_show_workspace_menu,
70
71 // NETWM atoms
72 // root window properties
73 net_supported,
74 net_client_list,
75 net_client_list_stacking,
76 net_number_of_desktops,
77 net_desktop_geometry,
78 net_desktop_viewport,
79 net_current_desktop,
80 net_desktop_names,
81 net_active_window,
82 net_workarea,
83 net_supporting_wm_check,
84 // net_virtual_roots,
85 // root window messages
86 net_close_window,
87 net_wm_moveresize,
88 // application window properties
89 // net_properties,
90 net_wm_name,
91 net_wm_visible_name,
92 net_wm_icon_name,
93 net_wm_visible_icon_name,
94 net_wm_desktop,
95 net_wm_window_type,
96 net_wm_state,
97 net_wm_strut,
98 // net_wm_icon_geometry,
99 // net_wm_icon,
100 // net_wm_pid,
101 // net_wm_handled_icons,
102 net_wm_allowed_actions,
103 // application protocols
104 // net_wm_ping,
105
106 net_wm_window_type_desktop,
107 net_wm_window_type_dock,
108 net_wm_window_type_toolbar,
109 net_wm_window_type_menu,
110 net_wm_window_type_utility,
111 net_wm_window_type_splash,
112 net_wm_window_type_dialog,
113 net_wm_window_type_normal,
114
115 net_wm_moveresize_size_topleft,
116 net_wm_moveresize_size_topright,
117 net_wm_moveresize_size_bottomleft,
118 net_wm_moveresize_size_bottomright,
119 net_wm_moveresize_move,
120
121 net_wm_action_move,
122 net_wm_action_resize,
123 net_wm_action_shade,
124 net_wm_action_maximize_horz,
125 net_wm_action_maximize_vert,
126 net_wm_action_change_desktop,
127 net_wm_action_close,
128
129 net_wm_state_modal,
130 net_wm_state_maximized_vert,
131 net_wm_state_maximized_horz,
132 net_wm_state_shaded,
133 net_wm_state_skip_taskbar,
134 net_wm_state_skip_pager,
135 net_wm_state_hidden,
136 net_wm_state_fullscreen,
137
138 kde_net_system_tray_windows,
139 kde_net_wm_system_tray_window_for,
140 kde_net_wm_window_type_override,
141
142 // constant for how many atoms exist in the enumerator
143 NUM_ATOMS
144 };
145
146 enum StringType {
147 ansi,
148 utf8,
149 NUM_STRING_TYPE
150 };
151
152 private:
153 typedef std::vector<Window> SupportWindows;
154
155 Display *_display;
156 // windows used to specify support for NETWM
157 SupportWindows _support_windows;
158 Atom _atoms[NUM_ATOMS];
159
160 Atom create(const char *name) const;
161
162 void setValue(Window win, Atom atom, Atom type, unsigned char *data,
163 int size, int nelements, bool append) const;
164 bool getValue(Window win, Atom atom, Atom type,
165 unsigned long &nelements, unsigned char **value,
166 int size) const;
167
168 // no copying!!
169 XAtom(const XAtom &);
170 XAtom& operator=(const XAtom&);
171
172 public:
173 typedef std::vector<std::string> StringVect;
174
175 XAtom(Display *d);
176 virtual ~XAtom();
177
178 // setup support on a screen, each screen should call this once in its
179 // constructor.
180 void setSupported(const otk::ScreenInfo *screen);
181
182 void setValue(Window win, Atoms atom, Atoms type, unsigned long value) const;
183 void setValue(Window win, Atoms atom, Atoms type,
184 unsigned long value[], int elements) const;
185 void setValue(Window win, Atoms atom, StringType type,
186 const std::string &value) const;
187 void setValue(Window win, Atoms atom, StringType type,
188 const StringVect &strings) const;
189
190 // the 'value' is allocated inside the function and
191 // delete [] value needs to be called when you are done with it.
192 // the 'value' array returned is null terminated, and has 'nelements'
193 // elements in it plus the null.
194 // nelements must be set to the maximum number of elements to read from
195 // the property.
196 bool getValue(Window win, Atoms atom, Atoms type,
197 unsigned long &nelements, unsigned long **value) const;
198 bool getValue(Window win, Atoms atom, Atoms type, unsigned long &value) const;
199 bool getValue(Window win, Atoms atom, StringType type,
200 std::string &value) const;
201 bool getValue(Window win, Atoms atom, StringType type,
202 unsigned long &nelements, StringVect &strings) const;
203
204 void eraseValue(Window win, Atoms atom) const;
205
206 // sends a client message a window
207 void sendClientMessage(Window target, Atoms type, Window about,
208 long data = 0, long data1 = 0, long data2 = 0,
209 long data3 = 0, long data4 = 0) const;
210
211 // temporary function!! remove when not used in blackbox.hh anymore!!
212 inline Atom getAtom(Atoms a)
213 { assert(a >= 0 && a < NUM_ATOMS); Atom ret = _atoms[a];
214 assert(ret != 0); return ret; }
215 };
216
217 }
218
219 #endif // __XAtom_h
This page took 0.040409 seconds and 4 git commands to generate.