]> Dogcows Code - chaz/openbox/blob - src/XAtom.h
better string get/set
[chaz/openbox] / src / XAtom.h
1 // XAtom.h for Openbox
2 // Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net)
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22 #ifndef __XAtom_h
23 #define __XAtom_h
24
25 #include "../config.h"
26
27 #include <X11/Xlib.h>
28 #include <X11/Xatom.h>
29 #include <vector>
30 #include <string>
31
32 class Openbox;
33 class ScreenInfo;
34
35 class XAtom {
36 typedef std::vector<Window> SupportWindows;
37
38 Display *_display;
39 // windows used to specify support for NETWM
40 SupportWindows _support_windows;
41
42 Atom
43 #ifdef HAVE_GETPID
44 openbox_pid,
45 #endif // HAVE_GETPID
46
47 // window hints
48 wm_colormap_windows,
49 wm_protocols,
50 wm_state,
51 wm_delete_window,
52 wm_take_focus,
53 wm_change_state,
54 motif_wm_hints,
55 openbox_attributes,
56 openbox_change_attributes,
57 openbox_hints,
58
59 // blackbox-protocol atoms (wm -> client)
60 openbox_structure_messages,
61 openbox_notify_startup,
62 openbox_notify_window_add,
63 openbox_notify_window_del,
64 openbox_notify_window_focus,
65 openbox_notify_current_workspace,
66 openbox_notify_workspace_count,
67 openbox_notify_window_raise,
68 openbox_notify_window_lower,
69 // blackbox-protocol atoms (client -> wm)
70 openbox_change_workspace,
71 openbox_change_window_focus,
72 openbox_cycle_window_focus,
73
74 // NETWM atoms
75 // root window properties
76 net_supported,
77 net_client_list,
78 net_client_list_stacking,
79 net_number_of_desktops,
80 net_desktop_geometry,
81 net_desktop_viewport,
82 net_current_desktop,
83 net_desktop_names,
84 net_active_window,
85 net_workarea,
86 net_supporting_wm_check,
87 net_virtual_roots,
88 // root window messages
89 net_close_window,
90 net_wm_moveresize,
91 // application window properties
92 net_properties,
93 net_wm_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 // application protocols
103 net_wm_ping;
104
105 Atom getAtom(const char *name) const;
106 void setSupported(const ScreenInfo *screen);
107
108 void setValue(Window win, Atom atom, Atom type, unsigned char *data,
109 int size, int nelements, bool append) const;
110 bool getValue(Window win, Atom atom, Atom type, unsigned long *nelements,
111 unsigned char **value, int size) const;
112
113 // no copying!!
114 XAtom(const XAtom &);
115 XAtom& operator=(const XAtom&);
116
117 public:
118 XAtom(Openbox &ob);
119 virtual ~XAtom();
120
121 void setCardValue(Window win, Atom atom, long value) const; // 32-bit CARDINAL
122 void setAtomValue(Window win, Atom atom, Atom value) const;
123 void setWindowValue(Window win, Atom atom, Window value) const;
124 void setPixmapValue(Window win, Atom atom, Pixmap value) const;
125 void setStringValue(Window win, Atom atom, const std::string &value) const;
126
127 void addCardValue(Window win, Atom atom, long value) const; // 32-bit CARDINAL
128 void addAtomValue(Window win, Atom atom, Atom value) const;
129 void addWindowValue(Window win, Atom atom, Window value) const;
130 void addPixmapValue(Window win, Atom atom, Pixmap value) const;
131 void addStringValue(Window win, Atom atom, const std::string &value) const;
132
133 // the 'value' is allocated inside the function and
134 // delete [] value needs to be called when you are done with it.
135 // teh 'value' array returned is null terminated, and has 'nelements'
136 // elements in it plus the null.
137 bool getCardValue(Window win, Atom atom, unsigned long *nelements,
138 long **value) const; // 32-bit CARDINAL
139 bool getAtomValue(Window win, Atom atom, unsigned long *nelements,
140 Atom **value) const;
141 bool getWindowValue(Window win, Atom atom, unsigned long *nelements,
142 Window **value) const;
143 bool getPixmapValue(Window win, Atom atom, unsigned long *nelements,
144 Pixmap **value) const;
145 bool getStringValue(Window win, Atom atom, std::string &value) const;
146
147 void eraseValue(Window win, Atom atom) const;
148
149 #ifdef HAVE_GETPID
150 inline Atom openboxPid() const { return openbox_pid; }
151 #endif // HAVE_GETPID
152
153 inline Atom wmChangeState() const { return wm_change_state; }
154 inline Atom wmState() const { return wm_state; }
155 inline Atom wmDelete() const { return wm_delete_window; }
156 inline Atom wmProtocols() const { return wm_protocols; }
157 inline Atom wmTakeFocus() const { return wm_take_focus; }
158 inline Atom wmColormap() const { return wm_colormap_windows; }
159 inline Atom motifWMHints() const { return motif_wm_hints; }
160
161 // this atom is for normal app->WM hints about decorations, stacking,
162 // starting workspace etc...
163 inline Atom openboxHints() const { return openbox_hints;}
164
165 // these atoms are for normal app->WM interaction beyond the scope of the
166 // ICCCM...
167 inline Atom openboxAttributes() const { return openbox_attributes; }
168 inline Atom openboxChangeAttributes() const
169 { return openbox_change_attributes; }
170
171 // these atoms are for window->WM interaction, with more control and
172 // information on window "structure"... common examples are
173 // notifying apps when windows are raised/lowered... when the user changes
174 // workspaces... i.e. "pager talk"
175 inline Atom openboxStructureMessages() const
176 { return openbox_structure_messages; }
177
178 inline Atom openboxNotifyStartup() const
179 { return openbox_notify_startup; }
180 inline Atom openboxNotifyWindowAdd() const
181 { return openbox_notify_window_add; }
182 inline Atom openboxNotifyWindowDel() const
183 { return openbox_notify_window_del; }
184 inline Atom openboxNotifyWindowFocus() const
185 { return openbox_notify_window_focus; }
186 inline Atom openboxNotifyCurrentWorkspace() const
187 { return openbox_notify_current_workspace; }
188 inline Atom openboxNotifyWorkspaceCount() const
189 { return openbox_notify_workspace_count; }
190 inline Atom openboxNotifyWindowRaise() const
191 { return openbox_notify_window_raise; }
192 inline Atom openboxNotifyWindowLower() const
193 { return openbox_notify_window_lower; }
194
195 // atoms to change that request changes to the desktop environment during
196 // runtime... these messages can be sent by any client... as the sending
197 // client window id is not included in the ClientMessage event...
198 inline Atom openboxChangeWorkspace() const
199 { return openbox_change_workspace; }
200 inline Atom openboxChangeWindowFocus() const
201 { return openbox_change_window_focus; }
202 inline Atom openboxCycleWindowFocus() const
203 { return openbox_cycle_window_focus; }
204
205 // root window properties
206 inline Atom netClientList() const { return net_client_list; }
207 inline Atom netClientListStacking() const { return net_client_list_stacking; }
208 inline Atom netNumberOfDesktops() const { return net_number_of_desktops; }
209 inline Atom netDesktopGeometry() const { return net_desktop_geometry; }
210 inline Atom netDesktopViewport() const { return net_desktop_viewport; }
211 inline Atom netCurrentDesktop() const { return net_current_desktop; }
212 inline Atom netDesktopNames() const { return net_desktop_names; }
213 inline Atom netActiveWindow() const { return net_active_window; }
214 inline Atom netWorkarea() const { return net_workarea; }
215 inline Atom netSupportingWMCheck() const { return net_supporting_wm_check; }
216 inline Atom netVirtualRoots() const { return net_virtual_roots; }
217
218 // root window messages
219 inline Atom netCloseWindow() const { return net_close_window; }
220 inline Atom netWMMoveResize() const { return net_wm_moveresize; }
221
222 // application window properties
223 inline Atom netProperties() const { return net_properties; }
224 inline Atom netWMName() const { return net_wm_name; }
225 inline Atom netWMDesktop() const { return net_wm_desktop; }
226 inline Atom netWMWindowType() const { return net_wm_window_type; }
227 inline Atom netWMState() const { return net_wm_state; }
228 inline Atom netWMStrut() const { return net_wm_strut; }
229 inline Atom netWMIconGeometry() const { return net_wm_icon_geometry; }
230 inline Atom netWMIcon() const { return net_wm_icon; }
231 inline Atom netWMPid() const { return net_wm_pid; }
232 inline Atom netWMHandledIcons() const { return net_wm_handled_icons; }
233
234 // application protocols
235 inline Atom netWMPing() const { return net_wm_ping; }
236 };
237
238 #endif // __XAtom_h
This page took 0.04784 seconds and 4 git commands to generate.