aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira@fluxbox.org>2015-01-16 07:36:49 (GMT)
committerMathias Gumz <akira@fluxbox.org>2015-01-16 07:36:49 (GMT)
commitb4958780650cfab97d4dc694a34c0c77bf99b26d (patch)
tree0982d91e368b1e9f020b606cb0f2b205cd619c4d /src/Screen.cc
parentbd9afcafb93382b5b7f32c222594699214581596 (diff)
downloadfluxbox-b4958780650cfab97d4dc694a34c0c77bf99b26d.zip
fluxbox-b4958780650cfab97d4dc694a34c0c77bf99b26d.tar.bz2
Reduce number of allocations for menu creation
Every time either the Slit menu or the Toolbar menu were added to the root menu, the whole root menu was (re)created from scratch. Now we create and remove only the menus needed. Side effect: the position of these menus is now at the end of the root menu and not somewhere in between. If users complaint, I' ll think about it.
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 9aab3f7..5e7ca8b 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1362,22 +1362,25 @@ void BScreen::rereadWindowMenu() {
1362} 1362}
1363 1363
1364void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) { 1364void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) {
1365 m_configmenu_list.push_back(make_pair(label, &menu)); 1365
1366 if (m_configmenu.get()) 1366 FbTk::Menu* cm = m_configmenu.get();
1367 setupConfigmenu(*m_configmenu.get()); 1367 if (cm) {
1368 int pos = cm->findSubmenuIndex(&menu);
1369 if (pos == -1) { // not found? add
1370 cm->insertSubmenu(label, &menu, pos);
1371 }
1372 }
1368} 1373}
1369 1374
1370void BScreen::removeConfigMenu(FbTk::Menu &menu) { 1375void BScreen::removeConfigMenu(FbTk::Menu &menu) {
1371 Configmenus::iterator erase_it = find_if(m_configmenu_list.begin(),
1372 m_configmenu_list.end(),
1373 FbTk::Compose(bind2nd(equal_to<FbTk::Menu *>(), &menu),
1374 FbTk::Select2nd<Configmenus::value_type>()));
1375 if (erase_it != m_configmenu_list.end())
1376 m_configmenu_list.erase(erase_it);
1377
1378 if (!isShuttingdown() && m_configmenu.get())
1379 setupConfigmenu(*m_configmenu.get());
1380 1376
1377 FbTk::Menu* cm = m_configmenu.get();
1378 if (cm) {
1379 int pos = cm->findSubmenuIndex(&menu);
1380 if (pos > -1) {
1381 cm->remove(pos);
1382 }
1383 }
1381} 1384}
1382 1385
1383 1386