]> icculus.org git repositories - mikachu/openbox.git/blob - src/XAtom.h
missing an include
[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 #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, 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, 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, unsigned long *nelements,
146                 std::string &value) const; 
147   
148   void eraseValue(Window win, Atom atom) const;
149   
150 #ifdef    HAVE_GETPID
151   inline Atom openboxPid() const { return openbox_pid; }
152 #endif // HAVE_GETPID
153
154   inline Atom wmChangeState() const { return wm_change_state; }
155   inline Atom wmState() const { return wm_state; }
156   inline Atom wmDelete() const { return wm_delete_window; }
157   inline Atom wmProtocols() const { return wm_protocols; }
158   inline Atom wmTakeFocus() const { return wm_take_focus; }
159   inline Atom wmColormap() const { return wm_colormap_windows; }
160   inline Atom motifWMHints() const { return motif_wm_hints; }
161
162   // this atom is for normal app->WM hints about decorations, stacking,
163   // starting workspace etc...
164   inline Atom openboxHints() const { return openbox_hints;}
165
166   // these atoms are for normal app->WM interaction beyond the scope of the
167   // ICCCM...
168   inline Atom openboxAttributes() const { return openbox_attributes; }
169   inline Atom openboxChangeAttributes() const
170   { return openbox_change_attributes; }
171
172   // these atoms are for window->WM interaction, with more control and
173   // information on window "structure"... common examples are
174   // notifying apps when windows are raised/lowered... when the user changes
175   // workspaces... i.e. "pager talk"
176   inline Atom openboxStructureMessages() const
177   { return openbox_structure_messages; }
178
179   inline Atom openboxNotifyStartup() const
180   { return openbox_notify_startup; }
181   inline Atom openboxNotifyWindowAdd() const
182   { return openbox_notify_window_add; }
183   inline Atom openboxNotifyWindowDel() const
184   { return openbox_notify_window_del; }
185   inline Atom openboxNotifyWindowFocus() const
186   { return openbox_notify_window_focus; }
187   inline Atom openboxNotifyCurrentWorkspace() const
188   { return openbox_notify_current_workspace; }
189   inline Atom openboxNotifyWorkspaceCount() const
190   { return openbox_notify_workspace_count; }
191   inline Atom openboxNotifyWindowRaise() const
192   { return openbox_notify_window_raise; }
193   inline Atom openboxNotifyWindowLower() const
194   { return openbox_notify_window_lower; }
195
196   // atoms to change that request changes to the desktop environment during
197   // runtime... these messages can be sent by any client... as the sending
198   // client window id is not included in the ClientMessage event...
199   inline Atom openboxChangeWorkspace() const
200   { return openbox_change_workspace; }
201   inline Atom openboxChangeWindowFocus() const
202   { return openbox_change_window_focus; }
203   inline Atom openboxCycleWindowFocus() const
204   { return openbox_cycle_window_focus; }
205
206   // root window properties
207   inline Atom netClientList() const { return net_client_list; }
208   inline Atom netClientListStacking() const { return net_client_list_stacking; }
209   inline Atom netNumberOfDesktops() const { return net_number_of_desktops; }
210   inline Atom netDesktopGeometry() const { return net_desktop_geometry; }
211   inline Atom netDesktopViewport() const { return net_desktop_viewport; }
212   inline Atom netCurrentDesktop() const { return net_current_desktop; }
213   inline Atom netDesktopNames() const { return net_desktop_names; }
214   inline Atom netActiveWindow() const { return net_active_window; }
215   inline Atom netWorkarea() const { return net_workarea; }
216   inline Atom netSupportingWMCheck() const { return net_supporting_wm_check; }
217   inline Atom netVirtualRoots() const { return net_virtual_roots; }
218
219   // root window messages
220   inline Atom netCloseWindow() const { return net_close_window; }
221   inline Atom netWMMoveResize() const { return net_wm_moveresize; }
222
223   // application window properties
224   inline Atom netProperties() const { return net_properties; }
225   inline Atom netWMName() const { return net_wm_name; }
226   inline Atom netWMDesktop() const { return net_wm_desktop; }
227   inline Atom netWMWindowType() const { return net_wm_window_type; }
228   inline Atom netWMState() const { return net_wm_state; }
229   inline Atom netWMStrut() const { return net_wm_strut; }
230   inline Atom netWMIconGeometry() const { return net_wm_icon_geometry; }
231   inline Atom netWMIcon() const { return net_wm_icon; }
232   inline Atom netWMPid() const { return net_wm_pid; }
233   inline Atom netWMHandledIcons() const { return net_wm_handled_icons; }
234
235   // application protocols
236   inline Atom netWMPing() const { return net_wm_ping; }
237 };
238
239 #endif // __XAtom_h