1 // BaseDisplay.h for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
23 #ifndef __BaseDisplay_hh
24 #define __BaseDisplay_hh
27 #include <X11/Xatom.h>
29 // forward declaration
33 #include "LinkedList.h"
39 #define AttribShaded (1l << 0)
40 #define AttribMaxHoriz (1l << 1)
41 #define AttribMaxVert (1l << 2)
42 #define AttribOmnipresent (1l << 3)
43 #define AttribWorkspace (1l << 4)
44 #define AttribStack (1l << 5)
45 #define AttribDecoration (1l << 6)
48 #define StackNormal (1)
49 #define StackBottom (2)
52 #define DecorNormal (1)
56 typedef struct _openbox_hints {
57 unsigned long flags, attrib, workspace, stack, decoration;
60 typedef struct _openbox_attributes {
61 unsigned long flags, attrib, workspace, stack, decoration;
62 int premax_x, premax_y;
63 unsigned int premax_w, premax_h;
66 #define PropOpenboxHintsElements (5)
67 #define PropOpenboxAttributesElements (9)
70 void bexec(const char *, char *);
73 char *bstrdup(const char *);
78 Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
83 int event_basep, error_basep;
87 unsigned int MaskList[8];
88 size_t MaskListLength;
91 Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state,
92 xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state,
96 Atom openbox_attributes, openbox_change_attributes, openbox_hints;
98 // NETStructureMessages
99 Atom openbox_structure_messages, openbox_notify_startup,
100 openbox_notify_window_add, openbox_notify_window_del,
101 openbox_notify_window_focus, openbox_notify_current_workspace,
102 openbox_notify_workspace_count, openbox_notify_window_raise,
103 openbox_notify_window_lower;
105 // message_types for client -> wm messages
106 Atom openbox_change_workspace, openbox_change_window_focus,
107 openbox_cycle_window_focus;
111 // root window properties
112 Atom net_supported, net_client_list, net_client_list_stacking,
113 net_number_of_desktops, net_desktop_geometry, net_desktop_viewport,
114 net_current_desktop, net_desktop_names, net_active_window, net_workarea,
115 net_supporting_wm_check, net_virtual_roots;
117 // root window messages
118 Atom net_close_window, net_wm_moveresize;
120 // application window properties
121 Atom net_properties, net_wm_name, net_wm_desktop, net_wm_window_type,
122 net_wm_state, net_wm_strut, net_wm_icon_geometry, net_wm_icon, net_wm_pid,
123 net_wm_handled_icons;
125 // application protocols
130 Bool _startup, _shutdown;
133 typedef std::vector<ScreenInfo*> ScreenInfoList;
134 ScreenInfoList screenInfoList;
136 LinkedList<BTimer> *timerList;
138 char *display_name, *application_name;
139 int number_of_screens, server_grabs, colors_per_channel;
143 // pure virtual function... you must override this
144 virtual void process_event(XEvent *) = 0;
146 // the masks of the modifiers which are ignored in button events.
147 int NumLockMask, ScrollLockMask;
151 BaseDisplay(const char *, char * = 0);
152 virtual ~BaseDisplay(void);
154 inline const Atom &getWMChangeStateAtom(void) const
155 { return xa_wm_change_state; }
156 inline const Atom &getWMStateAtom(void) const
157 { return xa_wm_state; }
158 inline const Atom &getWMDeleteAtom(void) const
159 { return xa_wm_delete_window; }
160 inline const Atom &getWMProtocolsAtom(void) const
161 { return xa_wm_protocols; }
162 inline const Atom &getWMTakeFocusAtom(void) const
163 { return xa_wm_take_focus; }
164 inline const Atom &getWMColormapAtom(void) const
165 { return xa_wm_colormap_windows; }
166 inline const Atom &getMotifWMHintsAtom(void) const
167 { return motif_wm_hints; }
169 // this atom is for normal app->WM hints about decorations, stacking,
170 // starting workspace etc...
171 inline const Atom &getOpenboxHintsAtom(void) const
172 { return openbox_hints;}
174 // these atoms are for normal app->WM interaction beyond the scope of the
176 inline const Atom &getOpenboxAttributesAtom(void) const
177 { return openbox_attributes; }
178 inline const Atom &getOpenboxChangeAttributesAtom(void) const
179 { return openbox_change_attributes; }
181 // these atoms are for window->WM interaction, with more control and
182 // information on window "structure"... common examples are
183 // notifying apps when windows are raised/lowered... when the user changes
184 // workspaces... i.e. "pager talk"
185 inline const Atom &getOpenboxStructureMessagesAtom(void) const
186 { return openbox_structure_messages; }
188 // *Notify* portions of the NETStructureMessages protocol
189 inline const Atom &getOpenboxNotifyStartupAtom(void) const
190 { return openbox_notify_startup; }
191 inline const Atom &getOpenboxNotifyWindowAddAtom(void) const
192 { return openbox_notify_window_add; }
193 inline const Atom &getOpenboxNotifyWindowDelAtom(void) const
194 { return openbox_notify_window_del; }
195 inline const Atom &getOpenboxNotifyWindowFocusAtom(void) const
196 { return openbox_notify_window_focus; }
197 inline const Atom &getOpenboxNotifyCurrentWorkspaceAtom(void) const
198 { return openbox_notify_current_workspace; }
199 inline const Atom &getOpenboxNotifyWorkspaceCountAtom(void) const
200 { return openbox_notify_workspace_count; }
201 inline const Atom &getOpenboxNotifyWindowRaiseAtom(void) const
202 { return openbox_notify_window_raise; }
203 inline const Atom &getOpenboxNotifyWindowLowerAtom(void) const
204 { return openbox_notify_window_lower; }
206 // atoms to change that request changes to the desktop environment during
207 // runtime... these messages can be sent by any client... as the sending
208 // client window id is not included in the ClientMessage event...
209 inline const Atom &getOpenboxChangeWorkspaceAtom(void) const
210 { return openbox_change_workspace; }
211 inline const Atom &getOpenboxChangeWindowFocusAtom(void) const
212 { return openbox_change_window_focus; }
213 inline const Atom &getOpenboxCycleWindowFocusAtom(void) const
214 { return openbox_cycle_window_focus; }
218 // root window properties
219 inline const Atom &getNETSupportedAtom(void) const
220 { return net_supported; }
221 inline const Atom &getNETClientListAtom(void) const
222 { return net_client_list; }
223 inline const Atom &getNETClientListStackingAtom(void) const
224 { return net_client_list_stacking; }
225 inline const Atom &getNETNumberOfDesktopsAtom(void) const
226 { return net_number_of_desktops; }
227 inline const Atom &getNETDesktopGeometryAtom(void) const
228 { return net_desktop_geometry; }
229 inline const Atom &getNETDesktopViewportAtom(void) const
230 { return net_desktop_viewport; }
231 inline const Atom &getNETCurrentDesktopAtom(void) const
232 { return net_current_desktop; }
233 inline const Atom &getNETDesktopNamesAtom(void) const
234 { return net_desktop_names; }
235 inline const Atom &getNETActiveWindowAtom(void) const
236 { return net_active_window; }
237 inline const Atom &getNETWorkareaAtom(void) const
238 { return net_workarea; }
239 inline const Atom &getNETSupportingWMCheckAtom(void) const
240 { return net_supporting_wm_check; }
241 inline const Atom &getNETVirtualRootsAtom(void) const
242 { return net_virtual_roots; }
244 // root window messages
245 inline const Atom &getNETCloseWindowAtom(void) const
246 { return net_close_window; }
247 inline const Atom &getNETWMMoveResizeAtom(void) const
248 { return net_wm_moveresize; }
250 // application window properties
251 inline const Atom &getNETPropertiesAtom(void) const
252 { return net_properties; }
253 inline const Atom &getNETWMNameAtom(void) const
254 { return net_wm_name; }
255 inline const Atom &getNETWMDesktopAtom(void) const
256 { return net_wm_desktop; }
257 inline const Atom &getNETWMWindowTypeAtom(void) const
258 { return net_wm_window_type; }
259 inline const Atom &getNETWMStateAtom(void) const
260 { return net_wm_state; }
261 inline const Atom &getNETWMStrutAtom(void) const
262 { return net_wm_strut; }
263 inline const Atom &getNETWMIconGeometryAtom(void) const
264 { return net_wm_icon_geometry; }
265 inline const Atom &getNETWMIconAtom(void) const
266 { return net_wm_icon; }
267 inline const Atom &getNETWMPidAtom(void) const
268 { return net_wm_pid; }
269 inline const Atom &getNETWMHandledIconsAtom(void) const
270 { return net_wm_handled_icons; }
272 // application protocols
273 inline const Atom &getNETWMPingAtom(void) const
274 { return net_wm_ping; }
278 inline ScreenInfo *getScreenInfo(int s) {
279 ASSERT(s < screenInfoList.size());
280 return screenInfoList[s];
283 inline const Bool &hasShapeExtensions(void) const
284 { return shape.extensions; }
285 inline const Bool &doShutdown(void) const
286 { return _shutdown; }
287 inline const Bool &isStartup(void) const
290 inline const Cursor &getSessionCursor(void) const
291 { return cursor.session; }
292 inline const Cursor &getMoveCursor(void) const
293 { return cursor.move; }
294 inline const Cursor &getLowerLeftAngleCursor(void) const
295 { return cursor.ll_angle; }
296 inline const Cursor &getLowerRightAngleCursor(void) const
297 { return cursor.lr_angle; }
298 inline const Cursor &getUpperLeftAngleCursor(void) const
299 { return cursor.ul_angle; }
300 inline const Cursor &getUpperRightAngleCursor(void) const
301 { return cursor.ur_angle; }
303 inline Display *getXDisplay(void) { return display; }
305 inline const char *getXDisplayName(void) const
306 { return (const char *) display_name; }
307 inline const char *getApplicationName(void) const
308 { return (const char *) application_name; }
310 inline const int &getNumberOfScreens(void) const
311 { return number_of_screens; }
312 inline const int &getShapeEventBase(void) const
313 { return shape.event_basep; }
315 inline void shutdown(void) { _shutdown = True; }
316 inline void run(void) { _startup = _shutdown = False; }
318 const Bool validateWindow(Window);
320 void grabButton(unsigned int, unsigned int, Window, Bool, unsigned int, int,
321 int, Window, Cursor) const;
322 void ungrabButton(unsigned int button, unsigned int modifiers,
323 Window grab_window) const;
327 void eventLoop(void);
328 void addTimer(BTimer *);
329 void removeTimer(BTimer *);
331 // another pure virtual... this is used to handle signals that BaseDisplay
332 // doesn't understand itself
333 virtual Bool handleSignal(int) = 0;
339 BaseDisplay &basedisplay;
344 int depth, screen_number;
349 ScreenInfo(BaseDisplay &, int);
351 inline BaseDisplay &getBaseDisplay(void) { return basedisplay; }
353 inline Visual *getVisual(void) { return visual; }
354 inline const Window &getRootWindow(void) const { return root_window; }
355 inline const Colormap &getColormap(void) const { return colormap; }
357 inline const int &getDepth(void) const { return depth; }
358 inline const int &getScreenNumber(void) const { return screen_number; }
360 // inline const unsigned int &getWidth(void) const { return width; }
361 // inline const unsigned int &getHeight(void) const { return height; }
362 inline const Size &size() const { return m_size; }
366 #endif // __BaseDisplay_hh