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
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 typedef std::list
<BTimer
*> TimerList
;
139 char *display_name
, *application_name
;
140 int number_of_screens
, server_grabs
, colors_per_channel
;
144 // pure virtual function... you must override this
145 virtual void process_event(XEvent
*) = 0;
147 // the masks of the modifiers which are ignored in button events.
148 int NumLockMask
, ScrollLockMask
;
152 BaseDisplay(const char *, char * = 0);
153 virtual ~BaseDisplay(void);
155 inline const Atom
&getWMChangeStateAtom(void) const
156 { return xa_wm_change_state
; }
157 inline const Atom
&getWMStateAtom(void) const
158 { return xa_wm_state
; }
159 inline const Atom
&getWMDeleteAtom(void) const
160 { return xa_wm_delete_window
; }
161 inline const Atom
&getWMProtocolsAtom(void) const
162 { return xa_wm_protocols
; }
163 inline const Atom
&getWMTakeFocusAtom(void) const
164 { return xa_wm_take_focus
; }
165 inline const Atom
&getWMColormapAtom(void) const
166 { return xa_wm_colormap_windows
; }
167 inline const Atom
&getMotifWMHintsAtom(void) const
168 { return motif_wm_hints
; }
170 // this atom is for normal app->WM hints about decorations, stacking,
171 // starting workspace etc...
172 inline const Atom
&getOpenboxHintsAtom(void) const
173 { return openbox_hints
;}
175 // these atoms are for normal app->WM interaction beyond the scope of the
177 inline const Atom
&getOpenboxAttributesAtom(void) const
178 { return openbox_attributes
; }
179 inline const Atom
&getOpenboxChangeAttributesAtom(void) const
180 { return openbox_change_attributes
; }
182 // these atoms are for window->WM interaction, with more control and
183 // information on window "structure"... common examples are
184 // notifying apps when windows are raised/lowered... when the user changes
185 // workspaces... i.e. "pager talk"
186 inline const Atom
&getOpenboxStructureMessagesAtom(void) const
187 { return openbox_structure_messages
; }
189 // *Notify* portions of the NETStructureMessages protocol
190 inline const Atom
&getOpenboxNotifyStartupAtom(void) const
191 { return openbox_notify_startup
; }
192 inline const Atom
&getOpenboxNotifyWindowAddAtom(void) const
193 { return openbox_notify_window_add
; }
194 inline const Atom
&getOpenboxNotifyWindowDelAtom(void) const
195 { return openbox_notify_window_del
; }
196 inline const Atom
&getOpenboxNotifyWindowFocusAtom(void) const
197 { return openbox_notify_window_focus
; }
198 inline const Atom
&getOpenboxNotifyCurrentWorkspaceAtom(void) const
199 { return openbox_notify_current_workspace
; }
200 inline const Atom
&getOpenboxNotifyWorkspaceCountAtom(void) const
201 { return openbox_notify_workspace_count
; }
202 inline const Atom
&getOpenboxNotifyWindowRaiseAtom(void) const
203 { return openbox_notify_window_raise
; }
204 inline const Atom
&getOpenboxNotifyWindowLowerAtom(void) const
205 { return openbox_notify_window_lower
; }
207 // atoms to change that request changes to the desktop environment during
208 // runtime... these messages can be sent by any client... as the sending
209 // client window id is not included in the ClientMessage event...
210 inline const Atom
&getOpenboxChangeWorkspaceAtom(void) const
211 { return openbox_change_workspace
; }
212 inline const Atom
&getOpenboxChangeWindowFocusAtom(void) const
213 { return openbox_change_window_focus
; }
214 inline const Atom
&getOpenboxCycleWindowFocusAtom(void) const
215 { return openbox_cycle_window_focus
; }
219 // root window properties
220 inline const Atom
&getNETSupportedAtom(void) const
221 { return net_supported
; }
222 inline const Atom
&getNETClientListAtom(void) const
223 { return net_client_list
; }
224 inline const Atom
&getNETClientListStackingAtom(void) const
225 { return net_client_list_stacking
; }
226 inline const Atom
&getNETNumberOfDesktopsAtom(void) const
227 { return net_number_of_desktops
; }
228 inline const Atom
&getNETDesktopGeometryAtom(void) const
229 { return net_desktop_geometry
; }
230 inline const Atom
&getNETDesktopViewportAtom(void) const
231 { return net_desktop_viewport
; }
232 inline const Atom
&getNETCurrentDesktopAtom(void) const
233 { return net_current_desktop
; }
234 inline const Atom
&getNETDesktopNamesAtom(void) const
235 { return net_desktop_names
; }
236 inline const Atom
&getNETActiveWindowAtom(void) const
237 { return net_active_window
; }
238 inline const Atom
&getNETWorkareaAtom(void) const
239 { return net_workarea
; }
240 inline const Atom
&getNETSupportingWMCheckAtom(void) const
241 { return net_supporting_wm_check
; }
242 inline const Atom
&getNETVirtualRootsAtom(void) const
243 { return net_virtual_roots
; }
245 // root window messages
246 inline const Atom
&getNETCloseWindowAtom(void) const
247 { return net_close_window
; }
248 inline const Atom
&getNETWMMoveResizeAtom(void) const
249 { return net_wm_moveresize
; }
251 // application window properties
252 inline const Atom
&getNETPropertiesAtom(void) const
253 { return net_properties
; }
254 inline const Atom
&getNETWMNameAtom(void) const
255 { return net_wm_name
; }
256 inline const Atom
&getNETWMDesktopAtom(void) const
257 { return net_wm_desktop
; }
258 inline const Atom
&getNETWMWindowTypeAtom(void) const
259 { return net_wm_window_type
; }
260 inline const Atom
&getNETWMStateAtom(void) const
261 { return net_wm_state
; }
262 inline const Atom
&getNETWMStrutAtom(void) const
263 { return net_wm_strut
; }
264 inline const Atom
&getNETWMIconGeometryAtom(void) const
265 { return net_wm_icon_geometry
; }
266 inline const Atom
&getNETWMIconAtom(void) const
267 { return net_wm_icon
; }
268 inline const Atom
&getNETWMPidAtom(void) const
269 { return net_wm_pid
; }
270 inline const Atom
&getNETWMHandledIconsAtom(void) const
271 { return net_wm_handled_icons
; }
273 // application protocols
274 inline const Atom
&getNETWMPingAtom(void) const
275 { return net_wm_ping
; }
279 inline ScreenInfo
*getScreenInfo(unsigned int s
) {
280 ASSERT(s
< screenInfoList
.size());
281 return screenInfoList
[s
];
284 inline const Bool
&hasShapeExtensions(void) const
285 { return shape
.extensions
; }
286 inline const Bool
&doShutdown(void) const
287 { return _shutdown
; }
288 inline const Bool
&isStartup(void) const
291 inline const Cursor
&getSessionCursor(void) const
292 { return cursor
.session
; }
293 inline const Cursor
&getMoveCursor(void) const
294 { return cursor
.move
; }
295 inline const Cursor
&getLowerLeftAngleCursor(void) const
296 { return cursor
.ll_angle
; }
297 inline const Cursor
&getLowerRightAngleCursor(void) const
298 { return cursor
.lr_angle
; }
299 inline const Cursor
&getUpperLeftAngleCursor(void) const
300 { return cursor
.ul_angle
; }
301 inline const Cursor
&getUpperRightAngleCursor(void) const
302 { return cursor
.ur_angle
; }
304 inline Display
*getXDisplay(void) { return display
; }
306 inline const char *getXDisplayName(void) const
307 { return (const char *) display_name
; }
308 inline const char *getApplicationName(void) const
309 { return (const char *) application_name
; }
311 inline const int &getNumberOfScreens(void) const
312 { return number_of_screens
; }
313 inline const int &getShapeEventBase(void) const
314 { return shape
.event_basep
; }
316 inline void shutdown(void) { _shutdown
= True
; }
317 inline void run(void) { _startup
= _shutdown
= False
; }
319 const Bool
validateWindow(Window
);
321 void grabButton(unsigned int, unsigned int, Window
, Bool
, unsigned int, int,
322 int, Window
, Cursor
) const;
323 void ungrabButton(unsigned int button
, unsigned int modifiers
,
324 Window grab_window
) const;
328 void eventLoop(void);
329 void addTimer(BTimer
*);
330 void removeTimer(BTimer
*);
332 // another pure virtual... this is used to handle signals that BaseDisplay
333 // doesn't understand itself
334 virtual Bool
handleSignal(int) = 0;
340 BaseDisplay
&basedisplay
;
345 int depth
, screen_number
;
350 ScreenInfo(BaseDisplay
&, int);
352 inline BaseDisplay
&getBaseDisplay(void) { return basedisplay
; }
354 inline Visual
*getVisual(void) { return visual
; }
355 inline const Window
&getRootWindow(void) const { return root_window
; }
356 inline const Colormap
&getColormap(void) const { return colormap
; }
358 inline const int &getDepth(void) const { return depth
; }
359 inline const int &getScreenNumber(void) const { return screen_number
; }
361 // inline const unsigned int &getWidth(void) const { return width; }
362 // inline const unsigned int &getHeight(void) const { return height; }
363 inline const Size
&size() const { return m_size
; }
367 #endif // __BaseDisplay_hh