#include <strstream>
#include <string>
#include <algorithm>
-using namespace std;
+#include <functional>
+using std::ends;
static Bool running = True;
slit = NULL;
#endif // SLIT
toolbar = NULL;
+ current_workspace = (Workspace *) 0;
#ifdef HAVE_GETPID
pid_t bpid = getpid();
XDefineCursor(getBaseDisplay().getXDisplay(), getRootWindow(),
openbox.getSessionCursor());
- workspaceNames = new LinkedList<char>;
- workspacesList = new LinkedList<Workspace>;
- iconList = new LinkedList<OpenboxWindow>;
-
image_control =
new BImageControl(openbox, *this, True, openbox.getColorsPerChannel(),
openbox.getCacheLife(), openbox.getCacheMax());
Workspace *wkspc = NULL;
if (resource.workspaces != 0) {
for (int i = 0; i < resource.workspaces; ++i) {
- wkspc = new Workspace(*this, workspacesList->count());
- workspacesList->insert(wkspc);
+ wkspc = new Workspace(*this, workspacesList.size());
+ workspacesList.push_back(wkspc);
workspacemenu->insert(wkspc->getName(), wkspc->getMenu());
}
} else {
- wkspc = new Workspace(*this, workspacesList->count());
- workspacesList->insert(wkspc);
+ setWorkspaceCount(1);
+ wkspc = new Workspace(*this, workspacesList.size());
+ workspacesList.push_back(wkspc);
workspacemenu->insert(wkspc->getName(), wkspc->getMenu());
}
saveWorkspaceNames();
iconmenu);
workspacemenu->update();
- current_workspace = workspacesList->first();
+ current_workspace = workspacesList.front();
workspacemenu->setItemSelected(2, True);
toolbar = new Toolbar(*this, config);
}
}
- XSetInputFocus(getBaseDisplay().getXDisplay(),
- PointerRoot, None, CurrentTime);
-
XFree(children);
XFlush(getBaseDisplay().getXDisplay());
}
removeWorkspaceNames();
- while (workspacesList->count())
- delete workspacesList->remove(0);
-
- while (!rootmenuList.empty())
- rootmenuList.erase(rootmenuList.begin());
-
- while (iconList->count())
- delete iconList->remove(0);
-
- while (!netizenList.empty())
- netizenList.erase(netizenList.begin());
+ std::for_each(workspacesList.begin(), workspacesList.end(),
+ PointerAssassin());
+ std::for_each(iconList.begin(), iconList.end(), PointerAssassin());
+ std::for_each(netizenList.begin(), netizenList.end(), PointerAssassin());
#ifdef HAVE_STRFTIME
if (resource.strftime_format)
delete toolbar;
delete image_control;
- delete workspacesList;
- delete workspaceNames;
- delete iconList;
-
if (resource.wstyle.fontset)
XFreeFontSet(getBaseDisplay().getXDisplay(), resource.wstyle.fontset);
if (resource.mstyle.t_fontset)
#ifdef SLIT
int slit_x = slit->autoHide() ? slit->hiddenOrigin().x() : slit->area().x(),
slit_y = slit->autoHide() ? slit->hiddenOrigin().y() : slit->area().y();
- int tbarh = resource.hide_toolbar ? 0 :
+ unsigned int tbarh = resource.hide_toolbar ? 0 :
toolbar->getExposedHeight() + resource.border_width * 2;
bool tbartop;
switch (toolbar->placement()) {
void BScreen::setSloppyFocus(bool b) {
resource.sloppy_focus = b;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
config.setValue(s.str(),
(resource.sloppy_focus ?
void BScreen::setAutoRaise(bool a) {
resource.auto_raise = a;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
config.setValue(s.str(),
(resource.sloppy_focus ?
void BScreen::setImageDither(bool d, bool reconfig) {
image_control->setDither(d);
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".imageDither" << ends;
config.setValue(s.str(), imageDither());
if (reconfig)
void BScreen::setOpaqueMove(bool o) {
resource.opaque_move = o;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends;
config.setValue(s.str(), resource.opaque_move);
s.rdbuf()->freeze(0);
void BScreen::setFullMax(bool f) {
resource.full_max = f;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends;
config.setValue(s.str(), resource.full_max);
s.rdbuf()->freeze(0);
void BScreen::setFocusNew(bool f) {
resource.focus_new = f;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends;
config.setValue(s.str(), resource.focus_new);
s.rdbuf()->freeze(0);
void BScreen::setFocusLast(bool f) {
resource.focus_last = f;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends;
config.setValue(s.str(), resource.focus_last);
s.rdbuf()->freeze(0);
void BScreen::setWindowZones(int z) {
resource.zones = z;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".windowZones" << ends;
config.setValue(s.str(), resource.zones);
s.rdbuf()->freeze(0);
void BScreen::setWorkspaceCount(int w) {
resource.workspaces = w;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".workspaces" << ends;
config.setValue(s.str(), resource.workspaces);
s.rdbuf()->freeze(0);
void BScreen::setPlacementPolicy(int p) {
resource.placement_policy = p;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".windowPlacement" << ends;
const char *placement;
switch (resource.placement_policy) {
void BScreen::setEdgeSnapThreshold(int t) {
resource.edge_snap_threshold = t;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".edgeSnapThreshold" << ends;
config.setValue(s.str(), resource.edge_snap_threshold);
s.rdbuf()->freeze(0);
void BScreen::setRowPlacementDirection(int d) {
resource.row_direction = d;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".rowPlacementDirection" << ends;
config.setValue(s.str(),
resource.row_direction == LeftRight ?
void BScreen::setColPlacementDirection(int d) {
resource.col_direction = d;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".colPlacementDirection" << ends;
config.setValue(s.str(),
resource.col_direction == TopBottom ?
delete [] resource.strftime_format;
resource.strftime_format = bstrdup(f);
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends;
config.setValue(s.str(), resource.strftime_format);
s.rdbuf()->freeze(0);
}
#else // !HAVE_STRFTIME
+
void BScreen::setDateFormat(int f) {
resource.date_format = f;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".dateFormat" << ends;
config.setValue(s.str(), resource.date_format == B_EuropeanDate ?
"European" : "American");
s.rdbuf()->freeze(0);
}
+
void BScreen::setClock24Hour(Bool c) {
resource.clock24hour = c;
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".clockFormat" << ends;
config.setValue(s.str(), resource.clock24hour ? 24 : 12);
s.rdbuf()->freeze(0);
}
#endif // HAVE_STRFTIME
+
void BScreen::setHideToolbar(bool b) {
resource.hide_toolbar = b;
if (resource.hide_toolbar)
getToolbar()->unMapToolbar();
else
getToolbar()->mapToolbar();
- ostrstream s;
+ std::ostrstream s;
s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends;
config.setValue(s.str(), resource.hide_toolbar ? "True" : "False");
s.rdbuf()->freeze(0);
}
+
void BScreen::saveWorkspaceNames() {
- ostrstream rc, names;
-
- for (int i = 0; i < resource.workspaces; i++) {
- Workspace *w = getWorkspace(i);
- if (w != NULL) {
- names << w->getName();
- if (i < resource.workspaces-1)
- names << ",";
- }
+ std::ostrstream rc, names;
+
+ wkspList::iterator it;
+ wkspList::iterator last = workspacesList.end() - 1;
+ for (it = workspacesList.begin(); it != workspacesList.end(); ++it) {
+ names << (*it)->getName();
+ if (it != last)
+ names << ",";
}
names << ends;
setClock24Hour(resource.clock24hour);
#endif // HAVE_STRFTIME
setHideToolbar(resource.hide_toolbar);
+
+ toolbar->save();
+#ifdef SLIT
+ slit->save();
+#endif // SLIT
}
void BScreen::load() {
- ostrstream rscreen, rname, rclass;
+ std::ostrstream rscreen, rname, rclass;
std::string s;
bool b;
long l;
rname << rscreen.str() << "workspaceNames" << ends;
rclass << rscreen.str() << "WorkspaceNames" << ends;
if (config.getValue(rname.str(), rclass.str(), s)) {
- string::const_iterator it = s.begin(), end = s.end();
+ std::string::const_iterator it = s.begin(), end = s.end();
while(1) {
- string::const_iterator tmp = it;// current string.begin()
+ std::string::const_iterator tmp = it;// current string.begin()
it = std::find(tmp, end, ','); // look for comma between tmp and end
std::string name(tmp, it); // name = s[tmp:it]
addWorkspaceName(name.c_str());
slit->reconfigure();
#endif // SLIT
- LinkedListIterator<Workspace> wit(workspacesList);
- for (Workspace *w = wit.current(); w; wit++, w = wit.current())
- w->reconfigure();
+ std::for_each(workspacesList.begin(), workspacesList.end(),
+ std::mem_fun(&Workspace::reconfigure));
- LinkedListIterator<OpenboxWindow> iit(iconList);
- for (OpenboxWindow *bw = iit.current(); bw; iit++, bw = iit.current())
- if (bw->validateClient())
- bw->reconfigure();
+ for (winList::iterator it = iconList.begin(); it != iconList.end(); ++it)
+ if ((*it)->validateClient())
+ (*it)->reconfigure();
image_control->timeout();
}
void BScreen::removeWorkspaceNames(void) {
- while (workspaceNames->count())
- delete [] workspaceNames->remove(0);
+ workspaceNames.clear();
}
// load bevel, border and handle widths
if (conf.getValue("handleWidth", "HandleWidth", l)) {
- if (l <= size().w() / 2 && l != 0)
+ if (l <= (signed)size().w() / 2 && l != 0)
resource.handle_width = l;
else
resource.handle_width = 6;
resource.border_width = 1;
if (conf.getValue("bevelWidth", "BevelWidth", l)) {
- if (l <= size().w() / 2 && l != 0)
+ if (l <= (signed)size().w() / 2 && l != 0)
resource.bevel_width = l;
else
resource.bevel_width = 3;
resource.bevel_width = 3;
if (conf.getValue("frameWidth", "FrameWidth", l)) {
- if (l <= size().w() / 2)
+ if (l <= (signed)size().w() / 2)
resource.frame_width = l;
else
resource.frame_width = resource.bevel_width;
if (! w) return;
w->setWorkspace(-1);
- w->setWindowNumber(iconList->count());
+ w->setWindowNumber(iconList.size());
- iconList->insert(w);
+ iconList.push_back(w);
iconmenu->insert((const char **) w->getIconTitle());
iconmenu->update();
void BScreen::removeIcon(OpenboxWindow *w) {
if (! w) return;
- iconList->remove(w->getWindowNumber());
+ iconList.remove(w);
iconmenu->remove(w->getWindowNumber());
iconmenu->update();
- LinkedListIterator<OpenboxWindow> it(iconList);
- OpenboxWindow *bw = it.current();
- for (int i = 0; bw; it++, bw = it.current())
- bw->setWindowNumber(i++);
+ winList::iterator it = iconList.begin();
+ for (int i = 0; it != iconList.end(); ++it, ++i)
+ (*it)->setWindowNumber(i);
}
OpenboxWindow *BScreen::getIcon(int index) {
- if (index >= 0 && index < iconList->count())
- return iconList->find(index);
+ if (index < 0 || index >= (signed)iconList.size())
+ return (OpenboxWindow *) 0;
- return NULL;
+ winList::iterator it = iconList.begin();
+ for (; index > 0; --index, ++it); // increment to index
+ return *it;
}
int BScreen::addWorkspace(void) {
- Workspace *wkspc = new Workspace(*this, workspacesList->count());
- workspacesList->insert(wkspc);
+ Workspace *wkspc = new Workspace(*this, workspacesList.size());
+ workspacesList.push_back(wkspc);
setWorkspaceCount(workspaceCount()+1);
saveWorkspaceNames();
updateNetizenWorkspaceCount();
- return workspacesList->count();
+ return workspacesList.size();
}
int BScreen::removeLastWorkspace(void) {
- if (workspacesList->count() == 1)
+ if (workspacesList.size() == 1)
return 0;
- Workspace *wkspc = workspacesList->last();
+ Workspace *wkspc = workspacesList.back();
if (current_workspace->getWorkspaceID() == wkspc->getWorkspaceID())
changeWorkspaceID(current_workspace->getWorkspaceID() - 1);
workspacemenu->remove(wkspc->getWorkspaceID() + 2);
workspacemenu->update();
- workspacesList->remove(wkspc);
+ workspacesList.pop_back();
delete wkspc;
+
setWorkspaceCount(workspaceCount()-1);
saveWorkspaceNames();
updateNetizenWorkspaceCount();
- return workspacesList->count();
+ return workspacesList.size();
}
if (openbox.focusedWindow() &&
openbox.focusedWindow()->getScreen() == this &&
(! openbox.focusedWindow()->isStuck())) {
- current_workspace->setLastFocusedWindow(openbox.focusedWindow());
- openbox.focusWindow((OpenboxWindow *) 0);
+ openbox.focusWindow(0);
}
current_workspace = getWorkspace(id);
current_workspace->showAll();
- if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
+ if (resource.focus_last && current_workspace->lastFocusedWindow()) {
XSync(openbox.getXDisplay(), False);
- current_workspace->getLastFocusedWindow()->setInputFocus();
+ current_workspace->lastFocusedWindow()->setInputFocus();
}
}
n->sendWorkspaceCount();
n->sendCurrentWorkspace();
- LinkedListIterator<Workspace> it(workspacesList);
- for (Workspace *w = it.current(); w; it++, w = it.current()) {
- for (int i = 0; i < w->getCount(); i++)
- n->sendWindowAdd(w->getWindow(i)->getClientWindow(),
- w->getWorkspaceID());
+ wkspList::iterator it;
+ for (it = workspacesList.begin(); it != workspacesList.end(); ++it) {
+ for (int i = 0; i < (*it)->getCount(); i++)
+ n->sendWindowAdd((*it)->getWindow(i)->getClientWindow(),
+ (*it)->getWorkspaceID());
}
Window f = ((openbox.focusedWindow()) ?
void BScreen::removeNetizen(Window w) {
netList::iterator it;
- int i = 0;
for (it = netizenList.begin(); it != netizenList.end(); ++it)
if ((*it)->getWindowID() == w) {
(*it)->sendWindowFocus(f);
}
+
void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) {
netList::iterator it;
for (it = netizenList.begin(); it != netizenList.end(); ++it)
void BScreen::raiseWindows(Window *workspace_stack, int num) {
Window *session_stack = new
- Window[(num + workspacesList->count() + rootmenuList.size() + 13)];
+ Window[(num + workspacesList.size() + rootmenuList.size() + 13)];
int i = 0, k = num;
XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID());
*(session_stack + i++) = iconmenu->getWindowID();
- LinkedListIterator<Workspace> wit(workspacesList);
- for (Workspace *tmp = wit.current(); tmp; wit++, tmp = wit.current())
- *(session_stack + i++) = tmp->getMenu()->getWindowID();
+ wkspList::iterator it;
+ for (it = workspacesList.begin(); it != workspacesList.end(); ++it)
+ *(session_stack + i++) = (*it)->getMenu()->getWindowID();
*(session_stack + i++) = workspacemenu->getWindowID();
void BScreen::addWorkspaceName(const char *name) {
- workspaceNames->insert(bstrdup(name));
+ workspaceNames.push_back(name);
}
-char* BScreen::getNameOfWorkspace(int id) {
- char *name = NULL;
-
- if (id >= 0 && id < workspaceNames->count()) {
- char *wkspc_name = workspaceNames->find(id);
- if (wkspc_name)
- name = wkspc_name;
- }
- return name;
+const char *BScreen::getNameOfWorkspace(int id) {
+ if (id < 0 || id >= (signed)workspaceNames.size())
+ return (const char *) 0;
+ return workspaceNames[id].c_str();
}
void BScreen::InitMenu(void) {
if (rootmenu) {
- while (!rootmenuList.empty())
- rootmenuList.erase(rootmenuList.begin());
-
+ rootmenuList.clear();
while (rootmenu->getCount())
rootmenu->remove(0);
} else {
XSelectInput(getBaseDisplay().getXDisplay(), getRootWindow(), NoEventMask);
XSync(getBaseDisplay().getXDisplay(), False);
- LinkedListIterator<Workspace> it(workspacesList);
- for (Workspace *w = it.current(); w; it++, w = it.current())
- w->shutdown();
+ std::for_each(workspacesList.begin(), workspacesList.end(),
+ std::mem_fun(&Workspace::shutdown));
- while (iconList->count()) {
- iconList->first()->restore();
- delete iconList->first();
- }
+ while (!iconList.empty())
+ iconList.front()->restore();
#ifdef SLIT
slit->shutdown();