aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc235
1 files changed, 217 insertions, 18 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 464b41f..851e407 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -156,9 +156,93 @@ int anotherWMRunning(Display *display, XErrorEvent *) {
156} 156}
157 157
158 158
159class TabPlacementMenuItem: public FbTk::MenuItem {
160public:
161 TabPlacementMenuItem(const char * label, BScreen &screen, FbWinFrame::TabPlacement place, FbTk::RefCount<FbTk::Command> &cmd):
162 FbTk::MenuItem(label, cmd),
163 m_screen(screen),
164 m_place(place) { }
165
166 bool isEnabled() const { return m_screen.getTabPlacement() != m_place; }
167 void click(int button, int time) {
168 m_screen.saveTabPlacement(m_place);
169 FbTk::MenuItem::click(button, time);
170 }
171
172
173private:
174 BScreen &m_screen;
175 FbWinFrame::TabPlacement m_place;
176};
159 177
160} // end anonymous namespace 178} // end anonymous namespace
161 179
180
181
182namespace FbTk {
183
184template<>
185void FbTk::Resource<FbWinFrame::TabPlacement>::
186setFromString(const char *strval) {
187 if (strcasecmp(strval, "TopLeft")==0)
188 m_value = FbWinFrame::TOPLEFT;
189 else if (strcasecmp(strval, "BottomLeft")==0)
190 m_value = FbWinFrame::BOTTOMLEFT;
191 else if (strcasecmp(strval, "TopRight")==0)
192 m_value = FbWinFrame::TOPRIGHT;
193 else if (strcasecmp(strval, "BottomRight")==0)
194 m_value = FbWinFrame::BOTTOMRIGHT;
195 /*
196 else if (strcasecmp(strval, "LeftTop") == 0)
197 m_value = FbWinFrame::LEFTTOP;
198 else if (strcasecmp(strval, "LeftBottom") == 0)
199 m_value = FbWinFrame::LEFTBOTTOM;
200 else if (strcasecmp(strval, "RightTop") == 0)
201 m_value = FbWinFrame::RIGHTTOP;
202 else if (strcasecmp(strval, "RightBottom") == 0)
203 m_value = FbWinFrame::RIGHTBOTTOM;
204 */
205 else
206 setDefaultValue();
207}
208
209template<>
210string FbTk::Resource<FbWinFrame::TabPlacement>::
211getString() const {
212 switch (m_value) {
213 case FbWinFrame::TOPLEFT:
214 return string("TopLeft");
215 break;
216 case FbWinFrame::BOTTOMLEFT:
217 return string("BottomLeft");
218 break;
219 case FbWinFrame::TOPRIGHT:
220 return string("TopRight");
221 break;
222 case FbWinFrame::BOTTOMRIGHT:
223 return string("BottomRight");
224 break;
225/*
226 case FbWinFrame::LEFTTOP:
227 return string("LeftTop");
228 break;
229 case FbWinFrame::LEFTBOTTOM:
230 return string("LeftBottom");
231 break;
232 case FbWinFrame::RIGHTTOP:
233 return string("RightTop");
234 break;
235 case FbWinFrame::RIGHTBOTTOM:
236 return string("RightBottom");
237 break;
238*/
239 }
240 //default string
241 return string("TopLeft");
242}
243} // end namespace FbTk
244
245
162BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, 246BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
163 const std::string &scrname, 247 const std::string &scrname,
164 const std::string &altscrname): 248 const std::string &altscrname):
@@ -176,6 +260,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
176 decorate_transient(rm, false, scrname+".decorateTransient", altscrname+".DecorateTransient"), 260 decorate_transient(rm, false, scrname+".decorateTransient", altscrname+".DecorateTransient"),
177 rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), 261 rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"),
178 resize_model(rm, BOTTOMRESIZE, scrname+".resizeMode", altscrname+".ResizeMode"), 262 resize_model(rm, BOTTOMRESIZE, scrname+".resizeMode", altscrname+".ResizeMode"),
263 tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"),
179 windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"), 264 windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"),
180 follow_model(rm, IGNORE_OTHER_WORKSPACES, scrname+".followModel", altscrname+".followModel"), 265 follow_model(rm, IGNORE_OTHER_WORKSPACES, scrname+".followModel", altscrname+".followModel"),
181 workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), 266 workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"),
@@ -202,7 +287,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
202 altscrname+".overlay.CapStyle"), 287 altscrname+".overlay.CapStyle"),
203 scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"), 288 scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"),
204 scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"), 289 scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"),
205 default_external_tabs(rm, false /* TODO: autoconf option? */ , scrname+".externalTabs", altscrname+".ExternalTabs") { 290 default_internal_tabs(rm, false /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") {
206 291
207 292
208} 293}
@@ -330,7 +415,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
330 } 415 }
331 416
332 m_current_workspace = m_workspaces_list.front(); 417 m_current_workspace = m_workspaces_list.front();
333 418
334 419
335 //!! TODO: we shouldn't do this more than once, but since slit handles their 420 //!! TODO: we shouldn't do this more than once, but since slit handles their
336 // own resources we must do this. 421 // own resources we must do this.
@@ -626,6 +711,15 @@ FbTk::Menu *BScreen::createMenu(const std::string &label) {
626 711
627 return menu; 712 return menu;
628} 713}
714FbTk::Menu *BScreen::createToggleMenu(const std::string &label) {
715 FbTk::Menu *menu = new ToggleMenu(menuTheme(),
716 imageControl(),
717 *layerManager().getLayer(Layer::MENU));
718 if (!label.empty())
719 menu->setLabel(label.c_str());
720
721 return menu;
722}
629 723
630void BScreen::addExtraWindowMenu(const char *label, FbTk::Menu *menu) { 724void BScreen::addExtraWindowMenu(const char *label, FbTk::Menu *menu) {
631 menu->setInternalMenu(); 725 menu->setInternalMenu();
@@ -794,6 +888,26 @@ void BScreen::reconfigure() {
794 FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(), 888 FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(),
795 fluxbox->getStyleOverlayFilename(), 889 fluxbox->getStyleOverlayFilename(),
796 m_root_theme->screenNum()); 890 m_root_theme->screenNum());
891
892 reconfigureTabs();
893}
894
895void BScreen::reconfigureTabs() {
896 Workspaces::iterator w_it = getWorkspacesList().begin();
897 const Workspaces::iterator w_it_end = getWorkspacesList().end();
898 for (; w_it != w_it_end; ++w_it) {
899 if ((*w_it)->windowList().size()) {
900 Workspace::Windows::iterator win_it = (*w_it)->windowList().begin();
901 const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end();
902 for (; win_it != win_it_end; ++win_it) {
903 (*win_it)->frame().setTabPlacement(*resource.tab_placement);
904 if (*resource.default_internal_tabs)
905 (*win_it)->frame().setTabMode(FbWinFrame::INTERNAL);
906 else
907 (*win_it)->frame().setTabMode(FbWinFrame::EXTERNAL);
908 }
909 }
910 }
797} 911}
798 912
799 913
@@ -1454,12 +1568,21 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1454 menu.removeAll(); 1568 menu.removeAll();
1455 1569
1456 FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); 1570 FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
1457 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(), 1571 FbTk::MacroCommand *s_a_reconftabs_macro = new FbTk::MacroCommand();
1458 &Fluxbox::save_rc)); 1572 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(
1573 *Fluxbox::instance(),
1574 &Fluxbox::save_rc));
1459 FbTk::RefCount<FbTk::Command> reconf_cmd(CommandParser::instance().parseLine("reconfigure")); 1575 FbTk::RefCount<FbTk::Command> reconf_cmd(CommandParser::instance().parseLine("reconfigure"));
1576
1577 FbTk::RefCount<FbTk::Command> reconftabs_cmd(new FbTk::SimpleCommand<BScreen>(
1578 *this,
1579 &BScreen::reconfigureTabs));
1460 s_a_reconf_macro->add(saverc_cmd); 1580 s_a_reconf_macro->add(saverc_cmd);
1461 s_a_reconf_macro->add(reconf_cmd); 1581 s_a_reconf_macro->add(reconf_cmd);
1582 s_a_reconftabs_macro->add(saverc_cmd);
1583 s_a_reconftabs_macro->add(reconftabs_cmd);
1462 FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro); 1584 FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro);
1585 FbTk::RefCount<FbTk::Command> save_and_reconftabs(s_a_reconftabs_macro);
1463 // create focus menu 1586 // create focus menu
1464 // we don't set this to internal menu so will 1587 // we don't set this to internal menu so will
1465 // be deleted toghether with the parent 1588 // be deleted toghether with the parent
@@ -1468,6 +1591,9 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1468 "Method used to give focus to windows"); 1591 "Method used to give focus to windows");
1469 FbTk::Menu *focus_menu = createMenu(focusmenu_label ? focusmenu_label : ""); 1592 FbTk::Menu *focus_menu = createMenu(focusmenu_label ? focusmenu_label : "");
1470 1593
1594#define _BOOLITEM(m,a, b, c, d, e, f) (m).insert(new BoolMenuItem(_FBTEXT(a, b, c, d), e, f))
1595
1596
1471#define _FOCUSITEM(a, b, c, d, e) \ 1597#define _FOCUSITEM(a, b, c, d, e) \
1472 focus_menu->insert(new FocusModelMenuItem(_FBTEXT(a, b, c, d), focusControl(), \ 1598 focus_menu->insert(new FocusModelMenuItem(_FBTEXT(a, b, c, d), focusControl(), \
1473 e, save_and_reconfigure)) 1599 e, save_and_reconfigure))
@@ -1498,6 +1624,84 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1498 focus_menu->updateMenu(); 1624 focus_menu->updateMenu();
1499 1625
1500 menu.insert(focusmenu_label, focus_menu); 1626 menu.insert(focusmenu_label, focus_menu);
1627
1628 // END focus menu
1629
1630 // BEGIN tab menu
1631
1632 const char *tabmenu_label = _FBTEXT(Configmenu, TabMenu,
1633 "Tab Options",
1634 "heading for tab-related options");
1635 FbTk::Menu *tab_menu = createMenu(tabmenu_label ? tabmenu_label : "");
1636 const char *tabplacement_label = _FBTEXT(Menu, Placement, "Placement", "Title of Placement menu");
1637 FbTk::Menu *tabplacement_menu = createToggleMenu(tabplacement_label);
1638
1639 tab_menu->insert(tabplacement_label, tabplacement_menu);
1640
1641 _BOOLITEM(*tab_menu,Configmenu, TabsInTitlebar,
1642 "Tabs in Titlebar", "Tabs in Titlebar",
1643 *resource.default_internal_tabs, save_and_reconftabs);
1644
1645 typedef pair<const char*, FbWinFrame::TabPlacement> PlacementP;
1646 typedef list<PlacementP> Placements;
1647 Placements place_menu;
1648
1649 // menu is 3 wide, 5 down
1650 place_menu.push_back(PlacementP(_FBTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT));
1651 place_menu.push_back(PlacementP(_FBTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT));
1652 place_menu.push_back(PlacementP(_FBTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT));
1653 place_menu.push_back(PlacementP(_FBTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT));
1654
1655/*
1656 place_menu.push_back(PlacementP(_FBTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP));
1657 place_menu.push_back(PlacementP(_FBTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM));
1658 place_menu.push_back(PlacementP(_FBTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP));
1659 place_menu.push_back(PlacementP(_FBTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM));
1660*/
1661
1662 tabplacement_menu->setMinimumSublevels(2);
1663 // create items in sub menu
1664 size_t i=0;
1665 while (!place_menu.empty()) {
1666 i++;
1667 const char *str = place_menu.front().first;
1668 FbWinFrame::TabPlacement placement = place_menu.front().second;
1669
1670 if (str == 0) {
1671 tabplacement_menu->insert("");
1672 tabplacement_menu->setItemEnabled(i, false);
1673 } else {
1674 tabplacement_menu->insert(new TabPlacementMenuItem(str, *this, placement, save_and_reconftabs));
1675 }
1676 place_menu.pop_front();
1677 }
1678 tabplacement_menu->updateMenu();
1679
1680 menu.insert(tabmenu_label, tab_menu);
1681
1682#undef _FOCUSITEM
1683
1684 focus_menu->insert(new TabFocusModelMenuItem("ClickTabFocus", focusControl(),
1685 FocusControl::CLICKTABFOCUS,
1686 save_and_reconfigure));
1687 focus_menu->insert(new TabFocusModelMenuItem("MouseTabFocus", focusControl(),
1688 FocusControl::MOUSETABFOCUS,
1689 save_and_reconfigure));
1690
1691
1692 focus_menu->insert(new BoolMenuItem(_FBTEXT(Configmenu,
1693 AutoRaise,
1694 "Auto Raise",
1695 "Auto Raise windows on sloppy"),
1696 *resource.auto_raise,
1697 save_and_reconfigure));
1698
1699 focus_menu->updateMenu();
1700
1701 menu.insert(focusmenu_label, focus_menu);
1702
1703 // end tab menu
1704
1501#ifdef SLIT 1705#ifdef SLIT
1502 if (slit() != 0) { 1706 if (slit() != 0) {
1503 slit()->menu().setInternalMenu(); 1707 slit()->menu().setInternalMenu();
@@ -1510,20 +1714,18 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1510 for (; it != it_end; ++it) 1714 for (; it != it_end; ++it)
1511 menu.insert(it->first, it->second); 1715 menu.insert(it->first, it->second);
1512 1716
1513#define _BOOLITEM(a, b, c, d, e, f) menu.insert(new BoolMenuItem(_FBTEXT(a, b, c, d), e, f)) 1717 _BOOLITEM(menu, Configmenu, ImageDithering,
1514
1515 _BOOLITEM(Configmenu, ImageDithering,
1516 "Image Dithering", "Image Dithering", 1718 "Image Dithering", "Image Dithering",
1517 *resource.image_dither, save_and_reconfigure); 1719 *resource.image_dither, save_and_reconfigure);
1518 _BOOLITEM(Configmenu, OpaqueMove, 1720 _BOOLITEM(menu, Configmenu, OpaqueMove,
1519 "Opaque Window Moving", 1721 "Opaque Window Moving",
1520 "Window Moving with whole window visible (as opposed to outline moving)", 1722 "Window Moving with whole window visible (as opposed to outline moving)",
1521 *resource.opaque_move, saverc_cmd); 1723 *resource.opaque_move, saverc_cmd);
1522 _BOOLITEM(Configmenu, FullMax, 1724 _BOOLITEM(menu, Configmenu, FullMax,
1523 "Full Maximization", "Maximise over slit, toolbar, etc", 1725 "Full Maximization", "Maximise over slit, toolbar, etc",
1524 *resource.full_max, saverc_cmd); 1726 *resource.full_max, saverc_cmd);
1525 try { 1727 try {
1526 _BOOLITEM(Configmenu, FocusNew, 1728 _BOOLITEM(menu, Configmenu, FocusNew,
1527 "Focus New Windows", "Focus newly created windows", 1729 "Focus New Windows", "Focus newly created windows",
1528 *m_resource_manager.getResource<bool>(name() + ".focusNewWindows"), 1730 *m_resource_manager.getResource<bool>(name() + ".focusNewWindows"),
1529 saverc_cmd); 1731 saverc_cmd);
@@ -1532,7 +1734,7 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1532 } 1734 }
1533 1735
1534 try { 1736 try {
1535 _BOOLITEM(Configmenu, FocusLast, 1737 _BOOLITEM(menu, Configmenu, FocusLast,
1536 "Focus Last Window on Workspace", "Focus Last Window on Workspace", 1738 "Focus Last Window on Workspace", "Focus Last Window on Workspace",
1537 *resourceManager().getResource<bool>(name() + ".focusLastWindow"), 1739 *resourceManager().getResource<bool>(name() + ".focusLastWindow"),
1538 saverc_cmd); 1740 saverc_cmd);
@@ -1540,20 +1742,17 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1540 cerr<<e.what()<<endl; 1742 cerr<<e.what()<<endl;
1541 } 1743 }
1542 1744
1543 _BOOLITEM(Configmenu, WorkspaceWarping, 1745 _BOOLITEM(menu, Configmenu, WorkspaceWarping,
1544 "Workspace Warping", 1746 "Workspace Warping",
1545 "Workspace Warping - dragging windows to the edge and onto the next workspace", 1747 "Workspace Warping - dragging windows to the edge and onto the next workspace",
1546 *resource.workspace_warping, saverc_cmd); 1748 *resource.workspace_warping, saverc_cmd);
1547 _BOOLITEM(Configmenu, DesktopWheeling, 1749 _BOOLITEM(menu, Configmenu, DesktopWheeling,
1548 "Desktop MouseWheel Switching", "Workspace switching using mouse wheel", 1750 "Desktop MouseWheel Switching", "Workspace switching using mouse wheel",
1549 *resource.desktop_wheeling, saverc_cmd); 1751 *resource.desktop_wheeling, saverc_cmd);
1550 _BOOLITEM(Configmenu, DecorateTransient, 1752 _BOOLITEM(menu, Configmenu, DecorateTransient,
1551 "Decorate Transient Windows", "Decorate Transient Windows", 1753 "Decorate Transient Windows", "Decorate Transient Windows",
1552 *resource.decorate_transient, saverc_cmd); 1754 *resource.decorate_transient, saverc_cmd);
1553 _BOOLITEM(Configmenu, ExternalTabs, 1755 _BOOLITEM(menu, Configmenu, ClickRaises,
1554 "Use External Tabs (experimental)", "Use External Tabs (experimental)",
1555 *resource.default_external_tabs, saverc_cmd);
1556 _BOOLITEM(Configmenu, ClickRaises,
1557 "Click Raises", "Click Raises", 1756 "Click Raises", "Click Raises",
1558 *resource.click_raises, saverc_cmd); 1757 *resource.click_raises, saverc_cmd);
1559 1758