# # ovrd_style.patch # # author: m.gumz # date: 051116 07:42:33 # # about: adds a new resource to the init-file: session.overrideStyleFile # this allows to define persistent stylesettings which overrides # the ones coming from the style itself. you can use this to # always use the same font or menu-look-alike etc etc. # # defaultvalue for this resource is ~.fluxbox/ovrd_style Index: src/FbCommands.cc =================================================================== --- src/FbCommands.cc (Revision 4129) +++ src/FbCommands.cc (Arbeitskopie) @@ -213,7 +213,8 @@ 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()->getOvrdStyleFilename()); } void ShowRootMenuCmd::execute() { Index: src/Screen.cc =================================================================== --- src/Screen.cc (Revision 4129) +++ src/Screen.cc (Arbeitskopie) @@ -358,6 +358,7 @@ // This must be fixed in the future. m_root_theme->lock(true); FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(), + fluxbox->getOvrdStyleFilename(), m_root_theme->screenNum()); m_root_theme->lock(false); m_root_theme->setLineAttributes(*resource.gc_line_width, @@ -789,6 +790,7 @@ // Reload style FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(), + fluxbox->getOvrdStyleFilename(), m_root_theme->screenNum()); } Index: src/fluxbox.hh =================================================================== --- src/fluxbox.hh (Revision 4129) +++ src/fluxbox.hh (Arbeitskopie) @@ -80,54 +80,56 @@ 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 &getOvrdStyleFilename() const { return *m_rc_ovrdstylefile; } - 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 @@ 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 @@ }; // 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 @@ void loadRootCommand(BScreen &scr); void loadTitlebar(); void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } + void saveOvrdStyleFilename(const char *val) { m_rc_ovrdstylefile = (val == 0 ? "" : val); } void saveMenuFilename(const char *); void clearMenuFilenames(); void saveTitlebarFilename(const char *); @@ -247,7 +250,7 @@ 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 @@ m_rc_tabs_padding, m_rc_focused_tab_min_width; FbTk::Resource m_rc_stylefile, + m_rc_ovrdstylefile, m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, m_rc_groupfile, m_rc_appsfile; @@ -280,7 +284,7 @@ // 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; Index: src/FbTk/XrmDatabaseHelper.hh =================================================================== --- src/FbTk/XrmDatabaseHelper.hh (Revision 4129) +++ src/FbTk/XrmDatabaseHelper.hh (Arbeitskopie) @@ -39,9 +39,9 @@ { public: XrmDatabaseHelper(char const * filename=0) - : m_database(0) + : m_database(0) { if (filename != 0) load(filename); } - + ~XrmDatabaseHelper() { close(); } @@ -49,7 +49,7 @@ /// assignment operator XrmDatabaseHelper& operator=(const XrmDatabase& database) { if (m_database!=0) - XrmDestroyDatabase(m_database); + close(); m_database = database; return *this; } @@ -69,11 +69,12 @@ m_database = 0; } } + bool operator == (const XrmDatabase& database) { return m_database == database; } - XrmDatabase & operator*(void) { return m_database; } + XrmDatabase & operator*() { return m_database; } private: - XrmDatabase m_database; + XrmDatabase m_database; }; } // namespace FbTk Index: src/FbTk/Theme.cc =================================================================== --- src/FbTk/Theme.cc (Revision 4129) +++ src/FbTk/Theme.cc (Arbeitskopie) @@ -83,7 +83,8 @@ return true; } -bool ThemeManager::load(const std::string &filename, int screen_num) { +bool ThemeManager::load(const std::string &filename, + const std::string &ovrd_filename, int screen_num) { std::string location = FbTk::StringUtil::expandFilename(filename); std::string prefix = ""; @@ -107,6 +108,20 @@ if (!m_database.load(location.c_str())) return false; + + if (!ovrd_filename.empty()) { + std::string ovrd_location = FbTk::StringUtil::expandFilename(ovrd_filename); + if (FileUtil::isRegularFile(ovrd_location.c_str())) { + XrmDatabaseHelper ovrd_db; + if (ovrd_db.load(ovrd_location.c_str())) { + // after a merge the src_db is destroyed + // so, make sure XrmDatabaseHelper::m_database == 0 + XrmMergeDatabases(*ovrd_db, &(*m_database)); + *ovrd_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 @@ 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) { Index: src/FbTk/Theme.hh =================================================================== --- src/FbTk/Theme.hh (Revision 4129) +++ src/FbTk/Theme.hh (Arbeitskopie) @@ -127,7 +127,7 @@ 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 &ovrd_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); Index: src/fluxbox.cc =================================================================== --- src/fluxbox.cc (Revision 4129) +++ src/fluxbox.cc (Arbeitskopie) @@ -205,6 +205,7 @@ 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_ovrdstylefile(m_resourcemanager, "~/.fluxbox/ovrd_style", "session.overrideStyleFile", "Session.OverrideStyleFile"), 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 @@ load_rc(); // setup theme manager to have our style file ready to be scanned - FbTk::ThemeManager::instance().load(getStyleFilename()); + FbTk::ThemeManager::instance().load(getStyleFilename(), getOvrdStyleFilename()); // setup atom handlers before we create any windows #ifdef REMEMBER @@ -379,7 +380,7 @@ 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(), getOvrdStyleFilename()); //XSynchronize(disp, False); sync(false); @@ -1587,7 +1588,7 @@ if (!(*it).empty() && (*it) != "") screen.addWorkspaceName((*it).c_str()); } - + } FbTk::Image::removeAllSearchPaths();