]> icculus.org git repositories - dana/openbox.git/blob - src/XAtom.h
adding new X base classes which encapsulate all X server interation
[dana/openbox.git] / 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 <X11/Xlib.h>
26 #include <X11/Xatom.h>
27 #include <vector>
28
29 class XDisplay;
30
31 class XAtom {
32   typedef std::vector<Window> SupportWindows;
33   
34   Display              *_display;
35   // windows used to specify support for NETWM
36   SupportWindows        _support_windows; 
37
38   Atom 
39     // window hints
40     wm_colormap_windows,
41     wm_protocols,
42     wm_state,
43     wm_delete_window,
44     wm_take_focus,
45     wm_change_state,
46     motif_wm_hints,
47     openbox_attributes,
48     openbox_change_attributes,
49     openbox_hints;
50
51     // blackbox-protocol atoms (wm -> client)
52     openbox_structure_messages,
53     openbox_notify_startup,
54     openbox_notify_window_add,
55     openbox_notify_window_del,
56     openbox_notify_window_focus,
57     openbox_notify_current_workspace,
58     openbox_notify_workspace_count,
59     openbox_notify_window_raise,
60     openbox_notify_window_lower;
61     // blackbox-protocol atoms (client -> wm)
62     openbox_change_workspace,
63     openbox_change_window_focus,
64     openbox_cycle_window_focus,
65
66     // NETWM atoms
67     // root window properties
68     net_supported,
69     net_client_list,
70     net_client_list_stacking,
71     net_number_of_desktops,
72     net_desktop_geometry,
73     net_desktop_viewport,
74     net_current_desktop,
75     net_desktop_names,
76     net_active_window,
77     net_workarea,
78     net_supporting_wm_check,
79     net_virtual_roots,
80     // root window messages
81     net_close_window,
82     net_wm_moveresize,
83     // application window properties
84     net_properties,
85     net_wm_name,
86     net_wm_desktop,
87     net_wm_window_type,
88     net_wm_state,
89     net_wm_strut,
90     net_wm_icon_geometry,
91     net_wm_icon,
92     net_wm_pid,
93     net_wm_handled_icons,
94     // application protocols
95     net_wm_ping;
96
97   Atom getAtom(const char *name) const;
98   void setSupported(const XScreen *screen) const;
99
100   void setValue(Window win, Atom atom, Atom type, unsigned char *data, int size,
101                 int nelements, bool append);
102   bool getValue(Window win, Atom atom, Atom type, unsigned long *nelements,
103                 unsigned char **value, int size) const;
104
105   // no copying!!
106   XAtom(const XAtom &);
107   XAtom& operator=(const XAtom&);
108
109 public:
110   XAtom(XDisplay *display);
111   virtual ~XAtom();
112
113   void setValue(Window win, Atom atom, long value) const; // a 32-bit CARDINAL
114   void setValue(Window win, Atom atom, Atom value) const;
115   void setValue(Window win, Atom atom, Window value) const;
116   void setValue(Window win, Atom atom, Pixmap value) const;
117   void setValue(Window win, Atom atom, std::string &value) const;
118   
119   void addValue(Window win, Atom atom, long value) const; // a 32-bit CARDINAL
120   void addValue(Window win, Atom atom, Atom value) const;
121   void addValue(Window win, Atom atom, Window value) const;
122   void addValue(Window win, Atom atom, Pixmap value) const;
123   void addValue(Window win, Atom atom, std::string &value) const;
124
125   // the 'value' is allocated inside the function and
126   // delete [] value needs to be called when you are done with it.
127   // teh 'value' array returned is null terminated, and has 'nelements'
128   // elements in it plus the null.
129   bool getValue(Window win, Atom atom, unsigned long *nelements,
130                 long **value) const; // a 32-bit CARDINAL
131   bool getValue(Window win, Atom atom, unsigned long *nelements,
132                 Atom **value) const;
133   bool getValue(Window win, Atom atom, unsigned long *nelements,
134                 Window **value) const;
135   bool getValue(Window win, Atom atom, unsigned long *nelements,
136                 Pixmap **value) const;
137   bool getValue(Window win, Atom atom, unsigned long *nelements,
138                 std::string &value) const; 
139   
140   void eraseValue(Window win, Atom atom) const;
141   
142   inline Atom wmChangeState() const { return wm_change_state; }
143   inline Atom wmState() const { return wm_state; }
144   inline Atom wmDelete() const { return wm_delete_window; }
145   inline Atom wmProtocols() const { return wm_protocols; }
146   inline Atom wmTakeFocus() const { return wm_take_focus; }
147   inline Atom wmColormap() const { return wm_colormap_windows; }
148   inline Atom motifWMHints() const { return motif_wm_hints; }
149
150   // this atom is for normal app->WM hints about decorations, stacking,
151   // starting workspace etc...
152   inline Atom openboxHints() const { return openbox_hints;}
153
154   // these atoms are for normal app->WM interaction beyond the scope of the
155   // ICCCM...
156   inline Atom openboxAttributes() const { return openbox_attributes; }
157   inline Atom openboxChangeAttributes() const
158   { return openbox_change_attributes; }
159
160   // these atoms are for window->WM interaction, with more control and
161   // information on window "structure"... common examples are
162   // notifying apps when windows are raised/lowered... when the user changes
163   // workspaces... i.e. "pager talk"
164   inline Atom openboxStructureMessages() const
165   { return openbox_structure_messages; }
166
167   inline Atom openboxNotifyStartup() const
168   { return openbox_notify_startup; }
169   inline Atom openboxNotifyWindowAdd() const
170   { return openbox_notify_window_add; }
171   inline Atom openboxNotifyWindowDel() const
172   { return openbox_notify_window_del; }
173   inline Atom openboxNotifyWindowFocus() const
174   { return openbox_notify_window_focus; }
175   inline Atom openboxNotifyCurrentWorkspace() const
176   { return openbox_notify_current_workspace; }
177   inline Atom openboxNotifyWorkspaceCount() const
178   { return openbox_notify_workspace_count; }
179   inline Atom openboxNotifyWindowRaise() const
180   { return openbox_notify_window_raise; }
181   inline Atom openboxNotifyWindowLower() const
182   { return openbox_notify_window_lower; }
183
184   // atoms to change that request changes to the desktop environment during
185   // runtime... these messages can be sent by any client... as the sending
186   // client window id is not included in the ClientMessage event...
187   inline Atom openboxChangeWorkspace() const
188   { return openbox_change_workspace; }
189   inline Atom openboxChangeWindowFocus() const
190   { return openbox_change_window_focus; }
191   inline Atom openboxCycleWindowFocus() const
192   { return openbox_cycle_window_focus; }
193
194   // root window properties
195   inline Atom netClientList() const { return net_client_list; }
196   inline Atom netClientListStacking() const { return net_client_list_stacking; }
197   inline Atom netNumberOfDesktops() const { return net_number_of_desktops; }
198   inline Atom netDesktopGeometry() const { return net_desktop_geometry; }
199   inline Atom netDesktopViewport() const { return net_desktop_viewport; }
200   inline Atom netCurrentDesktop() const { return net_current_desktop; }
201   inline Atom netDesktopNames() const { return net_desktop_names; }
202   inline Atom netActiveWindow() const { return net_active_window; }
203   inline Atom netWorkarea() const { return net_workarea; }
204   inline Atom netSupportingWMCheck() const { return net_supporting_wm_check; }
205   inline Atom netVirtualRoots() const { return net_virtual_roots; }
206
207   // root window messages
208   inline Atom netCloseWindow() const { return net_close_window; }
209   inline Atom netWMMoveResize() const { return net_wm_moveresize; }
210
211   // application window properties
212   inline Atom netProperties() const { return net_properties; }
213   inline Atom netWMName() const { return net_wm_name; }
214   inline Atom netWMDesktop() const { return net_wm_desktop; }
215   inline Atom netWMWindowType() const { return net_wm_window_type; }
216   inline Atom netWMState() const { return net_wm_state; }
217   inline Atom netWMStrut() const { return net_wm_strut; }
218   inline Atom netWMIconGeometry() const { return net_wm_icon_geometry; }
219   inline Atom netWMIcon() const { return net_wm_icon; }
220   inline Atom netWMPid() const { return net_wm_pid; }
221   inline Atom netWMHandledIcons() const { return net_wm_handled_icons; }
222
223   // application protocols
224   inline Atom netWMPing() const { return net_wm_ping; }
225 };
226
227 #endif // __XAtom_h