00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef FLUXBOX_HH
00028 #define FLUXBOX_HH
00029
00030 #include "FbTk/App.hh"
00031 #include "FbTk/Resource.hh"
00032 #include "FbTk/Timer.hh"
00033 #include "FbTk/Observer.hh"
00034 #include "FbTk/SignalHandler.hh"
00035
00036 #include <X11/Xlib.h>
00037 #include <X11/Xresource.h>
00038
00039 #include <cstdio>
00040
00041 #ifdef HAVE_CONFIG_H
00042 #include "config.h"
00043 #endif // HAVE_CONFIG_H
00044
00045 #ifdef TIME_WITH_SYS_TIME
00046 #include <sys/time.h>
00047 #include <time.h>
00048 #else // !TIME_WITH_SYS_TIME
00049 #ifdef HAVE_SYS_TIME_H
00050 #include <sys/time.h>
00051 #else // !HAVE_SYS_TIME_H
00052 #include <time.h>
00053 #endif // HAVE_SYS_TIME_H
00054 #endif // TIME_WITH_SYS_TIME
00055
00056 #include <list>
00057 #include <map>
00058 #include <memory>
00059 #include <string>
00060 #include <vector>
00061
00062 class AtomHandler;
00063 class FluxboxWindow;
00064 class WinClient;
00065 class Keys;
00066 class BScreen;
00067 class FbAtoms;
00068 class Toolbar;
00069
00070
00072
00075 class Fluxbox : public FbTk::App,
00076 public FbTk::SignalEventHandler,
00077 public FbTk::Observer {
00078 public:
00079 Fluxbox(int argc, char **argv, const char * dpy_name= 0,
00080 const char *rcfilename = 0);
00081 virtual ~Fluxbox();
00082
00083 static Fluxbox *instance() { return s_singleton; }
00085 void eventLoop();
00086 bool validateWindow(Window win) const;
00087 void grab();
00088 void ungrab();
00089 Keys *keys() { return m_key.get(); }
00090 inline Atom getFluxboxPidAtom() const { return m_fluxbox_pid; }
00091
00092
00093
00094 WinClient *searchWindow(Window);
00095 inline WinClient *getFocusedWindow() { return m_focused_window; }
00096
00097
00098 BScreen *searchScreen(Window w);
00099
00100 inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; }
00101 inline unsigned int getUpdateDelayTime() const { return *m_rc_update_delay_time; }
00102 inline Time getLastTime() const { return m_last_time; }
00103
00104 void addAtomHandler(AtomHandler *atomh);
00105 void removeAtomHandler(AtomHandler *atomh);
00106
00108 enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};
00109
00110
00111
00112 inline const Bool getIgnoreBorder() const { return *m_rc_ignoreborder; }
00113
00114 inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() const { return *m_rc_titlebar_right; }
00115 inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() const { return *m_rc_titlebar_left; }
00116 inline const std::string &getStyleFilename() const { return *m_rc_stylefile; }
00117
00118 inline const std::string &getMenuFilename() const { return *m_rc_menufile; }
00119 inline const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; }
00120 inline int colorsPerChannel() const { return *m_rc_colors_per_channel; }
00121 inline int getNumberOfLayers() const { return *m_rc_numlayers; }
00122
00123
00124
00125
00126 class Layer {
00127 public:
00128 explicit Layer(int i) : m_num(i) {};
00129 inline int getNum() const { return m_num; }
00130
00131 Layer &operator=(int num) { m_num = num; return *this; }
00132
00133 private:
00134 int m_num;
00135 };
00136
00137
00138 inline int getMenuLayer() const { return 0; }
00139 inline int getAboveDockLayer() const { return 2; }
00140 inline int getDockLayer() const { return 4; }
00141 inline int getTopLayer() const { return 6; }
00142 inline int getNormalLayer() const { return 8; }
00143 inline int getBottomLayer() const { return 10; }
00144 inline int getDesktopLayer() const { return 12; }
00145
00146
00147 inline time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; }
00148
00149 inline unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; }
00150 inline unsigned int getCacheMax() const { return *m_rc_cache_max; }
00151 inline bool useMod1() const { return *m_rc_use_mod1; }
00152
00153 inline void maskWindowEvents(Window w, FluxboxWindow *bw)
00154 { m_masked = w; m_masked_window = bw; }
00155
00156 void watchKeyRelease(BScreen &screen, unsigned int mods);
00157
00158 void setFocusedWindow(WinClient *w);
00159 void revertFocus(BScreen &screen);
00160 void shutdown();
00161 void load_rc(BScreen &scr);
00162 void loadRootCommand(BScreen &scr);
00163 void loadTitlebar();
00164 void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); }
00165 void saveMenuFilename(const char *);
00166 void clearMenuFilenames();
00167 void saveTitlebarFilename(const char *);
00168 void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); }
00169 void saveWindowSearch(Window win, WinClient *winclient);
00170
00171
00172 void saveWindowSearchGroup(Window win, FluxboxWindow *fbwin);
00173 void saveGroupSearch(Window win, WinClient *winclient);
00174 void save_rc();
00175 void removeWindowSearch(Window win);
00176 void removeWindowSearchGroup(Window win);
00177 void removeGroupSearch(Window win);
00178 void restart(const char *command = 0);
00179 void reconfigure();
00180 void rereadMenu();
00182 void checkMenu();
00183
00184 void hideExtraMenus(BScreen &screen);
00185
00187 void handleSignal(int signum);
00188 void update(FbTk::Subject *changed);
00189
00190 void attachSignals(FluxboxWindow &win);
00191 void attachSignals(WinClient &winclient);
00192
00193 void timed_reconfigure();
00194
00195 bool isStartup() const { return m_starting; }
00196
00197
00198
00199 typedef std::vector<Fluxbox::Titlebar> TitlebarList;
00201 bool menuTimestampsChanged() const;
00202 bool haveShape() const { return m_have_shape; }
00203 int shapeEventbase() const { return m_shape_eventbase; }
00204 void getDefaultDataFilename(char *, std::string &);
00205
00206 BScreen *mouseScreen() { return m_mousescreen; }
00207
00208 BScreen *keyScreen() { return m_keyscreen; }
00209
00210 BScreen *watchingScreen() { return m_watching_screen; }
00211 const XEvent &lastEvent() const { return m_last_event; }
00212 private:
00213
00214 typedef struct MenuTimestamp {
00215 std::string filename;
00216 time_t timestamp;
00217 } MenuTimestamp;
00218
00219
00220
00221 std::string getRcFilename();
00222 void load_rc();
00223
00224 void reload_rc();
00225 void real_rereadMenu();
00226 void real_reconfigure();
00227
00228 void handleEvent(XEvent *xe);
00229
00230 void setupConfigFiles();
00231 void handleButtonEvent(XButtonEvent &be);
00232 void handleUnmapNotify(XUnmapEvent &ue);
00233 void handleClientMessage(XClientMessageEvent &ce);
00234 void handleKeyEvent(XKeyEvent &ke);
00235 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
00236
00237 std::auto_ptr<FbAtoms> m_fbatoms;
00238
00239 FbTk::ResourceManager m_resourcemanager, &m_screen_rm;
00240
00241
00242
00243 FbTk::Resource<bool> m_rc_tabs, m_rc_ignoreborder;
00244 FbTk::Resource<int> m_rc_colors_per_channel, m_rc_numlayers,
00245 m_rc_double_click_interval, m_rc_update_delay_time;
00246 FbTk::Resource<std::string> m_rc_stylefile,
00247 m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
00248 m_rc_groupfile;
00249
00250
00251 FbTk::Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
00252 FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
00253 FbTk::Resource<time_t> m_rc_auto_raise_delay;
00254 FbTk::Resource<bool> m_rc_use_mod1;
00255
00256 std::map<Window, WinClient *> m_window_search;
00257 std::map<Window, FluxboxWindow *> m_window_search_group;
00258
00259
00260
00261
00262
00263 std::multimap<Window, WinClient *> m_group_search;
00264
00265 std::list<MenuTimestamp *> m_menu_timestamps;
00266 typedef std::list<BScreen *> ScreenList;
00267 ScreenList m_screen_list;
00268
00269 WinClient *m_focused_window;
00270 FluxboxWindow *m_masked_window;
00271
00272 BScreen *m_mousescreen, *m_keyscreen;
00273 BScreen *m_watching_screen;
00274 unsigned int m_watch_keyrelease;
00275
00276 Atom m_fluxbox_pid;
00277
00278 bool m_reconfigure_wait, m_reread_menu_wait;
00279 Time m_last_time;
00280 Window m_masked;
00281 std::string m_rc_file;
00282 char **m_argv;
00283 int m_argc;
00284 XEvent m_last_event;
00285
00286 FbTk::Timer m_reconfig_timer;
00287
00288 std::auto_ptr<Keys> m_key;
00289
00290
00291 static Fluxbox::Titlebar s_titlebar_left[], s_titlebar_right[];
00292 static Fluxbox *s_singleton;
00293 std::vector<AtomHandler *> m_atomhandler;
00294 std::vector<Toolbar *> m_toolbars;
00295
00296 bool m_starting;
00297 bool m_shutdown;
00298 int m_server_grabs;
00299 int m_randr_event_type;
00300 int m_shape_eventbase;
00301 bool m_have_shape;
00302 const char *m_RC_PATH;
00303 const char *m_RC_INIT_FILE;
00304 Atom m_kwm1_dockwindow, m_kwm2_dockwindow;
00305 };
00306
00307
00308 #endif // FLUXBOX_HH