add Configuration class for generic configuration data load/save-ing.

use Configuration class throughout code. no longer save rc file on exit, save when any options are changed.
This commit is contained in:
Dana Jansens 2002-05-26 20:25:38 +00:00
parent 60b2990e39
commit 0305cbdc3a
19 changed files with 1291 additions and 977 deletions

View file

@ -54,14 +54,19 @@ Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
insert(i18n(ConfigmenuSet, ConfigmenuFocusLast, insert(i18n(ConfigmenuSet, ConfigmenuFocusLast,
"Focus Last Window on Workspace"), 5); "Focus Last Window on Workspace"), 5);
update(); update();
setValues();
}
setItemSelected(2, getScreen()->getImageControl()->doDither());
void Configmenu::setValues(void) {
setItemSelected(2, getScreen()->doImageDither());
setItemSelected(3, getScreen()->doOpaqueMove()); setItemSelected(3, getScreen()->doOpaqueMove());
setItemSelected(4, getScreen()->doFullMax()); setItemSelected(4, getScreen()->doFullMax());
setItemSelected(5, getScreen()->doFocusNew()); setItemSelected(5, getScreen()->doFocusNew());
setItemSelected(6, getScreen()->doFocusLast()); setItemSelected(6, getScreen()->doFocusLast());
} }
Configmenu::~Configmenu(void) { Configmenu::~Configmenu(void) {
delete focusmenu; delete focusmenu;
delete placementmenu; delete placementmenu;
@ -78,32 +83,24 @@ void Configmenu::itemSelected(int button, unsigned int index) {
switch(item->function()) { switch(item->function()) {
case 1: { // dither case 1: { // dither
getScreen()->getImageControl()-> getScreen()->saveImageDither(! getScreen()->doImageDither());
setDither((! getScreen()->getImageControl()->doDither())); setItemSelected(index, getScreen()->doImageDither());
setItemSelected(index, getScreen()->getImageControl()->doDither());
break; break;
} }
case 2: { // opaque move case 2: { // opaque move
getScreen()->saveOpaqueMove((! getScreen()->doOpaqueMove())); getScreen()->saveOpaqueMove((! getScreen()->doOpaqueMove()));
setItemSelected(index, getScreen()->doOpaqueMove()); setItemSelected(index, getScreen()->doOpaqueMove());
break; break;
} }
case 3: { // full maximization case 3: { // full maximization
getScreen()->saveFullMax((! getScreen()->doFullMax())); getScreen()->saveFullMax((! getScreen()->doFullMax()));
setItemSelected(index, getScreen()->doFullMax()); setItemSelected(index, getScreen()->doFullMax());
break; break;
} }
case 4: { // focus new windows case 4: { // focus new windows
getScreen()->saveFocusNew((! getScreen()->doFocusNew())); getScreen()->saveFocusNew((! getScreen()->doFocusNew()));
setItemSelected(index, getScreen()->doFocusNew()); setItemSelected(index, getScreen()->doFocusNew());
break; break;
} }
@ -118,6 +115,7 @@ void Configmenu::itemSelected(int button, unsigned int index) {
void Configmenu::reconfigure(void) { void Configmenu::reconfigure(void) {
setValues();
focusmenu->reconfigure(); focusmenu->reconfigure();
placementmenu->reconfigure(); placementmenu->reconfigure();
@ -134,8 +132,12 @@ Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->getScreen()) {
insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise, "Auto Raise"), 3); insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise, "Auto Raise"), 3);
insert(i18n(ConfigmenuSet, ConfigmenuClickRaise, "Click Raise"), 4); insert(i18n(ConfigmenuSet, ConfigmenuClickRaise, "Click Raise"), 4);
update(); update();
setValues();
}
setItemSelected(0, (! getScreen()->isSloppyFocus()));
void Configmenu::Focusmenu::setValues(void) {
setItemSelected(0, ! getScreen()->isSloppyFocus());
setItemSelected(1, getScreen()->isSloppyFocus()); setItemSelected(1, getScreen()->isSloppyFocus());
setItemEnabled(2, getScreen()->isSloppyFocus()); setItemEnabled(2, getScreen()->isSloppyFocus());
setItemSelected(2, getScreen()->doAutoRaise()); setItemSelected(2, getScreen()->doAutoRaise());
@ -144,6 +146,12 @@ Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->getScreen()) {
} }
void Configmenu::Focusmenu::reconfigure(void) {
setValues();
Basemenu::reconfigure();
}
void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) { void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) {
if (button != 1) if (button != 1)
return; return;
@ -171,13 +179,7 @@ void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) {
getScreen()->updateFocusModel(); getScreen()->updateFocusModel();
break; break;
} }
setValues();
setItemSelected(0, (! getScreen()->isSloppyFocus()));
setItemSelected(1, getScreen()->isSloppyFocus());
setItemEnabled(2, getScreen()->isSloppyFocus());
setItemSelected(2, getScreen()->doAutoRaise());
setItemEnabled(3, getScreen()->isSloppyFocus());
setItemSelected(3, getScreen()->doClickRaise());
} }
@ -201,7 +203,11 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
insert(i18n(ConfigmenuSet, ConfigmenuBottomTop, "Bottom to Top"), insert(i18n(ConfigmenuSet, ConfigmenuBottomTop, "Bottom to Top"),
BScreen::BottomTop); BScreen::BottomTop);
update(); update();
setValues();
}
void Configmenu::Placementmenu::setValues(void) {
switch (getScreen()->getPlacementPolicy()) { switch (getScreen()->getPlacementPolicy()) {
case BScreen::RowSmartPlacement: case BScreen::RowSmartPlacement:
setItemSelected(0, True); setItemSelected(0, True);
@ -216,10 +222,8 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
break; break;
} }
bool rl = (getScreen()->getRowPlacementDirection() == bool rl = (getScreen()->getRowPlacementDirection() == BScreen::LeftRight),
BScreen::LeftRight), tb = (getScreen()->getColPlacementDirection() == BScreen::TopBottom);
tb = (getScreen()->getColPlacementDirection() ==
BScreen::TopBottom);
setItemSelected(3, rl); setItemSelected(3, rl);
setItemSelected(4, ! rl); setItemSelected(4, ! rl);
@ -229,6 +233,12 @@ Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
} }
void Configmenu::Placementmenu::reconfigure(void) {
setValues();
Basemenu::reconfigure();
}
void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) { void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) {
if (button != 1) if (button != 1)
return; return;

View file

@ -40,9 +40,11 @@ private:
protected: protected:
virtual void itemSelected(int button, unsigned int index); virtual void itemSelected(int button, unsigned int index);
virtual void setValues(void);
public: public:
Focusmenu(Configmenu *cm); Focusmenu(Configmenu *cm);
virtual void reconfigure(void);
}; };
class Placementmenu : public Basemenu { class Placementmenu : public Basemenu {
@ -52,9 +54,11 @@ private:
protected: protected:
virtual void itemSelected(int button, unsigned int index); virtual void itemSelected(int button, unsigned int index);
virtual void setValues(void);
public: public:
Placementmenu(Configmenu *cm); Placementmenu(Configmenu *cm);
virtual void reconfigure(void);
}; };
Focusmenu *focusmenu; Focusmenu *focusmenu;
@ -68,6 +72,7 @@ private:
protected: protected:
virtual void itemSelected(int button, unsigned int index); virtual void itemSelected(int button, unsigned int index);
virtual void setValues(void);
public: public:
Configmenu(BScreen *scr); Configmenu(BScreen *scr);
@ -76,7 +81,7 @@ public:
inline Basemenu *getFocusmenu(void) { return focusmenu; } inline Basemenu *getFocusmenu(void) { return focusmenu; }
inline Basemenu *getPlacementmenu(void) { return placementmenu; } inline Basemenu *getPlacementmenu(void) { return placementmenu; }
void reconfigure(void); virtual void reconfigure(void);
}; };
#endif // __Configmenu_hh #endif // __Configmenu_hh

238
src/Configuration.cc Normal file
View file

@ -0,0 +1,238 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
// Configuration.hh for Blackbox - an X11 Window manager
// Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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
// 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.
#include "../config.h"
#include "Configuration.hh"
#include "Util.hh"
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif // HAVE_STDLIB_H
using std::string;
bool Configuration::m_initialized = false;
Configuration::Configuration(const string &file) {
setFile(file);
m_modified = false;
m_database = NULL;
m_autosave = true;
if (! m_initialized) {
XrmInitialize();
m_initialized = true;
}
}
Configuration::Configuration() {
m_modified = false;
m_database = NULL;
m_autosave = true;
if (! m_initialized) {
XrmInitialize();
m_initialized = true;
}
}
Configuration::~Configuration() {
if (m_database != NULL)
XrmDestroyDatabase(m_database);
}
void Configuration::setFile(const string &file) {
m_file = file;
}
void Configuration::setAutoSave(bool autosave) {
m_autosave = autosave;
}
void Configuration::save() {
assert(m_database != NULL);
XrmPutFileDatabase(m_database, m_file.c_str());
m_modified = false;
}
bool Configuration::load() {
if (m_database != NULL)
XrmDestroyDatabase(m_database);
m_modified = false;
if (NULL == (m_database = XrmGetFileDatabase(m_file.c_str())))
return false;
return true;
}
void Configuration::create() {
if (m_database != NULL)
XrmDestroyDatabase(m_database);
m_modified = false;
assert(NULL != (m_database = XrmGetStringDatabase("")));
}
void Configuration::setValue(const string &rname, bool value) {
assert(m_database != NULL);
const char *val = (value ? "True" : "False");
string rc_string = rname + ": " + val;
XrmPutLineResource(&m_database, rc_string.c_str());
m_modified = true;
if (m_autosave)
save();
}
void Configuration::setValue(const string &rname, unsigned long value) {
assert(m_database != NULL);
string rc_string = rname + ": " + itostring(value);
XrmPutLineResource(&m_database, rc_string.c_str());
m_modified = true;
if (m_autosave)
save();
}
void Configuration::setValue(const string &rname, long value) {
assert(m_database != NULL);
string rc_string = rname + ": " + itostring(value);
XrmPutLineResource(&m_database, rc_string.c_str());
m_modified = true;
if (m_autosave)
save();
}
void Configuration::setValue(const string &rname, const char *value) {
assert(m_database != NULL);
assert(value != NULL);
string rc_string = rname + ": " + value;
XrmPutLineResource(&m_database, rc_string.c_str());
m_modified = true;
if (m_autosave)
save();
}
void Configuration::setValue(const string &rname, const string &value) {
assert(m_database != NULL);
string rc_string = rname + ": " + value;
XrmPutLineResource(&m_database, rc_string.c_str());
m_modified = true;
if (m_autosave)
save();
}
bool Configuration::getValue(const string &rname, bool &value) const {
assert(m_database != NULL);
string rclass = createClassName(rname);
char *rettype;
XrmValue retvalue;
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
&rettype, &retvalue) || retvalue.addr == NULL)
return false;
string val = retvalue.addr;
if (val == "true" || val == "True")
value = true;
else
value = false;
return true;
}
bool Configuration::getValue(const string &rname, long &value) const {
assert(m_database != NULL);
string rclass = createClassName(rname);
char *rettype;
XrmValue retvalue;
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
&rettype, &retvalue) || retvalue.addr == NULL)
return false;
char *end;
value = strtol(retvalue.addr, &end, 10);
if (end == retvalue.addr)
return false;
return true;
}
bool Configuration::getValue(const string &rname, unsigned long &value) const {
assert(m_database != NULL);
string rclass = createClassName(rname);
char *rettype;
XrmValue retvalue;
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
&rettype, &retvalue) || retvalue.addr == NULL)
return false;
char *end;
value = strtoul(retvalue.addr, &end, 10);
if (end == retvalue.addr)
return false;
return true;
}
bool Configuration::getValue(const string &rname,
string &value) const {
assert(m_database != NULL);
string rclass = createClassName(rname);
char *rettype;
XrmValue retvalue;
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
&rettype, &retvalue) || retvalue.addr == NULL)
return false;
value = retvalue.addr;
return true;
}
string Configuration::createClassName(const string &rname) const {
string rclass(rname);
string::iterator it = rclass.begin(), end = rclass.end();
while (true) {
*it = toUpper(*it);
++it;
if (it == end) break;
it = std::find(it, rclass.end(), '.');
if (it == end) break;
++it;
if (it == end) break;
}
return rclass;
}
char Configuration::toUpper(char c) const {
if (c >= 'a' && c <= 'z')
return c - 'a' + 'A';
return c;
}

97
src/Configuration.hh Normal file
View file

@ -0,0 +1,97 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
// Configuration.hh for Blackbox - an X11 Window manager
// Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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
// 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.
#ifndef __Configuration_hh
#define __Configuration_hh
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <string>
/*
* The Configuration class is a generic wrapper for configuration settings.
*
* This class is used for the global rc/config file, and for styles.
*
* This implementation of the Configuration class wraps an X resource database
* file.
*/
class Configuration {
public:
explicit Configuration(const std::string &file);
Configuration();
virtual ~Configuration();
inline const std::string &file() const {
return static_cast<const std::string &>(m_file);
}
void setFile(const std::string &file);
// defaults to true!
inline bool autoSave() const {
return m_autosave;
}
void setAutoSave(bool);
inline bool isModified() const {
return m_modified;
}
void save();
bool load();
void create();
void setValue(const std::string &rname, bool value);
inline void setValue(const std::string &rname, int value) {
setValue(rname, (long) value);
}
inline void setValue(const std::string &rname, unsigned int value) {
setValue(rname, (unsigned long) value);
}
void setValue(const std::string &rname, long value);
void setValue(const std::string &rname, unsigned long value);
void setValue(const std::string &rname, const std::string &value);
void setValue(const std::string &rname, const char *value);
bool getValue(const std::string &rname, bool &value) const;
inline bool getValue(const std::string &rname, int &value) const {
return getValue(rname, (long) value);
}
inline bool getValue(const std::string &rname, unsigned int &value) const {
return getValue(rname, (unsigned long) value);
}
bool getValue(const std::string &rname, long &value) const;
bool getValue(const std::string &rname, unsigned long &value) const;
bool getValue(const std::string &rname, std::string &value) const;
private:
std::string createClassName(const std::string &rname) const;
char toUpper(char) const;
static bool m_initialized;
std::string m_file;
bool m_modified;
bool m_autosave;
XrmDatabase m_database;
};
#endif // __Configuration_hh

View file

