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