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.
|
|
|
|
|
2004-11-19 11:37:27 +00:00
|
|
|
// $Id$
|
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
|
|
|
|
2003-12-19 00:35:08 +00:00
|
|
|
#include "FbTk/App.hh"
|
|
|
|
#include "FbTk/Resource.hh"
|
|
|
|
#include "FbTk/Timer.hh"
|
|
|
|
#include "FbTk/Observer.hh"
|
|
|
|
#include "FbTk/SignalHandler.hh"
|
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/Xlib.h>
|
|
|
|
#include <X11/Xresource.h>
|
|
|
|
|
2004-08-31 15:26:40 +00:00
|
|
|
#ifdef HAVE_CSTDIO
|
|
|
|
#include <cstdio>
|
|
|
|
#else
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2002-08-11 20:36:43 +00:00
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2002-08-11 20:36:43 +00:00
|
|
|
#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>
|
|
|
|
|
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-12-03 00:33:30 +00:00
|
|
|
class Toolbar;
|
2002-09-07 20:25:39 +00:00
|
|
|
|
2003-05-10 14:01:07 +00:00
|
|
|
|
|
|
|
/// main class for the window manager.
|
2002-08-04 15:55:13 +00:00
|
|
|
/**
|
|
|
|
singleton type
|
|
|
|
*/
|
2003-08-11 17:15:51 +00:00
|
|
|
class Fluxbox : public FbTk::App,
|
2002-12-01 13:42:15 +00:00
|
|
|
public FbTk::SignalEventHandler,
|
|
|
|
public FbTk::Observer {
|
2001-12-11 20:47:02 +00:00
|
|
|
public:
|
2005-11-16 22:08:05 +00:00
|
|
|
Fluxbox(int argc, char **argv, const char * dpy_name= 0,
|
2003-04-25 15:52:58 +00:00
|
|
|
const char *rcfilename = 0);
|
2002-12-01 13:42:15 +00:00
|
|
|
virtual ~Fluxbox();
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
static Fluxbox *instance() { return s_singleton; }
|
2005-11-16 22:08:05 +00:00
|
|
|
|
2003-05-10 14:01:07 +00:00
|
|
|
/// main event loop
|
|
|
|
void eventLoop();
|
|
|
|
bool validateWindow(Window win) const;
|
2006-02-18 20:19:22 +00:00
|
|
|
bool validateClient(const WinClient *client) const;
|
|
|
|
|
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
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
// Not currently implemented until we decide how it'll be used
|
|
|
|
//WinClient *searchGroup(Window);
|
|
|
|
WinClient *searchWindow(Window);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2007-01-01 01:44:35 +00:00
|
|
|
void initScreen(BScreen *screen);
|
2002-12-01 13:42:15 +00:00
|
|
|
BScreen *searchScreen(Window w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; }
|
|
|
|
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);
|
|
|
|
void addAtomHandler(AtomHandler *atomh, const std::string &name);
|
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
|
|
|
/// obsolete
|
2004-04-22 21:07:57 +00:00
|
|
|
enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR};
|
2003-02-22 15:10:43 +00:00
|
|
|
|
2003-12-19 00:35:08 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
bool getIgnoreBorder() const { return *m_rc_ignoreborder; }
|
|
|
|
bool &getPseudoTrans() { return *m_rc_pseudotrans; }
|
2003-05-04 16:55:40 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
Fluxbox::TabsAttachArea getTabsAttachArea() const { return *m_rc_tabs_attach_area; }
|
|
|
|
const std::string &getStyleFilename() const { return *m_rc_stylefile; }
|
|
|
|
const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; }
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
const std::string &getMenuFilename() const { return *m_rc_menufile; }
|
|
|
|
const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; }
|
|
|
|
const std::string &getAppsFilename() const { return *m_rc_appsfile; }
|
|
|
|
int colorsPerChannel() const { return *m_rc_colors_per_channel; }
|
|
|
|
int getTabsPadding() const { return *m_rc_tabs_padding; }
|
2003-02-02 16:32:41 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; }
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2005-11-16 22:08:05 +00:00
|
|
|
unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; }
|
|
|
|
unsigned int getCacheMax() const { return *m_rc_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; }
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
void shutdown();
|
2003-04-15 12:22:52 +00:00
|
|
|
void load_rc(BScreen &scr);
|
2002-12-01 13:42:15 +00:00
|
|
|
void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); }
|
|
|
|
void saveMenuFilename(const char *);
|
2003-05-13 00:20:49 +00:00
|
|
|
void clearMenuFilenames();
|
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();
|
2004-11-24 12:26:12 +00:00
|
|
|
void rereadMenu(bool show_after_reread = false);
|
2003-05-13 00:20:49 +00:00
|
|
|
/// reloads the menus if the timestamps changed
|
2004-01-11 16:10:51 +00:00
|
|
|
|
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);
|
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();
|
2006-07-23 09:51:54 +00:00
|
|
|
void revert_focus();
|
2006-07-25 21:54:58 +00:00
|
|
|
void setShowingDialog(bool value) { m_showing_dialog = value; }
|
2002-08-17 22:13:00 +00:00
|
|
|
|
2003-05-10 14:01:07 +00:00
|
|
|
bool isStartup() const { return m_starting; }
|
2004-10-18 01:26:54 +00:00
|
|
|
bool isRestarting() const { return m_restarting; }
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-01-05 16:54:34 +00:00
|
|
|
typedef std::list<BScreen *> ScreenList;
|
|
|
|
const ScreenList screenList() const { return m_screen_list; }
|
|
|
|
|
2003-05-13 00:20:49 +00:00
|
|
|
/// @return whether the timestamps on the menu changed
|
|
|
|
bool menuTimestampsChanged() const;
|
2003-05-14 14:37:06 +00:00
|
|
|
bool haveShape() const { return m_have_shape; }
|
|
|
|
int shapeEventbase() const { return m_shape_eventbase; }
|
2007-10-13 21:51:37 +00:00
|
|
|
void getDefaultDataFilename(const char *name, std::string &) const;
|
2003-07-19 13:51:24 +00:00
|
|
|
// screen mouse was in at last key event
|
2003-06-30 15:04:06 +00:00
|
|
|
BScreen *mouseScreen() { return m_mousescreen; }
|
2003-07-19 13:51:24 +00:00
|
|
|
// screen of window that last key event (i.e. focused window) went to
|
2003-06-30 15:04:06 +00:00
|
|
|
BScreen *keyScreen() { return m_keyscreen; }
|
|
|
|
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
|
|
|
|
|
|
|
typedef struct MenuTimestamp {
|
2003-04-25 15:52:58 +00:00
|
|
|
std::string filename;
|
2002-12-01 13:42:15 +00:00
|
|
|
time_t timestamp;
|
|
|
|
} MenuTimestamp;
|
|
|
|
|
2003-12-19 00:35:08 +00:00
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
std::string getRcFilename();
|
|
|
|
void load_rc();
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
void real_rereadMenu();
|
|
|
|
void real_reconfigure();
|
2002-09-07 20:25:39 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
void handleEvent(XEvent *xe);
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
void setupConfigFiles();
|
|
|
|
void handleUnmapNotify(XUnmapEvent &ue);
|
|
|
|
void handleClientMessage(XClientMessageEvent &ce);
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2003-04-15 12:22:52 +00:00
|
|
|
std::auto_ptr<FbAtoms> m_fbatoms;
|
|
|
|
|
2003-07-18 15:40:55 +00:00
|
|
|
FbTk::ResourceManager m_resourcemanager, &m_screen_rm;
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//--- Resources
|
2003-12-19 00:35:08 +00:00
|
|
|
|
2006-07-22 08:42:56 +00:00
|
|
|
FbTk::Resource<bool> m_rc_ignoreborder;
|
2004-09-12 14:56:20 +00:00
|
|
|
FbTk::Resource<bool> m_rc_pseudotrans;
|
2007-03-03 23:27:16 +00:00
|
|
|
FbTk::Resource<int> m_rc_colors_per_channel,
|
2005-04-10 18:18:14 +00:00
|
|
|
m_rc_double_click_interval,
|
2006-07-04 01:01:44 +00:00
|
|
|
m_rc_tabs_padding;
|
2004-10-18 01:26:54 +00:00
|
|
|
FbTk::Resource<std::string> m_rc_stylefile,
|
2005-11-16 22:08:05 +00:00
|
|
|
m_rc_styleoverlayfile,
|
2002-12-01 13:42:15 +00:00
|
|
|
m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
|
2007-10-13 21:51:37 +00:00
|
|
|
m_rc_appsfile;
|
2003-02-18 15:11:12 +00:00
|
|
|
|
2004-10-18 01:26:54 +00:00
|
|
|
|
2004-04-22 21:07:57 +00:00
|
|
|
FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area;
|
2003-05-18 22:04:06 +00:00
|
|
|
FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
|
2003-10-05 06:28:47 +00:00
|
|
|
FbTk::Resource<time_t> m_rc_auto_raise_delay;
|
2003-12-31 00:35:21 +00:00
|
|
|
|
2005-05-02 12:10:01 +00:00
|
|
|
typedef std::map<Window, WinClient *> WinClientMap;
|
|
|
|
WinClientMap m_window_search;
|
|
|
|
typedef std::map<Window, FluxboxWindow *> WindowMap;
|
|
|
|
WindowMap m_window_search_group;
|
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
|
|
|
std::list<MenuTimestamp *> m_menu_timestamps;
|
|
|
|
ScreenList m_screen_list;
|
|
|
|
|
2003-12-30 20:56:41 +00:00
|
|
|
FluxboxWindow *m_masked_window;
|
2003-04-25 15:52:58 +00:00
|
|
|
|
2003-06-30 15:04:06 +00:00
|
|
|
BScreen *m_mousescreen, *m_keyscreen;
|
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
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
bool m_reconfigure_wait, m_reread_menu_wait;
|
|
|
|
Time m_last_time;
|
2003-12-30 20:56:41 +00:00
|
|
|
Window m_masked;
|
2003-04-25 15:52:58 +00:00
|
|
|
std::string m_rc_file; ///< resource filename
|
|
|
|
char **m_argv;
|
|
|
|
int m_argc;
|
2004-10-18 01:26:54 +00:00
|
|
|
|
|
|
|
std::string m_restart_argument; ///< what to restart
|
|
|
|
|
2003-06-30 15:04:06 +00:00
|
|
|
XEvent m_last_event;
|
2002-10-13 21:55:56 +00:00
|
|
|
|
2006-07-23 09:51:54 +00:00
|
|
|
///< when we execute reconfig command we must wait until next event round
|
|
|
|
FbTk::Timer m_reconfig_timer, m_revert_timer;
|
|
|
|
BScreen *m_revert_screen;
|
2006-07-25 21:54:58 +00:00
|
|
|
bool m_showing_dialog;
|
2003-12-19 13:37:28 +00:00
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
std::auto_ptr<Keys> m_key;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//default arguments for titlebar left and right
|
2003-04-25 15:52:58 +00:00
|
|
|
static Fluxbox *s_singleton;
|
2004-04-18 21:16:06 +00:00
|
|
|
|
|
|
|
typedef std::map<AtomHandler *, std::string> AtomHandlerContainer;
|
|
|
|
typedef AtomHandlerContainer::iterator AtomHandlerContainerIt;
|
|
|
|
|
|
|
|
AtomHandlerContainer m_atomhandler;
|
2004-07-15 09:52:14 +00:00
|
|
|
typedef std::vector<Toolbar *> Toolbars;
|
|
|
|
Toolbars m_toolbars;
|
2003-12-03 00:33:30 +00:00
|
|
|
|
2003-05-10 14:01:07 +00:00
|
|
|
bool m_starting;
|
2004-10-18 01:26:54 +00:00
|
|
|
bool m_restarting;
|
2003-05-10 14:01:07 +00:00
|
|
|
bool m_shutdown;
|
2004-11-24 12:26:12 +00:00
|
|
|
bool m_show_menu_after_reread;
|
2003-05-10 14:01:07 +00:00
|
|
|
int m_server_grabs;
|
2003-05-12 04:23:31 +00:00
|
|
|
int m_randr_event_type; ///< the type number of randr event
|
2003-05-14 14:37:06 +00:00
|
|
|
int m_shape_eventbase; ///< event base for shape events
|
|
|
|
bool m_have_shape; ///< if shape is supported by server
|
2007-07-07 23:11:04 +00:00
|
|
|
std::string m_RC_PATH;
|
2003-05-11 22:19:17 +00:00
|
|
|
const char *m_RC_INIT_FILE;
|
2003-07-23 10:43:30 +00:00
|
|
|
Atom m_kwm1_dockwindow, m_kwm2_dockwindow;
|
2006-06-11 12:47:47 +00:00
|
|
|
|
|
|
|
AttentionNoticeHandler m_attention_handler;
|
2001-12-11 20:47:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-04-25 15:52:58 +00:00
|
|
|
#endif // FLUXBOX_HH
|