2002-01-09 14:11:20 +00:00
|
|
|
// fluxbox.hh for Fluxbox Window Manager
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2001 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2002-01-09 14:11:20 +00:00
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// blackbox.hh for Blackbox - an X11 Window manager
|
2003-03-22 13:31:04 +00:00
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
|
2001-12-11 20:47:02 +00:00
|
|
|
//
|
|
|
|
// 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,
|
2003-03-22 13:31:04 +00:00
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2001-12-11 20:47:02 +00:00
|
|
|
// 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.
|
|
|
|
|
2007-12-30 15:32:53 +00:00
|
|
|
#ifndef FLUXBOX_HH
|
|
|
|
#define FLUXBOX_HH
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-12-19 00:35:08 +00:00
|
|
|
#include "FbTk/App.hh"
|
|
|
|
#include "FbTk/Resource.hh"
|
|
|
|
#include "FbTk/Timer.hh"
|
2008-09-18 20:27:16 +00:00
|
|
|
#include "FbTk/Signal.hh"
|
2015-02-05 20:30:44 +00:00
|
|
|
#include "FbTk/MenuSearch.hh"
|
2008-09-18 20:27:16 +00:00
|
|
|
|
2006-06-11 12:47:47 +00:00
|
|
|
#include "AttentionNoticeHandler.hh"
|
2002-08-14 00:01:10 +00:00
|
|
|
|
2002-08-11 20:36:43 +00:00
|
|
|
#include <X11/Xresource.h>
|
|
|
|
|
|
|
|
#ifdef TIME_WITH_SYS_TIME
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
#else // !TIME_WITH_SYS_TIME
|
2007-12-30 15:32:53 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2002-08-11 20:36:43 +00:00
|
|
|
#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>
|
2015-01-22 15:28:53 +00:00
|
|
|
#include <cstdio>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
class AtomHandler;
|
2002-11-30 20:16:14 +00:00
|
|
|
class FluxboxWindow;
|
2003-07-04 01:03:41 +00:00
|
|
|
class WinClient;
|
2003-04-15 12:22:52 +00:00
|
|
|
class Keys;
|
|
|
|
class BScreen;
|
|
|
|
class FbAtoms;
|
2003-05-10 14:01:07 +00:00
|
|
|
|
2007-12-30 15:32:53 +00:00
|
|
|
/// main class for the window manager.
|
2002-08-04 15:55:13 +00:00
|
|
|
/**
|
2007-12-30 15:32:53 +00:00
|
|
|
singleton type
|
2002-08-04 15:55:13 +00:00
|
|
|
*/
|
2003-08-11 17:15:51 +00:00
|
|
|
class Fluxbox : public FbTk::App,
|
2008-09-18 20:27:16 +00:00
|
|
|
private FbTk::SignalTracker {
|
2001-12-11 20:47:02 +00:00
|
|
|
public:
|
2015-01-22 15:28:53 +00:00
|
|
|
|
|
|
|
typedef std::list<BScreen *> ScreenList;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
OPT_TOOLBAR = 1 << 0,
|
|
|
|
OPT_SLIT = 1 << 1
|
|
|
|
};
|
|
|
|
|
|
|
|
/// obsolete
|
|
|
|
enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR};
|
|
|
|
|
|
|
|
|
|
|
|
static Fluxbox *instance();
|
|
|
|
|
|
|
|
|
2010-09-18 15:51:30 +00:00
|
|
|
Fluxbox(int argc, char **argv,
|
|
|
|
const std::string& dpy_name,
|
|
|
|
const std::string& rc_path, const std::string& rc_filename,
|
|
|
|
bool xsync = false);
|
2002-12-01 13:42:15 +00:00
|
|
|
virtual ~Fluxbox();
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
|
2003-05-10 14:01:07 +00:00
|
|
|
/// main event loop
|
|
|
|
void eventLoop();
|
2006-02-18 20:19:22 +00:00
|
|
|
|
2003-05-10 14:01:07 +00:00
|
|
|
void grab();
|
|
|
|
void ungrab();
|
2003-12-20 17:40:50 +00:00
|
|
|
Keys *keys() { return m_key.get(); }
|
2005-11-16 22:08:05 +00:00
|
|
|
Atom getFluxboxPidAtom() const { return m_fluxbox_pid; }
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
2007-01-01 01:44:35 +00:00
|
|
|
void initScreen(BScreen *screen);
|
2015-01-22 15:28:53 +00:00
|
|
|
|
|
|
|
WinClient *searchWindow(Window);
|
2002-12-01 13:42:15 +00:00
|
|
|
BScreen *searchScreen(Window w);
|
2015-01-22 15:28:53 +00:00
|
|
|
bool validateWindow(Window win) const;
|
|
|
|
bool validateClient(const WinClient *client) const;
|
|
|
|
|
|
|
|
// Not currently implemented until we decide how it'll be used
|
|
|
|
//WinClient *searchGroup(Window);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
Time getLastTime() const { return m_last_time; }
|
2003-04-25 15:52:58 +00:00
|
|
|
|
2004-04-19 22:48:19 +00:00
|
|
|
AtomHandler *getAtomHandler(const std::string &name);
|
2010-09-13 20:04:24 +00:00
|
|
|
void addAtomHandler(AtomHandler *atomh);
|
2003-04-25 15:52:58 +00:00
|
|
|
void removeAtomHandler(AtomHandler *atomh);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
std::string getDefaultDataFilename(const char *name) const;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
bool &getPseudoTrans() { return *m_config.pseudotrans; }
|
|
|
|
bool getIgnoreBorder() const { return *m_config.ignore_border; }
|
|
|
|
Fluxbox::TabsAttachArea getTabsAttachArea() const { return *m_config.tabs_attach_area; }
|
|
|
|
const std::string &getStyleFilename() const { return *m_config.style_file; }
|
|
|
|
const std::string &getStyleOverlayFilename() const { return *m_config.overlay_file; }
|
|
|
|
const std::string &getMenuFilename() const { return *m_config.menu_file; }
|
|
|
|
const std::string &getSlitlistFilename() const { return *m_config.slit_file; }
|
|
|
|
const std::string &getAppsFilename() const { return *m_config.apps_file; }
|
|
|
|
const std::string &getKeysFilename() const { return *m_config.key_file; }
|
|
|
|
int colorsPerChannel() const { return *m_config.colors_per_channel; }
|
|
|
|
int getTabsPadding() const { return *m_config.tabs_padding; }
|
|
|
|
unsigned int getDoubleClickInterval() const { return *m_config.double_click_interval; }
|
|
|
|
time_t getAutoRaiseDelay() const { return *m_config.auto_raise_delay; }
|
|
|
|
unsigned int getCacheLife() const { return *m_config.cache_life * 60000; }
|
|
|
|
unsigned int getCacheMax() const { return *m_config.cache_max; }
|
2006-06-22 07:46:12 +00:00
|
|
|
|
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
void maskWindowEvents(Window w, FluxboxWindow *bw)
|
2003-12-30 20:56:41 +00:00
|
|
|
{ m_masked = w; m_masked_window = bw; }
|
|
|
|
|
2014-02-18 18:34:35 +00:00
|
|
|
void shutdown(int x_wants_down = 0);
|
2003-04-15 12:22:52 +00:00
|
|
|
void load_rc(BScreen &scr);
|
2015-01-22 15:28:53 +00:00
|
|
|
void saveStyleFilename(const char *val) { m_config.style_file = (val == 0 ? "" : val); }
|
2003-07-28 15:06:36 +00:00
|
|
|
void saveWindowSearch(Window win, WinClient *winclient);
|
|
|
|
// some windows relate to the group, not the client, so we record separately
|
|
|
|
// searchWindow on these windows will give the active client in the group
|
|
|
|
void saveWindowSearchGroup(Window win, FluxboxWindow *fbwin);
|
|
|
|
void saveGroupSearch(Window win, WinClient *winclient);
|
2002-12-01 13:42:15 +00:00
|
|
|
void save_rc();
|
2003-04-15 12:22:52 +00:00
|
|
|
void removeWindowSearch(Window win);
|
2003-07-28 15:06:36 +00:00
|
|
|
void removeWindowSearchGroup(Window win);
|
2003-04-15 12:22:52 +00:00
|
|
|
void removeGroupSearch(Window win);
|
|
|
|
void restart(const char *command = 0);
|
2002-12-01 13:42:15 +00:00
|
|
|
void reconfigure();
|
2016-07-25 15:47:42 +00:00
|
|
|
void reconfigThemes();
|
2004-01-11 16:10:51 +00:00
|
|
|
|
2006-06-18 21:23:24 +00:00
|
|
|
/// todo, remove this. just temporary
|
|
|
|
void updateFrameExtents(FluxboxWindow &win);
|
2002-09-07 20:25:39 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
void attachSignals(FluxboxWindow &win);
|
2003-07-04 01:03:41 +00:00
|
|
|
void attachSignals(WinClient &winclient);
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2003-08-11 17:15:51 +00:00
|
|
|
void timed_reconfigure();
|
2008-01-01 18:29:36 +00:00
|
|
|
void revertFocus();
|
2008-08-16 13:30:09 +00:00
|
|
|
void setShowingDialog(bool value) {
|
|
|
|
m_showing_dialog = value; if (!value) revertFocus();
|
|
|
|
}
|
2002-08-17 22:13:00 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
bool isStartup() const { return m_state.starting; }
|
|
|
|
bool isRestarting() const { return m_state.restarting; }
|
|
|
|
bool isShuttingDown() const { return m_state.shutdown; }
|
2004-10-18 01:26:54 +00:00
|
|
|
|
|
|
|
const std::string &getRestartArgument() const { return m_restart_argument; }
|
2004-01-11 16:10:51 +00:00
|
|
|
|
2004-05-02 20:48:16 +00:00
|
|
|
/// get screen from number
|
|
|
|
BScreen *findScreen(int num);
|
2004-01-11 16:10:51 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
const ScreenList screenList() const { return m_screens; }
|
2007-01-05 16:54:34 +00:00
|
|
|
|
2012-12-12 09:18:20 +00:00
|
|
|
bool haveShape() const;
|
|
|
|
int shapeEventbase() const;
|
2015-01-22 15:28:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
BScreen *mouseScreen() { return m_active_screen.mouse; }
|
|
|
|
BScreen *keyScreen() { return m_active_screen.key; }
|
2003-06-30 15:04:06 +00:00
|
|
|
const XEvent &lastEvent() const { return m_last_event; }
|
2006-06-11 12:47:47 +00:00
|
|
|
|
|
|
|
AttentionNoticeHandler &attentionHandler() { return m_attention_handler; }
|
2006-06-22 07:46:12 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
private:
|
2002-12-01 13:42:15 +00:00
|
|
|
std::string getRcFilename();
|
|
|
|
void load_rc();
|
|
|
|
void real_reconfigure();
|
|
|
|
void handleEvent(XEvent *xe);
|
|
|
|
void handleUnmapNotify(XUnmapEvent &ue);
|
|
|
|
void handleClientMessage(XClientMessageEvent &ce);
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2008-09-18 20:27:16 +00:00
|
|
|
/// Called when workspace count on a specific screen changed.
|
|
|
|
void workspaceCountChanged( BScreen& screen );
|
2008-09-21 11:44:48 +00:00
|
|
|
/// Called when workspace was switched
|
|
|
|
void workspaceChanged(BScreen& screen);
|
2008-09-21 13:25:47 +00:00
|
|
|
/// Called when workspace names changed
|
|
|
|
void workspaceNamesChanged(BScreen &screen);
|
2008-09-21 17:32:40 +00:00
|
|
|
/// Called when the client list changed.
|
|
|
|
void clientListChanged(BScreen &screen);
|
2008-09-28 08:46:49 +00:00
|
|
|
/// Called when the focused window changed on a screen
|
|
|
|
void focusedWindowChanged(BScreen &screen,
|
|
|
|
FluxboxWindow* win,
|
|
|
|
WinClient* client);
|
2008-09-18 20:27:16 +00:00
|
|
|
|
2008-09-28 14:00:48 +00:00
|
|
|
/// Called when the workspace area changed.
|
|
|
|
void workspaceAreaChanged(BScreen &screen);
|
2011-05-03 21:48:24 +00:00
|
|
|
/// Called when a window (FluxboxWindow) dies
|
|
|
|
void windowDied(Focusable &focusable);
|
|
|
|
/// Called when a client (WinClient) dies
|
|
|
|
void clientDied(Focusable &focusable);
|
2011-05-06 16:18:20 +00:00
|
|
|
/// Called when a window changes workspace
|
|
|
|
void windowWorkspaceChanged(FluxboxWindow &win);
|
2011-05-06 18:28:44 +00:00
|
|
|
/// Called when a window changes state
|
|
|
|
void windowStateChanged(FluxboxWindow &win);
|
2011-05-06 20:26:20 +00:00
|
|
|
/// Called when a window layer changes
|
|
|
|
void windowLayerChanged(FluxboxWindow &win);
|
2008-09-28 14:00:48 +00:00
|
|
|
|
2003-04-15 12:22:52 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
typedef std::map<Window, WinClient *> WinClientMap;
|
|
|
|
typedef std::map<Window, FluxboxWindow *> WindowMap;
|
|
|
|
typedef std::set<AtomHandler *> AtomHandlerContainer;
|
|
|
|
typedef AtomHandlerContainer::iterator AtomHandlerContainerIt;
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2010-09-18 15:51:30 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//--- Resources
|
2003-12-19 00:35:08 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
std::auto_ptr<FbAtoms> m_fbatoms;
|
|
|
|
FbTk::ResourceManager m_resourcemanager;
|
|
|
|
FbTk::ResourceManager& m_screen_rm;
|
2003-02-18 15:11:12 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
struct Config {
|
|
|
|
Config(FbTk::ResourceManager& rm, const std::string& path);
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
std::string path;
|
|
|
|
std::string file;
|
|
|
|
|
|
|
|
FbTk::Resource<bool> ignore_border;
|
|
|
|
FbTk::Resource<bool> pseudotrans;
|
|
|
|
FbTk::Resource<int> colors_per_channel;
|
|
|
|
FbTk::Resource<int> double_click_interval;
|
|
|
|
FbTk::Resource<int> tabs_padding;
|
|
|
|
|
|
|
|
FbTk::Resource<std::string> style_file;
|
|
|
|
FbTk::Resource<std::string> overlay_file;
|
|
|
|
FbTk::Resource<std::string> menu_file;
|
|
|
|
FbTk::Resource<std::string> key_file;
|
|
|
|
FbTk::Resource<std::string> slit_file;
|
|
|
|
FbTk::Resource<std::string> apps_file;
|
|
|
|
|
|
|
|
FbTk::Resource<TabsAttachArea> tabs_attach_area;
|
2015-02-05 20:30:44 +00:00
|
|
|
FbTk::Resource<FbTk::MenuSearch::Mode> menusearch;
|
2015-01-22 15:28:53 +00:00
|
|
|
FbTk::Resource<unsigned int> cache_life;
|
|
|
|
FbTk::Resource<unsigned int> cache_max;
|
|
|
|
FbTk::Resource<time_t> auto_raise_delay;
|
|
|
|
} m_config;
|
|
|
|
|
|
|
|
|
|
|
|
std::auto_ptr<Keys> m_key;
|
|
|
|
AtomHandlerContainer m_atomhandler;
|
|
|
|
AttentionNoticeHandler m_attention_handler;
|
|
|
|
|
|
|
|
ScreenList m_screens;
|
|
|
|
WinClientMap m_window_search;
|
|
|
|
WindowMap m_window_search_group;
|
2003-12-31 00:35:21 +00:00
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
// A window is the group leader, which can map to several
|
|
|
|
// WinClients in the group, it is *not* fluxbox's concept of groups
|
|
|
|
// See ICCCM section 4.1.11
|
2005-11-16 22:08:05 +00:00
|
|
|
// The group leader (which may not be mapped, so may not have a WinClient)
|
2003-07-28 15:06:36 +00:00
|
|
|
// will have it's window being the group index
|
|
|
|
std::multimap<Window, WinClient *> m_group_search;
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
Time m_last_time;
|
|
|
|
XEvent m_last_event;
|
|
|
|
|
|
|
|
Window m_masked;
|
2003-12-30 20:56:41 +00:00
|
|
|
FluxboxWindow *m_masked_window;
|
2003-04-25 15:52:58 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
struct {
|
|
|
|
BScreen* mouse;
|
|
|
|
BScreen* key;
|
|
|
|
} m_active_screen;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
Atom m_fluxbox_pid;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2008-05-11 15:54:18 +00:00
|
|
|
bool m_reconfigure_wait;
|
2003-04-25 15:52:58 +00:00
|
|
|
char **m_argv;
|
|
|
|
int m_argc;
|
2004-10-18 01:26:54 +00:00
|
|
|
std::string m_restart_argument; ///< what to restart
|
|
|
|
|
2006-07-23 09:51:54 +00:00
|
|
|
///< when we execute reconfig command we must wait until next event round
|
2008-01-01 18:29:36 +00:00
|
|
|
FbTk::Timer m_reconfig_timer;
|
2014-04-09 20:40:13 +00:00
|
|
|
FbTk::Timer m_key_reload_timer;
|
2006-07-25 21:54:58 +00:00
|
|
|
bool m_showing_dialog;
|
2003-12-19 13:37:28 +00:00
|
|
|
|
2015-01-22 15:28:53 +00:00
|
|
|
struct {
|
|
|
|
bool starting;
|
|
|
|
bool restarting;
|
|
|
|
bool shutdown;
|
|
|
|
} m_state;
|
2003-12-03 00:33:30 +00:00
|
|
|
|
2003-05-10 14:01:07 +00:00
|
|
|
int m_server_grabs;
|
2001-12-11 20:47:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
#endif // FLUXBOX_HH
|