aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc116
1 files changed, 60 insertions, 56 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 11dc5a5..9939c90 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,7 +22,7 @@
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.108 2003/04/15 08:54:40 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.109 2003/04/15 12:11:54 fluxgen Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -39,6 +39,8 @@
39#include "EventManager.hh" 39#include "EventManager.hh"
40#include "FbCommands.hh" 40#include "FbCommands.hh"
41#include "WinClient.hh" 41#include "WinClient.hh"
42#include "Keys.hh"
43#include "FbAtoms.hh"
42 44
43//Use GNU extensions 45//Use GNU extensions
44#ifndef _GNU_SOURCE 46#ifndef _GNU_SOURCE
@@ -356,7 +358,8 @@ Fluxbox::Titlebar Fluxbox::m_titlebar_left[] = {STICK};
356Fluxbox::Titlebar Fluxbox::m_titlebar_right[] = {MINIMIZE, MAXIMIZE, CLOSE}; 358Fluxbox::Titlebar Fluxbox::m_titlebar_right[] = {MINIMIZE, MAXIMIZE, CLOSE};
357 359
358Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc) 360Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc)
359 : BaseDisplay(m_argv[0], dpy_name), FbAtoms(getXDisplay()), 361 : BaseDisplay(m_argv[0], dpy_name),
362 m_fbatoms(new FbAtoms()),
360 m_resourcemanager(), m_screen_rm(), 363 m_resourcemanager(), m_screen_rm(),
361 m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"), 364 m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"),
362 m_rc_iconbar(m_resourcemanager, true, "session.iconbar", "Session.Iconbar"), 365 m_rc_iconbar(m_resourcemanager, true, "session.iconbar", "Session.Iconbar"),
@@ -970,7 +973,7 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
970 if (ce.format != 32) 973 if (ce.format != 32)
971 return; 974 return;
972 975
973 if (ce.message_type == getWMChangeStateAtom()) { 976 if (ce.message_type == m_fbatoms->getWMChangeStateAtom()) {
974 FluxboxWindow *win = searchWindow(ce.window); 977 FluxboxWindow *win = searchWindow(ce.window);
975 if (! win || ! win->validateClient()) 978 if (! win || ! win->validateClient())
976 return; 979 return;
@@ -979,18 +982,18 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
979 win->iconify(); 982 win->iconify();
980 if (ce.data.l[0] == NormalState) 983 if (ce.data.l[0] == NormalState)
981 win->deiconify(); 984 win->deiconify();
982 } else if (ce.message_type == getFluxboxChangeWorkspaceAtom()) { 985 } else if (ce.message_type == m_fbatoms->getFluxboxChangeWorkspaceAtom()) {
983 BScreen *screen = searchScreen(ce.window); 986 BScreen *screen = searchScreen(ce.window);
984 987
985 if (screen && ce.data.l[0] >= 0 && 988 if (screen && ce.data.l[0] >= 0 &&
986 ce.data.l[0] < (signed)screen->getCount()) 989 ce.data.l[0] < (signed)screen->getCount())
987 screen->changeWorkspaceID(ce.data.l[0]); 990 screen->changeWorkspaceID(ce.data.l[0]);
988 991
989 } else if (ce.message_type == getFluxboxChangeWindowFocusAtom()) { 992 } else if (ce.message_type == m_fbatoms->getFluxboxChangeWindowFocusAtom()) {
990 FluxboxWindow *win = searchWindow(ce.window); 993 FluxboxWindow *win = searchWindow(ce.window);
991 if (win && win->isVisible() && win->setInputFocus()) 994 if (win && win->isVisible() && win->setInputFocus())
992 win->installColormap(True); 995 win->installColormap(True);
993 } else if (ce.message_type == getFluxboxCycleWindowFocusAtom()) { 996 } else if (ce.message_type == m_fbatoms->getFluxboxCycleWindowFocusAtom()) {
994 BScreen *screen = searchScreen(ce.window); 997 BScreen *screen = searchScreen(ce.window);
995 998
996 if (screen) { 999 if (screen) {
@@ -999,7 +1002,7 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
999 else 1002 else
1000 screen->nextFocus(); 1003 screen->nextFocus();
1001 } 1004 }
1002 } else if (ce.message_type == getFluxboxChangeAttributesAtom()) { 1005 } else if (ce.message_type == m_fbatoms->getFluxboxChangeAttributesAtom()) {
1003 1006
1004 FluxboxWindow *win = searchWindow(ce.window); 1007 FluxboxWindow *win = searchWindow(ce.window);
1005 1008
@@ -1290,7 +1293,7 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1290 1293
1291 1294
1292} 1295}
1293void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) { 1296void Fluxbox::doWindowAction(int action, const int param) {
1294 if (!focused_window) 1297 if (!focused_window)
1295 return; 1298 return;
1296 1299
@@ -1913,7 +1916,7 @@ void Fluxbox::load_rc() {
1913 } 1916 }
1914} 1917}
1915 1918
1916void Fluxbox::load_rc(BScreen *screen) { 1919void Fluxbox::load_rc(BScreen &screen) {
1917 //get resource filename 1920 //get resource filename
1918 string dbfile(getRcFilename()); 1921 string dbfile(getRcFilename());
1919 if (dbfile.size() != 0) { 1922 if (dbfile.size() != 0) {
@@ -1936,50 +1939,51 @@ void Fluxbox::load_rc(BScreen *screen) {
1936 1939
1937 XrmValue value; 1940 XrmValue value;
1938 char *value_type, name_lookup[1024], class_lookup[1024]; 1941 char *value_type, name_lookup[1024], class_lookup[1024];
1939 int screen_number = screen->getScreenNumber(); 1942 int screen_number = screen.getScreenNumber();
1940 1943
1941 sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number); 1944 sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number);
1942 sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number); 1945 sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number);
1943 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 1946 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1944 &value)) { 1947 &value)) {
1945 if (! strncasecmp(value.addr, "righttoleft", value.size)) 1948 if (! strncasecmp(value.addr, "righttoleft", value.size))
1946 screen->saveRowPlacementDirection(BScreen::RIGHTLEFT); 1949 screen.saveRowPlacementDirection(BScreen::RIGHTLEFT);
1947 else 1950 else
1948 screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); 1951 screen.saveRowPlacementDirection(BScreen::LEFTRIGHT);
1949 } else 1952 } else
1950 screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); 1953 screen.saveRowPlacementDirection(BScreen::LEFTRIGHT);
1951 1954
1952 sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number); 1955 sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number);
1953 sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number); 1956 sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number);
1954 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 1957 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1955 &value)) { 1958 &value)) {
1956 if (! strncasecmp(value.addr, "bottomtotop", value.size)) 1959 if (! strncasecmp(value.addr, "bottomtotop", value.size))
1957 screen->saveColPlacementDirection(BScreen::BOTTOMTOP); 1960 screen.saveColPlacementDirection(BScreen::BOTTOMTOP);
1958 else 1961 else
1959 screen->saveColPlacementDirection(BScreen::TOPBOTTOM); 1962 screen.saveColPlacementDirection(BScreen::TOPBOTTOM);
1960 } else 1963 } else
1961 screen->saveColPlacementDirection(BScreen::TOPBOTTOM); 1964 screen.saveColPlacementDirection(BScreen::TOPBOTTOM);
1962 1965
1963 screen->removeWorkspaceNames(); 1966 screen.removeWorkspaceNames();
1964 1967
1965 sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number); 1968 sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number);
1966 sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number); 1969 sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number);
1967 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 1970 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1968 &value)) { 1971 &value)) {
1969#ifdef DEBUG 1972#ifdef DEBUG
1970 cerr<<__FILE__<<"("<<__LINE__<<"): Workspaces="<<screen->getNumberOfWorkspaces()<<endl; 1973 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Workspaces="<<
1974 screen.getNumberOfWorkspaces()<<endl;
1971#endif // DEBUG 1975#endif // DEBUG
1972 char *search = StringUtil::strdup(value.addr); 1976 char *search = StringUtil::strdup(value.addr);
1973 1977
1974 int i; 1978 int i;
1975 for (i = 0; i < screen->getNumberOfWorkspaces(); i++) { 1979 for (i = 0; i < screen.getNumberOfWorkspaces(); i++) {
1976 char *nn; 1980 char *nn;
1977 1981
1978 if (! i) nn = strtok(search, ","); 1982 if (! i) nn = strtok(search, ",");
1979 else nn = strtok(0, ","); 1983 else nn = strtok(0, ",");
1980 1984
1981 if (nn) 1985 if (nn)
1982 screen->addWorkspaceName(nn); 1986 screen.addWorkspaceName(nn);
1983 else break; 1987 else break;
1984 1988
1985 } 1989 }
@@ -1992,13 +1996,13 @@ void Fluxbox::load_rc(BScreen *screen) {
1992 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 1996 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
1993 &value)) { 1997 &value)) {
1994 if (! strncasecmp(value.addr, "RowSmartPlacement", value.size)) 1998 if (! strncasecmp(value.addr, "RowSmartPlacement", value.size))
1995 screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); 1999 screen.savePlacementPolicy(BScreen::ROWSMARTPLACEMENT);
1996 else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size)) 2000 else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size))
1997 screen->savePlacementPolicy(BScreen::COLSMARTPLACEMENT); 2001 screen.savePlacementPolicy(BScreen::COLSMARTPLACEMENT);
1998 else 2002 else
1999 screen->savePlacementPolicy(BScreen::CASCADEPLACEMENT); 2003 screen.savePlacementPolicy(BScreen::CASCADEPLACEMENT);
2000 } else 2004 } else
2001 screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); 2005 screen.savePlacementPolicy(BScreen::ROWSMARTPLACEMENT);
2002 2006
2003#ifdef SLIT 2007#ifdef SLIT
2004 sprintf(name_lookup, "session.screen%d.slit.placement", screen_number); 2008 sprintf(name_lookup, "session.screen%d.slit.placement", screen_number);
@@ -2006,34 +2010,34 @@ void Fluxbox::load_rc(BScreen *screen) {
2006 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 2010 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
2007 &value)) { 2011 &value)) {
2008 if (! strncasecmp(value.addr, "TopLeft", value.size)) 2012 if (! strncasecmp(value.addr, "TopLeft", value.size))
2009 screen->saveSlitPlacement(Slit::TOPLEFT); 2013 screen.saveSlitPlacement(Slit::TOPLEFT);
2010 else if (! strncasecmp(value.addr, "CenterLeft", value.size)) 2014 else if (! strncasecmp(value.addr, "CenterLeft", value.size))
2011 screen->saveSlitPlacement(Slit::CENTERLEFT); 2015 screen.saveSlitPlacement(Slit::CENTERLEFT);
2012 else if (! strncasecmp(value.addr, "BottomLeft", value.size)) 2016 else if (! strncasecmp(value.addr, "BottomLeft", value.size))
2013 screen->saveSlitPlacement(Slit::BOTTOMLEFT); 2017 screen.saveSlitPlacement(Slit::BOTTOMLEFT);
2014 else if (! strncasecmp(value.addr, "TopCenter", value.size)) 2018 else if (! strncasecmp(value.addr, "TopCenter", value.size))
2015 screen->saveSlitPlacement(Slit::TOPCENTER); 2019 screen.saveSlitPlacement(Slit::TOPCENTER);
2016 else if (! strncasecmp(value.addr, "BottomCenter", value.size)) 2020 else if (! strncasecmp(value.addr, "BottomCenter", value.size))
2017 screen->saveSlitPlacement(Slit::BOTTOMCENTER); 2021 screen.saveSlitPlacement(Slit::BOTTOMCENTER);
2018 else if (! strncasecmp(value.addr, "TopRight", value.size)) 2022 else if (! strncasecmp(value.addr, "TopRight", value.size))
2019 screen->saveSlitPlacement(Slit::TOPRIGHT); 2023 screen.saveSlitPlacement(Slit::TOPRIGHT);
2020 else if (! strncasecmp(value.addr, "BottomRight", value.size)) 2024 else if (! strncasecmp(value.addr, "BottomRight", value.size))
2021 screen->saveSlitPlacement(Slit::BOTTOMRIGHT); 2025 screen.saveSlitPlacement(Slit::BOTTOMRIGHT);
2022 else 2026 else
2023 screen->saveSlitPlacement(Slit::CENTERRIGHT); 2027 screen.saveSlitPlacement(Slit::CENTERRIGHT);
2024 } else 2028 } else
2025 screen->saveSlitPlacement(Slit::CENTERRIGHT); 2029 screen.saveSlitPlacement(Slit::CENTERRIGHT);
2026 2030
2027 sprintf(name_lookup, "session.screen%d.slit.direction", screen_number); 2031 sprintf(name_lookup, "session.screen%d.slit.direction", screen_number);
2028 sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number); 2032 sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number);
2029 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 2033 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
2030 &value)) { 2034 &value)) {
2031 if (! strncasecmp(value.addr, "Horizontal", value.size)) 2035 if (! strncasecmp(value.addr, "Horizontal", value.size))
2032 screen->saveSlitDirection(Slit::HORIZONTAL); 2036 screen.saveSlitDirection(Slit::HORIZONTAL);
2033 else 2037 else
2034 screen->saveSlitDirection(Slit::VERTICAL); 2038 screen.saveSlitDirection(Slit::VERTICAL);
2035 } else 2039 } else
2036 screen->saveSlitDirection(Slit::VERTICAL); 2040 screen.saveSlitDirection(Slit::VERTICAL);
2037 2041
2038 2042
2039 sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number); 2043 sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number);
@@ -2041,11 +2045,11 @@ void Fluxbox::load_rc(BScreen *screen) {
2041 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 2045 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
2042 &value)) { 2046 &value)) {
2043 if (! strncasecmp(value.addr, "True", value.size)) 2047 if (! strncasecmp(value.addr, "True", value.size))
2044 screen->saveSlitAutoHide(True); 2048 screen.saveSlitAutoHide(true);
2045 else 2049 else
2046 screen->saveSlitAutoHide(False); 2050 screen.saveSlitAutoHide(false);
2047 } else 2051 } else
2048 screen->saveSlitAutoHide(False); 2052 screen.saveSlitAutoHide(false);
2049 /* 2053 /*
2050 #ifdef XINERAMA 2054 #ifdef XINERAMA
2051 int tmp_head; 2055 int tmp_head;
@@ -2067,9 +2071,9 @@ void Fluxbox::load_rc(BScreen *screen) {
2067 sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number); 2071 sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number);
2068 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 2072 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
2069 &value)) 2073 &value))
2070 screen->saveStrftimeFormat(value.addr); 2074 screen.saveStrftimeFormat(value.addr);
2071 else 2075 else
2072 screen->saveStrftimeFormat("%I:%M %p"); 2076 screen.saveStrftimeFormat("%I:%M %p");
2073#else // HAVE_STRFTIME 2077#else // HAVE_STRFTIME
2074 2078
2075 sprintf(name_lookup, "session.screen%d.dateFormat", screen_number); 2079 sprintf(name_lookup, "session.screen%d.dateFormat", screen_number);
@@ -2077,11 +2081,11 @@ void Fluxbox::load_rc(BScreen *screen) {
2077 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 2081 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
2078 &value)) { 2082 &value)) {
2079 if (strncasecmp(value.addr, "european", value.size)) 2083 if (strncasecmp(value.addr, "european", value.size))
2080 screen->saveDateFormat(B_AMERICANDATE); 2084 screen.saveDateFormat(B_AMERICANDATE);
2081 else 2085 else
2082 screen->saveDateFormat(B_EUROPEANDATE); 2086 screen.saveDateFormat(B_EUROPEANDATE);
2083 } else 2087 } else
2084 screen->saveDateFormat(B_AMERICANDATE); 2088 screen.saveDateFormat(B_AMERICANDATE);
2085 2089
2086 sprintf(name_lookup, "session.screen%d.clockFormat", screen_number); 2090 sprintf(name_lookup, "session.screen%d.clockFormat", screen_number);
2087 sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number); 2091 sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number);
@@ -2089,23 +2093,23 @@ void Fluxbox::load_rc(BScreen *screen) {
2089 &value)) { 2093 &value)) {
2090 int clock; 2094 int clock;
2091 if (sscanf(value.addr, "%d", &clock) != 1) 2095 if (sscanf(value.addr, "%d", &clock) != 1)
2092 screen->saveClock24Hour(False); 2096 screen.saveClock24Hour(False);
2093 else if (clock == 24) 2097 else if (clock == 24)
2094 screen->saveClock24Hour(True); 2098 screen.saveClock24Hour(True);
2095 else 2099 else
2096 screen->saveClock24Hour(False); 2100 screen.saveClock24Hour(False);
2097 } else 2101 } else
2098 screen->saveClock24Hour(False); 2102 screen.saveClock24Hour(False);
2099#endif // HAVE_STRFTIME 2103#endif // HAVE_STRFTIME
2100 2104
2101 //check size on toolbarwidth percent 2105 //check size on toolbarwidth percent
2102 if (screen->getToolbarWidthPercent() <= 0 || 2106 if (screen.getToolbarWidthPercent() <= 0 ||
2103 screen->getToolbarWidthPercent() > 100) 2107 screen.getToolbarWidthPercent() > 100)
2104 screen->saveToolbarWidthPercent(66); 2108 screen.saveToolbarWidthPercent(66);
2105 2109
2106} 2110}
2107 2111
2108void Fluxbox::loadRootCommand(BScreen *screen) { 2112void Fluxbox::loadRootCommand(BScreen &screen) {
2109 2113
2110 string dbfile(getRcFilename()); 2114 string dbfile(getRcFilename());
2111 2115
@@ -2115,13 +2119,13 @@ void Fluxbox::loadRootCommand(BScreen *screen) {
2115 2119
2116 XrmValue value; 2120 XrmValue value;
2117 char *value_type, name_lookup[1024], class_lookup[1024]; 2121 char *value_type, name_lookup[1024], class_lookup[1024];
2118 sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber()); 2122 sprintf(name_lookup, "session.screen%d.rootCommand", screen.getScreenNumber());
2119 sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber()); 2123 sprintf(class_lookup, "Session.Screen%d.RootCommand", screen.getScreenNumber());
2120 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, 2124 if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
2121 &value)) { 2125 &value)) {
2122 screen->saveRootCommand(value.addr==0 ? "": value.addr); 2126 screen.saveRootCommand(value.addr==0 ? "": value.addr);
2123 } else 2127 } else
2124 screen->saveRootCommand(""); 2128 screen.saveRootCommand("");
2125 2129
2126} 2130}
2127 2131