diff options
author | Henrik Kinnunen <fluxgen@fluxbox.org> | 2008-05-13 15:07:30 (GMT) |
---|---|---|
committer | Henrik Kinnunen <fluxgen@fluxbox.org> | 2008-05-13 15:07:30 (GMT) |
commit | 7f45bae4629f345906e96c1fcb3a3d1e49c36382 (patch) | |
tree | b09708632d29ac4471c57446eb726e5401c8570f /src/Screen.cc | |
parent | 5ecebae4770cbe7e4feea46d2c074a818f1c9662 (diff) | |
parent | d7aa526d9275f7c94f0b1ce27464eaf3dae0d78d (diff) | |
download | fluxbox_lack-7f45bae4629f345906e96c1fcb3a3d1e49c36382.zip fluxbox_lack-7f45bae4629f345906e96c1fcb3a3d1e49c36382.tar.bz2 |
Merge branch 'master' of fluxbox@git.fluxbox.org:fluxbox
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 111 |
1 files changed, 58 insertions, 53 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 1ae5fbc..73b826b 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -283,7 +283,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, | |||
283 | follow_model(rm, IGNORE_OTHER_WORKSPACES, scrname+".followModel", altscrname+".followModel"), | 283 | follow_model(rm, IGNORE_OTHER_WORKSPACES, scrname+".followModel", altscrname+".followModel"), |
284 | user_follow_model(rm, FOLLOW_ACTIVE_WINDOW, scrname+".userFollowModel", altscrname+".UserFollowModel"), | 284 | user_follow_model(rm, FOLLOW_ACTIVE_WINDOW, scrname+".userFollowModel", altscrname+".UserFollowModel"), |
285 | workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), | 285 | workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), |
286 | edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), | 286 | edge_snap_threshold(rm, 10, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), |
287 | focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"), | 287 | focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"), |
288 | unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"), | 288 | unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"), |
289 | menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), | 289 | menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), |
@@ -502,6 +502,15 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
502 | // own resources we must do this. | 502 | // own resources we must do this. |
503 | fluxbox->load_rc(*this); | 503 | fluxbox->load_rc(*this); |
504 | 504 | ||
505 | m_windowmenu.reset(createMenu("")); | ||
506 | m_windowmenu->setInternalMenu(); | ||
507 | m_windowmenu->setReloadHelper(new FbTk::AutoReloadHelper()); | ||
508 | m_windowmenu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<BScreen>(*this, &BScreen::rereadWindowMenu))); | ||
509 | |||
510 | m_rootmenu.reset(createMenu("")); | ||
511 | m_rootmenu->setReloadHelper(new FbTk::AutoReloadHelper()); | ||
512 | m_rootmenu->reloadHelper()->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<BScreen>(*this, &BScreen::rereadMenu))); | ||
513 | |||
505 | m_configmenu.reset(createMenu(_FB_XTEXT(Menu, Configuration, | 514 | m_configmenu.reset(createMenu(_FB_XTEXT(Menu, Configuration, |
506 | "Configuration", "Title of configuration menu"))); | 515 | "Configuration", "Title of configuration menu"))); |
507 | setupConfigmenu(*m_configmenu.get()); | 516 | setupConfigmenu(*m_configmenu.get()); |
@@ -889,8 +898,8 @@ void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) { | |||
889 | 898 | ||
890 | } | 899 | } |
891 | 900 | ||
892 | FbTk::Menu *BScreen::createMenu(const string &label) { | 901 | FbMenu *BScreen::createMenu(const string &label) { |
893 | FbTk::Menu *menu = new FbMenu(menuTheme(), | 902 | FbMenu *menu = new FbMenu(menuTheme(), |
894 | imageControl(), | 903 | imageControl(), |
895 | *layerManager().getLayer(Layer::MENU)); | 904 | *layerManager().getLayer(Layer::MENU)); |
896 | if (!label.empty()) | 905 | if (!label.empty()) |
@@ -898,8 +907,9 @@ FbTk::Menu *BScreen::createMenu(const string &label) { | |||
898 | 907 | ||
899 | return menu; | 908 | return menu; |
900 | } | 909 | } |
901 | FbTk::Menu *BScreen::createToggleMenu(const string &label) { | 910 | |
902 | FbTk::Menu *menu = new ToggleMenu(menuTheme(), | 911 | FbMenu *BScreen::createToggleMenu(const string &label) { |
912 | FbMenu *menu = new ToggleMenu(menuTheme(), | ||
903 | imageControl(), | 913 | imageControl(), |
904 | *layerManager().getLayer(Layer::MENU)); | 914 | *layerManager().getLayer(Layer::MENU)); |
905 | if (!label.empty()) | 915 | if (!label.empty()) |
@@ -912,9 +922,7 @@ void BScreen::addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu) | |||
912 | menu->setInternalMenu(); | 922 | menu->setInternalMenu(); |
913 | menu->disableTitle(); | 923 | menu->disableTitle(); |
914 | m_extramenus.push_back(make_pair(label, menu)); | 924 | m_extramenus.push_back(make_pair(label, menu)); |
915 | // recreate window menu | 925 | rereadWindowMenu(); |
916 | m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber())); | ||
917 | m_windowmenu->setInternalMenu(); | ||
918 | } | 926 | } |
919 | 927 | ||
920 | void BScreen::reconfigure() { | 928 | void BScreen::reconfigure() { |
@@ -956,21 +964,9 @@ void BScreen::reconfigure() { | |||
956 | } | 964 | } |
957 | } | 965 | } |
958 | 966 | ||
959 | // if timestamp hasn't changed, then just a reconfigure is fine | 967 | // update menu filenames |
960 | // and that seems to happen somewhere else, anyway | 968 | m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename()); |
961 | if (fluxbox->menuTimestampsChanged()) { | 969 | m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename()); |
962 | // all bets are off, so just hide the menu and reset the filenames | ||
963 | fluxbox->clearMenuFilenames(); | ||
964 | m_rootmenu->hide(); | ||
965 | rereadMenu(); | ||
966 | } | ||
967 | |||
968 | //reconfigure menus | ||
969 | m_workspacemenu->reconfigure(); | ||
970 | m_configmenu->reconfigure(); | ||
971 | // recreate window menu | ||
972 | m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber())); | ||
973 | m_windowmenu->setInternalMenu(); | ||
974 | 970 | ||
975 | // reconfigure workspaces | 971 | // reconfigure workspaces |
976 | for_each(m_workspaces_list.begin(), | 972 | for_each(m_workspaces_list.begin(), |
@@ -1003,12 +999,6 @@ void BScreen::reconfigureTabs() { | |||
1003 | (*it)->fbwindow()->applyDecorations(); | 999 | (*it)->fbwindow()->applyDecorations(); |
1004 | } | 1000 | } |
1005 | 1001 | ||
1006 | |||
1007 | void BScreen::rereadMenu() { | ||
1008 | initMenu(); | ||
1009 | m_rootmenu->reconfigure(); | ||
1010 | } | ||
1011 | |||
1012 | void BScreen::updateWorkspaceName(unsigned int w) { | 1002 | void BScreen::updateWorkspaceName(unsigned int w) { |
1013 | Workspace *space = getWorkspace(w); | 1003 | Workspace *space = getWorkspace(w); |
1014 | if (space) { | 1004 | if (space) { |
@@ -1500,34 +1490,24 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, | |||
1500 | 1490 | ||
1501 | void BScreen::initMenus() { | 1491 | void BScreen::initMenus() { |
1502 | m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber())); | 1492 | m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber())); |
1503 | m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber())); | 1493 | m_rootmenu->reloadHelper()->setMainFile(Fluxbox::instance()->getMenuFilename()); |
1504 | m_windowmenu->setInternalMenu(); | 1494 | m_windowmenu->reloadHelper()->setMainFile(windowMenuFilename()); |
1505 | initMenu(); | ||
1506 | } | 1495 | } |
1507 | 1496 | ||
1508 | 1497 | ||
1509 | void BScreen::initMenu() { | 1498 | void BScreen::rereadMenu() { |
1510 | |||
1511 | if (m_rootmenu.get()) { | ||
1512 | // since all menus in root is submenus in m_rootmenu | ||
1513 | // just remove every item in m_rootmenu and then clear m_rootmenu_list | ||
1514 | while (m_rootmenu->numberOfItems()) | ||
1515 | m_rootmenu->remove(0); | ||
1516 | m_rootmenu_list.clear(); | ||
1517 | 1499 | ||
1518 | } else | 1500 | m_rootmenu->removeAll(); |
1519 | m_rootmenu.reset(createMenu("")); | 1501 | m_rootmenu->setLabel(""); |
1520 | 1502 | ||
1521 | Fluxbox * const fb = Fluxbox::instance(); | 1503 | Fluxbox * const fb = Fluxbox::instance(); |
1522 | if (!fb->getMenuFilename().empty()) { | 1504 | if (!fb->getMenuFilename().empty()) |
1523 | m_rootmenu.reset(MenuCreator::createFromFile(fb->getMenuFilename(), | 1505 | MenuCreator::createFromFile(fb->getMenuFilename(), *m_rootmenu, |
1524 | screenNumber())); | 1506 | m_rootmenu->reloadHelper()); |
1525 | 1507 | ||
1526 | } | 1508 | if (m_rootmenu->numberOfItems() == 0) { |
1527 | |||
1528 | if (m_rootmenu.get() == 0 || m_rootmenu->numberOfItems() == 0) { | ||
1529 | _FB_USES_NLS; | 1509 | _FB_USES_NLS; |
1530 | m_rootmenu.reset(createMenu(_FB_XTEXT(Menu, DefaultRootMenu, "Fluxbox default menu", "Title of fallback root menu"))); | 1510 | m_rootmenu->setLabel(_FB_XTEXT(Menu, DefaultRootMenu, "Fluxbox default menu", "Title of fallback root menu")); |
1531 | FbTk::RefCount<FbTk::Command<void> > restart_fb(FbTk::CommandParser<void>::instance().parse("restart")); | 1511 | FbTk::RefCount<FbTk::Command<void> > restart_fb(FbTk::CommandParser<void>::instance().parse("restart")); |
1532 | FbTk::RefCount<FbTk::Command<void> > exit_fb(FbTk::CommandParser<void>::instance().parse("exit")); | 1512 | FbTk::RefCount<FbTk::Command<void> > exit_fb(FbTk::CommandParser<void>::instance().parse("exit")); |
1533 | FbTk::RefCount<FbTk::Command<void> > execute_xterm(FbTk::CommandParser<void>::instance().parse("exec xterm")); | 1513 | FbTk::RefCount<FbTk::Command<void> > execute_xterm(FbTk::CommandParser<void>::instance().parse("exec xterm")); |
@@ -1539,14 +1519,39 @@ void BScreen::initMenu() { | |||
1539 | restart_fb); | 1519 | restart_fb); |
1540 | m_rootmenu->insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit command"), | 1520 | m_rootmenu->insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit command"), |
1541 | exit_fb); | 1521 | exit_fb); |
1542 | // still save the menu filename, in case it becomes valid later | ||
1543 | if (!fb->getMenuFilename().empty()) | ||
1544 | fb->saveMenuFilename(fb->getMenuFilename().c_str()); | ||
1545 | } | 1522 | } |
1546 | 1523 | ||
1547 | m_rootmenu->updateMenu(); | ||
1548 | } | 1524 | } |
1549 | 1525 | ||
1526 | void BScreen::rereadWindowMenu() { | ||
1527 | |||
1528 | m_windowmenu->removeAll(); | ||
1529 | if (!windowMenuFilename().empty()) | ||
1530 | MenuCreator::createWindowMenuFromFile(windowMenuFilename(), | ||
1531 | *m_windowmenu, | ||
1532 | m_windowmenu->reloadHelper()); | ||
1533 | |||
1534 | if (m_windowmenu->numberOfItems() == 0) { | ||
1535 | const char *defaults[] = { | ||
1536 | "shade", | ||
1537 | "stick", | ||
1538 | "maximize", | ||
1539 | "iconify", | ||
1540 | "raise", | ||
1541 | "lower", | ||
1542 | "sendto", | ||
1543 | "layer", | ||
1544 | "alpha", | ||
1545 | "extramenus", | ||
1546 | "separator", | ||
1547 | "close", | ||
1548 | 0 | ||
1549 | }; | ||
1550 | for (unsigned int i=0; defaults[i]; ++i) | ||
1551 | MenuCreator::createWindowMenuItem(defaults[i], "", *m_windowmenu); | ||
1552 | } | ||
1553 | |||
1554 | } | ||
1550 | 1555 | ||
1551 | void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) { | 1556 | void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) { |
1552 | m_configmenu_list.push_back(make_pair(label, &menu)); | 1557 | m_configmenu_list.push_back(make_pair(label, &menu)); |