fluxbox/src/fluxbox.hh

259 lines
8.4 KiB
C++
Raw Normal View History

// fluxbox.hh for Fluxbox Window Manager
// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
//
2001-12-11 20:47:02 +00:00
// blackbox.hh for Blackbox - an X11 Window manager
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@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.42 2003/02/17 12:29:35 fluxgen Exp $
2001-12-11 20:47:02 +00:00
2002-02-17 18:42:15 +00:00
#ifndef FLUXBOX_HH
#define FLUXBOX_HH
2001-12-11 20:47:02 +00:00
#include "Resource.hh"
#include "Keys.hh"
2001-12-11 20:47:02 +00:00
#include "BaseDisplay.hh"
#include "Timer.hh"
#include "Toolbar.hh"
#include "Observer.hh"
2002-10-13 21:55:56 +00:00
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#include "SignalHandler.hh"
#include "FbAtoms.hh"
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <cstdio>
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else // !TIME_WITH_SYS_TIME
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else // !HAVE_SYS_TIME_H
#include <time.h>
#endif // HAVE_SYS_TIME_H
#endif // TIME_WITH_SYS_TIME
2002-10-19 14:15:07 +00:00
#include <list>
#include <map>
#include <memory>
2001-12-11 20:47:02 +00:00
#include <string>
#include <vector>
class AtomHandler;
2002-11-30 20:16:14 +00:00
class FluxboxWindow;
class Tab;
2002-08-04 15:55:13 +00:00
/**
main class for the window manager.
singleton type
*/
2003-01-10 00:41:15 +00:00
class Fluxbox : public BaseDisplay, public FbTk::TimeoutHandler,
2002-12-01 13:42:15 +00:00
public FbTk::SignalEventHandler,
public FbAtoms,
public FbTk::Observer {
2001-12-11 20:47:02 +00:00
public:
2002-12-01 13:42:15 +00:00
Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0);
virtual ~Fluxbox();
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
static Fluxbox *instance() { return singleton; }
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
inline bool useTabs() { return *m_rc_tabs; }
inline bool useIconBar() { return *m_rc_iconbar; }
inline void saveTabs(bool value) { *m_rc_tabs = value; }
inline void saveIconBar(bool value) { m_rc_iconbar = value; }
2002-08-04 15:55:13 +00:00
#ifdef HAVE_GETPID
2002-12-01 13:42:15 +00:00
inline Atom getFluxboxPidAtom() const { return fluxbox_pid; }
2001-12-11 20:47:02 +00:00
#endif // HAVE_GETPID
2002-12-01 13:42:15 +00:00
FluxboxWindow *searchGroup(Window, FluxboxWindow *);
FluxboxWindow *searchWindow(Window);
inline FluxboxWindow *getFocusedWindow() { return focused_window; }
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
BScreen *searchScreen(Window w);
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
inline const Time &getDoubleClickInterval() const { return resource.double_click_interval; }
inline const Time &getLastTime() const { return last_time; }
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
Tab *searchTab(Window);
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
/// obsolete
enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return *m_rc_titlebar_right; }
inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return *m_rc_titlebar_left; }
inline const std::string &getStyleFilename() const { return *m_rc_stylefile; }
2002-12-01 13:42:15 +00:00
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; }
// TODO there probably should be configurable
2003-02-16 15:12:08 +00:00
inline int getDesktopLayer() const { return 12; }
inline int getBottomLayer() const { return 10; }
inline int getNormalLayer() const { return 8; }
inline int getTopLayer() const { return 6; }
inline int getSlitLayer() const { return 4; }
inline int getAboveSlitLayer() const { return 2; }
inline int getMenuLayer() const { return 0; }
2002-12-01 13:42:15 +00:00
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 setFocusedWindow(FluxboxWindow *w);
void shutdown();
void load_rc(BScreen *);
void loadRootCommand(BScreen *);
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, FluxboxWindow *);
void saveTabSearch(Window, Tab *);
void saveGroupSearch(Window, FluxboxWindow *);
void save_rc();
void removeWindowSearch(Window);
void removeTabSearch(Window);
void removeGroupSearch(Window);
void restart(const char * = 0);
void reconfigure();
void reconfigureTabs();
void rereadMenu();
void checkMenu();
2002-12-01 13:42:15 +00:00
/// handle any system signal sent to the application
void handleSignal(int signum);
void update(FbTk::Subject *changed);
2002-12-01 13:42:15 +00:00
void attachSignals(FluxboxWindow &win);
2002-10-13 21:55:56 +00:00
2002-12-01 13:42:15 +00:00
virtual void timeout();
2002-12-01 13:42:15 +00:00
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; }
2001-12-11 20:47:02 +00:00
#ifndef HAVE_STRFTIME
2002-12-01 13:42:15 +00:00
enum { B_AMERICANDATE = 1, B_EUROPEANDATE };
2001-12-11 20:47:02 +00:00
#endif // HAVE_STRFTIME
2002-12-01 13:42:15 +00:00
typedef std::vector<Fluxbox::Titlebar> TitlebarList;
2001-12-11 20:47:02 +00:00
private:
2002-12-01 13:42:15 +00:00
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;
2002-12-01 13:42:15 +00:00
std::string getRcFilename();
void getDefaultDataFilename(char *, std::string &);
void load_rc();
2002-12-01 13:42:15 +00:00
void reload_rc();
void real_rereadMenu();
void real_reconfigure();
2002-12-01 13:42:15 +00:00
void handleEvent(XEvent *xe);
2002-12-01 13:42:15 +00:00
void setupConfigFiles();
void handleButtonEvent(XButtonEvent &be);
void handleUnmapNotify(XUnmapEvent &ue);
void handleClientMessage(XClientMessageEvent &ce);
void handleKeyEvent(XKeyEvent &ke);
void doWindowAction(Keys::KeyAction action, const int param);
ResourceManager m_resourcemanager, m_screen_rm;
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
//--- Resources
Resource<bool> m_rc_tabs, m_rc_iconbar;
Resource<int> m_rc_colors_per_channel, m_rc_numlayers;
2002-12-01 13:42:15 +00:00
Resource<std::string> m_rc_stylefile,
m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
m_rc_groupfile;
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
2002-12-01 13:42:15 +00:00
void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
std::map<Window, FluxboxWindow *> windowSearch;
std::map<Window, FluxboxWindow *> groupSearch;
typedef std::map<Window, Tab *> TabList;
TabList tabSearch;
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
std::list<MenuTimestamp *> menuTimestamps;
typedef std::list<BScreen *> ScreenList;
ScreenList screenList;
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
FluxboxWindow *focused_window, *masked_window;
2003-01-10 00:41:15 +00:00
FbTk::Timer timer;
2001-12-11 20:47:02 +00:00
2002-10-13 21:55:56 +00:00
2003-01-12 18:09:22 +00:00
#ifdef HAVE_GETPID
2002-12-01 13:42:15 +00:00
Atom fluxbox_pid;
2001-12-11 20:47:02 +00:00
#endif // HAVE_GETPID
2002-12-01 13:42:15 +00:00
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<Keys> key;
std::string slitlist_path;
//default arguments for titlebar left and right
static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[];
2002-04-28 18:55:43 +00:00
2002-12-01 13:42:15 +00:00
static Fluxbox *singleton;
std::vector<AtomHandler *> m_atomhandler;
2001-12-11 20:47:02 +00:00
};
#endif // _FLUXBOX_HH_