all repos — fluxbox @ 68cf3092208830e075c4fe5eddfdcbef3f11596a

custom fork of the fluxbox windowmanager

implement smarter reloading for custom menus
Mark Tiefenbruck mark@fluxbox.org
commit

68cf3092208830e075c4fe5eddfdcbef3f11596a

parent

dcdc78332431ff2b258c54a99d6fac382c6a0595

3 files changed, 17 insertions(+), 6 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,8 @@

(Format: Year/Month/Day) Changes for 1.1 +*08/05/13: + * Only reload custom menus when necessary (Mark) + FbCommands.cc/hh *08/05/12: * Only reload the keys file if the contents have changed (Mark) Keys.cc/hh fluxbox.cc/hh
M src/FbCommands.ccsrc/FbCommands.cc

@@ -343,14 +343,21 @@ BScreen *screen = Fluxbox::instance()->mouseScreen();

if (screen == 0) return; - if (m_menu.get()) { - m_menu->removeAll(); - m_menu->setLabel(""); + if (!m_menu.get() || screen->screenNumber() != m_menu->screenNumber()) { + m_menu.reset(screen->createMenu("")); + m_menu->setReloadHelper(new FbTk::AutoReloadHelper()); + m_menu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<ShowCustomMenuCmd>(*this, &ShowCustomMenuCmd::reload))); + m_menu->reloadHelper()->setMainFile(custom_menu_file); } else - m_menu.reset(screen->createMenu("")); + m_menu->reloadHelper()->checkReload(); - MenuCreator::createFromFile(custom_menu_file, *m_menu.get()); ::showMenu(*screen, *m_menu.get()); +} + +void ShowCustomMenuCmd::reload() { + m_menu->removeAll(); + m_menu->setLabel(""); + MenuCreator::createFromFile(custom_menu_file, *m_menu.get(), m_menu->reloadHelper()); } REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void);
M src/FbCommands.hhsrc/FbCommands.hh

@@ -132,9 +132,10 @@ class ShowCustomMenuCmd: public FbTk::Command<void> {

public: explicit ShowCustomMenuCmd(const std::string &arguments); void execute(); + void reload(); private: std::string custom_menu_file; - std::auto_ptr<FbTk::Menu> m_menu; + std::auto_ptr<FbMenu> m_menu; }; class ShowRootMenuCmd: public FbTk::Command<void> {