diff options
author | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
commit | 18830ac9add80cbd3bf7369307d7e35a519dca9b (patch) | |
tree | 4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/BaseDisplay.hh | |
parent | 1523b48bff07dead084af3064ad11c79a9b25df0 (diff) | |
download | fluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip fluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2 |
Initial revision
Diffstat (limited to 'src/BaseDisplay.hh')
-rw-r--r-- | src/BaseDisplay.hh | 368 |
1 files changed, 368 insertions, 0 deletions
diff --git a/src/BaseDisplay.hh b/src/BaseDisplay.hh new file mode 100644 index 0000000..c25860e --- /dev/null +++ b/src/BaseDisplay.hh | |||
@@ -0,0 +1,368 @@ | |||
1 | // BaseDisplay.hh for Blackbox - an X11 Window manager | ||
2 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.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 _BASEDISPLAY_HH_ | ||
23 | #define _BASEDISPLAY_HH_ | ||
24 | |||
25 | #include <X11/Xlib.h> | ||
26 | #include <X11/Xatom.h> | ||
27 | |||
28 | // forward declaration | ||
29 | class BaseDisplay; | ||
30 | class ScreenInfo; | ||
31 | |||
32 | #include "LinkedList.hh" | ||
33 | #include "Timer.hh" | ||
34 | |||
35 | #define AttribShaded (1l << 0) | ||
36 | #define AttribMaxHoriz (1l << 1) | ||
37 | #define AttribMaxVert (1l << 2) | ||
38 | #define AttribOmnipresent (1l << 3) | ||
39 | #define AttribWorkspace (1l << 4) | ||
40 | #define AttribStack (1l << 5) | ||
41 | #define AttribDecoration (1l << 6) | ||
42 | |||
43 | #define StackTop (0) | ||
44 | #define StackNormal (1) | ||
45 | #define StackBottom (2) | ||
46 | |||
47 | #define DecorNone (0) | ||
48 | #define DecorNormal (1) | ||
49 | #define DecorTiny (2) | ||
50 | #define DecorTool (3) | ||
51 | |||
52 | typedef struct _blackbox_hints { | ||
53 | unsigned long flags, attrib, workspace, stack, decoration; | ||
54 | } BlackboxHints; | ||
55 | |||
56 | typedef struct _blackbox_attributes { | ||
57 | unsigned long flags, attrib, workspace, stack; | ||
58 | int premax_x, premax_y; | ||
59 | unsigned int premax_w, premax_h; | ||
60 | } BlackboxAttributes; | ||
61 | |||
62 | #define PropBlackboxHintsElements (5) | ||
63 | #define PropBlackboxAttributesElements (8) | ||
64 | |||
65 | #ifndef __EMX__ | ||
66 | void bexec(const char *, char *); | ||
67 | #endif // !__EMX__ | ||
68 | |||
69 | char *bstrdup(const char *); | ||
70 | template <typename Z> inline Z min(Z a, Z b) { return ((a < b) ? a : b); } | ||
71 | template <typename Z> inline Z max(Z a, Z b) { return ((a > b) ? a : b); } | ||
72 | |||
73 | class BaseDisplay { | ||
74 | |||
75 | public: | ||
76 | BaseDisplay(char *, char * = 0); | ||
77 | virtual ~BaseDisplay(void); | ||
78 | |||
79 | #ifdef GNOME | ||
80 | inline Atom *getGnomeListAtoms() { return gnome_atom_list; } | ||
81 | inline Atom &getGnomeProtAtom() { return gnome_wm_prot; } | ||
82 | inline Atom &getGnomeClientListAtom() { return gnome_wm_win_client_list; } | ||
83 | inline Atom &getGnomeSupportingWMCheckAtom() { return gnome_wm_supporting_wm_check; } | ||
84 | inline Atom &getGnomeWorkspaceAtom() { return gnome_wm_win_workspace; } | ||
85 | inline Atom &getGnomeWorkspaceCountAtom() { return gnome_wm_win_workspace_count; } | ||
86 | inline Atom &getGnomeWorkspaceNamesAtom() { return gnome_wm_win_workspace_names; } | ||
87 | #endif //GNOME | ||
88 | |||
89 | inline const Atom &getWMChangeStateAtom(void) const | ||
90 | { return xa_wm_change_state; } | ||
91 | inline const Atom &getWMStateAtom(void) const | ||
92 | { return xa_wm_state; } | ||
93 | inline const Atom &getWMDeleteAtom(void) const | ||
94 | { return xa_wm_delete_window; } | ||
95 | inline const Atom &getWMProtocolsAtom(void) const | ||
96 | { return xa_wm_protocols; } | ||
97 | inline const Atom &getWMTakeFocusAtom(void) const | ||
98 | { return xa_wm_take_focus; } | ||
99 | inline const Atom &getWMColormapAtom(void) const | ||
100 | { return xa_wm_colormap_windows; } | ||
101 | inline const Atom &getMotifWMHintsAtom(void) const | ||
102 | { return motif_wm_hints; } | ||
103 | |||
104 | // this atom is for normal app->WM hints about decorations, stacking, | ||
105 | // starting workspace etc... | ||
106 | inline const Atom &getFluxboxHintsAtom(void) const | ||
107 | { return blackbox_hints;} | ||
108 | |||
109 | // these atoms are for normal app->WM interaction beyond the scope of the | ||
110 | // ICCCM... | ||
111 | inline const Atom &getFluxboxAttributesAtom(void) const | ||
112 | { return blackbox_attributes; } | ||
113 | inline const Atom &getFluxboxChangeAttributesAtom(void) const | ||
114 | { return blackbox_change_attributes; } | ||
115 | |||
116 | // these atoms are for window->WM interaction, with more control and | ||
117 | // information on window "structure"... common examples are | ||
118 | // notifying apps when windows are raised/lowered... when the user changes | ||
119 | // workspaces... i.e. "pager talk" | ||
120 | inline const Atom &getFluxboxStructureMessagesAtom(void) const | ||
121 | { return blackbox_structure_messages; } | ||
122 | |||
123 | // *Notify* portions of the NETStructureMessages protocol | ||
124 | inline const Atom &getFluxboxNotifyStartupAtom(void) const | ||
125 | { return blackbox_notify_startup; } | ||
126 | inline const Atom &getFluxboxNotifyWindowAddAtom(void) const | ||
127 | { return blackbox_notify_window_add; } | ||
128 | inline const Atom &getFluxboxNotifyWindowDelAtom(void) const | ||
129 | { return blackbox_notify_window_del; } | ||
130 | inline const Atom &getFluxboxNotifyWindowFocusAtom(void) const | ||
131 | { return blackbox_notify_window_focus; } | ||
132 | inline const Atom &getFluxboxNotifyCurrentWorkspaceAtom(void) const | ||
133 | { return blackbox_notify_current_workspace; } | ||
134 | inline const Atom &getFluxboxNotifyWorkspaceCountAtom(void) const | ||
135 | { return blackbox_notify_workspace_count; } | ||
136 | inline const Atom &getFluxboxNotifyWindowRaiseAtom(void) const | ||
137 | { return blackbox_notify_window_raise; } | ||
138 | inline const Atom &getFluxboxNotifyWindowLowerAtom(void) const | ||
139 | { return blackbox_notify_window_lower; } | ||
140 | |||
141 | // atoms to change that request changes to the desktop environment during | ||
142 | // runtime... these messages can be sent by any client... as the sending | ||
143 | // client window id is not included in the ClientMessage event... | ||
144 | inline const Atom &getFluxboxChangeWorkspaceAtom(void) const | ||
145 | { return blackbox_change_workspace; } | ||
146 | inline const Atom &getFluxboxChangeWindowFocusAtom(void) const | ||
147 | { return blackbox_change_window_focus; } | ||
148 | inline const Atom &getFluxboxCycleWindowFocusAtom(void) const | ||
149 | { return blackbox_cycle_window_focus; } | ||
150 | |||
151 | #ifdef NEWWMSPEC | ||
152 | |||
153 | // root window properties | ||
154 | inline const Atom &getNETSupportedAtom(void) const | ||
155 | { return net_supported; } | ||
156 | inline const Atom &getNETClientListAtom(void) const | ||
157 | { return net_client_list; } | ||
158 | inline const Atom &getNETClientListStackingAtom(void) const | ||
159 | { return net_client_list_stacking; } | ||
160 | inline const Atom &getNETNumberOfDesktopsAtom(void) const | ||
161 | { return net_number_of_desktops; } | ||
162 | inline const Atom &getNETDesktopGeometryAtom(void) const | ||
163 | { return net_desktop_geometry; } | ||
164 | inline const Atom &getNETDesktopViewportAtom(void) const | ||
165 | { return net_desktop_viewport; } | ||
166 | inline const Atom &getNETCurrentDesktopAtom(void) const | ||
167 | { return net_current_desktop; } | ||
168 | inline const Atom &getNETDesktopNamesAtom(void) const | ||
169 | { return net_desktop_names; } | ||
170 | inline const Atom &getNETActiveWindowAtom(void) const | ||
171 | { return net_active_window; } | ||
172 | inline const Atom &getNETWorkareaAtom(void) const | ||
173 | { return net_workarea; } | ||
174 | inline const Atom &getNETSupportingWMCheckAtom(void) const | ||
175 | { return net_supporting_wm_check; } | ||
176 | inline const Atom &getNETVirtualRootsAtom(void) const | ||
177 | { return net_virtual_roots; } | ||
178 | |||
179 | // root window messages | ||
180 | inline const Atom &getNETCloseWindowAtom(void) const | ||
181 | { return net_close_window; } | ||
182 | inline const Atom &getNETWMMoveResizeAtom(void) const | ||
183 | { return net_wm_moveresize; } | ||
184 | |||
185 | // application window properties | ||
186 | inline const Atom &getNETPropertiesAtom(void) const | ||
187 | { return net_properties; } | ||
188 | inline const Atom &getNETWMNameAtom(void) const | ||
189 | { return net_wm_name; } | ||
190 | inline const Atom &getNETWMDesktopAtom(void) const | ||
191 | { return net_wm_desktop; } | ||
192 | inline const Atom &getNETWMWindowTypeAtom(void) const | ||
193 | { return net_wm_window_type; } | ||
194 | inline const Atom &getNETWMStateAtom(void) const | ||
195 | { return net_wm_state; } | ||
196 | inline const Atom &getNETWMStrutAtom(void) const | ||
197 | { return net_wm_strut; } | ||
198 | inline const Atom &getNETWMIconGeometryAtom(void) const | ||
199 | { return net_wm_icon_geometry; } | ||
200 | inline const Atom &getNETWMIconAtom(void) const | ||
201 | { return net_wm_icon; } | ||
202 | inline const Atom &getNETWMPidAtom(void) const | ||
203 | { return net_wm_pid; } | ||
204 | inline const Atom &getNETWMHandledIconsAtom(void) const | ||
205 | { return net_wm_handled_icons; } | ||
206 | |||
207 | // application protocols | ||
208 | inline const Atom &getNETWMPingAtom(void) const | ||
209 | { return net_wm_ping; } | ||
210 | |||
211 | #endif // NEWWMSPEC | ||
212 | |||
213 | inline ScreenInfo *getScreenInfo(int s) | ||
214 | { return (ScreenInfo *) screenInfoList->find(s); } | ||
215 | |||
216 | inline const Bool &hasShapeExtensions(void) const | ||
217 | { return shape.extensions; } | ||
218 | inline const Bool &doShutdown(void) const | ||
219 | { return _shutdown; } | ||
220 | inline const Bool &isStartup(void) const | ||
221 | { return _startup; } | ||
222 | |||
223 | inline const Cursor &getSessionCursor(void) const | ||
224 | { return cursor.session; } | ||
225 | inline const Cursor &getMoveCursor(void) const | ||
226 | { return cursor.move; } | ||
227 | inline const Cursor &getLowerLeftAngleCursor(void) const | ||
228 | { return cursor.ll_angle; } | ||
229 | inline const Cursor &getLowerRightAngleCursor(void) const | ||
230 | { return cursor.lr_angle; } | ||
231 | |||
232 | inline Display *getXDisplay(void) { return display; } | ||
233 | |||
234 | inline const char *getXDisplayName(void) const | ||
235 | { return (const char *) display_name; } | ||
236 | inline const char *getApplicationName(void) const | ||
237 | { return (const char *) application_name; } | ||
238 | |||
239 | inline const int &getNumberOfScreens(void) const | ||
240 | { return number_of_screens; } | ||
241 | inline const int &getShapeEventBase(void) const | ||
242 | { return shape.event_basep; } | ||
243 | |||
244 | inline void shutdown(void) { _shutdown = True; } | ||
245 | inline void run(void) { _startup = _shutdown = False; } | ||
246 | |||
247 | const Bool validateWindow(Window); | ||
248 | |||
249 | void grab(void); | ||
250 | void ungrab(void); | ||
251 | void eventLoop(void); | ||
252 | void addTimer(BTimer *); | ||
253 | void removeTimer(BTimer *); | ||
254 | |||
255 | // another pure virtual... this is used to handle signals that BaseDisplay | ||
256 | // doesn't understand itself | ||
257 | virtual Bool handleSignal(int) = 0; | ||
258 | |||
259 | private: | ||
260 | struct cursor { | ||
261 | Cursor session, move, ll_angle, lr_angle; | ||
262 | } cursor; | ||
263 | |||
264 | struct shape { | ||
265 | Bool extensions; | ||
266 | int event_basep, error_basep; | ||
267 | } shape; | ||
268 | |||
269 | Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state, | ||
270 | xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state, | ||
271 | motif_wm_hints; | ||
272 | |||
273 | // NETAttributes | ||
274 | Atom blackbox_attributes, blackbox_change_attributes, blackbox_hints; | ||
275 | |||
276 | // NETStructureMessages | ||
277 | Atom blackbox_structure_messages, blackbox_notify_startup, | ||
278 | blackbox_notify_window_add, blackbox_notify_window_del, | ||
279 | blackbox_notify_window_focus, blackbox_notify_current_workspace, | ||
280 | blackbox_notify_workspace_count, blackbox_notify_window_raise, | ||
281 | blackbox_notify_window_lower; | ||
282 | |||
283 | // message_types for client -> wm messages | ||
284 | Atom blackbox_change_workspace, blackbox_change_window_focus, | ||
285 | blackbox_cycle_window_focus; | ||
286 | |||
287 | #ifdef NEWWMSPEC | ||
288 | |||
289 | // root window properties | ||
290 | Atom net_supported, net_client_list, net_client_list_stacking, | ||
291 | net_number_of_desktops, net_desktop_geometry, net_desktop_viewport, | ||
292 | net_current_desktop, net_desktop_names, net_active_window, net_workarea, | ||
293 | net_supporting_wm_check, net_virtual_roots; | ||
294 | |||
295 | // root window messages | ||
296 | Atom net_close_window, net_wm_moveresize; | ||
297 | |||
298 | // application window properties | ||
299 | Atom net_properties, net_wm_name, net_wm_desktop, net_wm_window_type, | ||
300 | net_wm_state, net_wm_strut, net_wm_icon_geometry, net_wm_icon, net_wm_pid, | ||
301 | net_wm_handled_icons; | ||
302 | |||
303 | |||
304 | // application protocols | ||
305 | Atom net_wm_ping; | ||
306 | |||
307 | #endif // NEWWMSPEC | ||
308 | |||
309 | #ifdef GNOME | ||
310 | union { | ||
311 | Atom gnome_wm_win_layer, gnome_wm_win_state, gnome_wm_win_hints, | ||
312 | gnome_wm_win_app_state, gnome_wm_win_expanded_size, | ||
313 | gnome_wm_win_icons, gnome_wm_win_workspace, | ||
314 | gnome_wm_win_workspace_count, gnome_wm_win_workspace_names, | ||
315 | gnome_wm_win_client_list; | ||
316 | Atom gnome_atom_list[10]; | ||
317 | }; | ||
318 | Atom gnome_wm_prot; | ||
319 | Atom gnome_wm_supporting_wm_check; | ||
320 | #endif // GNOME | ||
321 | |||
322 | |||
323 | Bool _startup, _shutdown; | ||
324 | Display *display; | ||
325 | LinkedList<ScreenInfo> *screenInfoList; | ||
326 | LinkedList<BTimer> *timerList; | ||
327 | |||
328 | char *display_name, *application_name; | ||
329 | int number_of_screens, server_grabs, colors_per_channel; | ||
330 | |||
331 | protected: | ||
332 | |||
333 | virtual void process_event(XEvent *) = 0; | ||
334 | |||
335 | |||
336 | }; | ||
337 | |||
338 | |||
339 | class ScreenInfo { | ||
340 | public: | ||
341 | ScreenInfo(BaseDisplay *, int); | ||
342 | |||
343 | inline BaseDisplay *getBaseDisplay(void) { return basedisplay; } | ||
344 | |||
345 | inline Visual *getVisual(void) { return visual; } | ||
346 | inline const Window &getRootWindow(void) const { return root_window; } | ||
347 | inline const Colormap &getColormap(void) const { return colormap; } | ||
348 | |||
349 | inline const int &getDepth(void) const { return depth; } | ||
350 | inline const int &getScreenNumber(void) const { return screen_number; } | ||
351 | |||
352 | inline const unsigned int &getWidth(void) const { return width; } | ||
353 | inline const unsigned int &getHeight(void) const { return height; } | ||
354 | |||
355 | private: | ||
356 | BaseDisplay *basedisplay; | ||
357 | Visual *visual; | ||
358 | Window root_window; | ||
359 | Colormap colormap; | ||
360 | |||
361 | int depth, screen_number; | ||
362 | unsigned int width, height; | ||
363 | |||
364 | |||
365 | }; | ||
366 | |||
367 | |||
368 | #endif // __BaseDisplay_hh | ||