| 1 |
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- |
| 2 |
// blackbox.hh for Blackbox - an X11 Window manager |
| 3 |
// Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <[email protected]> |
| 4 |
// Copyright (c) 1997 - 2000, 2002 - 2005 |
| 5 |
// Bradley T Hughes <bhughes at trolltech.com> |
| 6 |
// |
| 7 |
// Permission is hereby granted, free of charge, to any person obtaining a |
| 8 |
// copy of this software and associated documentation files (the "Software"), |
| 9 |
// to deal in the Software without restriction, including without limitation |
| 10 |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 |
// and/or sell copies of the Software, and to permit persons to whom the |
| 12 |
// Software is furnished to do so, subject to the following conditions: |
| 13 |
// |
| 14 |
// The above copyright notice and this permission notice shall be included in |
| 15 |
// all copies or substantial portions of the Software. |
| 16 |
// |
| 17 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 |
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 |
// DEALINGS IN THE SOFTWARE. |
| 24 |
|
| 25 |
#ifndef __blackbox_hh |
| 26 |
#define __blackbox_hh |
| 27 |
|
| 28 |
#include <Application.hh> |
| 29 |
#include <Util.hh> |
| 30 |
|
| 31 |
#include "BlackboxResource.hh" |
| 32 |
|
| 33 |
#include <list> |
| 34 |
|
| 35 |
// forward declarations |
| 36 |
class BlackboxWindow; |
| 37 |
class BWindowGroup; |
| 38 |
|
| 39 |
namespace bt { |
| 40 |
class EWMH; |
| 41 |
} |
| 42 |
|
| 43 |
class Blackbox : public bt::Application, public bt::TimeoutHandler { |
| 44 |
private: |
| 45 |
unsigned int grab_count; |
| 46 |
|
| 47 |
struct MenuTimestamp { |
| 48 |
std::string filename; |
| 49 |
long timestamp; |
| 50 |
}; |
| 51 |
|
| 52 |
BlackboxResource _resource; |
| 53 |
|
| 54 |
BScreen** screen_list; |
| 55 |
size_t screen_list_count; |
| 56 |
BScreen *active_screen; |
| 57 |
|
| 58 |
typedef std::map<Window, BlackboxWindow*> WindowLookup; |
| 59 |
typedef WindowLookup::value_type WindowLookupPair; |
| 60 |
WindowLookup windowSearchList; |
| 61 |
|
| 62 |
typedef std::map<Window, BWindowGroup*> GroupLookup; |
| 63 |
typedef GroupLookup::value_type GroupLookupPair; |
| 64 |
GroupLookup groupSearchList; |
| 65 |
|
| 66 |
bt::EWMH* _ewmh; |
| 67 |
|
| 68 |
BlackboxWindow *focused_window; |
| 69 |
|
| 70 |
bt::Timer *timer; |
| 71 |
|
| 72 |
typedef std::list<MenuTimestamp*> MenuTimestampList; |
| 73 |
MenuTimestampList menuTimestamps; |
| 74 |
|
| 75 |
char **argv; |
| 76 |
|
| 77 |
Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state, |
| 78 |
xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state, |
| 79 |
motif_wm_hints; |
| 80 |
|
| 81 |
void load_rc(void); |
| 82 |
void save_rc(void); |
| 83 |
void reload_rc(void); |
| 84 |
|
| 85 |
void init_icccm(void); |
| 86 |
|
| 87 |
void updateActiveWindow() const; |
| 88 |
|
| 89 |
// reimplemented virtual functions |
| 90 |
void shutdown(void); |
| 91 |
|
| 92 |
void process_event(XEvent *e); |
| 93 |
bool process_signal(int sig); |
| 94 |
|
| 95 |
void timeout(bt::Timer *); |
| 96 |
|
| 97 |
public: |
| 98 |
Blackbox(char **m_argv, const char *dpy_name, const std::string& rc, |
| 99 |
bool multi_head); |
| 100 |
~Blackbox(void); |
| 101 |
|
| 102 |
void XGrabServer(void); |
| 103 |
void XUngrabServer(void); |
| 104 |
|
| 105 |
inline BlackboxResource &resource(void) |
| 106 |
{ return _resource; } |
| 107 |
|
| 108 |
// screen functions |
| 109 |
BScreen *findScreen(Window window) const; |
| 110 |
|
| 111 |
inline BScreen *activeScreen(void) const |
| 112 |
{ return active_screen; } |
| 113 |
void setActiveScreen(BScreen *screen); |
| 114 |
|
| 115 |
inline unsigned int screenCount(void) const |
| 116 |
{ return screen_list_count; } |
| 117 |
BScreen* screenNumber(unsigned int n); |
| 118 |
|
| 119 |
// window functions |
| 120 |
BlackboxWindow *findWindow(Window window) const; |
| 121 |
|
| 122 |
void insertWindow(Window window, BlackboxWindow *data); |
| 123 |
void removeWindow(Window window); |
| 124 |
|
| 125 |
// window group functions |
| 126 |
BWindowGroup *findWindowGroup(Window window) const; |
| 127 |
|
| 128 |
void insertWindowGroup(Window window, BWindowGroup *data); |
| 129 |
void removeWindowGroup(Window window); |
| 130 |
|
| 131 |
inline const bt::EWMH &ewmh(void) const |
| 132 |
{ return *_ewmh; } |
| 133 |
|
| 134 |
void setFocusedWindow(BlackboxWindow *win); |
| 135 |
inline void forgetFocusedWindow(void) |
| 136 |
{ focused_window = 0; } |
| 137 |
inline BlackboxWindow *focusedWindow(void) const |
| 138 |
{ return focused_window; } |
| 139 |
|
| 140 |
void saveMenuFilename(const std::string& filename); |
| 141 |
void restart(const std::string &prog = std::string()); |
| 142 |
void reconfigure(void); |
| 143 |
|
| 144 |
void checkMenu(void); |
| 145 |
void rereadMenu(void); |
| 146 |
|
| 147 |
inline Atom wmChangeStateAtom(void) const |
| 148 |
{ return xa_wm_change_state; } |
| 149 |
inline Atom wmStateAtom(void) const |
| 150 |
{ return xa_wm_state; } |
| 151 |
inline Atom wmDeleteWindowAtom(void) const |
| 152 |
{ return xa_wm_delete_window; } |
| 153 |
inline Atom wmProtocolsAtom(void) const |
| 154 |
{ return xa_wm_protocols; } |
| 155 |
inline Atom wmTakeFocusAtom(void) const |
| 156 |
{ return xa_wm_take_focus; } |
| 157 |
inline Atom wmColormapAtom(void) const |
| 158 |
{ return xa_wm_colormap_windows; } |
| 159 |
inline Atom motifWmHintsAtom(void) const |
| 160 |
{ return motif_wm_hints; } |
| 161 |
}; |
| 162 |
|
| 163 |
#endif // __blackbox_hh |