From f16075f27763005cd9de7a7166f7f56f86910bb4 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 18 Jan 2002 01:23:54 +0000 Subject: Fixed better resourcehandling with Resource --- src/fluxbox.cc | 2026 ++++++++++++++++++++++++++++---------------------------- src/fluxbox.hh | 76 ++- 2 files changed, 1037 insertions(+), 1065 deletions(-) diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 2f8d3cb..1eea987 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -16,22 +16,22 @@ // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.20 2002/01/11 22:48:45 pekdon Exp $ +// $Id: fluxbox.cc,v 1.21 2002/01/18 01:23:54 fluxgen Exp $ // stupid macros needed to access some functions in version 2 of the GNU C // library -#ifndef _GNU_SOURCE -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE #endif // _GNU_SOURCE -#ifdef HAVE_CONFIG_H -# include "../config.h" +#ifdef HAVE_CONFIG_H +# include "../config.h" #endif // HAVE_CONFIG_H #include "i18n.hh" @@ -41,7 +41,7 @@ #include "Rootmenu.hh" #include "Screen.hh" -#ifdef SLIT +#ifdef SLIT #include "Slit.hh" #endif // SLIT @@ -50,6 +50,7 @@ #include "Workspace.hh" #include "Workspacemenu.hh" #include "StringUtil.hh" +#include "Resource.hh" #include #include @@ -57,63 +58,63 @@ #include #include -#ifdef SHAPE +#ifdef SHAPE #include #endif // SHAPE -#ifdef HAVE_STDIO_H -# include +#ifdef HAVE_STDIO_H +# include #endif // HAVE_STDIO_H -#ifdef STDC_HEADERS -# include -# include +#ifdef STDC_HEADERS +# include +# include #endif // STDC_HEADERS -#ifdef HAVE_UNISTD_H -# include -# include +#ifdef HAVE_UNISTD_H +# include +# include #endif // HAVE_UNISTD_H -#ifdef HAVE_SYS_PARAM_H -# include +#ifdef HAVE_SYS_PARAM_H +# include #endif // HAVE_SYS_PARAM_H -#ifndef MAXPATHLEN -#define MAXPATHLEN 255 +#ifndef MAXPATHLEN +#define MAXPATHLEN 255 #endif // MAXPATHLEN -#ifdef HAVE_SYS_SELECT_H -# include +#ifdef HAVE_SYS_SELECT_H +# include #endif // HAVE_SYS_SELECT_H -#ifdef HAVE_SIGNAL_H -# include +#ifdef HAVE_SIGNAL_H +# include #endif // HAVE_SIGNAL_H -#ifdef HAVE_SYS_SIGNAL_H -# include +#ifdef HAVE_SYS_SIGNAL_H +# include #endif // HAVE_SYS_SIGNAL_H -#ifdef HAVE_SYS_STAT_H -# include -# include +#ifdef HAVE_SYS_STAT_H +# include +# include #endif // HAVE_SYS_STAT_H -#ifdef TIME_WITH_SYS_TIME -# include -# include +#ifdef TIME_WITH_SYS_TIME +# include +# include #else // !TIME_WITH_SYS_TIME -# ifdef HAVE_SYS_TIME_H -# include -# else // !HAVE_SYS_TIME_H -# include -# endif // HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H +# include +# else // !HAVE_SYS_TIME_H +# include +# endif // HAVE_SYS_TIME_H #endif // TIME_WITH_SYS_TIME -#ifdef HAVE_LIBGEN_H -# include +#ifdef HAVE_LIBGEN_H +# include #endif // HAVE_LIBGEN_H #include @@ -122,14 +123,14 @@ #include using namespace std; -#ifndef HAVE_BASENAME +#ifndef HAVE_BASENAME static inline char *basename (char *); static inline char *basename (char *s) { - char *save = s; + char *save = s; - while (*s) if (*s++ == '/') save = s; + while (*s) if (*s++ == '/') save = s; - return save; + return save; } #endif // HAVE_BASENAME @@ -139,23 +140,142 @@ static inline char *basename (char *s) { // X event scanner for enter/leave notifies - adapted from twm typedef struct scanargs { - Window w; - Bool leave, inferior, enter; + Window w; + Bool leave, inferior, enter; } scanargs; static Bool queueScanner(Display *, XEvent *e, char *args) { - if ((e->type == LeaveNotify) && - (e->xcrossing.window == ((scanargs *) args)->w) && - (e->xcrossing.mode == NotifyNormal)) { - ((scanargs *) args)->leave = True; - ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior); - } else if ((e->type == EnterNotify) && - (e->xcrossing.mode == NotifyUngrab)) - ((scanargs *) args)->enter = True; - - return False; + if ((e->type == LeaveNotify) && + (e->xcrossing.window == ((scanargs *) args)->w) && + (e->xcrossing.mode == NotifyNormal)) { + ((scanargs *) args)->leave = True; + ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior); + } else if ((e->type == EnterNotify) && + (e->xcrossing.mode == NotifyUngrab)) + ((scanargs *) args)->enter = True; + + return False; +} +//----------------------------------------------------------------- +//---- accessors for int, bool, and some enums with Resource ------ +//----------------------------------------------------------------- +template<> +void Resource:: +setFromString(const char* strval) { + int val; + if (sscanf(strval, "%d", &val)==1) + *this = val; +} + +template<> +void Resource:: +setFromString(const char *strval) { + *this = strval; +} + +template<> +void Resource:: +setFromString(char const *strval) { + if (strcasecmp(strval, "true")==0) + *this = true; + else + *this = false; +} + +template<> +void Resource:: +setFromString(char const *strval) { + vector val; + StringUtil::stringtok(val, strval); + int size=val.size(); + //clear old values + m_value.clear(); + + for (int i=0; i +void Resource:: +setFromString(const char *strval) { + if (sscanf(strval, "%ul", &m_value) != 1) + setDefaultValue(); +} + +//----------------------------------------------------------------- +//---- manipulators for int, bool, and some enums with Resource --- +//----------------------------------------------------------------- +template<> +std::string Resource:: +getString() { + return std::string(**this == true ? "true" : "false"); +} + +template<> +std::string Resource:: +getString() { + char strval[256]; + sprintf(strval, "%d", **this); + return std::string(strval); +} + +template<> +std::string Resource:: +getString() { return **this; } + +template<> +string Resource:: +getString() { + string retval; + int size=m_value.size(); + for (int i=0; i +string Resource:: +getString() { + char tmpstr[128]; + sprintf(tmpstr, "%ul", m_value); + return string(tmpstr); +} //static singleton var Fluxbox *Fluxbox::singleton=0; @@ -165,48 +285,59 @@ Fluxbox *Fluxbox::singleton=0; //since we only need to create one instance of Fluxbox //------------------------------------------- Fluxbox *Fluxbox::instance(int m_argc, char **m_argv, char *dpy_name, char *rc) { - return singleton; + return singleton; } Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc) -: BaseDisplay(m_argv[0], dpy_name) +: BaseDisplay(m_argv[0], dpy_name), +m_resourcemanager(), +m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"), +m_rc_iconbar(m_resourcemanager, true, "session.iconbar", "Session.Iconbar"), +m_rc_colors_per_channel(m_resourcemanager, 4, "session.colorsPerChannel", "Session.ColorsPerChannel"), +m_rc_stylefile(m_resourcemanager, "", "session.styleFile", "Session.StyleFile"), +m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"), +m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"), +m_rc_titlebar_left(m_resourcemanager, TitlebarList(0), "session.titlebar.left", "Session.Titlebar.Left"), +m_rc_titlebar_right(m_resourcemanager, TitlebarList(0), "session.titlebar.right", "Session.Titlebar.Right"), +m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), +m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), +focused_window(0), +masked_window(0), +no_focus(0), +rc_file(rc) + { - + //singleton pointer singleton = this; - grab(); + grab(); - if (! XSupportsLocale()) - fprintf(stderr, "X server does not support locale\n"); + if (! XSupportsLocale()) + fprintf(stderr, "X server does not support locale\n"); - if (XSetLocaleModifiers("") == NULL) - fprintf(stderr, "cannot set locale modifiers\n"); + if (XSetLocaleModifiers("") == NULL) + fprintf(stderr, "cannot set locale modifiers\n"); // Set default values to member variables - argc = m_argc; - argv = m_argv; - rc_file = rc; + argc = m_argc; + argv = m_argv; key=0; - no_focus = False; - resource.titlebar_file = resource.menu_file = resource.style_file = resource.keys_file = 0; + no_focus = False; +// resource.titlebar_file = resource.keys_file = 0; resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0; - focused_window = masked_window = (FluxboxWindow *) 0; - masked = None; - /*resource.tabtype.listtype = TabType::Vertical; - resource.tabtype.listpos = TabType::Top; - resource.tabtype.pos = TabType::Right; - */ - windowSearchList = new LinkedList; - menuSearchList = new LinkedList; + masked = None; + + windowSearchList = new LinkedList; + menuSearchList = new LinkedList; -#ifdef SLIT - slitSearchList = new LinkedList; +#ifdef SLIT + slitSearchList = new LinkedList; #ifdef KDE //For KDE dock applets kwm1_dockwindow = XInternAtom(getXDisplay(), "KWM_DOCKWINDOW", False); //KDE v1.x @@ -215,29 +346,28 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc) #endif // SLIT - toolbarSearchList = new LinkedList; + toolbarSearchList = new LinkedList; tabSearchList = new LinkedList; - groupSearchList = new LinkedList; + groupSearchList = new LinkedList; - menuTimestamps = new LinkedList; + menuTimestamps = new LinkedList; - XrmInitialize(); - load_rc(); + load_rc(); -#ifdef HAVE_GETPID - fluxbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False); +#ifdef HAVE_GETPID + fluxbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False); #endif // HAVE_GETPID - screenList = new LinkedList; - int i; + screenList = new LinkedList; + int i; - //allocate screens + //allocate screens for (i = 0; i < getNumberOfScreens(); i++) { - BScreen *screen = new BScreen(this, i); + BScreen *screen = new BScreen(this, i); - if (! screen->isScreenManaged()) { - delete screen; - continue; + if (! screen->isScreenManaged()) { + delete screen; + continue; } screenList->insert(screen); @@ -245,14 +375,14 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc) I18n *i18n = I18n::instance(); if (! screenList->count()) { fprintf(stderr, - i18n-> - getMessage( -#ifdef NLS - blackboxSet, blackboxNoManagableScreens, + i18n-> + getMessage( +#ifdef NLS + blackboxSet, blackboxNoManagableScreens, #else // !NLS - 0, 0, + 0, 0, #endif // NLS - "Fluxbox::Fluxbox: no managable screens found, aborting.\n")); + "Fluxbox::Fluxbox: no managable screens found, aborting.\n")); throw static_cast(3); } @@ -267,7 +397,7 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc) timer->fireOnce(True); //create keybindings handler and load keys file - key = new Keys(getXDisplay(), resource.keys_file); + key = new Keys(getXDisplay(), const_cast((*m_rc_keyfile).c_str())); ungrab(); } @@ -284,24 +414,12 @@ Fluxbox::~Fluxbox(void) { if (ts->filename) delete [] ts->filename; - delete ts; + delete ts; } delete key; key = 0; - - if (resource.menu_file) - delete [] resource.menu_file; - - if (resource.style_file) - delete [] resource.style_file; - - if (resource.titlebar_file) - delete resource.titlebar_file; - - if (resource.keys_file) - delete resource.keys_file; - + delete timer; delete screenList; @@ -313,7 +431,7 @@ Fluxbox::~Fluxbox(void) { delete tabSearchList; delete groupSearchList; -#ifdef SLIT +#ifdef SLIT delete slitSearchList; #endif // SLIT } @@ -322,12 +440,12 @@ Fluxbox::~Fluxbox(void) { void Fluxbox::process_event(XEvent *e) { if ((masked == e->xany.window) && masked_window && - (e->type == MotionNotify)) { - last_time = e->xmotion.time; - masked_window->motionNotifyEvent(&e->xmotion); + (e->type == MotionNotify)) { + last_time = e->xmotion.time; + masked_window->motionNotifyEvent(&e->xmotion); - return; - } + return; + } switch (e->type) { case ButtonPress: @@ -337,7 +455,7 @@ void Fluxbox::process_event(XEvent *e) { FluxboxWindow *win = (FluxboxWindow *) 0; Basemenu *menu = (Basemenu *) 0; - #ifdef SLIT + #ifdef SLIT Slit *slit = (Slit *) 0; #endif // SLIT @@ -354,10 +472,10 @@ void Fluxbox::process_event(XEvent *e) { } else if ((menu = searchMenu(e->xbutton.window))) { menu->buttonPressEvent(&e->xbutton); -#ifdef SLIT + #ifdef SLIT } else if ((slit = searchSlit(e->xbutton.window))) { slit->buttonPressEvent(&e->xbutton); -#endif // SLIT + #endif // SLIT } else if ((tbar = searchToolbar(e->xbutton.window))) { tbar->buttonPressEvent(&e->xbutton); @@ -388,40 +506,40 @@ void Fluxbox::process_event(XEvent *e) { } else if (e->xbutton.button == 2) { int mx = e->xbutton.x_root - (screen->getWorkspacemenu()->getWidth() / 2); - int my = e->xbutton.y_root - - (screen->getWorkspacemenu()->getTitleHeight() / 2); + int my = e->xbutton.y_root - + (screen->getWorkspacemenu()->getTitleHeight() / 2); - if (mx < 0) mx = 0; - if (my < 0) my = 0; + if (mx < 0) mx = 0; + if (my < 0) my = 0; - if (mx + screen->getWorkspacemenu()->getWidth() > + if (mx + screen->getWorkspacemenu()->getWidth() > screen->getWidth()) mx = screen->getWidth() - screen->getWorkspacemenu()->getWidth() - screen->getBorderWidth(); - if (my + screen->getWorkspacemenu()->getHeight() > - screen->getHeight()) + if (my + screen->getWorkspacemenu()->getHeight() > + screen->getHeight()) my = screen->getHeight() - screen->getWorkspacemenu()->getHeight() - screen->getBorderWidth(); - screen->getWorkspacemenu()->move(mx, my); + screen->getWorkspacemenu()->move(mx, my); - if (! screen->getWorkspacemenu()->isVisible()) { - screen->getWorkspacemenu()->removeParent(); + if (! screen->getWorkspacemenu()->isVisible()) { + screen->getWorkspacemenu()->removeParent(); screen->getWorkspacemenu()->show(); - } - } else if (e->xbutton.button == 3) { - int mx = e->xbutton.x_root - - (screen->getRootmenu()->getWidth() / 2); - int my = e->xbutton.y_root - - (screen->getRootmenu()->getTitleHeight() / 2); + } + } else if (e->xbutton.button == 3) { + int mx = e->xbutton.x_root - + (screen->getRootmenu()->getWidth() / 2); + int my = e->xbutton.y_root - + (screen->getRootmenu()->getTitleHeight() / 2); - if (mx < 0) mx = 0; - if (my < 0) my = 0; + if (mx < 0) mx = 0; + if (my < 0) my = 0; - if (mx + screen->getRootmenu()->getWidth() > screen->getWidth()) + if (mx + screen->getRootmenu()->getWidth() > screen->getWidth()) mx = screen->getWidth() - screen->getRootmenu()->getWidth() - screen->getBorderWidth(); @@ -429,7 +547,7 @@ void Fluxbox::process_event(XEvent *e) { if (my + screen->getRootmenu()->getHeight() > screen->getHeight()) my = screen->getHeight() - - screen->getRootmenu()->getHeight() - + screen->getRootmenu()->getHeight() - screen->getBorderWidth(); screen->getRootmenu()->move(mx, my); @@ -439,13 +557,13 @@ void Fluxbox::process_event(XEvent *e) { screen->getRootmenu()->show(); } - } + } } } } - break; + break; } case ButtonRelease: @@ -459,14 +577,14 @@ void Fluxbox::process_event(XEvent *e) { win->buttonReleaseEvent(&e->xbutton); else if ((menu = searchMenu(e->xbutton.window))) menu->buttonReleaseEvent(&e->xbutton); - else if ((tbar = searchToolbar(e->xbutton.window))) + else if ((tbar = searchToolbar(e->xbutton.window))) tbar->buttonReleaseEvent(&e->xbutton); else if ((tab = searchTab(e->xbutton.window))) tab->buttonReleaseEvent(&e->xbutton); - break; - } + break; + } - case ConfigureRequest: + case ConfigureRequest: { FluxboxWindow *win = (FluxboxWindow *) 0; @@ -506,21 +624,22 @@ void Fluxbox::process_event(XEvent *e) { break; } - case MapRequest: - { -#ifdef DEBUG - fprintf(stderr, - I18n::instance()-> - getMessage( -# ifdef NLS - blackboxSet, blackboxMapRequest, -# else // !NLS - 0, 0, -# endif // NLS - "Fluxbox::process_event(): MapRequest for 0x%lx\n"), - e->xmaprequest.window); -#endif // DEBUG - #ifdef SLIT + case MapRequest: + { + #ifdef DEBUG + fprintf(stderr, + I18n::instance()-> + getMessage( + #ifdef NLS + blackboxSet, blackboxMapRequest, + #else // !NLS + 0, 0, + #endif // NLS + "Fluxbox::process_event(): MapRequest for 0x%lx\n"), + e->xmaprequest.window); + #endif // DEBUG + + #ifdef SLIT #ifdef KDE //Check and see if client is KDE dock applet. //If so add to Slit @@ -529,7 +648,7 @@ void Fluxbox::process_event(XEvent *e) { int ijunk; unsigned long *data = (unsigned long *) 0, uljunk; - // Check if KDE v2.x dock applet + // Check if KDE v2.x dock applet if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window, getKWM2DockwindowAtom(), 0l, 1l, False, XA_WINDOW, &ajunk, &ijunk, &uljunk, @@ -538,15 +657,15 @@ void Fluxbox::process_event(XEvent *e) { if (data) iskdedockapp = True; XFree((char *) data); - + } - // Check if KDE v1.x dock applet + // Check if KDE v1.x dock applet if (!iskdedockapp) { if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window, - getKWM1DockwindowAtom(), 0l, 1l, False, - getKWM1DockwindowAtom(), &ajunk, &ijunk, &uljunk, - &uljunk, (unsigned char **) &data) == Success) { + getKWM1DockwindowAtom(), 0l, 1l, False, + getKWM1DockwindowAtom(), &ajunk, &ijunk, &uljunk, + &uljunk, (unsigned char **) &data) == Success) { iskdedockapp = (data && data[0] != 0); XFree((char *) data); } @@ -562,62 +681,68 @@ void Fluxbox::process_event(XEvent *e) { return; } #endif //KDE - #endif // SLIT - - FluxboxWindow *win = searchWindow(e->xmaprequest.window); - - if (! win) - win = new FluxboxWindow(e->xmaprequest.window); - + #endif // SLIT - if ((win = searchWindow(e->xmaprequest.window))) - win->mapRequestEvent(&e->xmaprequest); + FluxboxWindow *win = searchWindow(e->xmaprequest.window); + + if (! win) { + try { + win = new FluxboxWindow(e->xmaprequest.window); + } catch (FluxboxWindow::Error error) { + FluxboxWindow::showError(error); + delete win; + win = 0; + } + } + + if ((win = searchWindow(e->xmaprequest.window))) + win->mapRequestEvent(&e->xmaprequest); - break; - } + break; + } case MapNotify: - { - FluxboxWindow *win = searchWindow(e->xmap.window); + { + FluxboxWindow *win = searchWindow(e->xmap.window); - if (win) - win->mapNotifyEvent(&e->xmap); + if (win) + win->mapNotifyEvent(&e->xmap); - break; - } + break; + } case UnmapNotify: - { - FluxboxWindow *win = (FluxboxWindow *) 0; + { + FluxboxWindow *win = (FluxboxWindow *) 0; -#ifdef SLIT - Slit *slit = (Slit *) 0; +#ifdef SLIT + Slit *slit = (Slit *) 0; #endif // SLIT if ((win = searchWindow(e->xunmap.window))) { win->unmapNotifyEvent(&e->xunmap); -#ifdef SLIT +#ifdef SLIT } else if ((slit = searchSlit(e->xunmap.window))) { - slit->removeClient(e->xunmap.window); + slit->removeClient(e->xunmap.window); #endif // SLIT - } + } break; } - case DestroyNotify: - { - FluxboxWindow *win = (FluxboxWindow *) 0; + case DestroyNotify: + { + FluxboxWindow *win = (FluxboxWindow *) 0; -#ifdef SLIT +#ifdef SLIT Slit *slit = 0; #endif // SLIT if ((win = searchWindow(e->xdestroywindow.window))) { win->destroyNotifyEvent(&e->xdestroywindow); -#ifdef SLIT +#ifdef SLIT } else if ((slit = searchSlit(e->xdestroywindow.window))) { slit->removeClient(e->xdestroywindow.window, False); #endif // SLIT @@ -626,8 +751,8 @@ void Fluxbox::process_event(XEvent *e) { break; } - case MotionNotify: - { + case MotionNotify: + { last_time = e->xmotion.time; FluxboxWindow *win = 0; @@ -656,10 +781,10 @@ void Fluxbox::process_event(XEvent *e) { } break; - } + } - case EnterNotify: - { + case EnterNotify: + { last_time = e->xcrossing.time; BScreen *screen = (BScreen *) 0; @@ -667,8 +792,8 @@ void Fluxbox::process_event(XEvent *e) { Basemenu *menu = (Basemenu *) 0; Toolbar *tbar = (Toolbar *) 0; Tab *tab = (Tab *) 0; - #ifdef SLIT - Slit *slit = (Slit *) 0; + #ifdef SLIT + Slit *slit = (Slit *) 0; #endif // SLIT if (e->xcrossing.mode == NotifyGrab) @@ -716,25 +841,25 @@ void Fluxbox::process_event(XEvent *e) { } } -#ifdef SLIT - else if ((slit = searchSlit(e->xcrossing.window))) - slit->enterNotifyEvent(&e->xcrossing); +#ifdef SLIT + else if ((slit = searchSlit(e->xcrossing.window))) + slit->enterNotifyEvent(&e->xcrossing); #endif // SLIT - break; - } + break; + } - case LeaveNotify: - { - last_time = e->xcrossing.time; + case LeaveNotify: + { + last_time = e->xcrossing.time; - FluxboxWindow *win = (FluxboxWindow *) 0; - Basemenu *menu = (Basemenu *) 0; - Toolbar *tbar = (Toolbar *) 0; + FluxboxWindow *win = (FluxboxWindow *) 0; + Basemenu *menu = (Basemenu *) 0; + Toolbar *tbar = (Toolbar *) 0; // Tab *tab = 0; -#ifdef SLIT - Slit *slit = (Slit *) 0; +#ifdef SLIT + Slit *slit = (Slit *) 0; #endif // SLIT if ((menu = searchMenu(e->xcrossing.window))) @@ -745,19 +870,19 @@ void Fluxbox::process_event(XEvent *e) { tbar->leaveNotifyEvent(&e->xcrossing); // else if ((tab = searchTab(e->xcrossing.window))) // tab->leaveNotifyEvent(&e->xcrossing); -#ifdef SLIT - else if ((slit = searchSlit(e->xcrossing.window))) - slit->leaveNotifyEvent(&e->xcrossing); +#ifdef SLIT + else if ((slit = searchSlit(e->xcrossing.window))) + slit->leaveNotifyEvent(&e->xcrossing); #endif // SLIT - break; - } - - case Expose: - { - FluxboxWindow *win = (FluxboxWindow *) 0; - Basemenu *menu = (Basemenu *) 0; - Toolbar *tbar = (Toolbar *) 0; + break; + } + + case Expose: + { + FluxboxWindow *win = (FluxboxWindow *) 0; + Basemenu *menu = (Basemenu *) 0; + Toolbar *tbar = (Toolbar *) 0; Tab *tab = 0; if ((win = searchWindow(e->xexpose.window))) @@ -771,8 +896,8 @@ void Fluxbox::process_event(XEvent *e) { break; } - case KeyPress: - { + case KeyPress: + { Toolbar *tbar = searchToolbar(e->xkey.window); BScreen *screen = searchScreen(e->xkey.window); @@ -884,9 +1009,9 @@ void Fluxbox::process_event(XEvent *e) { break; case Keys::EXECUTE: //execute command on keypress { - #ifndef __EMX__ + #ifndef __EMX__ char displaystring[MAXPATHLEN]; - sprintf(displaystring, "DISPLAY=%s", + sprintf(displaystring, "DISPLAY=%s", DisplayString(getXDisplay())); sprintf(displaystring + strlen(displaystring) - 1, "%d", screen->getScreenNumber()); @@ -910,7 +1035,7 @@ void Fluxbox::process_event(XEvent *e) { case ColormapNotify: { - BScreen *screen = searchScreen(e->xcolormap.window); + BScreen *screen = searchScreen(e->xcolormap.window); if (screen) screen->setRootColormapInstalled((e->xcolormap.state == @@ -932,11 +1057,11 @@ void Fluxbox::process_event(XEvent *e) { break; } - case FocusOut: - break; + case FocusOut: + break; - case ClientMessage: - { + case ClientMessage: + { if (e->xclient.format == 32) { if (e->xclient.message_type == getWMChangeStateAtom()) { FluxboxWindow *win = searchWindow(e->xclient.window); @@ -957,13 +1082,13 @@ void Fluxbox::process_event(XEvent *e) { } else if (e->xclient.message_type == getFluxboxChangeWindowFocusAtom()) { FluxboxWindow *win = searchWindow(e->xclient.window); - if (win && win->isVisible() && win->setInputFocus()) + if (win && win->isVisible() && win->setInputFocus()) win->installColormap(True); } else if (e->xclient.message_type == getFluxboxCycleWindowFocusAtom()) { BScreen *screen = searchScreen(e->xclient.window); - if (screen) - if (! e->xclient.data.l[0]) + if (screen) + if (! e->xclient.data.l[0]) screen->prevFocus(); else screen->nextFocus(); @@ -979,7 +1104,7 @@ void Fluxbox::process_event(XEvent *e) { net.stack = e->xclient.data.l[3]; net.decoration = static_cast(e->xclient.data.l[4]); - win->changeBlackboxHints(&net); + win->changeBlackboxHints(&net); } } #ifdef GNOME @@ -996,25 +1121,25 @@ void Fluxbox::process_event(XEvent *e) { } break; - } + } - default: - { + default: + { -#ifdef SHAPE - if (e->type == getShapeEventBase()) { +#ifdef SHAPE + if (e->type == getShapeEventBase()) { XShapeEvent *shape_event = (XShapeEvent *) e; FluxboxWindow *win = (FluxboxWindow *) 0; if ((win = searchWindow(e->xany.window)) || - (shape_event->kind != ShapeBounding)) - win->shapeEvent(shape_event); - } + (shape_event->kind != ShapeBounding)) + win->shapeEvent(shape_event); + } #endif // SHAPE - } - } + } + } } void Fluxbox::doWindowAction(Keys::KeyAction action) { @@ -1159,46 +1284,46 @@ void Fluxbox::doWindowAction(Keys::KeyAction action) { } Bool Fluxbox::handleSignal(int sig) { - switch (sig) { - case SIGHUP: - reconfigure(); - break; - - case SIGUSR1: - reload_rc(); - break; - - case SIGUSR2: - rereadMenu(); - break; - - case SIGSEGV: - case SIGFPE: - case SIGINT: - case SIGTERM: - shutdown(); - - default: - return False; - } - - return True; + switch (sig) { + case SIGHUP: + reconfigure(); + break; + + case SIGUSR1: + reload_rc(); + break; + + case SIGUSR2: + rereadMenu(); + break; + + case SIGSEGV: + case SIGFPE: + case SIGINT: + case SIGTERM: + shutdown(); + + default: + return False; + } + + return True; } BScreen *Fluxbox::searchScreen(Window window) { - BScreen *screen = (BScreen *) 0; - LinkedListIterator it(screenList); + BScreen *screen = (BScreen *) 0; + LinkedListIterator it(screenList); - for (; it.current(); it++) { - if (it.current()) - if (it.current()->getRootWindow() == window) { - screen = it.current(); + for (; it.current(); it++) { + if (it.current()) + if (it.current()->getRootWindow() == window) { + screen = it.current(); return screen; - } - } + } + } - return (BScreen *) 0; + return (BScreen *) 0; } @@ -1216,72 +1341,72 @@ FluxboxWindow *Fluxbox::searchWindow(Window window) { FluxboxWindow *Fluxbox::searchGroup(Window window, FluxboxWindow *win) { - FluxboxWindow *w = (FluxboxWindow *) 0; - LinkedListIterator it(groupSearchList); - - for (; it.current(); it++) { - WindowSearch *tmp = it.current(); - if (tmp) - if (tmp->getWindow() == window) { - w = tmp->getData(); - if (w->getClientWindow() != win->getClientWindow()) - return win; - } - } - - return (FluxboxWindow *) 0; + FluxboxWindow *w = (FluxboxWindow *) 0; + LinkedListIterator it(groupSearchList); + + for (; it.current(); it++) { + WindowSearch *tmp = it.current(); + if (tmp) + if (tmp->getWindow() == window) { + w = tmp->getData(); + if (w->getClientWindow() != win->getClientWindow()) + return win; + } + } + + return (FluxboxWindow *) 0; } Basemenu *Fluxbox::searchMenu(Window window) { - Basemenu *menu = (Basemenu *) 0; - LinkedListIterator it(menuSearchList); + Basemenu *menu = (Basemenu *) 0; + LinkedListIterator it(menuSearchList); - for (; it.current(); it++) { - MenuSearch *tmp = it.current(); + for (; it.current(); it++) { + MenuSearch *tmp = it.current(); - if (tmp) - if (tmp->getWindow() == window) { - menu = tmp->getData(); - return menu; - } - } + if (tmp) + if (tmp->getWindow() == window) { + menu = tmp->getData(); + return menu; + } + } - return (Basemenu *) 0; + return (Basemenu *) 0; } Toolbar *Fluxbox::searchToolbar(Window window) { - Toolbar *tbar = (Toolbar *) 0; - LinkedListIterator it(toolbarSearchList); + Toolbar *tbar = (Toolbar *) 0; + LinkedListIterator it(toolbarSearchList); - for (; it.current(); it++) { - ToolbarSearch *tmp = it.current(); + for (; it.current(); it++) { + ToolbarSearch *tmp = it.current(); - if (tmp) - if (tmp->getWindow() == window) { - tbar = tmp->getData(); - return tbar; - } - } + if (tmp) + if (tmp->getWindow() == window) { + tbar = tmp->getData(); + return tbar; + } + } - return (Toolbar *) 0; + return (Toolbar *) 0; } Tab *Fluxbox::searchTab(Window window) { - LinkedListIterator it(tabSearchList); + LinkedListIterator it(tabSearchList); - for (; it.current(); it++) { - TabSearch *tmp = it.current(); - if (tmp && tmp->getWindow() == window) - return tmp->getData(); - } + for (; it.current(); it++) { + TabSearch *tmp = it.current(); + if (tmp && tmp->getWindow() == window) + return tmp->getData(); + } - return 0; + return 0; } -#ifdef SLIT +#ifdef SLIT Slit *Fluxbox::searchSlit(Window window) { Slit *s = (Slit *) 0; LinkedListIterator it(slitSearchList); @@ -1296,38 +1421,38 @@ Slit *Fluxbox::searchSlit(Window window) { } } - return (Slit *) 0; + return (Slit *) 0; } #endif // SLIT void Fluxbox::saveWindowSearch(Window window, FluxboxWindow *data) { - windowSearchList->insert(new WindowSearch(window, data)); + windowSearchList->insert(new WindowSearch(window, data)); } void Fluxbox::saveGroupSearch(Window window, FluxboxWindow *data) { - groupSearchList->insert(new WindowSearch(window, data)); + groupSearchList->insert(new WindowSearch(window, data)); } void Fluxbox::saveMenuSearch(Window window, Basemenu *data) { - menuSearchList->insert(new MenuSearch(window, data)); + menuSearchList->insert(new MenuSearch(window, data)); } void Fluxbox::saveToolbarSearch(Window window, Toolbar *data) { - toolbarSearchList->insert(new ToolbarSearch(window, data)); + toolbarSearchList->insert(new ToolbarSearch(window, data)); } void Fluxbox::saveTabSearch(Window window, Tab *data) { - tabSearchList->insert(new TabSearch(window, data)); + tabSearchList->insert(new TabSearch(window, data)); } -#ifdef SLIT +#ifdef SLIT void Fluxbox::saveSlitSearch(Window window, Slit *data) { - slitSearchList->insert(new SlitSearch(window, data)); + slitSearchList->insert(new SlitSearch(window, data)); } #endif // SLIT @@ -1343,7 +1468,7 @@ void Fluxbox::removeWindowSearch(Window window) { delete tmp; break; } - } + } } @@ -1367,8 +1492,8 @@ void Fluxbox::removeMenuSearch(Window window) { for (; it.current(); it++) { MenuSearch *tmp = it.current(); - if (tmp) - if (tmp->getWindow() == window) { + if (tmp) + if (tmp->getWindow() == window) { menuSearchList->remove(tmp); delete tmp; break; @@ -1378,9 +1503,9 @@ void Fluxbox::removeMenuSearch(Window window) { void Fluxbox::removeToolbarSearch(Window window) { - LinkedListIterator it(toolbarSearchList); - for (; it.current(); it++) { - ToolbarSearch *tmp = it.current(); + LinkedListIterator it(toolbarSearchList); + for (; it.current(); it++) { + ToolbarSearch *tmp = it.current(); if (tmp) if (tmp->getWindow() == window) { toolbarSearchList->remove(tmp); @@ -1392,9 +1517,9 @@ void Fluxbox::removeToolbarSearch(Window window) { void Fluxbox::removeTabSearch(Window window) { - LinkedListIterator it(tabSearchList); - for (; it.current(); it++) { - TabSearch *tmp = it.current(); + LinkedListIterator it(tabSearchList); + for (; it.current(); it++) { + TabSearch *tmp = it.current(); if (tmp && tmp->getWindow() == window) { tabSearchList->remove(tmp); delete tmp; @@ -1403,7 +1528,7 @@ void Fluxbox::removeTabSearch(Window window) { } } -#ifdef SLIT +#ifdef SLIT void Fluxbox::removeSlitSearch(Window window) { LinkedListIterator it(slitSearchList); for (; it.current(); it++) { @@ -1421,35 +1546,36 @@ void Fluxbox::removeSlitSearch(Window window) { void Fluxbox::restart(const char *prog) { - shutdown(); + shutdown(); - if (prog) { - execlp(prog, prog, NULL); - perror(prog); - } + if (prog) { + execlp(prog, prog, NULL); + perror(prog); + } - // fall back in case the above execlp doesn't work - execvp(argv[0], argv); - execvp(basename(argv[0]), argv); + // fall back in case the above execlp doesn't work + execvp(argv[0], argv); + execvp(basename(argv[0]), argv); } void Fluxbox::shutdown(void) { - BaseDisplay::shutdown(); + BaseDisplay::shutdown(); - XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime); + XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime); - LinkedListIterator it(screenList); - for (; it.current(); it++) - it.current()->shutdown(); + LinkedListIterator it(screenList); + for (; it.current(); it++) + it.current()->shutdown(); - XSync(getXDisplay(), False); + XSync(getXDisplay(), False); - save_rc(); + save_rc(); } -//save_rc +//------ save_rc -------- //saves resources +//---------------------- void Fluxbox::save_rc(void) { XrmDatabase new_blackboxrc = (XrmDatabase) 0; @@ -1457,50 +1583,29 @@ void Fluxbox::save_rc(void) { auto_ptr dbfile(getRcFilename()); -// load_rc(); -// This overwrites configs made while running, for example -// usage of iconbar and tabs - - sprintf(rc_string, "session.iconbar: %s", resource.iconbar ? "true" : "false"); - XrmPutLineResource(&new_blackboxrc, rc_string); - - sprintf(rc_string, "session.tabs: %s", resource.tabs ? "true" : "false"); - XrmPutLineResource(&new_blackboxrc, rc_string); - - sprintf(rc_string, "session.menuFile: %s", resource.menu_file); - XrmPutLineResource(&new_blackboxrc, rc_string); - - sprintf(rc_string, "session.titlebarFile: %s", resource.titlebar_file); - XrmPutLineResource(&new_blackboxrc, rc_string); - - sprintf(rc_string, "session.keyFile: %s", resource.keys_file); - XrmPutLineResource(&new_blackboxrc, rc_string); - - sprintf(rc_string, "session.colorsPerChannel: %d", - resource.colors_per_channel); - XrmPutLineResource(&new_blackboxrc, rc_string); + // load_rc(); + // This overwrites configs made while running, for example + // usage of iconbar and tabs + if (*dbfile) + m_resourcemanager.save(dbfile.get(), dbfile.get()); + else + cerr<<"database filename is invalid!"< it(screenList); for (; it.current(); it++) { BScreen *screen = it.current(); int screen_number = screen->getScreenNumber(); -#ifdef SLIT +#ifdef SLIT char *slit_placement = (char *) 0; switch (screen->getSlitPlacement()) { @@ -1586,7 +1691,7 @@ void Fluxbox::save_rc(void) { placement = "RowSmartPlacement"; break; } - sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number, + sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number, placement); XrmPutLineResource(&new_blackboxrc, rc_string); //TODO: This isn't pretty! @@ -1607,15 +1712,15 @@ void Fluxbox::save_rc(void) { XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.workspaces: %d", screen_number, + sprintf(rc_string, "session.screen%d.workspaces: %d", screen_number, screen->getCount()); XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.toolbar.onTop: %s", screen_number, + sprintf(rc_string, "session.screen%d.toolbar.onTop: %s", screen_number, ((screen->getToolbar()->isOnTop()) ? "True" : "False")); XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.toolbar.autoHide: %s", screen_number, + sprintf(rc_string, "session.screen%d.toolbar.autoHide: %s", screen_number, ((screen->getToolbar()->doAutoHide()) ? "True" : "False")); XrmPutLineResource(&new_blackboxrc, rc_string); @@ -1643,32 +1748,32 @@ void Fluxbox::save_rc(void) { Tab::getTabAlignmentString(screen->getTabAlignment())); XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.tab.rotatevertical: %s", screen_number, + sprintf(rc_string, "session.screen%d.tab.rotatevertical: %s", screen_number, ((screen->isTabRotateVertical()) ? "True" : "False")); XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.sloppywindowgrouping: %s", screen_number, + sprintf(rc_string, "session.screen%d.sloppywindowgrouping: %s", screen_number, ((screen->isSloppyWindowGrouping()) ? "True" : "False")); XrmPutLineResource(&new_blackboxrc, rc_string); load_rc(screen); // these are static, but may not be saved in the users resource file, - // writing these resources will allow the user to edit them at a later + // writing these resources will allow the user to edit them at a later // time... but loading the defaults before saving allows us to rewrite the // users changes... -#ifdef HAVE_STRFTIME +#ifdef HAVE_STRFTIME sprintf(rc_string, "session.screen%d.strftimeFormat: %s", screen_number, screen->getStrftimeFormat()); XrmPutLineResource(&new_blackboxrc, rc_string); #else // !HAVE_STRFTIME - sprintf(rc_string, "session.screen%d.dateFormat: %s", screen_number, + sprintf(rc_string, "session.screen%d.dateFormat: %s", screen_number, ((screen->getDateFormat() == B_EuropeanDate) ? "European" : "American")); XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.clockFormat: %d", screen_number, + sprintf(rc_string, "session.screen%d.clockFormat: %d", screen_number, ((screen->isClock24Hour()) ? 24 : 12)); XrmPutLineResource(&new_blackboxrc, rc_string); #endif // HAVE_STRFTIME @@ -1677,7 +1782,7 @@ void Fluxbox::save_rc(void) { screen->getEdgeSnapThreshold()); XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.toolbar.widthPercent: %d", + sprintf(rc_string, "session.screen%d.toolbar.widthPercent: %d", screen_number, screen->getToolbarWidthPercent()); XrmPutLineResource(&new_blackboxrc, rc_string); @@ -1695,37 +1800,37 @@ void Fluxbox::save_rc(void) { for (i = 0; i < screen->getCount(); i++) { len = strlen((screen->getWorkspace(i)->getName()) ? screen->getWorkspace(i)->getName() : "Null") + 1; - name_string_pos = + name_string_pos = (char *) ((screen->getWorkspace(i)->getName()) ? screen->getWorkspace(i)->getName() : "Null"); - while (--len) *(save_string_pos++) = *(name_string_pos++); + while (--len) + *(save_string_pos++) = *(name_string_pos++); *(save_string_pos++) = ','; } - } + } - *(--save_string_pos) = '\0'; + *(--save_string_pos) = '\0'; - sprintf(resource_string, "session.screen%d.workspaceNames: %s", - screen_number, save_string); - XrmPutLineResource(&new_blackboxrc, resource_string); + sprintf(resource_string, "session.screen%d.workspaceNames: %s", + screen_number, save_string); + XrmPutLineResource(&new_blackboxrc, resource_string); - delete [] resource_string; - delete [] save_string; - } + delete [] resource_string; + delete [] save_string; + } - XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.get()); + XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.get()); - XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together - XrmPutFileDatabase(old_blackboxrc, dbfile.get()); - XrmDestroyDatabase(old_blackboxrc); + XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together + XrmPutFileDatabase(old_blackboxrc, dbfile.get()); + XrmDestroyDatabase(old_blackboxrc); // XrmDestroyDatabase(new_blackboxrc); } //-------- getRcFilename ------------- // Returns filename of resource file -// TODO: possible replacement with strstream? //------------------------------------ char *Fluxbox::getRcFilename() { char *dbfile=0; @@ -1741,99 +1846,57 @@ char *Fluxbox::getRcFilename() { } void Fluxbox::load_rc(void) { - XrmDatabase database = (XrmDatabase) 0; - - //get resource filename - auto_ptr dbfile(getRcFilename()); - - //load file - database = XrmGetFileDatabase(dbfile.get()); - if (!database) { - cerr<<"Fluxbox: Cant open "< dbfile(getRcFilename()); + #ifdef DEBUG + cerr<<__FILE__<<"("<<__LINE__<<"): dbfile="< 6) - resource.colors_per_channel = 6; - } - } else - resource.colors_per_channel = 4; + if (m_rc_menufile->size()) { + char *tmpvar =StringUtil::expandFilename(m_rc_menufile->c_str()); + *m_rc_menufile = (tmpvar==0 ? "" : tmpvar); + if (!m_rc_menufile->size()) + m_rc_menufile.setDefaultValue(); - if (resource.style_file) - delete [] resource.style_file; + delete tmpvar; + } else + m_rc_menufile.setDefaultValue(); + + if (*m_rc_colors_per_channel < 2) + *m_rc_colors_per_channel = 2; + else if (*m_rc_colors_per_channel > 6) + *m_rc_colors_per_channel = 6; + + if (*m_rc_stylefile=="") + *m_rc_stylefile = DEFAULTSTYLE; + else { + auto_ptr tmpvar(StringUtil::expandFilename(m_rc_stylefile->c_str())); + *m_rc_stylefile = (tmpvar.get()==0 ? "" : tmpvar.get()); + } - if (XrmGetResource(database, "session.styleFile", "Session.StyleFile", - &value_type, &value)) - resource.style_file = StringUtil::expandFilename(value.addr); - else - resource.style_file = StringUtil::strdup(DEFAULTSTYLE); + //load file + database = XrmGetFileDatabase(dbfile.get()); + if (!database) { + cerr<<"Fluxbox: Cant open "< dbfile(getRcFilename()); + + database = XrmGetFileDatabase(dbfile.get()); + if (!database) + database = XrmGetFileDatabase(DEFAULT_INITFILE); + + XrmValue value; + char *value_type, name_lookup[1024], class_lookup[1024]; + int screen_number = screen->getScreenNumber(); + + sprintf(name_lookup, "session.screen%d.fullMaximization", screen_number); + sprintf(class_lookup, "Session.Screen%d.FullMaximization", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "true", value.size)) + screen->saveFullMax(True); + else + screen->saveFullMax(False); } else - resource.cache_life = 5l; + screen->saveFullMax(False); - resource.cache_life *= 60000; + sprintf(name_lookup, "session.screen%d.rootCommand", screen_number); + sprintf(class_lookup, "Session.Screen%d.RootCommand", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + screen->saveRootCommand(value.addr==0 ? "": value.addr); + } else + screen->saveRootCommand(""); + + sprintf(name_lookup, "session.screen%d.focusNewWindows", screen_number); + sprintf(class_lookup, "Session.Screen%d.FocusNewWindows", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "true", value.size)) + screen->saveFocusNew(True); + else + screen->saveFocusNew(False); + } else + screen->saveFocusNew(False); - if (XrmGetResource(database, "session.cacheMax", "Session.CacheMax", - &value_type, &value)) { - if (sscanf(value.addr, "%lu", &resource.cache_max) != 1) - resource.cache_max = 200; + sprintf(name_lookup, "session.screen%d.focusLastWindow", screen_number); + sprintf(class_lookup, "Session.Screen%d.focusLastWindow", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "true", value.size)) + screen->saveFocusLast(True); + else + screen->saveFocusLast(False); } else - resource.cache_max = 200; + screen->saveFocusLast(False); - //XrmDestroyDatabase(database); + sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number); + sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "righttoleft", value.size)) + screen->saveRowPlacementDirection(BScreen::RIGHTLEFT); + else - loadTitlebar(); -} -//parseTitleArgs -//parses the titlearg configline -vector Fluxbox::parseTitleArgs(const char *arg) { - vector args; - string tmp; - unsigned int i=0; - while ( isaveMaxOverSlit(True); + else + screen->saveMaxOverSlit(False); + } else + screen->saveMaxOverSlit(False); + screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); + } else + screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); -void Fluxbox::setTitlebar(vector& dir, const char *arg) { - vector argv = parseTitleArgs(arg); - for (unsigned int i=0; isaveColPlacementDirection(BScreen::BOTTOMTOP); else - cerr<<"Fluxbox::Titlebar Unknown type: \""<saveColPlacementDirection(BScreen::TOPBOTTOM); + } else + screen->saveColPlacementDirection(BScreen::TOPBOTTOM); -void Fluxbox::loadTitlebar() { - XrmDatabase database; - database = XrmGetFileDatabase(resource.titlebar_file); - if (!database) - cerr<<"Fluxbox: Cant open "<saveWorkspaces(i); + } else + screen->saveWorkspaces(1); -void Fluxbox::load_rc(BScreen *screen) { - XrmDatabase database = (XrmDatabase) 0; + sprintf(name_lookup, "session.screen%d.toolbar.widthPercent", + screen_number); + sprintf(class_lookup, "Session.Screen%d.Toolbar.WidthPercent", + screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + int i; + if (sscanf(value.addr, "%d", &i) != 1) i = 66; - auto_ptr dbfile(getRcFilename()); + if (i <= 0 || i > 100) + i = 66; - database = XrmGetFileDatabase(dbfile.get()); - if (!database) - database = XrmGetFileDatabase(DEFAULT_INITFILE); - - XrmValue value; - char *value_type, name_lookup[1024], class_lookup[1024]; - int screen_number = screen->getScreenNumber(); - - sprintf(name_lookup, "session.screen%d.fullMaximization", screen_number); - sprintf(class_lookup, "Session.Screen%d.FullMaximization", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "true", value.size)) - screen->saveFullMax(True); - else - screen->saveFullMax(False); - } else - screen->saveFullMax(False); - - sprintf(name_lookup, "session.screen%d.rootCommand", screen_number); - sprintf(class_lookup, "Session.Screen%d.RootCommand", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - screen->saveRootCommand(value.addr==0 ? "": value.addr); - } else - screen->saveRootCommand(""); - - sprintf(name_lookup, "session.screen%d.focusNewWindows", screen_number); - sprintf(class_lookup, "Session.Screen%d.FocusNewWindows", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "true", value.size)) - screen->saveFocusNew(True); - else - screen->saveFocusNew(False); - } else - screen->saveFocusNew(False); - - sprintf(name_lookup, "session.screen%d.focusLastWindow", screen_number); - sprintf(class_lookup, "Session.Screen%d.focusLastWindow", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "true", value.size)) - screen->saveFocusLast(True); - else - screen->saveFocusLast(False); - } else - screen->saveFocusLast(False); - - sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number); - sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "righttoleft", value.size)) - screen->saveRowPlacementDirection(BScreen::RIGHTLEFT); - else - - sprintf(name_lookup, "session.screen%d.maxOverSlit", screen_number); - sprintf(class_lookup, "Session.Screen%d.MaxOverSlit", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "true", value.size)) - screen->saveMaxOverSlit(True); - else - screen->saveMaxOverSlit(False); - } else - screen->saveMaxOverSlit(False); - screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); - } else - screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); - - sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number); - sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "bottomtotop", value.size)) - screen->saveColPlacementDirection(BScreen::BOTTOMTOP); - else - screen->saveColPlacementDirection(BScreen::TOPBOTTOM); - } else - screen->saveColPlacementDirection(BScreen::TOPBOTTOM); - - sprintf(name_lookup, "session.screen%d.workspaces", screen_number); - sprintf(class_lookup, "Session.Screen%d.Workspaces", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - int i; - if (sscanf(value.addr, "%d", &i) != 1) i = 1; - screen->saveWorkspaces(i); - } else - screen->saveWorkspaces(1); - - sprintf(name_lookup, "session.screen%d.toolbar.widthPercent", - screen_number); - sprintf(class_lookup, "Session.Screen%d.Toolbar.WidthPercent", - screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - int i; - if (sscanf(value.addr, "%d", &i) != 1) i = 66; - - if (i <= 0 || i > 100) - i = 66; - - screen->saveToolbarWidthPercent(i); - } else - screen->saveToolbarWidthPercent(66); - - sprintf(name_lookup, "session.screen%d.toolbar.placement", screen_number); - sprintf(class_lookup, "Session.Screen%d.Toolbar.Placement", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "TopLeft", value.size)) - screen->saveToolbarPlacement(Toolbar::TOPLEFT); - else if (! strncasecmp(value.addr, "BottomLeft", value.size)) - screen->saveToolbarPlacement(Toolbar::BOTTOMLEFT); - else if (! strncasecmp(value.addr, "TopCenter", value.size)) - screen->saveToolbarPlacement(Toolbar::TOPCENTER); - else if (! strncasecmp(value.addr, "TopRight", value.size)) - screen->saveToolbarPlacement(Toolbar::TOPRIGHT); - else if (! strncasecmp(value.addr, "BottomRight", value.size)) - screen->saveToolbarPlacement(Toolbar::BOTTOMRIGHT); - else - screen->saveToolbarPlacement(Toolbar::BOTTOMCENTER); - } else - screen->saveToolbarPlacement(Toolbar::BOTTOMCENTER); - - screen->removeWorkspaceNames(); - - sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number); - sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - char *search = StringUtil::strdup(value.addr); - - int i; - for (i = 0; i < screen->getNumberOfWorkspaces(); i++) { - char *nn; - - if (! i) nn = strtok(search, ","); - else nn = strtok(NULL, ","); - - if (nn) + screen->saveToolbarWidthPercent(i); + } else + screen->saveToolbarWidthPercent(66); + + sprintf(name_lookup, "session.screen%d.toolbar.placement", screen_number); + sprintf(class_lookup, "Session.Screen%d.Toolbar.Placement", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "TopLeft", value.size)) + screen->saveToolbarPlacement(Toolbar::TOPLEFT); + else if (! strncasecmp(value.addr, "BottomLeft", value.size)) + screen->saveToolbarPlacement(Toolbar::BOTTOMLEFT); + else if (! strncasecmp(value.addr, "TopCenter", value.size)) + screen->saveToolbarPlacement(Toolbar::TOPCENTER); + else if (! strncasecmp(value.addr, "TopRight", value.size)) + screen->saveToolbarPlacement(Toolbar::TOPRIGHT); + else if (! strncasecmp(value.addr, "BottomRight", value.size)) + screen->saveToolbarPlacement(Toolbar::BOTTOMRIGHT); + else + screen->saveToolbarPlacement(Toolbar::BOTTOMCENTER); + } else + screen->saveToolbarPlacement(Toolbar::BOTTOMCENTER); + + screen->removeWorkspaceNames(); + + sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number); + sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + char *search = StringUtil::strdup(value.addr); + + int i; + for (i = 0; i < screen->getNumberOfWorkspaces(); i++) { + char *nn; + + if (! i) nn = strtok(search, ","); + else nn = strtok(NULL, ","); + + if (nn) screen->addWorkspaceName(nn); else break; - } - - delete [] search; - } - - sprintf(name_lookup, "session.screen%d.toolbar.onTop", screen_number); - sprintf(class_lookup, "Session.Screen%d.Toolbar.OnTop", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "true", value.size)) - screen->saveToolbarOnTop(True); - else - screen->saveToolbarOnTop(False); - } else - screen->saveToolbarOnTop(False); - - sprintf(name_lookup, "session.screen%d.toolbar.autoHide", screen_number); - sprintf(class_lookup, "Session.Screen%d.Toolbar.autoHide", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "true", value.size)) - screen->saveToolbarAutoHide(True); - else - screen->saveToolbarAutoHide(False); - } else - screen->saveToolbarAutoHide(False); + } + + delete [] search; + } + + sprintf(name_lookup, "session.screen%d.toolbar.onTop", screen_number); + sprintf(class_lookup, "Session.Screen%d.Toolbar.OnTop", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "true", value.size)) + screen->saveToolbarOnTop(True); + else + screen->saveToolbarOnTop(False); + } else + screen->saveToolbarOnTop(False); + + sprintf(name_lookup, "session.screen%d.toolbar.autoHide", screen_number); + sprintf(class_lookup, "Session.Screen%d.Toolbar.autoHide", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "true", value.size)) + screen->saveToolbarAutoHide(True); + else + screen->saveToolbarAutoHide(False); + } else + screen->saveToolbarAutoHide(False); //TODO: make this nicer? - sprintf(name_lookup, "session.screen%d.focusModel", screen_number); + sprintf(name_lookup, "session.screen%d.focusModel", screen_number); sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number); if (XrmGetResource(database, name_lookup, class_lookup, &value_type, &value)) { @@ -2164,143 +2135,143 @@ void Fluxbox::load_rc(BScreen *screen) { screen->saveAutoRaise(False); //as click should be default, or? } - sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number); - sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) - if (! strncasecmp(value.addr, "RowSmartPlacement", value.size)) - screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); - else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size)) - screen->savePlacementPolicy(BScreen::COLSMARTPLACEMENT); - else - screen->savePlacementPolicy(BScreen::CASCADEPLACEMENT); - else - screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); - -#ifdef SLIT - sprintf(name_lookup, "session.screen%d.slit.placement", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.Placement", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) - if (! strncasecmp(value.addr, "TopLeft", value.size)) - screen->saveSlitPlacement(Slit::TOPLEFT); - else if (! strncasecmp(value.addr, "CenterLeft", value.size)) - screen->saveSlitPlacement(Slit::CENTERLEFT); - else if (! strncasecmp(value.addr, "BottomLeft", value.size)) - screen->saveSlitPlacement(Slit::BOTTOMLEFT); - else if (! strncasecmp(value.addr, "TopCenter", value.size)) - screen->saveSlitPlacement(Slit::TOPCENTER); - else if (! strncasecmp(value.addr, "BottomCenter", value.size)) - screen->saveSlitPlacement(Slit::BOTTOMCENTER); - else if (! strncasecmp(value.addr, "TopRight", value.size)) - screen->saveSlitPlacement(Slit::TOPRIGHT); - else if (! strncasecmp(value.addr, "BottomRight", value.size)) - screen->saveSlitPlacement(Slit::BOTTOMRIGHT); - else - screen->saveSlitPlacement(Slit::CENTERRIGHT); - else - screen->saveSlitPlacement(Slit::CENTERRIGHT); - - sprintf(name_lookup, "session.screen%d.slit.direction", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) - if (! strncasecmp(value.addr, "Horizontal", value.size)) - screen->saveSlitDirection(Slit::HORIZONTAL); - else - screen->saveSlitDirection(Slit::VERTICAL); - else - screen->saveSlitDirection(Slit::VERTICAL); - - sprintf(name_lookup, "session.screen%d.slit.onTop", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.OnTop", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) - if (! strncasecmp(value.addr, "True", value.size)) - screen->saveSlitOnTop(True); - else - screen->saveSlitOnTop(False); - else - screen->saveSlitOnTop(False); - - sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.AutoHide", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) - if (! strncasecmp(value.addr, "True", value.size)) - screen->saveSlitAutoHide(True); - else - screen->saveSlitAutoHide(False); - else - screen->saveSlitAutoHide(False); + sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number); + sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) + if (! strncasecmp(value.addr, "RowSmartPlacement", value.size)) + screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); + else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size)) + screen->savePlacementPolicy(BScreen::COLSMARTPLACEMENT); + else + screen->savePlacementPolicy(BScreen::CASCADEPLACEMENT); + else + screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); + +#ifdef SLIT + sprintf(name_lookup, "session.screen%d.slit.placement", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.Placement", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) + if (! strncasecmp(value.addr, "TopLeft", value.size)) + screen->saveSlitPlacement(Slit::TOPLEFT); + else if (! strncasecmp(value.addr, "CenterLeft", value.size)) + screen->saveSlitPlacement(Slit::CENTERLEFT); + else if (! strncasecmp(value.addr, "BottomLeft", value.size)) + screen->saveSlitPlacement(Slit::BOTTOMLEFT); + else if (! strncasecmp(value.addr, "TopCenter", value.size)) + screen->saveSlitPlacement(Slit::TOPCENTER); + else if (! strncasecmp(value.addr, "BottomCenter", value.size)) + screen->saveSlitPlacement(Slit::BOTTOMCENTER); + else if (! strncasecmp(value.addr, "TopRight", value.size)) + screen->saveSlitPlacement(Slit::TOPRIGHT); + else if (! strncasecmp(value.addr, "BottomRight", value.size)) + screen->saveSlitPlacement(Slit::BOTTOMRIGHT); + else + screen->saveSlitPlacement(Slit::CENTERRIGHT); + else + screen->saveSlitPlacement(Slit::CENTERRIGHT); + + sprintf(name_lookup, "session.screen%d.slit.direction", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) + if (! strncasecmp(value.addr, "Horizontal", value.size)) + screen->saveSlitDirection(Slit::HORIZONTAL); + else + screen->saveSlitDirection(Slit::VERTICAL); + else + screen->saveSlitDirection(Slit::VERTICAL); + + sprintf(name_lookup, "session.screen%d.slit.onTop", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.OnTop", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) + if (! strncasecmp(value.addr, "True", value.size)) + screen->saveSlitOnTop(True); + else + screen->saveSlitOnTop(False); + else + screen->saveSlitOnTop(False); + + sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.AutoHide", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) + if (! strncasecmp(value.addr, "True", value.size)) + screen->saveSlitAutoHide(True); + else + screen->saveSlitAutoHide(False); + else + screen->saveSlitAutoHide(False); #endif // SLIT -#ifdef HAVE_STRFTIME - sprintf(name_lookup, "session.screen%d.strftimeFormat", screen_number); - sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) - screen->saveStrftimeFormat(value.addr); - else - screen->saveStrftimeFormat("%I:%M %p"); -#else // HAVE_STRFTIME - - sprintf(name_lookup, "session.screen%d.dateFormat", screen_number); - sprintf(class_lookup, "Session.Screen%d.DateFormat", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - if (strncasecmp(value.addr, "european", value.size)) - screen->saveDateFormat(B_AmericanDate); - else - screen->saveDateFormat(B_EuropeanDate); - } else - screen->saveDateFormat(B_AmericanDate); - - sprintf(name_lookup, "session.screen%d.clockFormat", screen_number); - sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - int clock; - if (sscanf(value.addr, "%d", &clock) != 1) screen->saveClock24Hour(False); - else if (clock == 24) screen->saveClock24Hour(True); - else screen->saveClock24Hour(False); - } else - screen->saveClock24Hour(False); +#ifdef HAVE_STRFTIME + sprintf(name_lookup, "session.screen%d.strftimeFormat", screen_number); + sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) + screen->saveStrftimeFormat(value.addr); + else + screen->saveStrftimeFormat("%I:%M %p"); +#else // HAVE_STRFTIME + + sprintf(name_lookup, "session.screen%d.dateFormat", screen_number); + sprintf(class_lookup, "Session.Screen%d.DateFormat", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + if (strncasecmp(value.addr, "european", value.size)) + screen->saveDateFormat(B_AmericanDate); + else + screen->saveDateFormat(B_EuropeanDate); + } else + screen->saveDateFormat(B_AmericanDate); + + sprintf(name_lookup, "session.screen%d.clockFormat", screen_number); + sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + int clock; + if (sscanf(value.addr, "%d", &clock) != 1) screen->saveClock24Hour(False); + else if (clock == 24) screen->saveClock24Hour(True); + else screen->saveClock24Hour(False); + } else + screen->saveClock24Hour(False); #endif // HAVE_STRFTIME - sprintf(name_lookup, "session.screen%d.edgeSnapThreshold", screen_number); - sprintf(class_lookup, "Session.Screen%d.EdgeSnapThreshold", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - int threshold; - if (sscanf(value.addr, "%d", &threshold) != 1) - screen->saveEdgeSnapThreshold(0); - else - screen->saveEdgeSnapThreshold(threshold); - } else - screen->saveEdgeSnapThreshold(0); - - sprintf(name_lookup, "session.screen%d.imageDither", screen_number); - sprintf(class_lookup, "Session.Screen%d.ImageDither", screen_number); - if (XrmGetResource(database, "session.imageDither", "Session.ImageDither", - &value_type, &value)) { - if (! strncasecmp("true", value.addr, value.size)) - screen->saveImageDither(True); - else - screen->saveImageDither(False); - } else - screen->saveImageDither(True); - - if (XrmGetResource(database, "session.opaqueMove", "Session.OpaqueMove", - &value_type, &value)) { - if (! strncasecmp("true", value.addr, value.size)) - screen->saveOpaqueMove(True); - else - screen->saveOpaqueMove(False); - } else - screen->saveOpaqueMove(False); - - sprintf(name_lookup, "session.screen%d.tab.width", screen_number); + sprintf(name_lookup, "session.screen%d.edgeSnapThreshold", screen_number); + sprintf(class_lookup, "Session.Screen%d.EdgeSnapThreshold", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + int threshold; + if (sscanf(value.addr, "%d", &threshold) != 1) + screen->saveEdgeSnapThreshold(0); + else + screen->saveEdgeSnapThreshold(threshold); + } else + screen->saveEdgeSnapThreshold(0); + + sprintf(name_lookup, "session.screen%d.imageDither", screen_number); + sprintf(class_lookup, "Session.Screen%d.ImageDither", screen_number); + if (XrmGetResource(database, "session.imageDither", "Session.ImageDither", + &value_type, &value)) { + if (! strncasecmp("true", value.addr, value.size)) + screen->saveImageDither(True); + else + screen->saveImageDither(False); + } else + screen->saveImageDither(True); + + if (XrmGetResource(database, "session.opaqueMove", "Session.OpaqueMove", + &value_type, &value)) { + if (! strncasecmp("true", value.addr, value.size)) + screen->saveOpaqueMove(True); + else + screen->saveOpaqueMove(False); + } else + screen->saveOpaqueMove(False); + + sprintf(name_lookup, "session.screen%d.tab.width", screen_number); sprintf(class_lookup, "Session.Screen%d.Tab.Width", screen_number); if (XrmGetResource(database, name_lookup, class_lookup, &value_type, &value)) { @@ -2320,8 +2291,8 @@ void Fluxbox::load_rc(BScreen *screen) { } else screen->saveTabWidth(64); // default tab width - sprintf(name_lookup, "session.screen%d.tab.height", screen_number); - sprintf(class_lookup, "Session.Screen%d.Tab.Height", screen_number); + sprintf(name_lookup, "session.screen%d.tab.height", screen_number); + sprintf(class_lookup, "Session.Screen%d.Tab.Height", screen_number); if (XrmGetResource(database, name_lookup, class_lookup, &value_type, &value)) { unsigned int tmp_val; @@ -2340,77 +2311,77 @@ void Fluxbox::load_rc(BScreen *screen) { } else screen->saveTabHeight(16); // default tab height - sprintf(name_lookup, "session.screen%d.tab.placement", screen_number); - sprintf(class_lookup, "Session.Screen%d.Tab.Placement", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, - &value_type, &value)) { + sprintf(name_lookup, "session.screen%d.tab.placement", screen_number); + sprintf(class_lookup, "Session.Screen%d.Tab.Placement", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, + &value_type, &value)) { screen->saveTabPlacement(Tab::getTabPlacementNum(value.addr)); - } else + } else screen->saveTabPlacement(Tab::PTOP); - sprintf(name_lookup, "session.screen%d.tab.alignment", screen_number); - sprintf(class_lookup, "Session.Screen%d.Tab.Alignment", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, - &value_type, &value)) { + sprintf(name_lookup, "session.screen%d.tab.alignment", screen_number); + sprintf(class_lookup, "Session.Screen%d.Tab.Alignment", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, + &value_type, &value)) { screen->saveTabAlignment(Tab::getTabAlignmentNum(value.addr)); } else screen->saveTabAlignment(Tab::ALEFT); - sprintf(name_lookup, "session.screen%d.tab.rotatevertical", screen_number); - sprintf(class_lookup, "Session.Screen%d.Tab.RotateVertical", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, - &value_type, &value)) { - if (! strncasecmp("true", value.addr, value.size)) - screen->saveTabRotateVertical(True); - else - screen->saveTabRotateVertical(False); - } else - screen->saveTabRotateVertical(False); - - sprintf(name_lookup, "session.screen%d.sloppywindowgrouping", screen_number); - sprintf(class_lookup, "Session.Screen%d.SloppyWindowGrouping", screen_number); - if (XrmGetResource(database, name_lookup, class_lookup, - &value_type, &value)) { - if (! strncasecmp("true", value.addr, value.size)) - screen->saveSloppyWindowGrouping(True); - else - screen->saveSloppyWindowGrouping(False); - } else - screen->saveSloppyWindowGrouping(False); + sprintf(name_lookup, "session.screen%d.tab.rotatevertical", screen_number); + sprintf(class_lookup, "Session.Screen%d.Tab.RotateVertical", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, + &value_type, &value)) { + if (! strncasecmp("true", value.addr, value.size)) + screen->saveTabRotateVertical(True); + else + screen->saveTabRotateVertical(False); + } else + screen->saveTabRotateVertical(False); + + sprintf(name_lookup, "session.screen%d.sloppywindowgrouping", screen_number); + sprintf(class_lookup, "Session.Screen%d.SloppyWindowGrouping", screen_number); + if (XrmGetResource(database, name_lookup, class_lookup, + &value_type, &value)) { + if (! strncasecmp("true", value.addr, value.size)) + screen->saveSloppyWindowGrouping(True); + else + screen->saveSloppyWindowGrouping(False); + } else + screen->saveSloppyWindowGrouping(False); } -void Fluxbox::loadRootCommand(BScreen *screen) { +void Fluxbox::loadRootCommand(BScreen *screen) { XrmDatabase database = (XrmDatabase) 0; - auto_ptr dbfile(getRcFilename()); + auto_ptr dbfile(getRcFilename()); - database = XrmGetFileDatabase(dbfile.get()); + database = XrmGetFileDatabase(dbfile.get()); if (!database) database = XrmGetFileDatabase(DEFAULT_INITFILE); - XrmValue value; - char *value_type, name_lookup[1024], class_lookup[1024]; - sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber()); - sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber()); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - screen->saveRootCommand(value.addr==0 ? "": value.addr); - } else - screen->saveRootCommand(""); + XrmValue value; + char *value_type, name_lookup[1024], class_lookup[1024]; + sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber()); + sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber()); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + screen->saveRootCommand(value.addr==0 ? "": value.addr); + } else + screen->saveRootCommand(""); } void Fluxbox::reload_rc(void) { - load_rc(); - reconfigure(); + load_rc(); + reconfigure(); } void Fluxbox::reconfigure(void) { - reconfigure_wait = True; + reconfigure_wait = True; - if (! timer->isTiming()) timer->start(); + if (! timer->isTiming()) timer->start(); } @@ -2418,13 +2389,8 @@ void Fluxbox::real_reconfigure(void) { grab(); XrmDatabase new_blackboxrc = (XrmDatabase) 0; - char style[MAXPATHLEN + 64]; auto_ptr dbfile(getRcFilename()); - - sprintf(style, "session.styleFile: %s", resource.style_file); - XrmPutLineResource(&new_blackboxrc, style); - XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.get()); XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); @@ -2452,7 +2418,7 @@ void Fluxbox::real_reconfigure(void) { } //reconfigure keys - key->reconfigure(resource.keys_file); + key->reconfigure(const_cast(m_rc_keyfile->c_str())); //reconfigure tabs reconfigureTabs(); @@ -2487,127 +2453,127 @@ void Fluxbox::reconfigureTabs(void) { } void Fluxbox::checkMenu(void) { - Bool reread = False; - LinkedListIterator it(menuTimestamps); - for (; it.current() && (! reread); it++) { - struct stat buf; - - if (! stat(it.current()->filename, &buf)) { - if (it.current()->timestamp != buf.st_ctime) - reread = True; - } else - reread = True; - } - - if (reread) rereadMenu(); + Bool reread = False; + LinkedListIterator it(menuTimestamps); + for (; it.current() && (! reread); it++) { + struct stat buf; + + if (! stat(it.current()->filename, &buf)) { + if (it.current()->timestamp != buf.st_ctime) + reread = True; + } else + reread = True; + } + + if (reread) rereadMenu(); } void Fluxbox::rereadMenu(void) { - reread_menu_wait = True; + reread_menu_wait = True; - if (! timer->isTiming()) timer->start(); + if (! timer->isTiming()) timer->start(); } void Fluxbox::real_rereadMenu(void) { - for (int i = 0, n = menuTimestamps->count(); i < n; i++) { - MenuTimestamp *ts = menuTimestamps->remove(0); + for (int i = 0, n = menuTimestamps->count(); i < n; i++) { + MenuTimestamp *ts = menuTimestamps->remove(0); - if (ts) { - if (ts->filename) + if (ts) { + if (ts->filename) delete [] ts->filename; - delete ts; - } - } + delete ts; + } + } - LinkedListIterator it(screenList); - for (; it.current(); it++) - it.current()->rereadMenu(); + LinkedListIterator it(screenList); + for (; it.current(); it++) + it.current()->rereadMenu(); } - +/* void Fluxbox::saveStyleFilename(const char *filename) { - if (resource.style_file) - delete [] resource.style_file; + if (resource.style_file) + delete [] resource.style_file; - resource.style_file = StringUtil::strdup(filename); + resource.style_file = StringUtil::strdup(filename); } - +*/ void Fluxbox::saveMenuFilename(const char *filename) { - Bool found = False; + Bool found = False; - LinkedListIterator it(menuTimestamps); - for (; it.current() && (! found); it++) - if (! strcmp(it.current()->filename, filename)) found = True; + LinkedListIterator it(menuTimestamps); + for (; it.current() && (! found); it++) + if (! strcmp(it.current()->filename, filename)) found = True; - if (! found) { - struct stat buf; + if (! found) { + struct stat buf; - if (! stat(filename, &buf)) { - MenuTimestamp *ts = new MenuTimestamp; + if (! stat(filename, &buf)) { + MenuTimestamp *ts = new MenuTimestamp; - ts->filename = StringUtil::strdup(filename); - ts->timestamp = buf.st_ctime; + ts->filename = StringUtil::strdup(filename); + ts->timestamp = buf.st_ctime; - menuTimestamps->insert(ts); - } - } + menuTimestamps->insert(ts); + } + } } void Fluxbox::timeout(void) { - if (reconfigure_wait) - real_reconfigure(); + if (reconfigure_wait) + real_reconfigure(); - if (reread_menu_wait) - real_rereadMenu(); + if (reread_menu_wait) + real_rereadMenu(); - reconfigure_wait = reread_menu_wait = False; + reconfigure_wait = reread_menu_wait = False; } void Fluxbox::setFocusedWindow(FluxboxWindow *win) { BScreen *old_screen = (BScreen *) 0, *screen = (BScreen *) 0; - FluxboxWindow *old_win = (FluxboxWindow *) 0; - Toolbar *old_tbar = (Toolbar *) 0, *tbar = (Toolbar *) 0; - Workspace *old_wkspc = (Workspace *) 0, *wkspc = (Workspace *) 0; + FluxboxWindow *old_win = (FluxboxWindow *) 0; + Toolbar *old_tbar = (Toolbar *) 0, *tbar = (Toolbar *) 0; + Workspace *old_wkspc = (Workspace *) 0, *wkspc = (Workspace *) 0; - if (focused_window) { - old_win = focused_window; - old_screen = old_win->getScreen(); + if (focused_window) { + old_win = focused_window; + old_screen = old_win->getScreen(); - old_tbar = old_screen->getToolbar(); - old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber()); + old_tbar = old_screen->getToolbar(); + old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber()); - old_win->setFocusFlag(False); - old_wkspc->getMenu()->setItemSelected(old_win->getWindowNumber(), False); + old_win->setFocusFlag(False); + old_wkspc->getMenu()->setItemSelected(old_win->getWindowNumber(), False); - } + } - if (win && ! win->isIconic()) { + if (win && ! win->isIconic()) { screen = win->getScreen(); - tbar = screen->getToolbar(); - wkspc = screen->getWorkspace(win->getWorkspaceNumber()); - focused_window = win; - win->setFocusFlag(True); - wkspc->getMenu()->setItemSelected(win->getWindowNumber(), True); + tbar = screen->getToolbar(); + wkspc = screen->getWorkspace(win->getWorkspaceNumber()); + focused_window = win; + win->setFocusFlag(True); + wkspc->getMenu()->setItemSelected(win->getWindowNumber(), True); - } else - focused_window = (FluxboxWindow *) 0; - - if (tbar) - tbar->redrawWindowLabel(True); - if (screen) - screen->updateNetizenWindowFocus(); - - if (old_tbar && old_tbar != tbar) - old_tbar->redrawWindowLabel(True); - if (old_screen && old_screen != screen) - old_screen->updateNetizenWindowFocus(); + } else + focused_window = (FluxboxWindow *) 0; + + if (tbar) + tbar->redrawWindowLabel(True); + if (screen) + screen->updateNetizenWindowFocus(); + + if (old_tbar && old_tbar != tbar) + old_tbar->redrawWindowLabel(True); + if (old_screen && old_screen != screen) + old_screen->updateNetizenWindowFocus(); } diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 17228e9..ca1d614 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.hh,v 1.6 2002/01/11 09:18:58 fluxgen Exp $ +// $Id: fluxbox.hh,v 1.7 2002/01/18 01:23:54 fluxgen Exp $ #ifndef _FLUXBOX_HH_ #define _FLUXBOX_HH_ @@ -45,8 +45,13 @@ # endif // HAVE_SYS_TIME_H #endif // TIME_WITH_SYS_TIME -//forward declaration -class Fluxbox; +#ifndef _RESOURCE_HH_ +#include "Resource.hh" +#endif + +#ifndef _KEYS_HH_ +#include "Keys.hh" +#endif #ifndef _BASEDISPLAY_HH_ #include "BaseDisplay.hh" @@ -76,10 +81,6 @@ class Fluxbox; #include "Toolbar.hh" #endif -#ifndef _KEYS_HH_ -#include "Keys.hh" -#endif - #ifdef SLIT # include "Slit.hh" #endif // SLIT @@ -93,10 +94,10 @@ public: static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0); - inline bool useTabs() const { return resource.tabs; } - inline bool useIconBar() const { return resource.iconbar; } - inline void saveTabs(bool value) { resource.tabs = value; } - inline void saveIconBar(bool value) { resource.iconbar = value; } + inline bool useTabs() { return *m_rc_tabs; } + inline bool useIconBar() { return *m_rc_iconbar; } + inline void saveTabs(bool value) { *m_rc_tabs = value; } + inline void saveIconBar(bool value) { m_rc_iconbar = value; } #ifdef HAVE_GETPID inline const Atom &getFluxboxPidAtom(void) const { return fluxbox_pid; } #ifdef KDE @@ -124,24 +125,24 @@ public: enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY}; - inline const std::vector& getTitlebarRight() { return titlebar.right; } - inline const std::vector& getTitlebarLeft() { return titlebar.left; } - inline const char *getStyleFilename(void) const - { return resource.style_file; } + inline const std::vector& getTitlebarRight() { return *m_rc_titlebar_right; } + inline const std::vector& getTitlebarLeft() { return *m_rc_titlebar_left; } + inline const char *getStyleFilename(void) + { return m_rc_stylefile->c_str(); } - inline const char *getMenuFilename(void) const - { return resource.menu_file; } + inline const char *getMenuFilename(void) + { return m_rc_menufile->c_str(); } - inline const int &getColorsPerChannel(void) const - { return resource.colors_per_channel; } + inline const int &getColorsPerChannel(void) + { return *m_rc_colors_per_channel; } inline const timeval &getAutoRaiseDelay(void) const { return resource.auto_raise_delay; } - inline const unsigned long &getCacheLife(void) const - { return resource.cache_life; } - inline const unsigned long &getCacheMax(void) const - { return resource.cache_max; } + inline const unsigned int getCacheLife(void) + { return *m_rc_cache_life * 60000; } + inline const unsigned int getCacheMax(void) + { return *m_rc_cache_max; } inline void maskWindowEvents(Window w, FluxboxWindow *bw) { masked = w; masked_window = bw; } @@ -152,7 +153,7 @@ public: void load_rc(BScreen *); void loadRootCommand(BScreen *); void loadTitlebar(); - void saveStyleFilename(const char *); + void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } void saveMenuFilename(const char *); void saveTitlebarFilename(const char *); void saveMenuSearch(Window, Basemenu *); @@ -201,6 +202,7 @@ public: inline Z *getData(void) { return data; } }; + typedef std::vector TitlebarList; private: typedef struct MenuTimestamp { @@ -210,21 +212,23 @@ private: struct resource { Time double_click_interval; - - char *menu_file, *style_file, *titlebar_file, *keys_file; - int colors_per_channel; + timeval auto_raise_delay; - unsigned long cache_life, cache_max; - bool tabs, iconbar; + //unsigned long cache_life, cache_max; } resource; + + ResourceManager m_resourcemanager; - struct titlebar_t { - std::vector left; - std::vector right; - }; + //--- Resources + Resource m_rc_tabs, m_rc_iconbar; + Resource m_rc_colors_per_channel; + Resource m_rc_stylefile, + m_rc_menufile, m_rc_keyfile; - titlebar_t titlebar; - std::vector parseTitleArgs(const char *arg); + Resource m_rc_titlebar_left, m_rc_titlebar_right; + Resource m_rc_cache_life, m_rc_cache_max; + + //std::vector parseTitleArgs(const char *arg); void setTitlebar(std::vector& dir, const char *arg); typedef DataSearch WindowSearch; @@ -262,6 +266,7 @@ private: char *rc_file, **argv; int argc; Keys *key; + void doWindowAction(Keys::KeyAction action); protected: Fluxbox(int, char **, char * = 0, char * = 0); @@ -274,6 +279,7 @@ protected: virtual void process_event(XEvent *); //only main should be able to creat new blackbox object + //TODO this must be removed! friend int main(int,char **); static Fluxbox *singleton; //singleton object ( can only be destroyed by main ) virtual ~Fluxbox(void); -- cgit v0.11.2