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