2002-01-09 14:11:20 +00:00
|
|
|
// 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.
|
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
// $Id: fluxbox.hh,v 1.22 2002/08/04 15:55:13 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 <X11/Xlib.h>
|
|
|
|
#include <X11/Xresource.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_STDIO_H
|
|
|
|
# include <stdio.h>
|
|
|
|
#endif // HAVE_STDIO_H
|
|
|
|
|
|
|
|
#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-01-18 01:23:54 +00:00
|
|
|
#include "Resource.hh"
|
|
|
|
#include "Keys.hh"
|
2001-12-11 20:47:02 +00:00
|
|
|
#include "BaseDisplay.hh"
|
|
|
|
#include "Image.hh"
|
|
|
|
#include "Timer.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Tab.hh"
|
|
|
|
#include "Toolbar.hh"
|
|
|
|
#ifdef SLIT
|
|
|
|
# include "Slit.hh"
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2002-04-09 12:09:03 +00:00
|
|
|
#include <map>
|
|
|
|
#include <list>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
/**
|
|
|
|
main class for the window manager.
|
|
|
|
singleton type
|
|
|
|
*/
|
2001-12-11 20:47:02 +00:00
|
|
|
class Fluxbox : public BaseDisplay, public TimeoutHandler {
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0);
|
|
|
|
|
2002-01-18 01:23:54 +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
|
|
|
|
inline const Atom &getFluxboxPidAtom() const { return fluxbox_pid; }
|
2001-12-11 20:47:02 +00:00
|
|
|
#ifdef KDE
|
|
|
|
//For KDE dock applets
|
2002-08-04 15:55:13 +00:00
|
|
|
inline const Atom &getKWM1DockwindowAtom() const { return kwm1_dockwindow; } //KDE v1.x
|
|
|
|
inline const Atom &getKWM2DockwindowAtom() const { return kwm2_dockwindow; } //KDE v2.x
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif
|
|
|
|
#endif // HAVE_GETPID
|
|
|
|
|
|
|
|
Basemenu *searchMenu(Window);
|
|
|
|
|
|
|
|
FluxboxWindow *searchGroup(Window, FluxboxWindow *);
|
|
|
|
FluxboxWindow *searchWindow(Window);
|
2002-08-04 15:55:13 +00:00
|
|
|
inline FluxboxWindow *getFocusedWindow() { return focused_window; }
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
BScreen *searchScreen(Window w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-04 15:55:13 +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-08-04 15:55:13 +00:00
|
|
|
Toolbar *searchToolbar(Window w);
|
2001-12-11 20:47:02 +00:00
|
|
|
Tab *searchTab(Window);
|
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
/// obsolete
|
2002-01-11 09:26:33 +00:00
|
|
|
enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +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; }
|
2002-08-04 15:55:13 +00:00
|
|
|
inline const char *getStyleFilename() const { return m_rc_stylefile->c_str(); }
|
2002-01-10 12:51:21 +00:00
|
|
|
|
2002-08-04 15:55:13 +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; }
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
inline const timeval &getAutoRaiseDelay() const { return resource.auto_raise_delay; }
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
inline unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; }
|
|
|
|
inline unsigned int getCacheMax() const { return *m_rc_cache_max; }
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
inline void maskWindowEvents(Window w, FluxboxWindow *bw)
|
|
|
|
{ masked = w; masked_window = bw; }
|
|
|
|
inline void setNoFocus(Bool f) { no_focus = f; }
|
|
|
|
|
|
|
|
void setFocusedWindow(FluxboxWindow *w);
|
2002-08-04 15:55:13 +00:00
|
|
|
void shutdown();
|
2001-12-11 20:47:02 +00:00
|
|
|
void load_rc(BScreen *);
|
2002-01-10 12:51:21 +00:00
|
|
|
void loadRootCommand(BScreen *);
|
2001-12-11 20:47:02 +00:00
|
|
|
void loadTitlebar();
|
2002-01-18 01:23:54 +00:00
|
|
|
void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); }
|
2001-12-11 20:47:02 +00:00
|
|
|
void saveMenuFilename(const char *);
|
|
|
|
void saveTitlebarFilename(const char *);
|
2002-05-29 06:22:31 +00:00
|
|
|
void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); }
|
2001-12-11 20:47:02 +00:00
|
|
|
void saveMenuSearch(Window, Basemenu *);
|
|
|
|
void saveWindowSearch(Window, FluxboxWindow *);
|
|
|
|
void saveToolbarSearch(Window, Toolbar *);
|
|
|
|
void saveTabSearch(Window, Tab *);
|
|
|
|
void saveGroupSearch(Window, FluxboxWindow *);
|
2002-08-04 15:55:13 +00:00
|
|
|
void save_rc();
|
2001-12-11 20:47:02 +00:00
|
|
|
void removeMenuSearch(Window);
|
|
|
|
void removeWindowSearch(Window);
|
|
|
|
void removeToolbarSearch(Window);
|
|
|
|
void removeTabSearch(Window);
|
|
|
|
void removeGroupSearch(Window);
|
|
|
|
void restart(const char * = 0);
|
2002-08-04 15:55:13 +00:00
|
|
|
void reconfigure();
|
|
|
|
void reconfigureTabs();
|
|
|
|
void rereadMenu();
|
|
|
|
void checkMenu();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
virtual Bool handleSignal(int);
|
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
virtual void timeout();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
Slit *searchSlit(Window);
|
|
|
|
|
|
|
|
void saveSlitSearch(Window, Slit *);
|
|
|
|
void removeSlitSearch(Window);
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
#ifndef HAVE_STRFTIME
|
|
|
|
|
2002-01-11 09:26:33 +00:00
|
|
|
enum { B_AMERICANDATE = 1, B_EUROPEANDATE };
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
typedef std::vector<Fluxbox::Titlebar> TitlebarList;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
private:
|
2002-02-26 22:42:58 +00:00
|
|
|
void setupConfigFiles();
|
2002-02-06 17:12:39 +00:00
|
|
|
void handleButtonEvent(XButtonEvent &be);
|
2002-02-17 18:42:15 +00:00
|
|
|
void handleUnmapNotify(XUnmapEvent &ue);
|
2002-02-06 17:12:39 +00:00
|
|
|
void handleClientMessage(XClientMessageEvent &ce);
|
|
|
|
void handleKeyEvent(XKeyEvent &ke);
|
2002-02-20 23:12:46 +00:00
|
|
|
void doWindowAction(Keys::KeyAction action, const int param);
|
2002-02-06 17:12:39 +00:00
|
|
|
#ifdef GNOME
|
|
|
|
bool checkGnomeAtoms(XClientMessageEvent &ce);
|
|
|
|
#endif
|
|
|
|
#ifdef NEWWMSPEC
|
|
|
|
bool checkNETWMAtoms(XClientMessageEvent &ce);
|
|
|
|
#endif
|
2001-12-11 20:47:02 +00:00
|
|
|
typedef struct MenuTimestamp {
|
|
|
|
char *filename;
|
|
|
|
time_t timestamp;
|
|
|
|
} MenuTimestamp;
|
|
|
|
|
|
|
|
struct resource {
|
2002-01-20 02:18:18 +00:00
|
|
|
Time double_click_interval;
|
2001-12-11 20:47:02 +00:00
|
|
|
timeval auto_raise_delay;
|
|
|
|
} resource;
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2002-01-20 02:18:18 +00:00
|
|
|
ResourceManager m_resourcemanager, m_screen_rm;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
//--- Resources
|
|
|
|
Resource<bool> m_rc_tabs, m_rc_iconbar;
|
|
|
|
Resource<int> m_rc_colors_per_channel;
|
|
|
|
Resource<std::string> m_rc_stylefile,
|
2002-05-29 06:22:31 +00:00
|
|
|
m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
|
|
|
|
Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
|
|
|
|
|
|
|
|
//std::vector<std::string> parseTitleArgs(const char *arg);
|
2001-12-11 20:47:02 +00:00
|
|
|
void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
|
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, FluxboxWindow *> windowSearch;
|
|
|
|
std::map<Window, FluxboxWindow *> groupSearch;
|
|
|
|
std::map<Window, Basemenu *> menuSearch;
|
|
|
|
std::map<Window, Toolbar *> toolbarSearch;
|
2002-04-28 18:55:43 +00:00
|
|
|
typedef std::map<Window, Tab *> TabList;
|
|
|
|
TabList tabSearch;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-02 07:14:22 +00:00
|
|
|
#ifdef SLIT
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, Slit *> slitSearch;
|
2002-05-02 07:14:22 +00:00
|
|
|
#ifdef KDE
|
2001-12-11 20:47:02 +00:00
|
|
|
//For KDE dock applets
|
|
|
|
Atom kwm1_dockwindow; //KDE v1.x
|
|
|
|
Atom kwm2_dockwindow; //KDE v2.x
|
2002-05-02 07:14:22 +00:00
|
|
|
#endif//KDE
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // SLIT
|
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
std::list<MenuTimestamp *> menuTimestamps;
|
2002-04-12 13:02:12 +00:00
|
|
|
typedef std::list<BScreen *> ScreenList;
|
|
|
|
ScreenList screenList;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
FluxboxWindow *focused_window, *masked_window;
|
2002-03-19 00:16:44 +00:00
|
|
|
BTimer timer;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_GETPID
|
|
|
|
Atom fluxbox_pid;
|
|
|
|
#endif // HAVE_GETPID
|
|
|
|
|
2002-02-06 17:12:39 +00:00
|
|
|
bool no_focus, reconfigure_wait, reread_menu_wait;
|
2001-12-11 20:47:02 +00:00
|
|
|
Time last_time;
|
|
|
|
Window masked;
|
|
|
|
char *rc_file, **argv;
|
|
|
|
int argc;
|
|
|
|
Keys *key;
|
2002-05-29 06:22:31 +00:00
|
|
|
std::string slitlist_path;
|
2002-03-01 15:28:56 +00:00
|
|
|
//default arguments for titlebar left and right
|
|
|
|
static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[];
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
protected:
|
|
|
|
Fluxbox(int, char **, char * = 0, char * = 0);
|
|
|
|
char *getRcFilename();
|
2002-05-29 06:22:31 +00:00
|
|
|
void getDefaultDataFilename(char *, std::string &);
|
2002-08-04 15:55:13 +00:00
|
|
|
void load_rc();
|
2002-04-28 18:55:43 +00:00
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
void reload_rc();
|
|
|
|
void real_rereadMenu();
|
|
|
|
void real_reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
virtual void process_event(XEvent *);
|
|
|
|
//only main should be able to creat new blackbox object
|
2002-01-18 01:23:54 +00:00
|
|
|
//TODO this must be removed!
|
2001-12-11 20:47:02 +00:00
|
|
|
friend int main(int,char **);
|
|
|
|
static Fluxbox *singleton; //singleton object ( can only be destroyed by main )
|
2002-08-04 15:55:13 +00:00
|
|
|
virtual ~Fluxbox();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _FLUXBOX_HH_
|