From 28837ee6e1e3226bec37a7854bd36c45406058f6 Mon Sep 17 00:00:00 2001 From: mathias Date: Wed, 16 Nov 2005 22:08:05 +0000 Subject: introduced session.styleOverlay (~/.fluxbox/overlay), all style settings made in that file will override/overlay the ones made in the used style. TODO: write more specific docu about it --- ChangeLog | 6 +++++ src/FbCommands.cc | 3 ++- src/FbTk/Theme.cc | 19 +++++++++++++-- src/FbTk/Theme.hh | 2 +- src/Screen.cc | 2 ++ src/fluxbox.cc | 9 +++---- src/fluxbox.hh | 72 +++++++++++++++++++++++++++++-------------------------- 7 files changed, 71 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4664416..8897a3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ (Format: Year/Month/Day) Changes for 0.9.15: +*05/11/16: + * Added overlayStyle resource to init-file (Mathias) + session.overlayStyle : ~/.fluxbox/overlay + Style settings in this file override any settings from a + regular style + fluxbox.hh/cc Screen.cc FbCommands.cc FbTk/Theme.hh/cc *05/11/13: * Fixed #1307877 fbsetbg did not create ~/.fluxbox/lastwallpaper (Henrik) diff --git a/src/FbCommands.cc b/src/FbCommands.cc index cdecc2b..e188a40 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -213,7 +213,8 @@ SetStyleCmd::SetStyleCmd(const std::string &filename):m_filename(filename) { void SetStyleCmd::execute() { Fluxbox::instance()->saveStyleFilename(m_filename.c_str()); Fluxbox::instance()->save_rc(); - FbTk::ThemeManager::instance().load(m_filename); + FbTk::ThemeManager::instance().load(m_filename, + Fluxbox::instance()->getStyleOverlayFilename()); } void ShowRootMenuCmd::execute() { diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index e6a07d0..8978e11 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc @@ -83,7 +83,8 @@ bool ThemeManager::unregisterTheme(Theme &tm) { return true; } -bool ThemeManager::load(const std::string &filename, int screen_num) { +bool ThemeManager::load(const std::string &filename, + const std::string &overlay_filename, int screen_num) { std::string location = FbTk::StringUtil::expandFilename(filename); std::string prefix = ""; @@ -107,6 +108,20 @@ bool ThemeManager::load(const std::string &filename, int screen_num) { if (!m_database.load(location.c_str())) return false; + + if (!overlay_filename.empty()) { + std::string overlay_location = FbTk::StringUtil::expandFilename(overlay_filename); + if (FileUtil::isRegularFile(overlay_location.c_str())) { + XrmDatabaseHelper overlay_db; + if (overlay_db.load(overlay_location.c_str())) { + // after a merge the src_db is destroyed + // so, make sure XrmDatabaseHelper::m_database == 0 + XrmMergeDatabases(*overlay_db, &(*m_database)); + *overlay_db = 0; + } + } + } + // relies on the fact that load_rc clears search paths each time if (m_themelocation != "") { Image::removeSearchPath(m_themelocation); @@ -129,8 +144,8 @@ bool ThemeManager::load(const std::string &filename, int screen_num) { loadTheme(**theme_it); else if (screen_num == (*theme_it)->screenNum()) // specified screen loadTheme(**theme_it); - } + // notify all themes that we reconfigured theme_it = m_themelist.begin(); for (; theme_it != theme_it_end; ++theme_it) { diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index 18348c2..c5d8e36 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh @@ -127,7 +127,7 @@ class ThemeManager { public: static ThemeManager &instance(); /// load style file "filename" to screen - bool load(const std::string &filename, int screen_num = -1); + bool load(const std::string &filename, const std::string &overlay_filename, int screen_num = -1); std::string resourceValue(const std::string &name, const std::string &altname); void loadTheme(Theme &tm); bool loadItem(ThemeItem_base &resource); diff --git a/src/Screen.cc b/src/Screen.cc index 80c382f..c7fe1d3 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -358,6 +358,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, // This must be fixed in the future. m_root_theme->lock(true); FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(), + fluxbox->getStyleOverlayFilename(), m_root_theme->screenNum()); m_root_theme->lock(false); m_root_theme->setLineAttributes(*resource.gc_line_width, @@ -789,6 +790,7 @@ void BScreen::reconfigure() { // Reload style FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(), + fluxbox->getStyleOverlayFilename(), m_root_theme->screenNum()); } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index ef90d4e..94020f2 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -205,6 +205,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile m_rc_numlayers(m_resourcemanager, 13, "session.numLayers", "Session.NumLayers"), m_rc_double_click_interval(m_resourcemanager, 250, "session.doubleClickInterval", "Session.DoubleClickInterval"), m_rc_stylefile(m_resourcemanager, DEFAULTSTYLE, "session.styleFile", "Session.StyleFile"), + m_rc_styleoverlayfile(m_resourcemanager, "~/.fluxbox/ovrd_style", "session.styleOverlay", "Session.StyleOverlay"), m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"), m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"), m_rc_slitlistfile(m_resourcemanager, "~/.fluxbox/slitlist", "session.slitlistFile", "Session.SlitlistFile"), @@ -299,7 +300,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile load_rc(); // setup theme manager to have our style file ready to be scanned - FbTk::ThemeManager::instance().load(getStyleFilename()); + FbTk::ThemeManager::instance().load(getStyleFilename(), getStyleOverlayFilename()); // setup atom handlers before we create any windows #ifdef REMEMBER @@ -377,9 +378,9 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile } m_keyscreen = m_mousescreen = m_screen_list.front(); - + // setup theme manager to have our style file ready to be scanned - FbTk::ThemeManager::instance().load(FbTk::StringUtil::expandFilename(getStyleFilename())); + FbTk::ThemeManager::instance().load(getStyleFilename(), getStyleOverlayFilename()); //XSynchronize(disp, False); sync(false); @@ -1587,7 +1588,7 @@ void Fluxbox::load_rc(BScreen &screen) { if (!(*it).empty() && (*it) != "") screen.addWorkspaceName((*it).c_str()); } - + } FbTk::Image::removeAllSearchPaths(); diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 0da630d..c32e74b 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -80,54 +80,56 @@ class Fluxbox : public FbTk::App, public FbTk::SignalEventHandler, public FbTk::Observer { public: - Fluxbox(int argc, char **argv, const char * dpy_name= 0, + Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rcfilename = 0); virtual ~Fluxbox(); static Fluxbox *instance() { return s_singleton; } + /// main event loop void eventLoop(); bool validateWindow(Window win) const; void grab(); void ungrab(); Keys *keys() { return m_key.get(); } - inline Atom getFluxboxPidAtom() const { return m_fluxbox_pid; } + Atom getFluxboxPidAtom() const { return m_fluxbox_pid; } // Not currently implemented until we decide how it'll be used //WinClient *searchGroup(Window); WinClient *searchWindow(Window); - inline WinClient *getFocusedWindow() { return m_focused_window; } + WinClient *getFocusedWindow() { return m_focused_window; } int initScreen(int screen_nr); BScreen *searchScreen(Window w); - inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; } - inline Time getLastTime() const { return m_last_time; } + unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; } + Time getLastTime() const { return m_last_time; } AtomHandler *getAtomHandler(const std::string &name); void addAtomHandler(AtomHandler *atomh, const std::string &name); void removeAtomHandler(AtomHandler *atomh); /// obsolete - enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENUICON, EMPTY}; + enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENUICON, EMPTY}; enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR}; - inline bool getIgnoreBorder() const { return *m_rc_ignoreborder; } - inline bool &getPseudoTrans() { return *m_rc_pseudotrans; } + bool getIgnoreBorder() const { return *m_rc_ignoreborder; } + bool &getPseudoTrans() { return *m_rc_pseudotrans; } - inline const std::vector& getTitlebarRight() const { return *m_rc_titlebar_right; } - inline const std::vector& getTitlebarLeft() const { return *m_rc_titlebar_left; } - inline Fluxbox::TabsAttachArea getTabsAttachArea() const { return *m_rc_tabs_attach_area; } - inline const std::string &getStyleFilename() const { return *m_rc_stylefile; } + const std::vector& getTitlebarRight() const { return *m_rc_titlebar_right; } + const std::vector& getTitlebarLeft() const { return *m_rc_titlebar_left; } + 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; } - inline const std::string &getMenuFilename() const { return *m_rc_menufile; } - inline const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; } - inline const std::string &getAppsFilename() const { return *m_rc_appsfile; } - inline int colorsPerChannel() const { return *m_rc_colors_per_channel; } - inline int getNumberOfLayers() const { return *m_rc_numlayers; } - inline int getTabsPadding() const { return *m_rc_tabs_padding; } - inline int getFocusedTabMinWidth() const { return *m_rc_focused_tab_min_width; } + 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 getNumberOfLayers() const { return *m_rc_numlayers; } + int getTabsPadding() const { return *m_rc_tabs_padding; } + int getFocusedTabMinWidth() const { return *m_rc_focused_tab_min_width; } // class to store layer numbers (special Resource type) // we have a special resource type because we need to be able to name certain layers @@ -135,7 +137,7 @@ public: class Layer { public: explicit Layer(int i) : m_num(i) {}; - inline int getNum() const { return m_num; } + int getNum() const { return m_num; } Layer &operator=(int num) { m_num = num; return *this; } @@ -144,22 +146,22 @@ public: }; // 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; } + int getMenuLayer() const { return 0; } + int getAboveDockLayer() const { return 2; } + int getDockLayer() const { return 4; } + int getTopLayer() const { return 6; } + int getNormalLayer() const { return 8; } + int getBottomLayer() const { return 10; } + int getDesktopLayer() const { return 12; } - inline time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; } + time_t getAutoRaiseDelay() const { return *m_rc_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 bool useMod1() const { return *m_rc_use_mod1; } + unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; } + unsigned int getCacheMax() const { return *m_rc_cache_max; } + bool useMod1() const { return *m_rc_use_mod1; } - inline void maskWindowEvents(Window w, FluxboxWindow *bw) + void maskWindowEvents(Window w, FluxboxWindow *bw) { m_masked = w; m_masked_window = bw; } void watchKeyRelease(BScreen &screen, unsigned int mods); @@ -173,6 +175,7 @@ public: void loadRootCommand(BScreen &scr); void loadTitlebar(); void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } + void saveStyleOverlayFilename(const char *val) { m_rc_styleoverlayfile = (val == 0 ? "" : val); } void saveMenuFilename(const char *); void clearMenuFilenames(); void saveTitlebarFilename(const char *); @@ -247,7 +250,7 @@ private: void handleButtonEvent(XButtonEvent &be); void handleUnmapNotify(XUnmapEvent &ue); void handleClientMessage(XClientMessageEvent &ce); - void handleKeyEvent(XKeyEvent &ke); + void handleKeyEvent(XKeyEvent &ke); void setTitlebar(std::vector& dir, const char *arg); std::auto_ptr m_fbatoms; @@ -263,6 +266,7 @@ private: m_rc_tabs_padding, m_rc_focused_tab_min_width; FbTk::Resource m_rc_stylefile, + m_rc_styleoverlayfile, m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, m_rc_groupfile, m_rc_appsfile; @@ -280,7 +284,7 @@ private: // 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 - // The group leader (which may not be mapped, so may not have a WinClient) + // The group leader (which may not be mapped, so may not have a WinClient) // will have it's window being the group index std::multimap m_group_search; -- cgit v0.11.2