]> icculus.org git repositories - mikachu/openbox.git/blob - src/XAtom.h
updated goals
[mikachu/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 "../config.h"
26
27 #include <X11/Xlib.h>
28 #include <X11/Xatom.h>
29 #include <vector>
30
31 class XDisplay;
32 class XScreen;
33
34 class XAtom {
35   typedef std::vector<Window> SupportWindows;
36   
37   Display              *_display;
38   // windows used to specify support for NETWM
39   SupportWindows        _support_windows; 
40
41   Atom 
42 #ifdef    HAVE_GETPID
43     openbox_pid,
44 #endif // HAVE_GETPID
45
46     // window hints
47     wm_colormap_windows,
48     wm_protocols,
49     wm_state,
50     wm_delete_window,
51     wm_take_focus,
52     wm_change_state,
53     motif_wm_hints,
54     openbox_attributes,
55     openbox_change_attributes,
56     openbox_hints,
57
58     // blackbox-protocol atoms (wm -> client)
59     openbox_structure_messages,
60     openbox_notify_startup,
61     openbox_notify_window_add,
62     openbox_notify_window_del,
63     openbox_notify_window_focus,
64     openbox_notify_current_workspace,
65     openbox_notify_workspace_count,
66     openbox_notify_window_raise,
67     openbox_notify_window_lower,
68     // blackbox-protocol atoms (client -> wm)
69     openbox_change_workspace,
70     openbox_change_window_focus,
71     openbox_cycle_window_focus,
72
73     // NETWM atoms
74     // root window properties
75     net_supported,
76     net_client_list,
77     net_client_list_stacking,
78     net_number_of_desktops,
79     net_desktop_geometry,
80     net_desktop_viewport,
81     net_current_desktop,
82     net_desktop_names,
83     net_active_window,
84     net_workarea,
85     net_supporting_wm_check,
86     net_virtual_roots,
87     // root window messages
88     net_close_window,
89     net_wm_moveresize,
90     // application window properties
91     net_properties,
92     net_wm_name,
93     net_wm_desktop,
94     net_wm_window_type,
95     net_wm_state,
96     net_wm_strut,
97     net_wm_icon_geometry,
98     net_wm_icon,
99     net_wm_pid,
100     net_wm_handled_icons,
101     // application protocols
102     net_wm_ping;
103
104   Atom getAtom(const char *name) const;
105   void setSupported(const XScreen *screen);
106
107   void setValue(Window win, Atom atom, Atom type, unsigned char *data,
108                 int size, int nelements, bool append) const;
109   bool getValue(Window win, Atom atom, Atom type, unsigned long *nelements,
110                 unsigned char **value, int size) const;
111
112   // no copying!!
113   XAtom(const XAtom &);
114   XAtom& operator=(const XAtom&);
115
116 public:
117   XAtom(const XDisplay *display);
118   virtual ~XAtom();
119
120   void setCardValue(Window win, Atom atom, long value) const; // 32-bit CARDINAL
121   void setAtomValue(Window win, Atom atom, Atom value) const;
122   void setWindowValue(Window win, Atom atom, Window value) const;
123   void setPixmapValue(Window win, Atom atom, Pixmap value) const;
124   void setStringValue(Window win, Atom atom, std::string &value) const;
125   
126   void addCardValue(Window win, Atom atom, long value) const; // 32-bit CARDINAL
127   void addAtomValue(Window win, Atom atom, Atom value) const;
128   void addWindowValue(Window win, Atom atom, Window value) const;
129   void addPixmapValue(Window win, Atom atom, Pixmap value) const;
130   void addStringValue(Window win, Atom atom, std::string &value) const;
131
132   // the 'value' is allocated inside the function and
133   // delete [] value needs to be called when you are done with it.
134   // teh 'value' array returned is null terminated, and has 'nelements'
135   // elements in it plus the null.
136   bool getCardValue(Window win, Atom atom, unsigned long *nelements,
137                 long **value) const; // 32-bit CARDINAL
138   bool getAtomValue(Window win, Atom atom, unsigned long *nelements,
139                 Atom **value) const;
140   bool getWindowValue(Window win, Atom atom, unsigned long *nelements,
141                 Window **value) const;
142   bool getPixmapValue(Window win, Atom atom, unsigned long *nelements,
143                 Pixmap **value) const;
144   bool getStringValue(Window win, Atom atom, unsigned long *nelements,
145                 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