@ -30,7 +30,7 @@ CPPFLAGS= @CPPFLAGS@ @SHAPE@ @ORDEREDPSEUDO@ \
bin_PROGRAMS= openbox bin_PROGRAMS= openbox
openbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Color.cc Configmenu.cc GCCache.cc Iconmenu.cc Image.cc ImageControl.cc Netizen.cc Rootmenu.cc Screen.cc Slit.cc Texture.cc Timer.cc Toolbar.cc Util.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc blackbox.cc i18n.cc main.cc openbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Color.cc Configmenu.cc Configuration.cc GCCache.cc Iconmenu.cc Image.cc ImageControl.cc Netizen.cc Rootmenu.cc Screen.cc Slit.cc Texture.cc Timer.cc Toolbar.cc Util.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc blackbox.cc i18n.cc main.cc
MAINTAINERCLEANFILES= Makefile.in MAINTAINERCLEANFILES= Makefile.in
@ -39,87 +39,86 @@ distclean-local:
# local dependencies # local dependencies
BaseDisplay.o: BaseDisplay.cc ../config.h i18n.hh \ BaseDisplay.o: BaseDisplay.cc i18n.hh ../nls/blackbox-nls.hh \
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh \ BaseDisplay.hh Timer.hh Util.hh GCCache.hh Color.hh
Util.hh Basemenu.o: Basemenu.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
Basemenu.o: Basemenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Basemenu.hh GCCache.hh \
blackbox.hh BaseDisplay.hh Timer.hh Basemenu.hh GCCache.hh Color.hh \ Color.hh Image.hh Screen.hh Texture.hh Configmenu.hh Iconmenu.hh \
Image.hh Screen.hh Texture.hh Util.hh Configmenu.hh Iconmenu.hh \
Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh
Clientmenu.o: Clientmenu.cc ../config.h blackbox.hh i18n.hh \ Clientmenu.o: Clientmenu.cc blackbox.hh i18n.hh ../nls/blackbox-nls.hh \
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Clientmenu.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Clientmenu.hh \
Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \ Basemenu.hh Screen.hh Color.hh Texture.hh Image.hh Configmenu.hh \
Iconmenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \ Iconmenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \
Window.hh Windowmenu.hh Window.hh Windowmenu.hh
Color.o: Color.cc ../config.h Color.hh BaseDisplay.hh Timer.hh Color.o: Color.cc Color.hh BaseDisplay.hh Timer.hh Util.hh
Configmenu.o: Configmenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ Configmenu.o: Configmenu.cc i18n.hh ../nls/blackbox-nls.hh Configmenu.hh \
Configmenu.hh Basemenu.hh Image.hh Timer.hh BaseDisplay.hh Color.hh \ Basemenu.hh Image.hh Timer.hh BaseDisplay.hh Util.hh Color.hh \
Toolbar.hh Screen.hh Texture.hh Util.hh Iconmenu.hh Netizen.hh \ Toolbar.hh Screen.hh Texture.hh Iconmenu.hh Netizen.hh Rootmenu.hh \
Rootmenu.hh Workspace.hh Workspacemenu.hh blackbox.hh Window.hh \ Workspace.hh Workspacemenu.hh blackbox.hh Configuration.hh Window.hh \
Windowmenu.hh Windowmenu.hh
GCCache.o: GCCache.cc ../config.h GCCache.hh BaseDisplay.hh Timer.hh \ Configuration.o: Configuration.cc ../config.h Configuration.hh Util.hh
Color.hh Util.hh GCCache.o: GCCache.cc GCCache.hh BaseDisplay.hh Timer.hh Util.hh Color.hh
Iconmenu.o: Iconmenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ Iconmenu.o: Iconmenu.cc i18n.hh ../nls/blackbox-nls.hh Iconmenu.hh \
Iconmenu.hh Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh \ Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh Image.hh Timer.hh \
Configmenu.hh Netizen.hh Rootmenu.hh Timer.hh Workspace.hh \ BaseDisplay.hh Configmenu.hh Netizen.hh Rootmenu.hh Workspace.hh \
Workspacemenu.hh blackbox.hh BaseDisplay.hh Window.hh Windowmenu.hh Workspacemenu.hh blackbox.hh Configuration.hh Window.hh Windowmenu.hh
Image.o: Image.cc ../config.h blackbox.hh i18n.hh \ Image.o: Image.cc blackbox.hh i18n.hh ../nls/blackbox-nls.hh \
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh GCCache.hh Color.hh \
Image.hh Texture.hh Util.hh Image.hh Texture.hh
ImageControl.o: ImageControl.cc ../config.h blackbox.hh i18n.hh \ ImageControl.o: ImageControl.cc blackbox.hh i18n.hh \
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Color.hh Image.hh \ ../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Util.hh Configuration.hh \
Texture.hh Util.hh Color.hh Image.hh Texture.hh
Netizen.o: Netizen.cc ../config.h Netizen.hh Screen.hh Color.hh \ Netizen.o: Netizen.cc Netizen.hh Screen.hh Color.hh Texture.hh Util.hh \
Texture.hh Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh Rootmenu.hh \ Image.hh Timer.hh BaseDisplay.hh Configmenu.hh Basemenu.hh Iconmenu.hh \
Timer.hh Workspace.hh Workspacemenu.hh blackbox.hh i18n.hh \ Rootmenu.hh Workspace.hh Workspacemenu.hh blackbox.hh i18n.hh \
../nls/blackbox-nls.hh BaseDisplay.hh ../nls/blackbox-nls.hh Configuration.hh
Rootmenu.o: Rootmenu.cc ../config.h blackbox.hh i18n.hh \ Rootmenu.o: Rootmenu.cc blackbox.hh i18n.hh ../nls/blackbox-nls.hh \
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Rootmenu.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Rootmenu.hh \
Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \ Basemenu.hh Screen.hh Color.hh Texture.hh Image.hh Configmenu.hh \
Iconmenu.hh Netizen.hh Workspace.hh Workspacemenu.hh Iconmenu.hh Netizen.hh Workspace.hh Workspacemenu.hh
Screen.o: Screen.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ Screen.o: Screen.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Clientmenu.hh \
GCCache.hh Color.hh Iconmenu.hh Image.hh Screen.hh Texture.hh Util.hh \ Basemenu.hh GCCache.hh Color.hh Iconmenu.hh Image.hh Screen.hh \
Configmenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \ Texture.hh Configmenu.hh Netizen.hh Rootmenu.hh Workspace.hh \
Slit.hh Toolbar.hh Window.hh Windowmenu.hh Workspacemenu.hh Slit.hh Toolbar.hh Window.hh Windowmenu.hh
Slit.o: Slit.cc ../config.h i18n.hh ../nls/blackbox-nls.hh blackbox.hh \ Slit.o: Slit.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh BaseDisplay.hh \
BaseDisplay.hh Timer.hh Image.hh Color.hh Screen.hh Texture.hh \ Timer.hh Util.hh Configuration.hh Image.hh Color.hh Screen.hh \
Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh Rootmenu.hh \ Texture.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh Rootmenu.hh \
Workspace.hh Workspacemenu.hh Slit.hh Toolbar.hh Workspace.hh Workspacemenu.hh Slit.hh Toolbar.hh
Texture.o: Texture.cc ../config.h Texture.hh Color.hh Util.hh \ Texture.o: Texture.cc Texture.hh Color.hh Util.hh BaseDisplay.hh Timer.hh \
BaseDisplay.hh Timer.hh Image.hh Screen.hh Configmenu.hh Basemenu.hh \ Image.hh Screen.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh \
Iconmenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \ Rootmenu.hh Workspace.hh Workspacemenu.hh blackbox.hh i18n.hh \
blackbox.hh i18n.hh ../nls/blackbox-nls.hh ../nls/blackbox-nls.hh Configuration.hh
Timer.o: Timer.cc ../config.h BaseDisplay.hh Timer.hh Util.hh Timer.o: Timer.cc BaseDisplay.hh Timer.hh Util.hh
Toolbar.o: Toolbar.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ Toolbar.o: Toolbar.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Clientmenu.hh \
GCCache.hh Color.hh Iconmenu.hh Image.hh Rootmenu.hh Screen.hh \ Basemenu.hh GCCache.hh Color.hh Iconmenu.hh Image.hh Rootmenu.hh \
Texture.hh Util.hh Configmenu.hh Netizen.hh Workspace.hh \ Screen.hh Texture.hh Configmenu.hh Netizen.hh Workspace.hh \
Workspacemenu.hh Toolbar.hh Window.hh Windowmenu.hh Slit.hh Workspacemenu.hh Toolbar.hh Window.hh Windowmenu.hh Slit.hh
Util.o: Util.cc ../config.h Util.hh Util.o: Util.cc Util.hh
Window.o: Window.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ Window.o: Window.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
blackbox.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh Iconmenu.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh GCCache.hh Color.hh \
Basemenu.hh Image.hh Screen.hh Texture.hh Util.hh Configmenu.hh \ Iconmenu.hh Basemenu.hh Image.hh Screen.hh Texture.hh Configmenu.hh \
Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh \ Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh \
Window.hh Windowmenu.hh Slit.hh Window.hh Windowmenu.hh Slit.hh
Windowmenu.o: Windowmenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ Windowmenu.o: Windowmenu.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
blackbox.hh BaseDisplay.hh Timer.hh Screen.hh Color.hh Texture.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Screen.hh Color.hh \
Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh Rootmenu.hh \ Texture.hh Image.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh \
Workspace.hh Workspacemenu.hh Window.hh Windowmenu.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Window.hh Windowmenu.hh
Workspace.o: Workspace.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ Workspace.o: Workspace.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Clientmenu.hh \
Netizen.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \ Basemenu.hh Netizen.hh Screen.hh Color.hh Texture.hh Image.hh \
Iconmenu.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh \ Configmenu.hh Iconmenu.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \
Window.hh Windowmenu.hh Toolbar.hh Window.hh Windowmenu.hh
Workspacemenu.o: Workspacemenu.cc ../config.h i18n.hh \ Workspacemenu.o: Workspacemenu.cc i18n.hh ../nls/blackbox-nls.hh \
../nls/blackbox-nls.hh blackbox.hh BaseDisplay.hh Timer.hh Screen.hh \ blackbox.hh BaseDisplay.hh Timer.hh Util.hh Configuration.hh Screen.hh \
Color.hh Texture.hh Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh \ Color.hh Texture.hh Image.hh Configmenu.hh Basemenu.hh Iconmenu.hh \
Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh
blackbox.o: blackbox.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \ blackbox.o: blackbox.cc i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
blackbox.hh BaseDisplay.hh Timer.hh Basemenu.hh Clientmenu.hh \ BaseDisplay.hh Timer.hh Util.hh Configuration.hh Basemenu.hh \
GCCache.hh Color.hh Image.hh Rootmenu.hh Screen.hh Texture.hh Util.hh \ Clientmenu.hh GCCache.hh Color.hh Image.hh Rootmenu.hh Screen.hh \
Configmenu.hh Iconmenu.hh Netizen.hh Workspace.hh Workspacemenu.hh \ Texture.hh Configmenu.hh Iconmenu.hh Netizen.hh Workspace.hh \
Slit.hh Toolbar.hh Window.hh Windowmenu.hh Workspacemenu.hh Slit.hh Toolbar.hh Window.hh Windowmenu.hh
i18n.o: i18n.cc ../config.h i18n.hh ../nls/blackbox-nls.hh i18n.o: i18n.cc i18n.hh ../nls/blackbox-nls.hh
main.o: main.cc ../version.h ../config.h i18n.hh \ main.o: main.cc ../version.h i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
../nls/blackbox-nls.hh blackbox.hh BaseDisplay.hh Timer.hh BaseDisplay.hh Timer.hh Util.hh Configuration.hh

View file

