// fluxbox.hh for Fluxbox Window Manager // Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) // // blackbox.hh for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // $Id: fluxbox.hh,v 1.49 2003/04/15 12:11:10 fluxgen Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH #include "Resource.hh" #include "BaseDisplay.hh" #include "Timer.hh" #include "Observer.hh" #ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H #include "SignalHandler.hh" #include #include #include #ifdef TIME_WITH_SYS_TIME #include #include #else // !TIME_WITH_SYS_TIME #ifdef HAVE_SYS_TIME_H #include #else // !HAVE_SYS_TIME_H #include #endif // HAVE_SYS_TIME_H #endif // TIME_WITH_SYS_TIME #include #include #include #include #include class AtomHandler; class FluxboxWindow; class Keys; class BScreen; class FbAtoms; /** main class for the window manager. singleton type */ class Fluxbox : public BaseDisplay, public FbTk::TimeoutHandler, public FbTk::SignalEventHandler, public FbTk::Observer { public: Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0); virtual ~Fluxbox(); static Fluxbox *instance() { return singleton; } inline bool useIconBar() const { return *m_rc_iconbar; } inline void saveIconBar(bool value) { m_rc_iconbar = value; } inline Atom getFluxboxPidAtom() const { return fluxbox_pid; } FluxboxWindow *searchGroup(Window, FluxboxWindow *); FluxboxWindow *searchWindow(Window); inline FluxboxWindow *getFocusedWindow() { return focused_window; } BScreen *searchScreen(Window w); inline const Time &getDoubleClickInterval() const { return resource.double_click_interval; } inline const Time &getLastTime() const { return last_time; } /// obsolete enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY}; enum FocusModel { SLOPPYFOCUS=0, SEMISLOPPYFOCUS, CLICKTOFOCUS }; inline const std::vector& getTitlebarRight() const { return *m_rc_titlebar_right; } inline const std::vector& getTitlebarLeft() const { return *m_rc_titlebar_left; } inline const std::string &getStyleFilename() const { return *m_rc_stylefile; } inline const char *getMenuFilename() const { return m_rc_menufile->c_str(); } inline const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; } inline int colorsPerChannel() const { return *m_rc_colors_per_channel; } inline int getNumberOfLayers() const { return *m_rc_numlayers; } // class to store layer numbers (special Resource type) class Layer { public: explicit Layer(int i) : m_num(i) {}; inline int getNum() const { return m_num; } Layer &operator=(int num) { m_num = num; return *this; } private: int m_num; }; // TODO these probably should be configurable inline int getMenuLayer() const { return 0; } inline int getAboveDockLayer() const { return 2; } inline int getDockLayer() const { return 4; } inline int getTopLayer() const { return 6; } inline int getNormalLayer() const { return 8; } inline int getBottomLayer() const { return 10; } inline int getDesktopLayer() const { return 12; } inline const timeval &getAutoRaiseDelay() const { return resource.auto_raise_delay; } inline unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; } inline unsigned int getCacheMax() const { return *m_rc_cache_max; } inline void maskWindowEvents(Window w, FluxboxWindow *bw) { masked = w; masked_window = bw; } inline void setNoFocus(bool f) { no_focus = f; } void watchKeyRelease(BScreen *screen, unsigned int mods); void setFocusedWindow(FluxboxWindow *w); void shutdown(); void load_rc(BScreen &scr); void loadRootCommand(BScreen &scr); void loadTitlebar(); void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } void saveMenuFilename(const char *); void saveTitlebarFilename(const char *); void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); } void saveWindowSearch(Window win, FluxboxWindow *fbwin); void saveGroupSearch(Window win, FluxboxWindow *fbwin); void save_rc(); void removeWindowSearch(Window win); void removeGroupSearch(Window win); void restart(const char *command = 0); void reconfigure(); void rereadMenu(); void checkMenu(); /// handle any system signal sent to the application void handleSignal(int signum); void update(FbTk::Subject *changed); void attachSignals(FluxboxWindow &win); virtual void timeout(); inline const Cursor &getSessionCursor() const { return cursor.session; } inline const Cursor &getMoveCursor() const { return cursor.move; } inline const Cursor &getLowerLeftAngleCursor() const { return cursor.ll_angle; } inline const Cursor &getLowerRightAngleCursor() const { return cursor.lr_angle; } enum { B_AMERICANDATE = 1, B_EUROPEANDATE }; typedef std::vector TitlebarList; private: struct cursor { Cursor session, move, ll_angle, lr_angle; } cursor; typedef struct MenuTimestamp { char *filename; time_t timestamp; } MenuTimestamp; struct resource { Time double_click_interval; timeval auto_raise_delay; } resource; std::string getRcFilename(); void getDefaultDataFilename(char *, std::string &); void load_rc(); void reload_rc(); void real_rereadMenu(); void real_reconfigure(); void handleEvent(XEvent *xe); void setupConfigFiles(); void handleButtonEvent(XButtonEvent &be); void handleUnmapNotify(XUnmapEvent &ue); void handleClientMessage(XClientMessageEvent &ce); void handleKeyEvent(XKeyEvent &ke); void doWindowAction(int action, const int param); void setTitlebar(std::vector& dir, const char *arg); std::auto_ptr m_fbatoms; ResourceManager m_resourcemanager, m_screen_rm; //--- Resources Resource m_rc_tabs, m_rc_iconbar; Resource m_rc_colors_per_channel, m_rc_numlayers; Resource m_rc_stylefile, m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, m_rc_groupfile; Resource m_rc_titlebar_left, m_rc_titlebar_right; Resource m_rc_cache_life, m_rc_cache_max; std::map windowSearch; std::map groupSearch; std::list menuTimestamps; typedef std::list ScreenList; ScreenList screenList; FluxboxWindow *focused_window, *masked_window; FbTk::Timer timer; BScreen *watching_screen; unsigned int watch_keyrelease; Atom fluxbox_pid; bool no_focus, reconfigure_wait, reread_menu_wait; Time last_time; Window masked; std::string rc_file; ///< resource filename char **argv; int argc; std::auto_ptr key; std::string slitlist_path; //default arguments for titlebar left and right static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[]; static Fluxbox *singleton; std::vector m_atomhandler; }; #endif // _FLUXBOX_HH_