]> icculus.org git repositories - dana/openbox.git/blob - src/xatom.hh
dont have any languages yet
[dana/openbox.git] / src / xatom.hh
1 // XAtom.h for Openbox
2 #ifndef   __XAtom_h
3 #define   __XAtom_h
4
5 #include <X11/Xlib.h>
6 #include <X11/Xatom.h>
7
8 #include <assert.h>
9
10 #include <vector>
11 #include <string>
12
13 class Blackbox;
14 class ScreenInfo;
15
16 class XAtom {
17 public:
18   enum Atoms {
19     // types
20     cardinal,
21     window,
22     pixmap,
23     atom,
24     string,
25     utf8_string,
26     
27 #ifdef    HAVE_GETPID
28     blackbox_pid,
29 #endif // HAVE_GETPID
30
31     // window hints
32     wm_colormap_windows,
33     wm_protocols,
34     wm_state,
35     wm_delete_window,
36     wm_take_focus,
37     wm_change_state,
38     wm_name,
39     wm_icon_name,
40     wm_class,
41     motif_wm_hints,
42     blackbox_attributes,
43     blackbox_change_attributes,
44     blackbox_hints,
45
46     // blackbox-protocol atoms (wm -> client)
47     blackbox_structure_messages,
48     blackbox_notify_startup,
49     blackbox_notify_window_add,
50     blackbox_notify_window_del,
51     blackbox_notify_window_focus,
52     blackbox_notify_current_workspace,
53     blackbox_notify_workspace_count,
54     blackbox_notify_window_raise,
55     blackbox_notify_window_lower,
56     // blackbox-protocol atoms (client -> wm)
57     blackbox_change_workspace,
58     blackbox_change_window_focus,
59     blackbox_cycle_window_focus,
60
61     openbox_show_root_menu,
62     openbox_show_workspace_menu,
63
64     // NETWM atoms
65     // root window properties
66     net_supported,
67     net_client_list,
68     net_client_list_stacking,
69     net_number_of_desktops,
70     net_desktop_geometry,
71     net_desktop_viewport,
72     net_current_desktop,
73     net_desktop_names,
74     net_active_window,
75     net_workarea,
76     net_supporting_wm_check,
77 //    net_virtual_roots,
78     // root window messages
79     net_close_window,
80     net_wm_moveresize,
81     // application window properties
82 //    net_properties,
83     net_wm_name,
84     net_wm_visible_name,
85     net_wm_icon_name,
86     net_wm_visible_icon_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     net_wm_allowed_actions,
96     // application protocols
97 //    net_wm_ping,
98
99     net_wm_window_type_desktop,
100     net_wm_window_type_dock,
101     net_wm_window_type_toolbar,
102     net_wm_window_type_menu,
103     net_wm_window_type_utility,
104     net_wm_window_type_splash,
105     net_wm_window_type_dialog,
106     net_wm_window_type_normal,
107
108     net_wm_moveresize_size_topleft,
109     net_wm_moveresize_size_topright,
110     net_wm_moveresize_size_bottomleft,
111     net_wm_moveresize_size_bottomright,
112     net_wm_moveresize_move,
113
114     net_wm_action_move,
115     net_wm_action_resize,
116     net_wm_action_shade,
117     net_wm_action_maximize_horz,
118     net_wm_action_maximize_vert,
119     net_wm_action_change_desktop,
120     net_wm_action_close,
121
122     net_wm_state_modal,
123     net_wm_state_maximized_vert,
124     net_wm_state_maximized_horz,
125     net_wm_state_shaded,
126     net_wm_state_skip_taskbar,
127     net_wm_state_skip_pager,
128     net_wm_state_hidden,
129     net_wm_state_fullscreen,
130
131     kde_net_system_tray_windows,
132     kde_net_wm_system_tray_window_for,
133     kde_net_wm_window_type_override,
134  
135     // constant for how many atoms exist in the enumerator
136     NUM_ATOMS
137   };
138
139   enum StringType {
140     ansi,
141     utf8,
142     NUM_STRING_TYPE
143   };
144
145 private:
146   typedef std::vector<Window> SupportWindows;
147   
148   Display              *_display;
149   // windows used to specify support for NETWM
150   SupportWindows        _support_windows;
151   Atom                  _atoms[NUM_ATOMS];
152
153   Atom create(const char *name) const;
154
155   void setValue(Window win, Atom atom, Atom type, unsigned char *data,
156                 int size, int nelements, bool append) const;
157   bool getValue(Window win, Atom atom, Atom type,
158                 unsigned long &nelements, unsigned char **value,
159                 int size) const;
160
161   // no copying!!
162   XAtom(const XAtom &);
163   XAtom& operator=(const XAtom&);
164
165 public:
166   typedef std::vector<std::string> StringVect;
167   
168   XAtom(Display *d);
169   virtual ~XAtom();
170
171   // setup support on a screen, each screen should call this once in its
172   // constructor.
173   void setSupported(const ScreenInfo *screen);
174   
175   void setValue(Window win, Atoms atom, Atoms type, unsigned long value) const;
176   void setValue(Window win, Atoms atom, Atoms type,
177                 unsigned long value[], int elements) const;
178   void setValue(Window win, Atoms atom, StringType type,
179                 const std::string &value) const;
180   void setValue(Window win, Atoms atom, StringType type,
181                 const StringVect &strings) const;
182
183   // the 'value' is allocated inside the function and
184   // delete [] value needs to be called when you are done with it.
185   // the 'value' array returned is null terminated, and has 'nelements'
186   // elements in it plus the null.
187   // nelements must be set to the maximum number of elements to read from
188   // the property.
189   bool getValue(Window win, Atoms atom, Atoms type,
190                 unsigned long &nelements, unsigned long **value) const;
191   bool getValue(Window win, Atoms atom, Atoms type, unsigned long &value) const;
192   bool getValue(Window win, Atoms atom, StringType type,
193                 std::string &value) const;
194   bool getValue(Window win, Atoms atom, StringType type,
195                 unsigned long &nelements, StringVect &strings) const;
196   
197   void eraseValue(Window win, Atoms atom) const;
198
199   // sends a client message a window
200   void sendClientMessage(Window target, Atoms type, Window about,
201                          long data = 0, long data1 = 0, long data2 = 0,
202                          long data3 = 0, long data4 = 0) const;
203
204   // temporary function!! remove when not used in blackbox.hh anymore!!
205   inline Atom getAtom(Atoms a)
206   { assert(a >= 0 && a < NUM_ATOMS); Atom ret = _atoms[a];
207     assert(ret != 0); return ret; }
208 };
209
210 #endif // __XAtom_h