@ -108,6 +108,8 @@ static int anotherWMRunning(Display *display, XErrorEvent *) {
BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) { BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
blackbox = bb; blackbox = bb;
screenstr = (string)"session.screen" + itostring(scrn) + '.';
config = blackbox->getConfig();
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask; SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask;
@ -127,7 +129,6 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
getDepth()); getDepth());
rootmenu = 0; rootmenu = 0;
resource.stylerc = 0;
resource.mstyle.t_fontset = resource.mstyle.f_fontset = resource.mstyle.t_fontset = resource.mstyle.f_fontset =
resource.tstyle.fontset = resource.wstyle.fontset = (XFontSet) 0; resource.tstyle.fontset = resource.wstyle.fontset = (XFontSet) 0;
@ -155,10 +156,7 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(bb, scrn) {
image_control->installRootColormap(); image_control->installRootColormap();
root_colormap_installed = True; root_colormap_installed = True;
blackbox->load_rc(this); load_rc();
image_control->setDither(resource.image_dither);
LoadStyle(); LoadStyle();
XGCValues gcv; XGCValues gcv;
@ -352,8 +350,261 @@ void BScreen::removeWorkspaceNames(void) {
workspaceNames.clear(); workspaceNames.clear();
} }
void BScreen::saveSloppyFocus(bool s) {
resource.sloppy_focus = s;
string fmodel;
if (resource.sloppy_focus) {
fmodel = "SloppyFocus";
if (resource.auto_raise) fmodel += " AutoRaise";
if (resource.click_raise) fmodel += " ClickRaise";
} else {
fmodel = "ClickToFocus";
}
config->setValue(screenstr + "focusModel", fmodel);
}
void BScreen::saveAutoRaise(bool a) {
resource.auto_raise = a;
saveSloppyFocus(resource.sloppy_focus);
}
void BScreen::saveClickRaise(bool c) {
resource.click_raise = c;
saveSloppyFocus(resource.sloppy_focus);
}
void BScreen::saveImageDither(bool d) {
image_control->setDither(d);
config->setValue(screenstr + "imageDither", doImageDither());
}
void BScreen::saveOpaqueMove(bool o) {
resource.opaque_move = o;
config->setValue(screenstr + "opaqueMove", resource.opaque_move);
}
void BScreen::saveFullMax(bool f) {
resource.full_max = f;
config->setValue(screenstr + "fullMaximization", resource.full_max);
}
void BScreen::saveFocusNew(bool f) {
resource.focus_new = f;
config->setValue(screenstr + "focusNewWindows", resource.focus_new);
}
void BScreen::saveFocusLast(bool f) {
resource.focus_last = f;
config->setValue(screenstr + "focusLastWindow", resource.focus_last);
}
void BScreen::saveWorkspaces(unsigned int w) {
resource.workspaces = w;
config->setValue(screenstr + "workspaces", resource.workspaces);
}
void BScreen::savePlacementPolicy(int p) {
resource.placement_policy = p;
const char *placement;
switch (resource.placement_policy) {
case CascadePlacement: placement = "CascadePlacement"; break;
case ColSmartPlacement: placement = "ColSmartPlacement"; break;
case RowSmartPlacement: default: placement = "RowSmartPlacement"; break;
}
config->setValue(screenstr + "windowPlacement", placement);
}
void BScreen::saveEdgeSnapThreshold(int t) {
resource.edge_snap_threshold = t;
config->setValue(screenstr + "edgeSnapThreshold",
resource.edge_snap_threshold);
}
void BScreen::saveRowPlacementDirection(int d) {
resource.row_direction = d;
config->setValue(screenstr + "rowPlacementDirection",
resource.row_direction == LeftRight ?
"LeftToRight" : "RightToLeft");
}
void BScreen::saveColPlacementDirection(int d) {
resource.col_direction = d;
config->setValue(screenstr + "colPlacementDirection",
resource.col_direction == TopBottom ?
"TopToBottom" : "BottomToTop");
}
#ifdef HAVE_STRFTIME
void BScreen::saveStrftimeFormat(const std::string& format) {
resource.strftime_format = format;
config->setValue(screenstr + "strftimeFormat", resource.strftime_format);
}
#else // !HAVE_STRFTIME
void BScreen::saveDateFormat(int f) {
resource.date_format = f;
config->setValue(screenstr + "dateFormat",
resource.date_format == B_EuropeanDate ?
"European" : "American");
}
void BScreen::saveClock24Hour(Bool c) {
resource.clock24hour = c;
config->setValue(screenstr + "clockFormat", resource.clock24hour ? 24 : 12);
}
#endif // HAVE_STRFTIME
void BScreen::saveWorkspaceNames() {
string save_string = getWorkspace(0)->getName();
for (unsigned int i = 1; i < getWorkspaceCount(); ++i)
save_string += ',' + getWorkspace(i)->getName();
config->setValue(screenstr + "workspaceNames", save_string);
}
void BScreen::save_rc(void) {
saveSloppyFocus(resource.sloppy_focus);
saveAutoRaise(resource.auto_raise);
saveImageDither(doImageDither());
saveOpaqueMove(resource.opaque_move);
saveFullMax(resource.full_max);
saveFocusNew(resource.focus_new);
saveFocusLast(resource.focus_last);
saveWorkspaces(resource.workspaces);
savePlacementPolicy(resource.placement_policy);
saveEdgeSnapThreshold(resource.edge_snap_threshold);
saveRowPlacementDirection(resource.row_direction);
saveColPlacementDirection(resource.col_direction);
#ifdef HAVE_STRFTIME
saveStrftimeFormat(resource.strftime_format);
#else // !HAVE_STRFTIME
saveDateFormat(resource.date_format);
savwClock24Hour(resource.clock24hour);
#endif // HAVE_STRFTIME
toolbar->save_rc();
slit->save_rc();
}
void BScreen::load_rc(void) {
std::string s;
bool b;
if (! config->getValue(screenstr + "fullMaximization", resource.full_max))
resource.full_max = false;
if (! config->getValue(screenstr + "focusNewWindows", resource.focus_new))
resource.focus_new = false;
if (! config->getValue(screenstr + "focusLastWindow", resource.focus_last))
resource.focus_last = false;
if (! config->getValue(screenstr + "workspaces", resource.workspaces))
resource.workspaces = 1;
if (! config->getValue(screenstr + "opaqueMove", resource.opaque_move))
resource.opaque_move = false;
if (! config->getValue(screenstr + "imageDither", b))
b = true;
image_control->setDither(b);
if (! config->getValue(screenstr + "edgeSnapThreshold",
resource.edge_snap_threshold))
resource.edge_snap_threshold = 4;
if (config->getValue(screenstr + "rowPlacementDirection", s) &&
s == "RightToLeft")
resource.row_direction = RightLeft;
else
resource.row_direction = LeftRight;
if (config->getValue(screenstr + "colPlacementDirection", s) &&
s == "BottomToTop")
resource.col_direction = BottomTop;
else
resource.col_direction = TopBottom;
removeWorkspaceNames();
if (config->getValue(screenstr + "workspaceNames", s)) {
string::const_iterator it = s.begin(), end = s.end();
while(1) {
string::const_iterator tmp = it; // current string.begin()
it = std::find(tmp, end, ','); // look for comma between tmp and end
addWorkspaceName(string(tmp, it)); // s[tmp:it]
if (it == end)
break;
++it;
}
}
resource.sloppy_focus = true;
resource.auto_raise = false;
resource.click_raise = false;
if (config->getValue(screenstr + "focusModel", s)) {
if (s.find("ClickToFocus") != string::npos) {
resource.sloppy_focus = false;
} else {
// must be sloppy
if (s.find("AutoRaise") != string::npos)
resource.auto_raise = true;
if (s.find("ClickRaise") != string::npos)
resource.click_raise = true;
}
}
if (config->getValue(screenstr + "windowPlacement", s)) {
if (s == "CascadePlacement")
resource.placement_policy = CascadePlacement;
else if (s == "ColSmartPlacement")
resource.placement_policy = ColSmartPlacement;
else //if (s == "RowSmartPlacement")
resource.placement_policy = RowSmartPlacement;
} else
resource.placement_policy = RowSmartPlacement;
#ifdef HAVE_STRFTIME
if (config->getValue(screenstr + "strftimeFormat", s))
resource.strftime_format = s;
else
resource.strftime_format = "%I:%M %p";
#else // !HAVE_STRFTIME
long l;
if (config->getValue(screenstr + "dateFormat", s) && s == "European")
resource.date_format = B_EuropeanDate;
else
resource.date_format = B_AmericanDate;
if (! config->getValue(screenstr + "clockFormat", l))
l = 12;
resource.clock24hour = l == 24;
#endif // HAVE_STRFTIME
}
void BScreen::reconfigure(void) { void BScreen::reconfigure(void) {
load_rc();
toolbar->load_rc();
slit->load_rc();
LoadStyle(); LoadStyle();
XGCValues gcv; XGCValues gcv;
@ -442,12 +693,19 @@ void BScreen::rereadMenu(void) {
void BScreen::LoadStyle(void) { void BScreen::LoadStyle(void) {
resource.stylerc = XrmGetFileDatabase(blackbox->getStyleFilename()); Configuration style;
if (! resource.stylerc)
resource.stylerc = XrmGetFileDatabase(DEFAULTSTYLE);
XrmValue value; const char *sfile = blackbox->getStyleFilename();
char *value_type; if (sfile != NULL) {
style.setFile(sfile);
if (! style.load()) {
style.setFile(DEFAULTSTYLE);
if (! style.load())
style.create(); // hardcoded default values will be used.
}
}
string s;
// load fonts/fontsets // load fonts/fontsets
if (resource.wstyle.fontset) if (resource.wstyle.fontset)
@ -476,14 +734,10 @@ void BScreen::LoadStyle(void) {
resource.mstyle.t_font = 0; resource.mstyle.t_font = 0;
if (i18n.multibyte()) { if (i18n.multibyte()) {
resource.wstyle.fontset = resource.wstyle.fontset = readDatabaseFontSet("window.font", style);
readDatabaseFontSet("window.font", "Window.Font"); resource.tstyle.fontset = readDatabaseFontSet("toolbar.font", style);
resource.tstyle.fontset = resource.mstyle.t_fontset = readDatabaseFontSet("menu.title.font", style);
readDatabaseFontSet("toolbar.font", "Toolbar.Font"); resource.mstyle.f_fontset = readDatabaseFontSet("menu.frame.font", style);
resource.mstyle.t_fontset =
readDatabaseFontSet("menu.title.font", "Menu.Title.Font");
resource.mstyle.f_fontset =
readDatabaseFontSet("menu.frame.font", "Menu.Frame.Font");
resource.mstyle.t_fontset_extents = resource.mstyle.t_fontset_extents =
XExtentsOfFontSet(resource.mstyle.t_fontset); XExtentsOfFontSet(resource.mstyle.t_fontset);
@ -494,207 +748,155 @@ void BScreen::LoadStyle(void) {
resource.wstyle.fontset_extents = resource.wstyle.fontset_extents =
XExtentsOfFontSet(resource.wstyle.fontset); XExtentsOfFontSet(resource.wstyle.fontset);
} else { } else {
resource.wstyle.font = resource.wstyle.font = readDatabaseFont("window.font", style);
readDatabaseFont("window.font", "Window.Font"); resource.tstyle.font = readDatabaseFont("toolbar.font", style);
resource.tstyle.font = resource.mstyle.t_font = readDatabaseFont("menu.title.font", style);
readDatabaseFont("toolbar.font", "Toolbar.Font"); resource.mstyle.f_font = readDatabaseFont("menu.frame.font", style);
resource.mstyle.t_font =
readDatabaseFont("menu.title.font", "Menu.Title.Font");
resource.mstyle.f_font =
readDatabaseFont("menu.frame.font", "Menu.Frame.Font");
} }
// load window config // load window config
resource.wstyle.t_focus = resource.wstyle.t_focus =
readDatabaseTexture("window.title.focus", "Window.Title.Focus", "white"); readDatabaseTexture("window.title.focus", "white", style);
resource.wstyle.t_unfocus = resource.wstyle.t_unfocus =
readDatabaseTexture("window.title.unfocus", readDatabaseTexture("window.title.unfocus", "black", style);
"Window.Title.Unfocus", "black");
resource.wstyle.l_focus = resource.wstyle.l_focus =
readDatabaseTexture("window.label.focus", "Window.Label.Focus", "white" ); readDatabaseTexture("window.label.focus", "white", style);
resource.wstyle.l_unfocus = resource.wstyle.l_unfocus =
readDatabaseTexture("window.label.unfocus", "Window.Label.Unfocus", readDatabaseTexture("window.label.unfocus", "black", style);
"black");
resource.wstyle.h_focus = resource.wstyle.h_focus =
readDatabaseTexture("window.handle.focus", "Window.Handle.Focus", "white"); readDatabaseTexture("window.handle.focus", "white", style);
resource.wstyle.h_unfocus = resource.wstyle.h_unfocus =
readDatabaseTexture("window.handle.unfocus", readDatabaseTexture("window.handle.unfocus", "black", style);
"Window.Handle.Unfocus", "black");
resource.wstyle.g_focus = resource.wstyle.g_focus =
readDatabaseTexture("window.grip.focus", "Window.Grip.Focus", "white"); readDatabaseTexture("window.grip.focus", "white", style);
resource.wstyle.g_unfocus = resource.wstyle.g_unfocus =
readDatabaseTexture("window.grip.unfocus", "Window.Grip.Unfocus", "black"); readDatabaseTexture("window.grip.unfocus", "black", style);
resource.wstyle.b_focus = resource.wstyle.b_focus =
readDatabaseTexture("window.button.focus", "Window.Button.Focus", "white"); readDatabaseTexture("window.button.focus", "white", style);
resource.wstyle.b_unfocus = resource.wstyle.b_unfocus =
readDatabaseTexture("window.button.unfocus", readDatabaseTexture("window.button.unfocus", "black", style);
"Window.Button.Unfocus", "black");
resource.wstyle.b_pressed = resource.wstyle.b_pressed =
readDatabaseTexture("window.button.pressed", readDatabaseTexture("window.button.pressed", "black", style);
"Window.Button.Pressed", "black");
resource.wstyle.f_focus = resource.wstyle.f_focus =
readDatabaseColor("window.frame.focusColor", readDatabaseColor("window.frame.focusColor", "white", style);
"Window.Frame.FocusColor", "white");
resource.wstyle.f_unfocus = resource.wstyle.f_unfocus =
readDatabaseColor("window.frame.unfocusColor", readDatabaseColor("window.frame.unfocusColor", "black", style);
"Window.Frame.UnfocusColor", "black");
resource.wstyle.l_text_focus = resource.wstyle.l_text_focus =
readDatabaseColor("window.label.focus.textColor", readDatabaseColor("window.label.focus.textColor", "black", style);
"Window.Label.Focus.TextColor", "black");
resource.wstyle.l_text_unfocus = resource.wstyle.l_text_unfocus =
readDatabaseColor("window.label.unfocus.textColor", readDatabaseColor("window.label.unfocus.textColor", "white", style);
"Window.Label.Unfocus.TextColor", "white");
resource.wstyle.b_pic_focus = resource.wstyle.b_pic_focus =
readDatabaseColor("window.button.focus.picColor", readDatabaseColor("window.button.focus.picColor", "black", style);
"Window.Button.Focus.PicColor", "black");
resource.wstyle.b_pic_unfocus = resource.wstyle.b_pic_unfocus =
readDatabaseColor("window.button.unfocus.picColor", readDatabaseColor("window.button.unfocus.picColor", "white", style);
"Window.Button.Unfocus.PicColor", "white");
resource.wstyle.justify = LeftJustify; resource.wstyle.justify = LeftJustify;
if (XrmGetResource(resource.stylerc, "window.justify", "Window.Justify", if (style.getValue("window.justify", s)) {
&value_type, &value)) { if (s == "right" || s == "Right")
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
resource.wstyle.justify = RightJustify; resource.wstyle.justify = RightJustify;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) else if (s == "center" || s == "Center")
resource.wstyle.justify = CenterJustify; resource.wstyle.justify = CenterJustify;
} }
// load toolbar config // load toolbar config
resource.tstyle.toolbar = resource.tstyle.toolbar =
readDatabaseTexture("toolbar", "Toolbar", "black"); readDatabaseTexture("toolbar", "black", style);
resource.tstyle.label = resource.tstyle.label =
readDatabaseTexture("toolbar.label", "Toolbar.Label", "black"); readDatabaseTexture("toolbar.label", "black", style);
resource.tstyle.window = resource.tstyle.window =
readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel", "black"); readDatabaseTexture("toolbar.windowLabel", "black", style);
resource.tstyle.button = resource.tstyle.button =
readDatabaseTexture("toolbar.button", "Toolbar.Button", "white"); readDatabaseTexture("toolbar.button", "white", style);
resource.tstyle.pressed = resource.tstyle.pressed =
readDatabaseTexture("toolbar.button.pressed", readDatabaseTexture("toolbar.button.pressed", "black", style);
"Toolbar.Button.Pressed", "black");
resource.tstyle.clock = resource.tstyle.clock =
readDatabaseTexture("toolbar.clock", "Toolbar.Clock", "black"); readDatabaseTexture("toolbar.clock", "black", style);
resource.tstyle.l_text = resource.tstyle.l_text =
readDatabaseColor("toolbar.label.textColor", readDatabaseColor("toolbar.label.textColor", "white", style);
"Toolbar.Label.TextColor", "white");
resource.tstyle.w_text = resource.tstyle.w_text =
readDatabaseColor("toolbar.windowLabel.textColor", readDatabaseColor("toolbar.windowLabel.textColor", "white", style);
"Toolbar.WindowLabel.TextColor", "white");
resource.tstyle.c_text = resource.tstyle.c_text =
readDatabaseColor("toolbar.clock.textColor", readDatabaseColor("toolbar.clock.textColor", "white", style);
"Toolbar.Clock.TextColor", "white");
resource.tstyle.b_pic = resource.tstyle.b_pic =
readDatabaseColor("toolbar.button.picColor", readDatabaseColor("toolbar.button.picColor", "black", style);
"Toolbar.Button.PicColor", "black");
resource.tstyle.justify = LeftJustify; resource.tstyle.justify = LeftJustify;
if (XrmGetResource(resource.stylerc, "toolbar.justify", if (style.getValue("toolbar.justify", s)) {
"Toolbar.Justify", &value_type, &value)) { if (s == "right" || s == "Right")
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
resource.tstyle.justify = RightJustify; resource.tstyle.justify = RightJustify;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) else if (s == "center" || s == "Center")
resource.tstyle.justify = CenterJustify; resource.tstyle.justify = CenterJustify;
} }
// load menu config // load menu config
resource.mstyle.title = resource.mstyle.title =
readDatabaseTexture("menu.title", "Menu.Title", "white"); readDatabaseTexture("menu.title", "white", style);
resource.mstyle.frame = resource.mstyle.frame =
readDatabaseTexture("menu.frame", "Menu.Frame", "black"); readDatabaseTexture("menu.frame", "black", style);
resource.mstyle.hilite = resource.mstyle.hilite =
readDatabaseTexture("menu.hilite", "Menu.Hilite", "white"); readDatabaseTexture("menu.hilite", "white", style);
resource.mstyle.t_text = resource.mstyle.t_text =
readDatabaseColor("menu.title.textColor", "Menu.Title.TextColor", "black"); readDatabaseColor("menu.title.textColor", "black", style);
resource.mstyle.f_text = resource.mstyle.f_text =
readDatabaseColor("menu.frame.textColor", "Menu.Frame.TextColor", "white"); readDatabaseColor("menu.frame.textColor", "white", style);
resource.mstyle.d_text = resource.mstyle.d_text =
readDatabaseColor("menu.frame.disableColor", readDatabaseColor("menu.frame.disableColor", "black", style);
"Menu.Frame.DisableColor", "black");
resource.mstyle.h_text = resource.mstyle.h_text =
readDatabaseColor("menu.hilite.textColor", readDatabaseColor("menu.hilite.textColor", "black", style);
"Menu.Hilite.TextColor", "black");
resource.mstyle.t_justify = LeftJustify; resource.mstyle.t_justify = LeftJustify;
if (XrmGetResource(resource.stylerc, "menu.title.justify", if (style.getValue("menu.title.justify", s)) {
"Menu.Title.Justify", if (s == "right" || s == "Right")
&value_type, &value)) {
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
resource.mstyle.t_justify = RightJustify; resource.mstyle.t_justify = RightJustify;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) else if (s == "center" || s == "Center")
resource.mstyle.t_justify = CenterJustify; resource.mstyle.t_justify = CenterJustify;
} }
resource.mstyle.f_justify = LeftJustify; resource.mstyle.f_justify = LeftJustify;
if (XrmGetResource(resource.stylerc, "menu.frame.justify", if (style.getValue("menu.frame.justify", s)) {
"Menu.Frame.Justify", if (s == "right" || s == "Right")
&value_type, &value)) {
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
resource.mstyle.f_justify = RightJustify; resource.mstyle.f_justify = RightJustify;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) else if (s == "center" || s == "Center")
resource.mstyle.f_justify = CenterJustify; resource.mstyle.f_justify = CenterJustify;
} }
resource.mstyle.bullet = Basemenu::Triangle; resource.mstyle.bullet = Basemenu::Triangle;
if (XrmGetResource(resource.stylerc, "menu.bullet", "Menu.Bullet", if (style.getValue("menu.bullet", s)) {
&value_type, &value)) { if (s == "empty" || s == "Empty")
if (! strncasecmp(value.addr, "empty", value.size))
resource.mstyle.bullet = Basemenu::Empty; resource.mstyle.bullet = Basemenu::Empty;
else if (! strncasecmp(value.addr, "square", value.size)) else if (s == "square" || s == "Square")
resource.mstyle.bullet = Basemenu::Square; resource.mstyle.bullet = Basemenu::Square;
else if (! strncasecmp(value.addr, "diamond", value.size)) else if (s == "diamond" || s == "Diamond")
resource.mstyle.bullet = Basemenu::Diamond; resource.mstyle.bullet = Basemenu::Diamond;
} }
resource.mstyle.bullet_pos = Basemenu::Left; resource.mstyle.bullet_pos = Basemenu::Left;
if (XrmGetResource(resource.stylerc, "menu.bullet.position", if (style.getValue("menu.bullet.position", s)) {
"Menu.Bullet.Position", &value_type, &value)) { if (s == "right" || s == "Right")
if (! strncasecmp(value.addr, "right", value.size))
resource.mstyle.bullet_pos = Basemenu::Right; resource.mstyle.bullet_pos = Basemenu::Right;
} }
resource.border_color = resource.border_color =
readDatabaseColor("borderColor", "BorderColor", "black"); readDatabaseColor("borderColor", "black", style);
unsigned int uint_value;
// load bevel, border and handle widths // load bevel, border and handle widths
if (! style.getValue("handleWidth", resource.handle_width) ||
resource.handle_width > (getWidth() / 2) || resource.handle_width == 0)
resource.handle_width = 6; resource.handle_width = 6;
if (XrmGetResource(resource.stylerc, "handleWidth", "HandleWidth",
&value_type, &value) &&
sscanf(value.addr, "%u", &uint_value) == 1 &&
uint_value <= (getWidth() / 2) && uint_value != 0) {
resource.handle_width = uint_value;
}
if (! style.getValue("borderWidth", resource.border_width))
resource.border_width = 1; resource.border_width = 1;
if (XrmGetResource(resource.stylerc, "borderWidth", "BorderWidth",
&value_type, &value) &&
sscanf(value.addr, "%u", &uint_value) == 1) {
resource.border_width = uint_value;
}
if (! style.getValue("bevelWidth", resource.bevel_width) ||
resource.bevel_width > (getWidth() / 2) || resource.bevel_width == 0)
resource.bevel_width = 3; resource.bevel_width = 3;
if (XrmGetResource(resource.stylerc, "bevelWidth", "BevelWidth",
&value_type, &value) &&
sscanf(value.addr, "%u", &uint_value) == 1 &&
uint_value <= (getWidth() / 2) && uint_value != 0) {
resource.bevel_width = uint_value;
}
if (! style.getValue("frameWidth", resource.frame_width) ||
resource.frame_width > (getWidth() / 2))
resource.frame_width = resource.bevel_width; resource.frame_width = resource.bevel_width;
if (XrmGetResource(resource.stylerc, "frameWidth", "FrameWidth",
&value_type, &value) &&
sscanf(value.addr, "%u", &uint_value) == 1 &&
uint_value <= (getWidth() / 2)) {
resource.frame_width = uint_value;
}
if (XrmGetResource(resource.stylerc, "rootCommand", "RootCommand", if (style.getValue("rootCommand", s))
&value_type, &value)) { bexec(s, displayString());
bexec(value.addr, displayString());
}
XrmDestroyDatabase(resource.stylerc);
} }
@ -741,6 +943,8 @@ BlackboxWindow *BScreen::getIcon(unsigned int index) {
unsigned int BScreen::addWorkspace(void) { unsigned int BScreen::addWorkspace(void) {
Workspace *wkspc = new Workspace(this, workspacesList.size()); Workspace *wkspc = new Workspace(this, workspacesList.size());
workspacesList.push_back(wkspc); workspacesList.push_back(wkspc);
saveWorkspaces(getWorkspaceCount() + 1);
saveWorkspaceNames();
workspacemenu->insert(wkspc->getName(), wkspc->getMenu(), workspacemenu->insert(wkspc->getName(), wkspc->getMenu(),
wkspc->getID() + 2); wkspc->getID() + 2);
@ -771,6 +975,9 @@ unsigned int BScreen::removeLastWorkspace(void) {
workspacesList.pop_back(); workspacesList.pop_back();
delete wkspc; delete wkspc;
saveWorkspaces(getWorkspaceCount() - 1);
saveWorkspaceNames();
toolbar->reconfigure(); toolbar->reconfigure();
updateNetizenWorkspaceCount(); updateNetizenWorkspaceCount();
@ -981,13 +1188,6 @@ void BScreen::raiseWindows(Window *workspace_stack, unsigned int num) {
} }
#ifdef HAVE_STRFTIME
void BScreen::saveStrftimeFormat(const string& format) {
resource.strftime_format = format;
}
#endif // HAVE_STRFTIME
void BScreen::addWorkspaceName(const string& name) { void BScreen::addWorkspaceName(const string& name) {
workspaceNames.push_back(name); workspaceNames.push_back(name);
} }
@ -1746,15 +1946,13 @@ void BScreen::updateFocusModel()
BTexture BScreen::readDatabaseTexture(const string &rname, BTexture BScreen::readDatabaseTexture(const string &rname,
const string &rclass, const string &default_color,
const string &default_color) { Configuration &style) {
BTexture texture; BTexture texture;
XrmValue value; string s;
char *value_type;
if (XrmGetResource(resource.stylerc, rname.c_str(), rclass.c_str(), if (style.getValue(rname, s))
&value_type, &value)) texture = BTexture(s);
texture = BTexture(value.addr);
else else
texture.setTexture(BTexture::Solid | BTexture::Flat); texture.setTexture(BTexture::Solid | BTexture::Flat);
@ -1764,32 +1962,27 @@ BTexture BScreen::readDatabaseTexture(const string &rname,
if (texture.texture() & BTexture::Solid) { if (texture.texture() & BTexture::Solid) {
texture.setColor(readDatabaseColor(rname + ".color", texture.setColor(readDatabaseColor(rname + ".color",
rclass + ".Color", default_color, style));
default_color));
texture.setColorTo(readDatabaseColor(rname + ".colorTo", texture.setColorTo(readDatabaseColor(rname + ".colorTo",
rclass + ".ColorTo", default_color, style));
default_color));
} else if (texture.texture() & BTexture::Gradient) { } else if (texture.texture() & BTexture::Gradient) {
texture.setColor(readDatabaseColor(rname + ".color", texture.setColor(readDatabaseColor(rname + ".color",
rclass + ".Color", default_color, style));
default_color));
texture.setColorTo(readDatabaseColor(rname + ".colorTo", texture.setColorTo(readDatabaseColor(rname + ".colorTo",
rclass + ".ColorTo", default_color, style));
default_color));
} }
return texture; return texture;
} }
BColor BScreen::readDatabaseColor(const string &rname, const string &rclass, BColor BScreen::readDatabaseColor(const string &rname,
const string &default_color) { const string &default_color,
Configuration &style) {
BColor color; BColor color;
XrmValue value; string s;
char *value_type; if (style.getValue(rname, s))
if (XrmGetResource(resource.stylerc, rname.c_str(), rclass.c_str(), color = BColor(s, getBaseDisplay(), getScreenNumber());
&value_type, &value))
color = BColor(value.addr, getBaseDisplay(), getScreenNumber());
else else
color = BColor(default_color, getBaseDisplay(), getScreenNumber()); color = BColor(default_color, getBaseDisplay(), getScreenNumber());
return color; return color;
@ -1797,18 +1990,14 @@ BColor BScreen::readDatabaseColor(const string &rname, const string &rclass,
XFontSet BScreen::readDatabaseFontSet(const string &rname, XFontSet BScreen::readDatabaseFontSet(const string &rname,
const string &rclass) { Configuration &style) {
char *defaultFont = "fixed"; char *defaultFont = "fixed";
bool load_default = True; bool load_default = True;
XrmValue value; string s;
char *value_type;
XFontSet fontset = 0; XFontSet fontset = 0;
if (XrmGetResource(resource.stylerc, rname.c_str(), rclass.c_str(), if (style.getValue(rname, s) && (fontset = createFontSet(s)))
&value_type, &value) &&
(fontset = createFontSet(value.addr))) {
load_default = False; load_default = False;
}
if (load_default) { if (load_default) {
fontset = createFontSet(defaultFont); fontset = createFontSet(defaultFont);
@ -1826,20 +2015,18 @@ XFontSet BScreen::readDatabaseFontSet(const string &rname,
XFontStruct *BScreen::readDatabaseFont(const string &rname, XFontStruct *BScreen::readDatabaseFont(const string &rname,
const string &rclass) { Configuration &style) {
char *defaultFont = "fixed"; char *defaultFont = "fixed";
bool load_default = False; bool load_default = False;
XrmValue value; string s;
char *value_type;
XFontStruct *font = 0; XFontStruct *font = 0;
if (XrmGetResource(resource.stylerc, rname.c_str(), rclass.c_str(), if (style.getValue(rname, s)) {
&value_type, &value)) { if ((font = XLoadQueryFont(blackbox->getXDisplay(), s.c_str())) == NULL) {
if ((font = XLoadQueryFont(blackbox->getXDisplay(), value.addr)) == NULL) {
fprintf(stderr, fprintf(stderr,
i18n(ScreenSet, ScreenFontLoadFail, i18n(ScreenSet, ScreenFontLoadFail,
"BScreen::setCurrentStyle(): couldn't load font '%s'\n"), "BScreen::setCurrentStyle(): couldn't load font '%s'\n"),
value.addr); s.c_str());
load_default = True; load_default = True;
} }

View file

@ -45,6 +45,7 @@ extern "C" {
#include "Color.hh" #include "Color.hh"
#include "Texture.hh" #include "Texture.hh"
#include "Image.hh"
#include "Configmenu.hh" #include "Configmenu.hh"
#include "Iconmenu.hh" #include "Iconmenu.hh"
#include "Netizen.hh" #include "Netizen.hh"
@ -117,6 +118,7 @@ private:
Configmenu *configmenu; Configmenu *configmenu;
Iconmenu *iconmenu; Iconmenu *iconmenu;
Rootmenu *rootmenu; Rootmenu *rootmenu;
Configuration *config;
typedef std::list<Rootmenu*> RootmenuList; typedef std::list<Rootmenu*> RootmenuList;
RootmenuList rootmenuList; RootmenuList rootmenuList;
@ -147,19 +149,14 @@ private:
ToolbarStyle tstyle; ToolbarStyle tstyle;
MenuStyle mstyle; MenuStyle mstyle;
bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise, bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max, opaque_move, full_max, focus_new, focus_last, click_raise;
focus_new, focus_last, click_raise;
BColor border_color; BColor border_color;
XrmDatabase stylerc;
unsigned int workspaces; unsigned int workspaces;
int toolbar_placement, toolbar_width_percent, placement_policy, int toolbar_placement, toolbar_width_percent, placement_policy,
edge_snap_threshold, row_direction, col_direction; edge_snap_threshold, row_direction, col_direction;
bool slit_on_top, slit_auto_hide;
int slit_placement, slit_direction;
unsigned int handle_width, bevel_width, frame_width, border_width; unsigned int handle_width, bevel_width, frame_width, border_width;
#ifdef HAVE_STRFTIME #ifdef HAVE_STRFTIME
@ -170,6 +167,7 @@ private:
#endif // HAVE_STRFTIME #endif // HAVE_STRFTIME
} resource; } resource;
std::string screenstr;
BScreen(const BScreen&); BScreen(const BScreen&);
BScreen& operator=(const BScreen&); BScreen& operator=(const BScreen&);
@ -177,15 +175,13 @@ private:
bool parseMenuFile(FILE *file, Rootmenu *menu); bool parseMenuFile(FILE *file, Rootmenu *menu);
BTexture readDatabaseTexture(const std::string &rname, BTexture readDatabaseTexture(const std::string &rname,
const std::string &rclass, const std::string &default_color,
const std::string &default_color); Configuration &style);
BColor readDatabaseColor(const std::string &rname, BColor readDatabaseColor(const std::string &rname,
const std::string &rclass, const std::string &default_color,
const std::string &default_color); Configuration &style);
XFontSet readDatabaseFontSet(const std::string &rname, XFontSet readDatabaseFontSet(const std::string &rname, Configuration &style);
const std::string &rclass); XFontStruct *readDatabaseFont(const std::string &rname, Configuration &style);
XFontStruct *readDatabaseFont(const std::string &rname,
const std::string &rclass);
XFontSet createFontSet(const std::string &fontname); XFontSet createFontSet(const std::string &fontname);
void InitMenu(void); void InitMenu(void);
@ -204,21 +200,14 @@ public:
BScreen(Blackbox *bb, unsigned int scrn); BScreen(Blackbox *bb, unsigned int scrn);
~BScreen(void); ~BScreen(void);
inline bool isToolbarOnTop(void) const inline bool isSloppyFocus(void) const { return resource.sloppy_focus; }
{ return resource.toolbar_on_top; }
inline bool doToolbarAutoHide(void) const
{ return resource.toolbar_auto_hide; }
inline bool isSloppyFocus(void) const
{ return resource.sloppy_focus; }
inline bool isRootColormapInstalled(void) const inline bool isRootColormapInstalled(void) const
{ return root_colormap_installed; } { return root_colormap_installed; }
inline bool doAutoRaise(void) const { return resource.auto_raise; } inline bool doAutoRaise(void) const { return resource.auto_raise; }
inline bool doClickRaise(void) const { return resource.click_raise; } inline bool doClickRaise(void) const { return resource.click_raise; }
inline bool isScreenManaged(void) const { return managed; } inline bool isScreenManaged(void) const { return managed; }
inline bool doImageDither(void) const inline bool doImageDither(void) const { return image_control->doDither(); }
{ return resource.image_dither; } inline bool doOrderedDither(void) const { return resource.ordered_dither; }
inline bool doOrderedDither(void) const
{ return resource.ordered_dither; }
inline bool doOpaqueMove(void) const { return resource.opaque_move; } inline bool doOpaqueMove(void) const { return resource.opaque_move; }
inline bool doFullMax(void) const { return resource.full_max; } inline bool doFullMax(void) const { return resource.full_max; }
inline bool doFocusNew(void) const { return resource.focus_new; } inline bool doFocusNew(void) const { return resource.focus_new; }
@ -231,19 +220,7 @@ public:
inline BImageControl *getImageControl(void) { return image_control; } inline BImageControl *getImageControl(void) { return image_control; }
inline Rootmenu *getRootmenu(void) { return rootmenu; } inline Rootmenu *getRootmenu(void) { return rootmenu; }
inline bool isSlitOnTop(void) const { return resource.slit_on_top; }
inline bool doSlitAutoHide(void) const
{ return resource.slit_auto_hide; }
inline Slit *getSlit(void) { return slit; } inline Slit *getSlit(void) { return slit; }
inline int getSlitPlacement(void) const
{ return resource.slit_placement; }
inline int getSlitDirection(void) const
{ return resource.slit_direction; }
inline void saveSlitPlacement(int p) { resource.slit_placement = p; }
inline void saveSlitDirection(int d) { resource.slit_direction = d; }
inline void saveSlitOnTop(bool t) { resource.slit_on_top = t; }
inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; }
inline Toolbar *getToolbar(void) { return toolbar; } inline Toolbar *getToolbar(void) { return toolbar; }
Workspace *getWorkspace(unsigned int index); Workspace *getWorkspace(unsigned int index);
@ -268,10 +245,6 @@ public:
inline unsigned int getIconCount(void) { return iconList.size(); } inline unsigned int getIconCount(void) { return iconList.size(); }
inline unsigned int getNumberOfWorkspaces(void) const inline unsigned int getNumberOfWorkspaces(void) const
{ return resource.workspaces; } { return resource.workspaces; }
inline int getToolbarPlacement(void) const
{ return resource.toolbar_placement; }
inline int getToolbarWidthPercent(void) const
{ return resource.toolbar_width_percent; }
inline int getPlacementPolicy(void) const inline int getPlacementPolicy(void) const
{ return resource.placement_policy; } { return resource.placement_policy; }
inline int getEdgeSnapThreshold(void) const inline int getEdgeSnapThreshold(void) const
@ -282,25 +255,19 @@ public:
{ return resource.col_direction; } { return resource.col_direction; }
inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; } inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
inline void saveSloppyFocus(bool s) { resource.sloppy_focus = s; } void saveSloppyFocus(bool s);
inline void saveAutoRaise(bool a) { resource.auto_raise = a; } void saveAutoRaise(bool a);
inline void saveClickRaise(bool c) { resource.click_raise = c; } void saveClickRaise(bool c);
inline void saveWorkspaces(unsigned int w) { resource.workspaces = w; } void saveWorkspaces(unsigned int w);
inline void saveToolbarOnTop(bool r) { resource.toolbar_on_top = r; } void savePlacementPolicy(int p);
inline void saveToolbarAutoHide(bool r) { resource.toolbar_auto_hide = r; } void saveRowPlacementDirection(int d);
inline void saveToolbarWidthPercent(int w) void saveColPlacementDirection(int d);
{ resource.toolbar_width_percent = w; } void saveEdgeSnapThreshold(int t);
inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; } void saveImageDither(bool d);
inline void savePlacementPolicy(int p) { resource.placement_policy = p; } void saveOpaqueMove(bool o);
inline void saveRowPlacementDirection(int d) { resource.row_direction = d; } void saveFullMax(bool f);
inline void saveColPlacementDirection(int d) { resource.col_direction = d; } void saveFocusNew(bool f);
inline void saveEdgeSnapThreshold(int t) void saveFocusLast(bool f);
{ resource.edge_snap_threshold = t; }
inline void saveImageDither(bool d) { resource.image_dither = d; }
inline void saveOpaqueMove(bool o) { resource.opaque_move = o; }
inline void saveFullMax(bool f) { resource.full_max = f; }
inline void saveFocusNew(bool f) { resource.focus_new = f; }
inline void saveFocusLast(bool f) { resource.focus_last = f; }
inline void iconUpdate(void) { iconmenu->update(); } inline void iconUpdate(void) { iconmenu->update(); }
#ifdef HAVE_STRFTIME #ifdef HAVE_STRFTIME
@ -309,9 +276,9 @@ public:
void saveStrftimeFormat(const std::string& format); void saveStrftimeFormat(const std::string& format);
#else // !HAVE_STRFTIME #else // !HAVE_STRFTIME
inline int getDateFormat(void) { return resource.date_format; } inline int getDateFormat(void) { return resource.date_format; }
inline void saveDateFormat(int f) { resource.date_format = f; } inline void saveDateFormat(int f);
inline bool isClock24Hour(void) { return resource.clock24hour; } inline bool isClock24Hour(void) { return resource.clock24hour; }
inline void saveClock24Hour(bool c) { resource.clock24hour = c; } inline void saveClock24Hour(bool c);
#endif // HAVE_STRFTIME #endif // HAVE_STRFTIME
inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; } inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
@ -331,6 +298,7 @@ public:
void addWorkspaceName(const std::string& name); void addWorkspaceName(const std::string& name);
const std::string getNameOfWorkspace(unsigned int id); const std::string getNameOfWorkspace(unsigned int id);
void changeWorkspaceID(unsigned int id); void changeWorkspaceID(unsigned int id);
void saveWorkspaceNames(void);
void addNetizen(Netizen *n); void addNetizen(Netizen *n);
void removeNetizen(Window w); void removeNetizen(Window w);
@ -347,6 +315,8 @@ public:
void prevFocus(void); void prevFocus(void);
void nextFocus(void); void nextFocus(void);
void raiseFocus(void); void raiseFocus(void);
void load_rc(void);
void save_rc(void);
void reconfigure(void); void reconfigure(void);
void toggleFocusModel(FocusModel model); void toggleFocusModel(FocusModel model);
void updateFocusModel(void); void updateFocusModel(void);

View file

@ -40,9 +40,11 @@ extern "C" {
Slit::Slit(BScreen *scr) { Slit::Slit(BScreen *scr) {
screen = scr; screen = scr;
blackbox = screen->getBlackbox(); blackbox = screen->getBlackbox();
slitstr = (std::string)"session.screen" + itostring(screen->getScreenNumber())
+ ".slit.";
config = blackbox->getConfig();
on_top = screen->isSlitOnTop(); load_rc();
hidden = do_auto_hide = screen->doSlitAutoHide();
display = screen->getBaseDisplay()->getXDisplay(); display = screen->getBaseDisplay()->getXDisplay();
frame.window = frame.pixmap = None; frame.window = frame.pixmap = None;
@ -197,6 +199,82 @@ void Slit::removeClient(Window w, bool remap) {
} }
void Slit::saveOnTop(bool b) {
on_top = b;
config->setValue(slitstr + "onTop", on_top);
}
void Slit::saveAutoHide(bool b) {
do_auto_hide = b;
config->setValue(slitstr + "autoHide", do_auto_hide);
}
void Slit::savePlacement(int p) {
placement = p;
const char *pname;
switch (placement) {
case TopLeft: pname = "TopLeft"; break;
case CenterLeft: pname = "CenterLeft"; break;
case BottomLeft: pname = "BottomLeft"; break;
case TopCenter: pname = "TopCenter"; break;
case BottomCenter: pname = "BottomCenter"; break;
case TopRight: pname = "TopRight"; break;
case BottomRight: pname = "BottomRight"; break;
case CenterRight: default: pname = "CenterRight"; break;
}
config->setValue(slitstr + "placement", pname);
}
void Slit::saveDirection(int d) {
direction = d;
config->setValue(slitstr + "direction", (direction == Horizontal ?
"Horizontal" : "Vertical"));
}
void Slit::save_rc(void) {
saveOnTop(on_top);
saveAutoHide(do_auto_hide);
savePlacement(placement);
saveDirection(direction);
}
void Slit::load_rc(void) {
std::string s;
if (! config->getValue(slitstr + "onTop", on_top))
on_top = false;
if (! config->getValue(slitstr + "autoHide", do_auto_hide))
do_auto_hide = false;
hidden = do_auto_hide;
if (config->getValue(slitstr + "direction", s) && s == "Horizontal")
direction = Horizontal;
else
direction = Vertical;
if (config->getValue(slitstr + "placement", s)) {
if (s == "TopLeft")
placement = TopLeft;
else if (s == "CenterLeft")
placement = CenterLeft;
else if (s == "BottomLeft")
placement = BottomLeft;
else if (s == "TopCenter")
placement = TopCenter;
else if (s == "BottomCenter")
placement = BottomCenter;
else if (s == "TopRight")
placement = TopRight;
else if (s == "BottomRight")
placement = BottomRight;
else //if (s == "CenterRight")
placement = CenterRight;
} else
placement = CenterRight;
}
void Slit::reconfigure(void) { void Slit::reconfigure(void) {
SlitClientList::iterator it = clientList.begin(); SlitClientList::iterator it = clientList.begin();
const SlitClientList::iterator end = clientList.end(); const SlitClientList::iterator end = clientList.end();
@ -204,7 +282,7 @@ void Slit::reconfigure(void) {
unsigned int width = 0, height = 0; unsigned int width = 0, height = 0;
switch (screen->getSlitDirection()) { switch (direction) {
case Vertical: case Vertical:
for (; it != end; ++it) { for (; it != end; ++it) {
client = *it; client = *it;
@ -274,7 +352,7 @@ void Slit::reconfigure(void) {
int x, y; int x, y;
switch (screen->getSlitDirection()) { switch (direction) {
case Vertical: case Vertical:
x = 0; x = 0;
y = screen->getBevelWidth(); y = screen->getBevelWidth();
@ -355,9 +433,9 @@ void Slit::updateStrut(void) {
strut.top = strut.bottom = strut.left = strut.right = 0; strut.top = strut.bottom = strut.left = strut.right = 0;
if (! clientList.empty()) { if (! clientList.empty()) {
switch (screen->getSlitDirection()) { switch (direction) {
case Vertical: case Vertical:
switch (screen->getSlitPlacement()) { switch (placement) {
case TopCenter: case TopCenter:
strut.top = getY() + getExposedHeight() + strut.top = getY() + getExposedHeight() +
(screen->getBorderWidth() * 2); (screen->getBorderWidth() * 2);
@ -378,7 +456,7 @@ void Slit::updateStrut(void) {
} }
break; break;
case Horizontal: case Horizontal:
switch (screen->getSlitPlacement()) { switch (placement) {
case TopCenter: case TopCenter:
case TopLeft: case TopLeft:
case TopRight: case TopRight:
@ -408,11 +486,11 @@ void Slit::updateStrut(void) {
void Slit::reposition(void) { void Slit::reposition(void) {
// place the slit in the appropriate place // place the slit in the appropriate place
switch (screen->getSlitPlacement()) { switch (placement) {
case TopLeft: case TopLeft:
frame.rect.setPos(0, 0); frame.rect.setPos(0, 0);
if (screen->getSlitDirection() == Vertical) { if (direction == Vertical) {
frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth() frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth()
- frame.rect.width(); - frame.rect.width();
frame.y_hidden = 0; frame.y_hidden = 0;
@ -435,7 +513,7 @@ void Slit::reposition(void) {
frame.rect.setPos(0, (screen->getHeight() - frame.rect.height() frame.rect.setPos(0, (screen->getHeight() - frame.rect.height()
- (screen->getBorderWidth() * 2))); - (screen->getBorderWidth() * 2)));
if (screen->getSlitDirection() == Vertical) { if (direction == Vertical) {
frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth() frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth()
- frame.rect.width(); - frame.rect.width();
frame.y_hidden = frame.rect.y(); frame.y_hidden = frame.rect.y();
@ -467,7 +545,7 @@ void Slit::reposition(void) {
frame.rect.setPos((screen->getWidth() - frame.rect.width() frame.rect.setPos((screen->getWidth() - frame.rect.width()
- (screen->getBorderWidth() * 2)), 0); - (screen->getBorderWidth() * 2)), 0);
if (screen->getSlitDirection() == Vertical) { if (direction == Vertical) {
frame.x_hidden = screen->getWidth() - screen->getBevelWidth() frame.x_hidden = screen->getWidth() - screen->getBevelWidth()
- screen->getBorderWidth(); - screen->getBorderWidth();
frame.y_hidden = 0; frame.y_hidden = 0;
@ -495,7 +573,7 @@ void Slit::reposition(void) {
(screen->getHeight() - frame.rect.height() (screen->getHeight() - frame.rect.height()
- (screen->getBorderWidth() * 2))); - (screen->getBorderWidth() * 2)));
if (screen->getSlitDirection() == Vertical) { if (direction == Vertical) {
frame.x_hidden = screen->getWidth() - screen->getBevelWidth() frame.x_hidden = screen->getWidth() - screen->getBevelWidth()
- screen->getBorderWidth(); - screen->getBorderWidth();
frame.y_hidden = frame.rect.y(); frame.y_hidden = frame.rect.y();
@ -523,7 +601,7 @@ void Slit::reposition(void) {
delta = -delta; delta = -delta;
} }
frame.rect.setY(frame.rect.y() + delta); frame.rect.setY(frame.rect.y() + delta);
if (screen->getSlitDirection() == Vertical) if (direction == Vertical)
frame.y_hidden += delta; frame.y_hidden += delta;
} }
@ -644,7 +722,7 @@ void Slit::timeout(void) {
void Slit::toggleAutoHide(void) { void Slit::toggleAutoHide(void) {
do_auto_hide = (do_auto_hide) ? False : True; saveAutoHide(do_auto_hide ? False : True);
updateStrut(); updateStrut();
@ -699,8 +777,8 @@ void Slitmenu::itemSelected(int button, unsigned int index) {
switch (item->function()) { switch (item->function()) {
case 1: { // always on top case 1: { // always on top
slit->on_top = ((slit->isOnTop()) ? False : True); slit->saveOnTop(! slit->isOnTop());
setItemSelected(2, slit->on_top); setItemSelected(2, slit->isOnTop());
if (slit->isOnTop()) slit->screen->raiseWindows((Window *) 0, 0); if (slit->isOnTop()) slit->screen->raiseWindows((Window *) 0, 0);
break; break;
@ -708,7 +786,7 @@ void Slitmenu::itemSelected(int button, unsigned int index) {
case 2: { // auto hide case 2: { // auto hide
slit->toggleAutoHide(); slit->toggleAutoHide();
setItemSelected(3, slit->do_auto_hide); setItemSelected(3, slit->doAutoHide());
break; break;
} }
@ -732,7 +810,7 @@ void Slitmenu::reconfigure(void) {
Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm) Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm)
: Basemenu(sm->slit->screen) { : Basemenu(sm->slit->screen), slit(sm->slit) {
setLabel(i18n(SlitSet, SlitSlitDirection, "Slit Direction")); setLabel(i18n(SlitSet, SlitSlitDirection, "Slit Direction"));
setInternalMenu(); setInternalMenu();
@ -743,11 +821,20 @@ Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm)
Slit::Vertical); Slit::Vertical);
update(); update();
setValues();
}
if (getScreen()->getSlitDirection() == Slit::Horizontal)
setItemSelected(0, True); void Slitmenu::Directionmenu::reconfigure(void) {
else setValues();
setItemSelected(1, True); Basemenu::reconfigure();
}
void Slitmenu::Directionmenu::setValues(void) {
const bool horiz = slit->getDirection() == Slit::Horizontal;
setItemSelected(0, horiz);
setItemSelected(1, ! horiz);
} }
@ -758,23 +845,14 @@ void Slitmenu::Directionmenu::itemSelected(int button, unsigned int index) {
BasemenuItem *item = find(index); BasemenuItem *item = find(index);
if (! item) return; if (! item) return;
getScreen()->saveSlitDirection(item->function()); slit->saveDirection(item->function());
if (item->function() == Slit::Horizontal) {
setItemSelected(0, True);
setItemSelected(1, False);
} else {
setItemSelected(0, False);
setItemSelected(1, True);
}
hide(); hide();
getScreen()->getSlit()->reconfigure(); slit->reconfigure();
} }
Slitmenu::Placementmenu::Placementmenu(Slitmenu *sm) Slitmenu::Placementmenu::Placementmenu(Slitmenu *sm)
: Basemenu(sm->slit->screen) { : Basemenu(sm->slit->screen), slit(sm->slit) {
setLabel(i18n(SlitSet, SlitSlitPlacement, "Slit Placement")); setLabel(i18n(SlitSet, SlitSlitPlacement, "Slit Placement"));
setMinimumSublevels(3); setMinimumSublevels(3);
@ -799,6 +877,45 @@ Slitmenu::Placementmenu::Placementmenu(Slitmenu *sm)
Slit::BottomRight); Slit::BottomRight);
update(); update();
setValues();
}
void Slitmenu::Placementmenu::reconfigure(void) {
setValues();
Basemenu::reconfigure();
}
void Slitmenu::Placementmenu::setValues(void) {
int place = 0;
switch (slit->getPlacement()) {
case Slit::BottomRight:
place++;
case Slit::CenterRight:
place++;
case Slit::TopRight:
place++;
case Slit::BottomCenter:
place++;
case Slit::TopCenter:
place++;
case Slit::BottomLeft:
place++;
case Slit::CenterLeft:
place++;
case Slit::TopLeft:
break;
}
setItemSelected(0, 0 == place);
setItemSelected(1, 1 == place);
setItemSelected(2, 2 == place);
setItemSelected(3, 3 == place);
setItemSelected(5, 4 == place);
setItemSelected(6, 5 == place);
setItemSelected(7, 6 == place);
setItemSelected(8, 7 == place);
} }
@ -809,8 +926,8 @@ void Slitmenu::Placementmenu::itemSelected(int button, unsigned int index) {
BasemenuItem *item = find(index); BasemenuItem *item = find(index);
if (! (item && item->function())) return; if (! (item && item->function())) return;
getScreen()->saveSlitPlacement(item->function()); slit->savePlacement(item->function());
hide(); hide();
getScreen()->getSlit()->reconfigure(); slit->reconfigure();
} }

View file

@ -30,6 +30,7 @@ extern "C" {
} }
#include <list> #include <list>
#include <string>
#include "Screen.hh" #include "Screen.hh"
#include "Basemenu.hh" #include "Basemenu.hh"
@ -44,24 +45,30 @@ private:
private: private:
Directionmenu(const Directionmenu&); Directionmenu(const Directionmenu&);
Directionmenu& operator=(const Directionmenu&); Directionmenu& operator=(const Directionmenu&);
Slit *slit;
protected: protected:
virtual void itemSelected(int button, unsigned int index); virtual void itemSelected(int button, unsigned int index);
virtual void setValues(void);
public: public:
Directionmenu(Slitmenu *sm); Directionmenu(Slitmenu *sm);
virtual void reconfigure(void);
}; };
class Placementmenu : public Basemenu { class Placementmenu : public Basemenu {
private: private:
Placementmenu(const Placementmenu&); Placementmenu(const Placementmenu&);
Placementmenu& operator=(const Placementmenu&); Placementmenu& operator=(const Placementmenu&);
Slit *slit;
protected: protected:
virtual void itemSelected(int buton, unsigned int index); virtual void itemSelected(int buton, unsigned int index);
virtual void setValues(void);
public: public:
Placementmenu(Slitmenu *sm); Placementmenu(Slitmenu *sm);
virtual void reconfigure(void);
}; };
Directionmenu *directionmenu; Directionmenu *directionmenu;
@ -103,10 +110,13 @@ private:
typedef std::list<SlitClient*> SlitClientList; typedef std::list<SlitClient*> SlitClientList;
bool on_top, hidden, do_auto_hide; bool on_top, hidden, do_auto_hide;
int direction, placement;
std::string slitstr;
Display *display; Display *display;
Blackbox *blackbox; Blackbox *blackbox;
BScreen *screen; BScreen *screen;
Configuration *config;
BTimer *timer; BTimer *timer;
Strut strut; Strut strut;
@ -137,6 +147,13 @@ public:
inline bool isOnTop(void) const { return on_top; } inline bool isOnTop(void) const { return on_top; }
inline bool isHidden(void) const { return hidden; } inline bool isHidden(void) const { return hidden; }
inline bool doAutoHide(void) const { return do_auto_hide; } inline bool doAutoHide(void) const { return do_auto_hide; }
inline int getPlacement(void) const { return placement; }
inline int getDirection(void) const { return direction; }
void saveOnTop(bool);
void saveAutoHide(bool);
void savePlacement(int);
void saveDirection(int);
inline Slitmenu *getMenu(void) { return slitmenu; } inline Slitmenu *getMenu(void) { return slitmenu; }
@ -149,13 +166,13 @@ public:
inline unsigned int getWidth(void) const { return frame.rect.width(); } inline unsigned int getWidth(void) const { return frame.rect.width(); }
inline unsigned int getExposedWidth(void) const { inline unsigned int getExposedWidth(void) const {
if (screen->getSlitDirection() == Vertical && do_auto_hide) if (direction == Vertical && do_auto_hide)
return screen->getBevelWidth(); return screen->getBevelWidth();
return frame.rect.width(); return frame.rect.width();
} }
inline unsigned int getHeight(void) const { return frame.rect.height(); } inline unsigned int getHeight(void) const { return frame.rect.height(); }
inline unsigned int getExposedHeight(void) const { inline unsigned int getExposedHeight(void) const {
if (screen->getSlitDirection() == Horizontal && do_auto_hide) if (direction == Horizontal && do_auto_hide)
return screen->getBevelWidth(); return screen->getBevelWidth();
return frame.rect.height(); return frame.rect.height();
} }
@ -163,6 +180,8 @@ public:
void addClient(Window w); void addClient(Window w);
void removeClient(SlitClient *client, bool remap = True); void removeClient(SlitClient *client, bool remap = True);
void removeClient(Window w, bool remap = True); void removeClient(Window w, bool remap = True);
void load_rc(void);
void save_rc(void);
void reconfigure(void); void reconfigure(void);
void updateSlit(void); void updateSlit(void);
void reposition(void); void reposition(void);

View file

@ -76,6 +76,11 @@ static long aMinuteFromNow(void) {
Toolbar::Toolbar(BScreen *scrn) { Toolbar::Toolbar(BScreen *scrn) {
screen = scrn; screen = scrn;
blackbox = screen->getBlackbox(); blackbox = screen->getBlackbox();
toolbarstr = (string)"session.screen" + itostring(screen->getScreenNumber())
+ ".toolbar.";
config = blackbox->getConfig();
load_rc();
// get the clock updating every minute // get the clock updating every minute
clock_timer = new BTimer(blackbox, this); clock_timer = new BTimer(blackbox, this);
@ -88,9 +93,6 @@ Toolbar::Toolbar(BScreen *scrn) {
hide_timer = new BTimer(blackbox, &hide_handler); hide_timer = new BTimer(blackbox, &hide_handler);
hide_timer->setTimeout(blackbox->getAutoRaiseDelay()); hide_timer->setTimeout(blackbox->getAutoRaiseDelay());
on_top = screen->isToolbarOnTop();
hidden = do_auto_hide = screen->doToolbarAutoHide();
editing = False; editing = False;
new_name_pos = 0; new_name_pos = 0;
frame.grab_x = frame.grab_y = 0; frame.grab_x = frame.grab_y = 0;
@ -196,9 +198,82 @@ Toolbar::~Toolbar(void) {
} }
void Toolbar::saveOnTop(bool b) {
on_top = b;
config->setValue(toolbarstr + "onTop", on_top);
}
void Toolbar::saveAutoHide(bool b) {
do_auto_hide = b;
config->setValue(toolbarstr + "autoHide", do_auto_hide);
}
void Toolbar::saveWidthPercent(unsigned int w) {
width_percent = w;
config->setValue(toolbarstr + "widthPercent", width_percent);
}
void Toolbar::savePlacement(int p) {
placement = p;
const char *pname;
switch (placement) {
case TopLeft: pname = "TopLeft"; break;
case BottomLeft: pname = "BottomLeft"; break;
case TopCenter: pname = "TopCenter"; break;
case TopRight: pname = "TopRight"; break;
case BottomRight: pname = "BottomRight"; break;
case BottomCenter: default: pname = "BottomCenter"; break;
}
config->setValue(toolbarstr + "placement", pname);
}
void Toolbar::save_rc(void) {
saveOnTop(on_top);
saveAutoHide(do_auto_hide);
saveWidthPercent(width_percent);
savePlacement(placement);
}
void Toolbar::load_rc(void) {
string s;
if (! config->getValue(toolbarstr + "onTop", on_top))
on_top = false;
if (! config->getValue(toolbarstr + "autoHide", do_auto_hide))
do_auto_hide = false;
hidden = do_auto_hide;
if (! config->getValue(toolbarstr + "widthPercent", width_percent) ||
width_percent == 0 || width_percent > 100)
width_percent = 66;
if (config->getValue(toolbarstr + "placement", s)) {
if (s == "TopLeft")
placement = TopLeft;
else if (s == "BottomLeft")
placement = BottomLeft;
else if (s == "TopCenter")
placement = TopCenter;
else if (s == "TopRight")
placement = TopRight;
else if (s == "BottomRight")
placement = BottomRight;
else //if (s == "BottomCenter")
placement = BottomCenter;
} else
placement = BottomCenter;
}
void Toolbar::reconfigure(void) { void Toolbar::reconfigure(void) {
unsigned int height = 0, unsigned int height = 0,
width = (screen->getWidth() * screen->getToolbarWidthPercent()) / 100; width = (screen->getWidth() * width_percent) / 100;
if (i18n.multibyte()) if (i18n.multibyte())
height = screen->getToolbarStyle()->fontset_extents->max_ink_extent.height; height = screen->getToolbarStyle()->fontset_extents->max_ink_extent.height;
@ -215,13 +290,13 @@ void Toolbar::reconfigure(void) {
frame.rect.setSize(width, height); frame.rect.setSize(width, height);
int x, y; int x, y;
switch (screen->getToolbarPlacement()) { switch (placement) {
case TopLeft: case TopLeft:
case TopRight: case TopRight:
case TopCenter: case TopCenter:
if (screen->getToolbarPlacement() == TopLeft) if (placement == TopLeft)
x = 0; x = 0;
else if (screen->getToolbarPlacement() == TopRight) else if (placement == TopRight)
x = screen->getWidth() - frame.rect.width() x = screen->getWidth() - frame.rect.width()
- (screen->getBorderWidth() * 2); - (screen->getBorderWidth() * 2);
else else
@ -238,9 +313,9 @@ void Toolbar::reconfigure(void) {
case BottomRight: case BottomRight:
case BottomCenter: case BottomCenter:
default: default:
if (screen->getToolbarPlacement() == BottomLeft) if (placement == BottomLeft)
x = 0; x = 0;
else if (screen->getToolbarPlacement() == BottomRight) else if (placement == BottomRight)
x = screen->getWidth() - frame.rect.width() x = screen->getWidth() - frame.rect.width()
- (screen->getBorderWidth() * 2); - (screen->getBorderWidth() * 2);
else else
@ -436,7 +511,7 @@ void Toolbar::updateStrut(void) {
// left and right are always 0 // left and right are always 0
strut.top = strut.bottom = 0; strut.top = strut.bottom = 0;
switch(screen->getToolbarPlacement()) { switch(placement) {
case TopLeft: case TopLeft:
case TopCenter: case TopCenter:
case TopRight: case TopRight:
@ -973,7 +1048,7 @@ void Toolbar::HideHandler::timeout(void) {
void Toolbar::toggleAutoHide(void) { void Toolbar::toggleAutoHide(void) {
do_auto_hide = (do_auto_hide) ? False : True; saveAutoHide(! doAutoHide());
updateStrut(); updateStrut();
screen->getSlit()->reposition(); screen->getSlit()->reposition();
@ -1002,9 +1077,13 @@ Toolbarmenu::Toolbarmenu(Toolbar *tb) : Basemenu(tb->screen) {
"Edit current workspace name"), 3); "Edit current workspace name"), 3);
update(); update();
setValues();
}
if (toolbar->isOnTop()) setItemSelected(1, True);
if (toolbar->doAutoHide()) setItemSelected(2, True); void Toolbarmenu::setValues() {
setItemSelected(1, toolbar->isOnTop());
setItemSelected(2, toolbar->doAutoHide());
} }
@ -1022,8 +1101,8 @@ void Toolbarmenu::itemSelected(int button, unsigned int index) {
switch (item->function()) { switch (item->function()) {
case 1: { // always on top case 1: { // always on top
toolbar->on_top = ((toolbar->isOnTop()) ? False : True);; toolbar->saveOnTop(! toolbar->isOnTop());
setItemSelected(1, toolbar->on_top); setItemSelected(1, toolbar->isOnTop());
if (toolbar->isOnTop()) getScreen()->raiseWindows((Window *) 0, 0); if (toolbar->isOnTop()) getScreen()->raiseWindows((Window *) 0, 0);
break; break;
@ -1031,7 +1110,7 @@ void Toolbarmenu::itemSelected(int button, unsigned int index) {
case 2: { // auto hide case 2: { // auto hide
toolbar->toggleAutoHide(); toolbar->toggleAutoHide();
setItemSelected(2, toolbar->do_auto_hide); setItemSelected(2, toolbar->doAutoHide());
break; break;
} }
@ -1054,6 +1133,7 @@ void Toolbarmenu::internal_hide(void) {
void Toolbarmenu::reconfigure(void) { void Toolbarmenu::reconfigure(void) {
setValues();
placementmenu->reconfigure(); placementmenu->reconfigure();
Basemenu::reconfigure(); Basemenu::reconfigure();
@ -1061,7 +1141,7 @@ void Toolbarmenu::reconfigure(void) {
Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu *tm) Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu *tm)
: Basemenu(tm->toolbar->screen) { : Basemenu(tm->toolbar->screen), toolbar(tm->toolbar) {
setLabel(i18n(ToolbarSet, ToolbarToolbarPlacement, "Toolbar Placement")); setLabel(i18n(ToolbarSet, ToolbarToolbarPlacement, "Toolbar Placement"));
setInternalMenu(); setInternalMenu();
setMinimumSublevels(3); setMinimumSublevels(3);
@ -1079,6 +1159,38 @@ Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu *tm)
insert(i18n(CommonSet, CommonPlacementBottomRight, "Bottom Right"), insert(i18n(CommonSet, CommonPlacementBottomRight, "Bottom Right"),
Toolbar::BottomRight); Toolbar::BottomRight);
update(); update();
setValues();
}
void Toolbarmenu::Placementmenu::setValues(void) {
int place = 0;
switch (toolbar->getPlacement()) {
case Toolbar::BottomRight:
place++;
case Toolbar::TopRight:
place++;
case Toolbar::BottomCenter:
place++;
case Toolbar::TopCenter:
place++;
case Toolbar::BottomLeft:
place++;
case Toolbar::TopLeft:
break;
}
setItemSelected(0, 0 == place);
setItemSelected(1, 1 == place);
setItemSelected(2, 2 == place);
setItemSelected(3, 3 == place);
setItemSelected(4, 4 == place);
setItemSelected(5, 5 == place);
}
void Toolbarmenu::Placementmenu::reconfigure(void) {
setValues();
Basemenu::reconfigure();
} }
@ -1089,9 +1201,9 @@ void Toolbarmenu::Placementmenu::itemSelected(int button, unsigned int index) {
BasemenuItem *item = find(index); BasemenuItem *item = find(index);
if (! item) return; if (! item) return;
getScreen()->saveToolbarPlacement(item->function()); toolbar->savePlacement(item->function());
hide(); hide();
getScreen()->getToolbar()->reconfigure(); toolbar->reconfigure();
// reposition the slit as well to make sure it doesn't intersect the // reposition the slit as well to make sure it doesn't intersect the
// toolbar // toolbar

View file

@ -41,12 +41,15 @@ private:
private: private:
Placementmenu(const Placementmenu&); Placementmenu(const Placementmenu&);
Placementmenu& operator=(const Placementmenu&); Placementmenu& operator=(const Placementmenu&);
Toolbar *toolbar;
protected: protected:
virtual void itemSelected(int button, unsigned int index); virtual void itemSelected(int button, unsigned int index);
virtual void setValues(void);
public: public:
Placementmenu(Toolbarmenu *tm); Placementmenu(Toolbarmenu *tm);
virtual void reconfigure(void);
}; };
Toolbar *toolbar; Toolbar *toolbar;
@ -61,6 +64,7 @@ private:
protected: protected:
virtual void itemSelected(int button, unsigned int index); virtual void itemSelected(int button, unsigned int index);
virtual void internal_hide(void); virtual void internal_hide(void);
virtual void setValues(void);
public: public:
Toolbarmenu(Toolbar *tb); Toolbarmenu(Toolbar *tb);
@ -68,13 +72,16 @@ public:
inline Basemenu *getPlacementmenu(void) { return placementmenu; } inline Basemenu *getPlacementmenu(void) { return placementmenu; }
void reconfigure(void); virtual void reconfigure(void);
}; };
class Toolbar : public TimeoutHandler { class Toolbar : public TimeoutHandler {
private: private:
bool on_top, editing, hidden, do_auto_hide; bool on_top, editing, hidden, do_auto_hide;
unsigned int width_percent;
int placement;
std::string toolbarstr;
Display *display; Display *display;
struct ToolbarFrame { struct ToolbarFrame {
@ -99,6 +106,7 @@ private:
Blackbox *blackbox; Blackbox *blackbox;
BScreen *screen; BScreen *screen;
Configuration *config;
BTimer *clock_timer, *hide_timer; BTimer *clock_timer, *hide_timer;
Toolbarmenu *toolbarmenu; Toolbarmenu *toolbarmenu;
Strut strut; Strut strut;
@ -136,6 +144,16 @@ public:
inline bool isOnTop(void) const { return on_top; } inline bool isOnTop(void) const { return on_top; }
inline bool isHidden(void) const { return hidden; } inline bool isHidden(void) const { return hidden; }
inline bool doAutoHide(void) const { return do_auto_hide; } inline bool doAutoHide(void) const { return do_auto_hide; }
inline unsigned int getWidthPercent(void) const { return width_percent; }
inline int getPlacement(void) const { return placement; }
void saveOnTop(bool);
void saveAutoHide(bool);
void saveWidthPercent(unsigned int);
void savePlacement(int);
void save_rc(void);
void load_rc(void);
inline Window getWindowID(void) const { return frame.window; } inline Window getWindowID(void) const { return frame.window; }

View file

@ -220,3 +220,24 @@ timeval normalizeTimeval(const timeval &tm) {
return ret; return ret;
} }
string itostring(unsigned long i) {
if (i == 0)
return string("0");
string tmp;
for (; i > 0; i /= 10)
tmp.insert(tmp.begin(), "0123456789"[i%10]);
return tmp;
}
string itostring(long i) {
if (i < 0) {
std::string tmp = itostring( (unsigned long) -i);
tmp.insert(tmp.begin(), '-');
return tmp;
} else
return itostring( (unsigned long) i);
}

View file

@ -99,4 +99,13 @@ struct PointerAssassin {
} }
}; };
std::string itostring(unsigned long i);
std::string itostring(long i);
inline std::string itostring(unsigned int i) {
return itostring((unsigned long) i);
}
inline std::string itostring(int i) {
return itostring((long) i);
}
#endif #endif

View file

@ -28,7 +28,6 @@
extern "C" { extern "C" {
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xresource.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
#include <X11/keysym.h> #include <X11/keysym.h>
@ -146,6 +145,7 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc, char *menu)
argv = m_argv; argv = m_argv;
if (! rc) rc = "~/.openbox/rc"; if (! rc) rc = "~/.openbox/rc";
rc_file = expandTilde(rc); rc_file = expandTilde(rc);
config.setFile(rc_file);
if (! menu) menu = "~/.openbox/menu"; if (! menu) menu = "~/.openbox/menu";
menu_file = expandTilde(menu); menu_file = expandTilde(menu);
@ -184,6 +184,9 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc, char *menu)
::exit(3); ::exit(3);
} }
// save current settings and default values
save_rc();
// set the screen with mouse to the first managed screen // set the screen with mouse to the first managed screen
active_screen = screenList.front(); active_screen = screenList.front();
setFocusedWindow(0); setFocusedWindow(0);
@ -716,11 +719,8 @@ void Blackbox::process_event(XEvent *e) {
bool Blackbox::handleSignal(int sig) { bool Blackbox::handleSignal(int sig) {
switch (sig) { switch (sig) {
case SIGHUP: case SIGHUP:
reconfigure();
break;
case SIGUSR1: case SIGUSR1:
reload_rc(); reconfigure();
break; break;
case SIGUSR2: case SIGUSR2:
@ -969,546 +969,69 @@ void Blackbox::shutdown(void) {
std::mem_fun(&BScreen::shutdown)); std::mem_fun(&BScreen::shutdown));
XSync(getXDisplay(), False); XSync(getXDisplay(), False);
save_rc();
} }
/*
* Save all values as they are so that the defaults will be written to the rc
* file
*/
void Blackbox::save_rc(void) { void Blackbox::save_rc(void) {
XrmDatabase new_blackboxrc = (XrmDatabase) 0; config.setAutoSave(false);
char rc_string[1024];
load_rc(); config.setValue("session.colorsPerChannel", resource.colors_per_channel);
config.setValue("session.doubleClickInterval",
sprintf(rc_string, "session.colorsPerChannel: %d",
resource.colors_per_channel);
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.doubleClickInterval: %lu",
resource.double_click_interval); resource.double_click_interval);
XrmPutLineResource(&new_blackboxrc, rc_string); config.setValue("session.autoRaiseDelay",
sprintf(rc_string, "session.autoRaiseDelay: %lu",
((resource.auto_raise_delay.tv_sec * 1000) + ((resource.auto_raise_delay.tv_sec * 1000) +
(resource.auto_raise_delay.tv_usec / 1000))); (resource.auto_raise_delay.tv_usec / 1000)));
XrmPutLineResource(&new_blackboxrc, rc_string); config.setValue("session.cacheLife", resource.cache_life / 60000);
config.setValue("session.cacheMax", resource.cache_max);
config.setValue("session.styleFile", resource.style_file);
sprintf(rc_string, "session.cacheLife: %lu", resource.cache_life / 60000); std::for_each(screenList.begin(), screenList.end(),
XrmPutLineResource(&new_blackboxrc, rc_string); std::mem_fun(&BScreen::save_rc));
sprintf(rc_string, "session.cacheMax: %lu", resource.cache_max); config.setAutoSave(true);
XrmPutLineResource(&new_blackboxrc, rc_string); config.save();
ScreenList::iterator it = screenList.begin();
for (; it != screenList.end(); ++it) {
BScreen *screen = *it;
int screen_number = screen->getScreenNumber();
char *placement = (char *) 0;
switch (screen->getSlitPlacement()) {
case Slit::TopLeft: placement = "TopLeft"; break;
case Slit::CenterLeft: placement = "CenterLeft"; break;
case Slit::BottomLeft: placement = "BottomLeft"; break;
case Slit::TopCenter: placement = "TopCenter"; break;
case Slit::BottomCenter: placement = "BottomCenter"; break;
case Slit::TopRight: placement = "TopRight"; break;
case Slit::BottomRight: placement = "BottomRight"; break;
case Slit::CenterRight: default: placement = "CenterRight"; break;
}
sprintf(rc_string, "session.screen%d.slit.placement: %s", screen_number,
placement);
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.slit.direction: %s", screen_number,
((screen->getSlitDirection() == Slit::Horizontal) ? "Horizontal" :
"Vertical"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.slit.onTop: %s", screen_number,
((screen->getSlit()->isOnTop()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.slit.autoHide: %s", screen_number,
((screen->getSlit()->doAutoHide()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.opaqueMove: %s",
((screen->doOpaqueMove()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.imageDither: %s",
((screen->getImageControl()->doDither()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.fullMaximization: %s", screen_number,
((screen->doFullMax()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.focusNewWindows: %s", screen_number,
((screen->doFocusNew()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.focusLastWindow: %s", screen_number,
((screen->doFocusLast()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s",
screen_number,
((screen->getRowPlacementDirection() == BScreen::LeftRight) ?
"LeftToRight" : "RightToLeft"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.colPlacementDirection: %s",
screen_number,
((screen->getColPlacementDirection() == BScreen::TopBottom) ?
"TopToBottom" : "BottomToTop"));
XrmPutLineResource(&new_blackboxrc, rc_string);
switch (screen->getPlacementPolicy()) {
case BScreen::CascadePlacement:
placement = "CascadePlacement";
break;
case BScreen::ColSmartPlacement:
placement = "ColSmartPlacement";
break;
case BScreen::RowSmartPlacement:
default:
placement = "RowSmartPlacement";
break;
}
sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number,
placement);
XrmPutLineResource(&new_blackboxrc, rc_string);
string fmodel;
if (screen->isSloppyFocus()) {
fmodel = "SloppyFocus";
if (screen->doAutoRaise()) fmodel += " AutoRaise";
if (screen->doClickRaise()) fmodel += " ClickRaise";
} else {
fmodel = "ClickToFocus";
}
sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number,
fmodel.c_str());
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.workspaces: %d", screen_number,
screen->getWorkspaceCount());
XrmPutLineResource(&new_blackboxrc, rc_string);
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,
((screen->getToolbar()->doAutoHide()) ? "True" : "False"));
XrmPutLineResource(&new_blackboxrc, rc_string);
switch (screen->getToolbarPlacement()) {
case Toolbar::TopLeft: placement = "TopLeft"; break;
case Toolbar::BottomLeft: placement = "BottomLeft"; break;
case Toolbar::TopCenter: placement = "TopCenter"; break;
case Toolbar::TopRight: placement = "TopRight"; break;
case Toolbar::BottomRight: placement = "BottomRight"; break;
case Toolbar::BottomCenter: default: placement = "BottomCenter"; break;
}
sprintf(rc_string, "session.screen%d.toolbar.placement: %s",
screen_number, placement);
XrmPutLineResource(&new_blackboxrc, rc_string);
load_rc(screen);
// these are static, but may not be saved in the users .blackboxrc,
// 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
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,
((screen->getDateFormat() == B_EuropeanDate) ?
"European" : "American"));
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.clockFormat: %d", screen_number,
((screen->isClock24Hour()) ? 24 : 12));
XrmPutLineResource(&new_blackboxrc, rc_string);
#endif // HAVE_STRFTIME
sprintf(rc_string, "session.screen%d.edgeSnapThreshold: %d",
screen_number, screen->getEdgeSnapThreshold());
XrmPutLineResource(&new_blackboxrc, rc_string);
sprintf(rc_string, "session.screen%d.toolbar.widthPercent: %d",
screen_number, screen->getToolbarWidthPercent());
XrmPutLineResource(&new_blackboxrc, rc_string);
// write out the user's workspace names
string save_string = screen->getWorkspace(0)->getName();
for (unsigned int i = 1; i < screen->getWorkspaceCount(); ++i) {
save_string += ',';
save_string += screen->getWorkspace(i)->getName();
}
char *resource_string = new char[save_string.length() + 48];
sprintf(resource_string, "session.screen%d.workspaceNames: %s",
screen_number, save_string.c_str());
XrmPutLineResource(&new_blackboxrc, resource_string);
delete [] resource_string;
}
XrmDatabase old_blackboxrc = XrmGetFileDatabase(rc_file.c_str());
XrmMergeDatabases(new_blackboxrc, &old_blackboxrc);
XrmPutFileDatabase(old_blackboxrc, rc_file.c_str());
XrmDestroyDatabase(old_blackboxrc);
} }
void Blackbox::load_rc(void) { void Blackbox::load_rc(void) {
XrmDatabase database = (XrmDatabase) 0; if (! config.load())
config.create();
database = XrmGetFileDatabase(rc_file.c_str()); string s;
XrmValue value;
char *value_type;
int int_value;
unsigned long long_value;
if (! config.getValue("session.colorsPerChannel",
resource.colors_per_channel))
resource.colors_per_channel = 4; resource.colors_per_channel = 4;
if (XrmGetResource(database, "session.colorsPerChannel",
"Session.ColorsPerChannel", &value_type, &value) &&
sscanf(value.addr, "%d", &int_value) == 1) {
resource.colors_per_channel = int_value;
if (resource.colors_per_channel < 2) resource.colors_per_channel = 2; if (resource.colors_per_channel < 2) resource.colors_per_channel = 2;
if (resource.colors_per_channel > 6) resource.colors_per_channel = 6; else if (resource.colors_per_channel > 6) resource.colors_per_channel = 6;
}
if (XrmGetResource(database, "session.styleFile", "Session.StyleFile", if (config.getValue("session.styleFile", s))
&value_type, &value)) resource.style_file = expandTilde(s);
resource.style_file = expandTilde(value.addr);
else else
resource.style_file = DEFAULTSTYLE; resource.style_file = DEFAULTSTYLE;
if (! config.getValue("session.doubleClickInterval",
resource.double_click_interval));
resource.double_click_interval = 250; resource.double_click_interval = 250;
if (XrmGetResource(database, "session.doubleClickInterval",
"Session.DoubleClickInterval", &value_type, &value) &&
sscanf(value.addr, "%lu", &long_value) == 1) {
resource.double_click_interval = long_value;
}
if (! config.getValue("session.autoRaiseDelay",
resource.auto_raise_delay.tv_usec))
resource.auto_raise_delay.tv_usec = 400; resource.auto_raise_delay.tv_usec = 400;
if (XrmGetResource(database, "session.autoRaiseDelay",
"Session.AutoRaiseDelay", &value_type, &value) &&
sscanf(value.addr, "%lu", &long_value) == 1) {
resource.auto_raise_delay.tv_usec = long_value;
}
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec / 1000; resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec / 1000;
resource.auto_raise_delay.tv_usec -= resource.auto_raise_delay.tv_usec -=
(resource.auto_raise_delay.tv_sec * 1000); (resource.auto_raise_delay.tv_sec * 1000);
resource.auto_raise_delay.tv_usec *= 1000; resource.auto_raise_delay.tv_usec *= 1000;
resource.cache_life = 5l; if (! config.getValue("session.cacheLife", resource.cache_life))
if (XrmGetResource(database, "session.cacheLife", "Session.CacheLife", resource.cache_life = 5;
&value_type, &value) &&
sscanf(value.addr, "%lu", &long_value) == 1) {
resource.cache_life = long_value;
}
resource.cache_life *= 60000; resource.cache_life *= 60000;
if (! config.getValue("session.cacheMax", resource.cache_max))
resource.cache_max = 200; resource.cache_max = 200;
if (XrmGetResource(database, "session.cacheMax", "Session.CacheMax",
&value_type, &value) &&
sscanf(value.addr, "%lu", &long_value) == 1) {
resource.cache_max = long_value;
}
}
void Blackbox::load_rc(BScreen *screen) {
XrmDatabase database = (XrmDatabase) 0;
database = XrmGetFileDatabase(rc_file.c_str());
XrmValue value;
char *value_type, name_lookup[1024], class_lookup[1024];
int screen_number = screen->getScreenNumber();
int int_value;
sprintf(name_lookup, "session.screen%d.fullMaximization", screen_number);
sprintf(class_lookup, "Session.Screen%d.FullMaximization", screen_number);
screen->saveFullMax(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "true", value.size)) {
screen->saveFullMax(True);
}
sprintf(name_lookup, "session.screen%d.focusNewWindows", screen_number);
sprintf(class_lookup, "Session.Screen%d.FocusNewWindows", screen_number);
screen->saveFocusNew(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "true", value.size)) {
screen->saveFocusNew(True);
}
sprintf(name_lookup, "session.screen%d.focusLastWindow", screen_number);
sprintf(class_lookup, "Session.Screen%d.focusLastWindow", screen_number);
screen->saveFocusLast(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "true", value.size)) {
screen->saveFocusLast(True);
}
sprintf(name_lookup, "session.screen%d.rowPlacementDirection",
screen_number);
sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection",
screen_number);
screen->saveRowPlacementDirection(BScreen::LeftRight);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "righttoleft", value.size)) {
screen->saveRowPlacementDirection(BScreen::RightLeft);
}
sprintf(name_lookup, "session.screen%d.colPlacementDirection",
screen_number);
sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection",
screen_number);
screen->saveColPlacementDirection(BScreen::TopBottom);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "bottomtotop", value.size)) {
screen->saveColPlacementDirection(BScreen::BottomTop);
}
sprintf(name_lookup, "session.screen%d.workspaces", screen_number);
sprintf(class_lookup, "Session.Screen%d.Workspaces", screen_number);
screen->saveWorkspaces(1);
if (XrmGetResource(database, name_lookup, class_lookup,
&value_type, &value) &&
sscanf(value.addr, "%d", &int_value) == 1 &&
int_value > 0 && int_value < 128) {
screen->saveWorkspaces(int_value);
}
sprintf(name_lookup, "session.screen%d.toolbar.widthPercent",
screen_number);
sprintf(class_lookup, "Session.Screen%d.Toolbar.WidthPercent",
screen_number);
screen->saveToolbarWidthPercent(66);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
sscanf(value.addr, "%d", &int_value) == 1 &&
int_value > 0 && int_value <= 100) {
screen->saveToolbarWidthPercent(int_value);
}
sprintf(name_lookup, "session.screen%d.toolbar.placement", screen_number);
sprintf(class_lookup, "Session.Screen%d.Toolbar.Placement", screen_number);
screen->saveToolbarPlacement(Toolbar::BottomCenter);
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);
}
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)) {
string search = value.addr;
string::const_iterator it = search.begin(),
end = search.end();
while (1) {
string::const_iterator tmp = it; // current string.begin()
it = std::find(tmp, end, ','); // look for comma between tmp and end
screen->addWorkspaceName(string(tmp, it)); // string = search[tmp:it]
if (it == end) break;
++it;
}
}
sprintf(name_lookup, "session.screen%d.toolbar.onTop", screen_number);
sprintf(class_lookup, "Session.Screen%d.Toolbar.OnTop", screen_number);
screen->saveToolbarOnTop(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "true", value.size)) {
screen->saveToolbarOnTop(True);
}
sprintf(name_lookup, "session.screen%d.toolbar.autoHide", screen_number);
sprintf(class_lookup, "Session.Screen%d.Toolbar.autoHide", screen_number);
screen->saveToolbarAutoHide(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "true", value.size)) {
screen->saveToolbarAutoHide(True);
}
sprintf(name_lookup, "session.screen%d.focusModel", screen_number);
sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number);
screen->saveSloppyFocus(True);
screen->saveAutoRaise(False);
screen->saveClickRaise(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value)) {
string fmodel = value.addr;
if (fmodel.find("ClickToFocus") != string::npos) {
screen->saveSloppyFocus(False);
} else {
// must be sloppy
if (fmodel.find("AutoRaise") != string::npos)
screen->saveAutoRaise(True);
if (fmodel.find("ClickRaise") != string::npos)
screen->saveClickRaise(True);
}
}
sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number);
sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number);
screen->savePlacementPolicy(BScreen::RowSmartPlacement);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value)) {
if (! strncasecmp(value.addr, "RowSmartPlacement", value.size))
/* pass */;
else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size))
screen->savePlacementPolicy(BScreen::ColSmartPlacement);
else if (! strncasecmp(value.addr, "CascadePlacement", value.size))
screen->savePlacementPolicy(BScreen::CascadePlacement);
}
sprintf(name_lookup, "session.screen%d.slit.placement", screen_number);
sprintf(class_lookup, "Session.Screen%d.Slit.Placement", screen_number);
screen->saveSlitPlacement(Slit::CenterRight);
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);
}
sprintf(name_lookup, "session.screen%d.slit.direction", screen_number);
sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number);
screen->saveSlitDirection(Slit::Vertical);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "Horizontal", value.size)) {
screen->saveSlitDirection(Slit::Horizontal);
}
sprintf(name_lookup, "session.screen%d.slit.onTop", screen_number);
sprintf(class_lookup, "Session.Screen%d.Slit.OnTop", screen_number);
screen->saveSlitOnTop(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "True", value.size)) {
screen->saveSlitOnTop(True);
}
sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number);
sprintf(class_lookup, "Session.Screen%d.Slit.AutoHide", screen_number);
screen->saveSlitAutoHide(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
! strncasecmp(value.addr, "true", value.size)) {
screen->saveSlitAutoHide(True);
}
#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);
screen->saveDateFormat(B_AmericanDate);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value)) {
if (! strncasecmp(value.addr, "european", value.size))
screen->saveDateFormat(B_EuropeanDate);
}
sprintf(name_lookup, "session.screen%d.clockFormat", screen_number);
sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number);
screen->saveClock24Hour(False);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value) &&
sscanf(value.addr, "%d", &int_value) == 1 && int_value == 24) {
screen->saveClock24Hour(True);
}
#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) &&
sscanf(value.addr, "%d", &int_value) == 1) {
screen->saveEdgeSnapThreshold(int_value);
}
screen->saveImageDither(True);
if (XrmGetResource(database, "session.imageDither", "Session.ImageDither",
&value_type, &value) &&
! strncasecmp("false", value.addr, value.size)) {
screen->saveImageDither(False);
}
screen->saveOpaqueMove(False);
if (XrmGetResource(database, "session.opaqueMove", "Session.OpaqueMove",
&value_type, &value) &&
! strncasecmp("true", value.addr, value.size)) {
screen->saveOpaqueMove(True);
}
XrmDestroyDatabase(database);
}
void Blackbox::reload_rc(void) {
load_rc();
reconfigure();
} }
@ -1520,19 +1043,7 @@ void Blackbox::reconfigure(void) {
void Blackbox::real_reconfigure(void) { void Blackbox::real_reconfigure(void) {
XrmDatabase new_blackboxrc = (XrmDatabase) 0; load_rc();
char *style = new char[resource.style_file.length() + 20];
sprintf(style, "session.styleFile: %s", getStyleFilename());
XrmPutLineResource(&new_blackboxrc, style);
delete [] style;
XrmDatabase old_blackboxrc = XrmGetFileDatabase(rc_file.c_str());
XrmMergeDatabases(new_blackboxrc, &old_blackboxrc);
XrmPutFileDatabase(old_blackboxrc, rc_file.c_str());
if (old_blackboxrc) XrmDestroyDatabase(old_blackboxrc);
std::for_each(menuTimestamps.begin(), menuTimestamps.end(), std::for_each(menuTimestamps.begin(), menuTimestamps.end(),
PointerAssassin()); PointerAssassin());
@ -1584,6 +1095,7 @@ void Blackbox::real_rereadMenu(void) {
void Blackbox::saveStyleFilename(const string& filename) { void Blackbox::saveStyleFilename(const string& filename) {
assert(! filename.empty()); assert(! filename.empty());
resource.style_file = filename; resource.style_file = filename;
config.setValue("session.styleFile", resource.style_file);
} }

View file

@ -26,7 +26,6 @@
extern "C" { extern "C" {
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xresource.h>
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
# include <stdio.h> # include <stdio.h>
@ -50,6 +49,7 @@ extern "C" {
#include "i18n.hh" #include "i18n.hh"
#include "BaseDisplay.hh" #include "BaseDisplay.hh"
#include "Configuration.hh"
#include "Timer.hh" #include "Timer.hh"
#define AttribShaded (1l << 0) #define AttribShaded (1l << 0)
@ -144,6 +144,7 @@ private:
BScreen *active_screen; BScreen *active_screen;
BlackboxWindow *focused_window; BlackboxWindow *focused_window;
BTimer *timer; BTimer *timer;
Configuration config;
bool no_focus, reconfigure_wait, reread_menu_wait; bool no_focus, reconfigure_wait, reread_menu_wait;
Time last_time; Time last_time;
@ -195,7 +196,6 @@ private:
void load_rc(void); void load_rc(void);
void save_rc(void); void save_rc(void);
void reload_rc(void);
void real_rereadMenu(void); void real_rereadMenu(void);
void real_reconfigure(void); void real_reconfigure(void);
@ -228,6 +228,7 @@ public:
inline BlackboxWindow *getFocusedWindow(void) { return focused_window; } inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
inline Configuration *getConfig() { return &config; }
inline const Time &getDoubleClickInterval(void) const inline const Time &getDoubleClickInterval(void) const
{ return resource.double_click_interval; } { return resource.double_click_interval; }
inline const Time &getLastTime(void) const { return last_time; } inline const Time &getLastTime(void) const { return last_time; }
@ -261,7 +262,6 @@ public:
void setFocusedWindow(BlackboxWindow *w); void setFocusedWindow(BlackboxWindow *w);
void shutdown(void); void shutdown(void);
void load_rc(BScreen *screen);
void saveStyleFilename(const std::string& filename); void saveStyleFilename(const std::string& filename);
void addMenuTimestamp(const std::string& filename); void addMenuTimestamp(const std::string& filename);
void restart(const char *prog = 0); void restart(const char *prog = 0);