summaryrefslogtreecommitdiff
path: root/src/FbCommands.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbCommands.cc')
-rw-r--r--src/FbCommands.cc40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index cb55469..e0d0768 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -73,16 +73,11 @@ namespace {
73 73
74void showMenu(const BScreen &screen, FbTk::Menu &menu) { 74void showMenu(const BScreen &screen, FbTk::Menu &menu) {
75 75
76 // special case for root menu 76 // check if menu has changed
77 if (&menu == &screen.rootMenu()) { 77 if (typeid(menu) == typeid(FbMenu)) {
78 Fluxbox* fb = Fluxbox::instance(); 78 FbMenu *fbmenu = static_cast<FbMenu *>(&menu);
79 if(fb->menuTimestampsChanged()) { 79 if (fbmenu->reloadHelper())
80 // we dont show the menu here because fluxbox 80 fbmenu->reloadHelper()->checkReload();
81 // will bring up the rootmenu after the timed
82 // reread of the menu
83 fb->rereadMenu(true);
84 return;
85 }
86 } 81 }
87 82
88 Window root_ret; // not used 83 Window root_ret; // not used
@@ -335,8 +330,8 @@ void ShowClientMenuCmd::execute() {
335 m_list.push_back(static_cast<FluxboxWindow *>(*it)); 330 m_list.push_back(static_cast<FluxboxWindow *>(*it));
336 } 331 }
337 332
338 m_menu = new ClientMenu(*screen, m_list, 0); 333 m_menu.reset(new ClientMenu(*screen, m_list, 0));
339 ::showMenu(*screen, **m_menu); 334 ::showMenu(*screen, *m_menu.get());
340} 335}
341 336
342REGISTER_COMMAND_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, void); 337REGISTER_COMMAND_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, void);
@@ -347,11 +342,22 @@ void ShowCustomMenuCmd::execute() {
347 BScreen *screen = Fluxbox::instance()->mouseScreen(); 342 BScreen *screen = Fluxbox::instance()->mouseScreen();
348 if (screen == 0) 343 if (screen == 0)
349 return; 344 return;
350 m_menu = MenuCreator::createFromFile(custom_menu_file, 345
351 screen->screenNumber()); 346 if (!m_menu.get() || screen->screenNumber() != m_menu->screenNumber()) {
352 if (!m_menu.get()) 347 m_menu.reset(screen->createMenu(""));
353 return; 348 m_menu->setReloadHelper(new FbTk::AutoReloadHelper());
354 ::showMenu(*screen, **m_menu); 349 m_menu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<ShowCustomMenuCmd>(*this, &ShowCustomMenuCmd::reload)));
350 m_menu->reloadHelper()->setMainFile(custom_menu_file);
351 } else
352 m_menu->reloadHelper()->checkReload();
353
354 ::showMenu(*screen, *m_menu.get());
355}
356
357void ShowCustomMenuCmd::reload() {
358 m_menu->removeAll();
359 m_menu->setLabel("");
360 MenuCreator::createFromFile(custom_menu_file, *m_menu.get(), m_menu->reloadHelper());
355} 361}
356 362
357REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void); 363REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void);