aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fluxbox.cc131
1 files changed, 50 insertions, 81 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 1711187..e859921 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,10 +22,9 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.cc,v 1.23 2002/01/20 02:19:16 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.24 2002/01/21 02:04:23 fluxgen Exp $
26 26
27// stupid macros needed to access some functions in version 2 of the GNU C 27//Use some GNU extensions
28// library
29#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
30#define _GNU_SOURCE 29#define _GNU_SOURCE
31#endif // _GNU_SOURCE 30#endif // _GNU_SOURCE
@@ -41,7 +40,7 @@
41#include "Rootmenu.hh" 40#include "Rootmenu.hh"
42#include "Screen.hh" 41#include "Screen.hh"
43 42
44#ifdef SLIT 43#ifdef SLIT
45#include "Slit.hh" 44#include "Slit.hh"
46#endif // SLIT 45#endif // SLIT
47 46
@@ -153,7 +152,7 @@ static Bool queueScanner(Display *, XEvent *e, char *args) {
153 ((scanargs *) args)->leave = True; 152 ((scanargs *) args)->leave = True;
154 ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior); 153 ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior);
155 } else if ((e->type == EnterNotify) && 154 } else if ((e->type == EnterNotify) &&
156 (e->xcrossing.mode == NotifyUngrab)) 155 (e->xcrossing.mode == NotifyUngrab))
157 ((scanargs *) args)->enter = True; 156 ((scanargs *) args)->enter = True;
158 157
159 return False; 158 return False;
@@ -858,11 +857,10 @@ void Fluxbox::process_event(XEvent *e) {
858 FluxboxWindow *win = (FluxboxWindow *) 0; 857 FluxboxWindow *win = (FluxboxWindow *) 0;
859 Basemenu *menu = (Basemenu *) 0; 858 Basemenu *menu = (Basemenu *) 0;
860 Toolbar *tbar = (Toolbar *) 0; 859 Toolbar *tbar = (Toolbar *) 0;
861 // Tab *tab = 0;
862 860
863#ifdef SLIT 861 #ifdef SLIT
864 Slit *slit = (Slit *) 0; 862 Slit *slit = (Slit *) 0;
865#endif // SLIT 863 #endif // SLIT
866 864
867 if ((menu = searchMenu(e->xcrossing.window))) 865 if ((menu = searchMenu(e->xcrossing.window)))
868 menu->leaveNotifyEvent(&e->xcrossing); 866 menu->leaveNotifyEvent(&e->xcrossing);
@@ -870,12 +868,10 @@ void Fluxbox::process_event(XEvent *e) {
870 win->installColormap(False); 868 win->installColormap(False);
871 else if ((tbar = searchToolbar(e->xcrossing.window))) 869 else if ((tbar = searchToolbar(e->xcrossing.window)))
872 tbar->leaveNotifyEvent(&e->xcrossing); 870 tbar->leaveNotifyEvent(&e->xcrossing);
873 // else if ((tab = searchTab(e->xcrossing.window))) 871 #ifdef SLIT
874 // tab->leaveNotifyEvent(&e->xcrossing);
875#ifdef SLIT
876 else if ((slit = searchSlit(e->xcrossing.window))) 872 else if ((slit = searchSlit(e->xcrossing.window)))
877 slit->leaveNotifyEvent(&e->xcrossing); 873 slit->leaveNotifyEvent(&e->xcrossing);
878#endif // SLIT 874 #endif // SLIT
879 875
880 break; 876 break;
881 } 877 }
@@ -1594,6 +1590,9 @@ void Fluxbox::shutdown(void) {
1594//saves resources 1590//saves resources
1595//---------------------- 1591//----------------------
1596void Fluxbox::save_rc(void) { 1592void Fluxbox::save_rc(void) {
1593 #ifdef DEBUG
1594 cerr<<__FILE__<<"("<<__LINE__<<"): Saving resources --------------"<<endl;
1595 #endif
1597 1596
1598 XrmDatabase new_blackboxrc = 0; 1597 XrmDatabase new_blackboxrc = 0;
1599 1598
@@ -1604,15 +1603,10 @@ void Fluxbox::save_rc(void) {
1604 // load_rc(); 1603 // load_rc();
1605 // This overwrites configs made while running, for example 1604 // This overwrites configs made while running, for example
1606 // usage of iconbar and tabs 1605 // usage of iconbar and tabs
1607 #ifndef DEBUG 1606
1608 cerr<<__FILE__<<"("<<__LINE__<<"): Here"<<endl;
1609 #endif
1610 1607
1611 if (*dbfile) { 1608 if (*dbfile) {
1612 m_resourcemanager.save(dbfile.get(), dbfile.get()); 1609 m_resourcemanager.save(dbfile.get(), dbfile.get());
1613 #ifdef DEBUG
1614 cerr<<"Saving resource"<<endl;
1615 #endif
1616 m_screen_rm.save(dbfile.get(), dbfile.get()); 1610 m_screen_rm.save(dbfile.get(), dbfile.get());
1617 } else 1611 } else
1618 cerr<<"database filename is invalid!"<<endl; 1612 cerr<<"database filename is invalid!"<<endl;
@@ -1628,13 +1622,15 @@ void Fluxbox::save_rc(void) {
1628 XrmPutLineResource(&new_blackboxrc, rc_string); 1622 XrmPutLineResource(&new_blackboxrc, rc_string);
1629 1623
1630 LinkedListIterator<BScreen> it(screenList); 1624 LinkedListIterator<BScreen> it(screenList);
1631 1625
1626 //Save screen resources
1627
1632 for (; it.current(); it++) { 1628 for (; it.current(); it++) {
1633 BScreen *screen = it.current(); 1629 BScreen *screen = it.current();
1634 int screen_number = screen->getScreenNumber(); 1630 int screen_number = screen->getScreenNumber();
1635 1631
1636#ifdef SLIT 1632#ifdef SLIT
1637 char *slit_placement = (char *) 0; 1633 string slit_placement;
1638 1634
1639 switch (screen->getSlitPlacement()) { 1635 switch (screen->getSlitPlacement()) {
1640 case Slit::TOPLEFT: slit_placement = "TopLeft"; break; 1636 case Slit::TOPLEFT: slit_placement = "TopLeft"; break;
@@ -1648,31 +1644,23 @@ void Fluxbox::save_rc(void) {
1648 } 1644 }
1649 1645
1650 sprintf(rc_string, "session.screen%d.slit.placement: %s", screen_number, 1646 sprintf(rc_string, "session.screen%d.slit.placement: %s", screen_number,
1651 slit_placement); 1647 slit_placement.c_str());
1652 XrmPutLineResource(&new_blackboxrc, rc_string); 1648 XrmPutLineResource(&new_blackboxrc, rc_string);
1653 1649
1654 sprintf(rc_string, "session.screen%d.slit.direction: %s", screen_number, 1650 sprintf(rc_string, "session.screen%d.slit.direction: %s", screen_number,
1655 ((screen->getSlitDirection() == Slit::HORIZONTAL) ? "Horizontal" : 1651 ((screen->getSlitDirection() == Slit::HORIZONTAL) ? "Horizontal" :
1656 "Vertical")); 1652 "Vertical"));
1657 XrmPutLineResource(&new_blackboxrc, rc_string); 1653 XrmPutLineResource(&new_blackboxrc, rc_string);
1658 1654
1659 sprintf(rc_string, "session.screen%d.slit.onTop: %s", screen_number, 1655 sprintf(rc_string, "session.screen%d.slit.onTop: %s", screen_number,
1660 ((screen->getSlit()->isOnTop()) ? "True" : "False")); 1656 ((screen->getSlit()->isOnTop()) ? "True" : "False"));
1661 XrmPutLineResource(&new_blackboxrc, rc_string); 1657 XrmPutLineResource(&new_blackboxrc, rc_string);
1662 1658
1663 sprintf(rc_string, "session.screen%d.slit.autoHide: %s", screen_number, 1659 sprintf(rc_string, "session.screen%d.slit.autoHide: %s", screen_number,
1664 ((screen->getSlit()->doAutoHide()) ? "True" : "False")); 1660 ((screen->getSlit()->doAutoHide()) ? "True" : "False"));
1665 XrmPutLineResource(&new_blackboxrc, rc_string); 1661 XrmPutLineResource(&new_blackboxrc, rc_string);
1666#endif // SLIT 1662#endif // SLIT
1667 1663
1668 sprintf(rc_string, "session.screen%d.focusNewWindows: %s", screen_number,
1669 ((screen->doFocusNew()) ? "True" : "False"));
1670 XrmPutLineResource(&new_blackboxrc, rc_string);
1671
1672 sprintf(rc_string, "session.screen%d.focusLastWindow: %s", screen_number,
1673 ((screen->doFocusLast()) ? "True" : "False"));
1674 XrmPutLineResource(&new_blackboxrc, rc_string);
1675
1676 sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number, 1664 sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number,
1677 ((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ? 1665 ((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ?
1678 "LeftToRight" : "RightToLeft")); 1666 "LeftToRight" : "RightToLeft"));
@@ -1680,10 +1668,10 @@ void Fluxbox::save_rc(void) {
1680 1668
1681 sprintf(rc_string, "session.screen%d.colPlacementDirection: %s", screen_number, 1669 sprintf(rc_string, "session.screen%d.colPlacementDirection: %s", screen_number,
1682 ((screen->getColPlacementDirection() == BScreen::TOPBOTTOM) ? 1670 ((screen->getColPlacementDirection() == BScreen::TOPBOTTOM) ?
1683 "TopToBottom" : "BottomToTop")); 1671 "TopToBottom" : "BottomToTop"));
1684 XrmPutLineResource(&new_blackboxrc, rc_string); 1672 XrmPutLineResource(&new_blackboxrc, rc_string);
1685 1673
1686 std::string placement; 1674 string placement;
1687 1675
1688 switch (screen->getPlacementPolicy()) { 1676 switch (screen->getPlacementPolicy()) {
1689 case BScreen::CASCADEPLACEMENT: 1677 case BScreen::CASCADEPLACEMENT:
@@ -1699,11 +1687,12 @@ void Fluxbox::save_rc(void) {
1699 placement = "RowSmartPlacement"; 1687 placement = "RowSmartPlacement";
1700 break; 1688 break;
1701 } 1689 }
1702 sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number, 1690
1703 placement.c_str()); 1691 sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number,
1692 placement.c_str());
1704 XrmPutLineResource(&new_blackboxrc, rc_string); 1693 XrmPutLineResource(&new_blackboxrc, rc_string);
1705 1694
1706 char *focus_mode = 0; 1695 std::string focus_mode;
1707 if (screen->isSloppyFocus() && screen->doAutoRaise()) 1696 if (screen->isSloppyFocus() && screen->doAutoRaise())
1708 focus_mode = "AutoRaiseSloppyFocus"; 1697 focus_mode = "AutoRaiseSloppyFocus";
1709 else if (screen->isSloppyFocus()) 1698 else if (screen->isSloppyFocus())
@@ -1716,12 +1705,10 @@ void Fluxbox::save_rc(void) {
1716 focus_mode = "ClickToFocus"; 1705 focus_mode = "ClickToFocus";
1717 1706
1718 sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number, 1707 sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number,
1719 focus_mode); 1708 focus_mode.c_str());
1720
1721 XrmPutLineResource(&new_blackboxrc, rc_string); 1709 XrmPutLineResource(&new_blackboxrc, rc_string);
1722 1710
1723 load_rc(screen); 1711// load_rc(screen);
1724
1725 // these are static, but may not be saved in the users resource file, 1712 // these are static, but may not be saved in the users resource file,
1726 // writing these resources will allow the user to edit them at a later 1713 // writing these resources will allow the user to edit them at a later
1727 // time... but loading the defaults before saving allows us to rewrite the 1714 // time... but loading the defaults before saving allows us to rewrite the
@@ -1742,15 +1729,10 @@ void Fluxbox::save_rc(void) {
1742 XrmPutLineResource(&new_blackboxrc, rc_string); 1729 XrmPutLineResource(&new_blackboxrc, rc_string);
1743#endif // HAVE_STRFTIME 1730#endif // HAVE_STRFTIME
1744 1731
1745 sprintf(rc_string, "session.screen%d.edgeSnapThreshold: %d", screen_number,
1746 screen->getEdgeSnapThreshold());
1747 XrmPutLineResource(&new_blackboxrc, rc_string);
1748
1749 // write out the users workspace names 1732 // write out the users workspace names
1750
1751 sprintf(rc_string, "session.screen%d.workspaceNames: ", screen_number); 1733 sprintf(rc_string, "session.screen%d.workspaceNames: ", screen_number);
1752 string workspaces_string(rc_string); 1734 string workspaces_string(rc_string);
1753 #ifndef DEBUG 1735 #ifdef DEBUG
1754 cerr<<__FILE__<<"("<<__LINE__<<"): workspaces="<<screen->getCount()<<endl; 1736 cerr<<__FILE__<<"("<<__LINE__<<"): workspaces="<<screen->getCount()<<endl;
1755 #endif 1737 #endif
1756 for (int workspace=0; workspace < screen->getCount(); workspace++) { 1738 for (int workspace=0; workspace < screen->getCount(); workspace++) {
@@ -1760,7 +1742,7 @@ void Fluxbox::save_rc(void) {
1760 workspaces_string.append("Null"); 1742 workspaces_string.append("Null");
1761 workspaces_string.append(", "); 1743 workspaces_string.append(", ");
1762 } 1744 }
1763 1745
1764 XrmPutLineResource(&new_blackboxrc, workspaces_string.c_str()); 1746 XrmPutLineResource(&new_blackboxrc, workspaces_string.c_str());
1765 1747
1766 } 1748 }
@@ -1770,7 +1752,9 @@ void Fluxbox::save_rc(void) {
1770 XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together 1752 XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together
1771 XrmPutFileDatabase(old_blackboxrc, dbfile.get()); 1753 XrmPutFileDatabase(old_blackboxrc, dbfile.get());
1772 XrmDestroyDatabase(old_blackboxrc); 1754 XrmDestroyDatabase(old_blackboxrc);
1773 1755 #ifdef DEBUG
1756 cerr<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl;
1757 #endif
1774} 1758}
1775 1759
1776//-------- getRcFilename ------------- 1760//-------- getRcFilename -------------
@@ -1864,7 +1848,9 @@ void Fluxbox::load_rc(void) {
1864} 1848}
1865 1849
1866void Fluxbox::load_rc(BScreen *screen) { 1850void Fluxbox::load_rc(BScreen *screen) {
1867 1851 #ifdef DEBUG
1852 cerr<<"Loading BScreen(this="<<screen<<") num="<<screen->getScreenNumber()<<"------------"<<endl;
1853 #endif
1868 //get resource filename 1854 //get resource filename
1869 auto_ptr<char> dbfile(getRcFilename()); 1855 auto_ptr<char> dbfile(getRcFilename());
1870 #ifdef DEBUG 1856 #ifdef DEBUG
@@ -1892,28 +1878,6 @@ void Fluxbox::load_rc(BScreen *screen) {
1892 char *value_type, name_lookup[1024], class_lookup[1024]; 1878 char *value_type, name_lookup[1024], class_lookup[1024];
1893 int screen_number = screen->getScreenNumber(); 1879 int screen_number = screen->getScreenNumber();
1894 1880
1895 sprintf(name_lookup, "session.screen%d.focusNewWindows", screen_number);
1896 sprintf(class_lookup, "Session.Screen%d.FocusNewWindows", screen_number);
1897 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1898 &value)) {
1899 if (! strncasecmp(value.addr, "true", value.size))
1900 screen->saveFocusNew(True);
1901 else
1902 screen->saveFocusNew(False);
1903 } else
1904 screen->saveFocusNew(False);
1905
1906 sprintf(name_lookup, "session.screen%d.focusLastWindow", screen_number);
1907 sprintf(class_lookup, "Session.Screen%d.focusLastWindow", screen_number);
1908 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1909 &value)) {
1910 if (! strncasecmp(value.addr, "true", value.size))
1911 screen->saveFocusLast(True);
1912 else
1913 screen->saveFocusLast(False);
1914 } else
1915 screen->saveFocusLast(False);
1916
1917 sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number); 1881 sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number);
1918 sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number); 1882 sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number);
1919 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 1883 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
@@ -1928,7 +1892,7 @@ void Fluxbox::load_rc(BScreen *screen) {
1928 sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number); 1892 sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number);
1929 sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number); 1893 sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number);
1930 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 1894 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1931 &value)) { 1895 &value)) {
1932 if (! strncasecmp(value.addr, "bottomtotop", value.size)) 1896 if (! strncasecmp(value.addr, "bottomtotop", value.size))
1933 screen->saveColPlacementDirection(BScreen::BOTTOMTOP); 1897 screen->saveColPlacementDirection(BScreen::BOTTOMTOP);
1934 else 1898 else
@@ -1936,17 +1900,15 @@ void Fluxbox::load_rc(BScreen *screen) {
1936 } else 1900 } else
1937 screen->saveColPlacementDirection(BScreen::TOPBOTTOM); 1901 screen->saveColPlacementDirection(BScreen::TOPBOTTOM);
1938 1902
1939 //check size on toolbarwidth percent
1940 if (screen->getToolbarWidthPercent() <= 0 ||
1941 screen->getToolbarWidthPercent() > 100)
1942 screen->saveToolbarWidthPercent(66);
1943
1944 screen->removeWorkspaceNames(); 1903 screen->removeWorkspaceNames();
1945 1904
1946 sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number); 1905 sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number);
1947 sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number); 1906 sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number);
1948 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 1907 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1949 &value)) { 1908 &value)) {
1909 #ifdef DEBUG
1910 cerr<<__FILE__<<"("<<__LINE__<<"): Workspaces="<<screen->getNumberOfWorkspaces()<<endl;
1911 #endif
1950 char *search = StringUtil::strdup(value.addr); 1912 char *search = StringUtil::strdup(value.addr);
1951 1913
1952 int i; 1914 int i;
@@ -2104,6 +2066,11 @@ void Fluxbox::load_rc(BScreen *screen) {
2104 screen->saveClock24Hour(False); 2066 screen->saveClock24Hour(False);
2105#endif // HAVE_STRFTIME 2067#endif // HAVE_STRFTIME
2106 2068
2069 //check size on toolbarwidth percent
2070 if (screen->getToolbarWidthPercent() <= 0 ||
2071 screen->getToolbarWidthPercent() > 100)
2072 screen->saveToolbarWidthPercent(66);
2073
2107 if (screen->getTabWidth()>512) 2074 if (screen->getTabWidth()>512)
2108 screen->saveTabWidth(512); 2075 screen->saveTabWidth(512);
2109 else if (screen->getTabWidth()<0) 2076 else if (screen->getTabWidth()<0)
@@ -2113,7 +2080,9 @@ void Fluxbox::load_rc(BScreen *screen) {
2113 screen->saveTabHeight(512); 2080 screen->saveTabHeight(512);
2114 else if (screen->getTabHeight()<0) 2081 else if (screen->getTabHeight()<0)
2115 screen->saveTabHeight(5); 2082 screen->saveTabHeight(5);
2116 2083 #ifdef DEBUG
2084 cerr<<__FILE__<<"("<<__LINE__<<"---------------------- LOADING DONE"<<endl;
2085 #endif
2117} 2086}
2118 2087
2119void Fluxbox::loadRootCommand(BScreen *screen) { 2088void Fluxbox::loadRootCommand(BScreen *screen) {