]> Dogcows Code - chaz/openbox/blob - src/XAtom.hh
merge in netwm branch at tag netwm-merge2
[chaz/openbox] / src / XAtom.hh
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 #include <string>
29
30 class Blackbox;
31 class ScreenInfo;
32
33 class XAtom {
34 public:
35 enum Atoms {
36 // types
37 cardinal,
38 window,
39 pixmap,
40 atom,
41 string,
42 utf8_string,
43
44 #ifdef HAVE_GETPID
45 blackbox_pid,
46 #endif // HAVE_GETPID
47
48 // window hints
49 wm_colormap_windows,
50 wm_protocols,
51 wm_state,
52 wm_delete_window,
53 wm_take_focus,
54 wm_change_state,
55 motif_wm_hints,
56 blackbox_attributes,
57 blackbox_change_attributes,
58 blackbox_hints,
59
60 // blackbox-protocol atoms (wm -> client)
61 blackbox_structure_messages,
62 blackbox_notify_startup,
63 blackbox_notify_window_add,
64 blackbox_notify_window_del,
65 blackbox_notify_window_focus,
66 blackbox_notify_current_workspace,
67 blackbox_notify_workspace_count,
68 blackbox_notify_window_raise,
69 blackbox_notify_window_lower,
70 // blackbox-protocol atoms (client -> wm)
71 blackbox_change_workspace,
72 blackbox_change_window_focus,
73 blackbox_cycle_window_focus,
74
75 // NETWM atoms
76 // root window properties
77 net_supported,
78 net_client_list,
79 net_client_list_stacking,
80 net_number_of_desktops,
81 net_desktop_geometry,
82 net_desktop_viewport,
83 net_current_desktop,
84 net_desktop_names,
85 net_active_window,
86 net_workarea,
87 net_supporting_wm_check,
88 net_virtual_roots,
89 // root window messages
90 net_close_window,
91 net_wm_moveresize,
92 // application window properties
93 net_properties,
94 net_wm_name,
95 net_wm_desktop,
96 net_wm_window_type,
97 net_wm_state,
98 net_wm_strut,
99 net_wm_icon_geometry,
100 net_wm_icon,
101 net_wm_pid,
102 net_wm_handled_icons,
103 // application protocols
104 net_wm_ping,
105
106 // constant for how many atoms exist in the enumerator
107 NUM_ATOMS
108 };
109
110 enum StringType {
111 ansi,
112 utf8,
113 NUM_STRING_TYPE
114 };
115
116 private:
117 typedef std::vector<Window> SupportWindows;
118
119 Display *_display;
120 // windows used to specify support for NETWM
121 SupportWindows _support_windows;
122 Atom _atoms[NUM_ATOMS];
123
124 Atom create(const char *name) const;
125
126 void setValue(Window win, Atom atom, Atom type, unsigned char *data,
127 int size, int nelements, bool append) const;
128 bool getValue(Window win, Atom atom, Atom type,
129 unsigned long &nelements, unsigned char **value,
130 int size) const;
131
132 // no copying!!
133 XAtom(const XAtom &);
134 XAtom& operator=(const XAtom&);
135
136 public:
137 XAtom(Blackbox *bb);
138 virtual ~XAtom();
139
140 // setup support on a screen, each screen should call this once in its
141 // constructor.
142 void setSupported(const ScreenInfo *screen);
143
144 void setValue(Window win, Atoms atom, Atoms type, unsigned long value) const;
145 void setValue(Window win, Atoms atom, Atoms type,
146 unsigned long value[], int elements) const;
147 void setValue(Window win, Atoms atom, StringType type,
148 const std::string &value) const;
149
150 // the 'value' is allocated inside the function and
151 // delete [] value needs to be called when you are done with it.
152 // the 'value' array returned is null terminated, and has 'nelements'
153 // elements in it plus the null.
154 bool getValue(Window win, Atoms atom, Atoms type,
155 unsigned long &nelements, unsigned long **value) const;
156 bool getValue(Window win, Atoms atom, StringType type,
157 std::string &value) const;
158
159 void eraseValue(Window win, Atoms atom) const;
160
161 // temporary function!! remove when not used in blackbox.hh anymore!!
162 inline Atom getAtom(Atoms a)
163 { Atom ret = _atoms[a]; assert(ret != 0); return ret; }
164 };
165
166 #endif // __XAtom_h
This page took 0.045587 seconds and 5 git commands to generate.