X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FScreen.cc;h=bc1b9e65bfeca7e5f514a65c31088fa2833eacec;hb=f75083669f65aadd6b32f8ed25880ca362296a2f;hp=3e7df54b4b5f7ad3aceb2f2092bfb8d70090c658;hpb=098fae70a6d8d15877938080437f0fc20f52bbf5;p=chaz%2Fopenbox diff --git a/src/Screen.cc b/src/Screen.cc index 3e7df54b..bc1b9e65 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -32,7 +32,6 @@ #include #include -#include #include "i18n.h" #include "openbox.h" @@ -104,7 +103,8 @@ #include #include #include -using namespace std; +#include +using std::ends; static Bool running = True; @@ -217,11 +217,15 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), resource.mstyle.t_font = resource.mstyle.f_font = resource.tstyle.font = resource.wstyle.font = NULL; resource.root_command = NULL; +#ifdef HAVE_STRFTIME + resource.strftime_format = NULL; +#endif // HAVE_STRFTIME #ifdef SLIT slit = NULL; #endif // SLIT toolbar = NULL; + current_workspace = (Workspace *) 0; #ifdef HAVE_GETPID pid_t bpid = getpid(); @@ -235,12 +239,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), XDefineCursor(getBaseDisplay().getXDisplay(), getRootWindow(), openbox.getSessionCursor()); - workspaceNames = new LinkedList; - workspacesList = new LinkedList; - rootmenuList = new LinkedList; - netizenList = new LinkedList; - iconList = new LinkedList; - image_control = new BImageControl(openbox, *this, True, openbox.getColorsPerChannel(), openbox.getCacheLife(), openbox.getCacheMax()); @@ -403,23 +401,23 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), Workspace *wkspc = NULL; if (resource.workspaces != 0) { for (int i = 0; i < resource.workspaces; ++i) { - wkspc = new Workspace(*this, workspacesList->count()); - workspacesList->insert(wkspc); - saveWorkspaceNames(); + 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); - saveWorkspaceNames(); + setWorkspaceCount(1); + wkspc = new Workspace(*this, workspacesList.size()); + workspacesList.push_back(wkspc); workspacemenu->insert(wkspc->getName(), wkspc->getMenu()); } + saveWorkspaceNames(); workspacemenu->insert(i18n->getMessage(IconSet, IconIcons, "Icons"), iconmenu); workspacemenu->update(); - current_workspace = workspacesList->first(); + current_workspace = workspacesList.front(); workspacemenu->setItemSelected(2, True); toolbar = new Toolbar(*this, config); @@ -486,10 +484,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), } } - if (! resource.sloppy_focus) - XSetInputFocus(getBaseDisplay().getXDisplay(), toolbar->getWindowID(), - RevertToParent, CurrentTime); - XFree(children); XFlush(getBaseDisplay().getXDisplay()); } @@ -506,17 +500,10 @@ BScreen::~BScreen(void) { removeWorkspaceNames(); - while (workspacesList->count()) - delete workspacesList->remove(0); - - while (rootmenuList->count()) - rootmenuList->remove(0); - - while (iconList->count()) - delete iconList->remove(0); - - while (netizenList->count()) - delete netizenList->remove(0); + 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) @@ -535,12 +522,6 @@ BScreen::~BScreen(void) { delete toolbar; delete image_control; - delete workspacesList; - delete workspaceNames; - delete rootmenuList; - delete iconList; - delete netizenList; - if (resource.wstyle.fontset) XFreeFontSet(getBaseDisplay().getXDisplay(), resource.wstyle.fontset); if (resource.mstyle.t_fontset) @@ -602,7 +583,7 @@ Rect BScreen::availableArea() const { #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()) { @@ -699,7 +680,7 @@ void BScreen::readDatabaseTexture(const char *rname, const char *rclass, BTexture *texture, unsigned long default_pixel) { - string s; + std::string s; if (resource.styleconfig.getValue(rname, rclass, s)) image_control->parseTexture(texture, s.c_str()); @@ -796,12 +777,12 @@ void BScreen::readDatabaseTexture(const char *rname, const char *rclass, void BScreen::readDatabaseColor(const char *rname, const char *rclass, BColor *color, unsigned long default_pixel) { - string s; + std::string s; if (resource.styleconfig.getValue(rname, rclass, s)) image_control->parseColor(color, s.c_str()); else { - // parsing with no color string just deallocates the color, if it has + // parsing with no color std::string just deallocates the color, if it has // been previously allocated image_control->parseColor(color); color->setPixel(default_pixel); @@ -815,7 +796,7 @@ void BScreen::readDatabaseFontSet(const char *rname, const char *rclass, static char *defaultFont = "fixed"; bool load_default = false; - string s; + std::string s; if (*fontset) XFreeFontSet(getBaseDisplay().getXDisplay(), *fontset); @@ -844,7 +825,7 @@ void BScreen::readDatabaseFont(const char *rname, const char *rclass, static char *defaultFont = "fixed"; bool load_default = false; - string s; + std::string s; if (*font) XFreeFont(getBaseDisplay().getXDisplay(), *font); @@ -932,7 +913,7 @@ XFontSet BScreen::createFontSet(const char *fontname) { 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 ? @@ -944,7 +925,7 @@ void BScreen::setSloppyFocus(bool b) { 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 ? @@ -955,11 +936,10 @@ void BScreen::setAutoRaise(bool a) { void BScreen::setImageDither(bool d, bool reconfig) { - resource.image_dither = d; image_control->setDither(d); - ostrstream s; + std::ostrstream s; s << "session.screen" << getScreenNumber() << ".imageDither" << ends; - config.setValue(s.str(), resource.image_dither); + config.setValue(s.str(), imageDither()); if (reconfig) reconfigure(); s.rdbuf()->freeze(0); @@ -968,7 +948,7 @@ void BScreen::setImageDither(bool d, bool 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); @@ -977,7 +957,7 @@ void BScreen::setOpaqueMove(bool o) { 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); @@ -986,7 +966,7 @@ void BScreen::setFullMax(bool f) { 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); @@ -995,7 +975,7 @@ void BScreen::setFocusNew(bool f) { 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); @@ -1004,7 +984,7 @@ void BScreen::setFocusLast(bool f) { 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); @@ -1013,7 +993,7 @@ void BScreen::setWindowZones(int z) { 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); @@ -1022,7 +1002,7 @@ void BScreen::setWorkspaceCount(int w) { 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) { @@ -1041,7 +1021,7 @@ void BScreen::setPlacementPolicy(int p) { 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); @@ -1050,7 +1030,7 @@ void BScreen::setEdgeSnapThreshold(int t) { 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 ? @@ -1061,7 +1041,7 @@ void BScreen::setRowPlacementDirection(int d) { 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 ? @@ -1089,53 +1069,56 @@ void BScreen::setStrftimeFormat(const char *f) { 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; @@ -1148,7 +1131,7 @@ void BScreen::saveWorkspaceNames() { void BScreen::save() { setSloppyFocus(resource.sloppy_focus); setAutoRaise(resource.auto_raise); - setImageDither(resource.image_dither, false); + setImageDither(imageDither(), false); setOpaqueMove(resource.opaque_move); setFullMax(resource.full_max); setFocusNew(resource.focus_new); @@ -1163,18 +1146,24 @@ void BScreen::save() { #ifdef HAVE_STRFTIME // it deletes the current value before setting the new one, so we have to // duplicate the current value. - string s = resource.strftime_format; + std::string s = resource.strftime_format; setStrftimeFormat(s.c_str()); #else // !HAVE_STRFTIME setDateFormat(resource.date_format); 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; - string s; + std::ostrstream rscreen, rname, rclass; + std::string s; bool b; long l; rscreen << "session.screen" << getScreenNumber() << '.' << ends; @@ -1194,6 +1183,7 @@ void BScreen::load() { } rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "fullMaximization" << ends; rclass << rscreen.str() << "FullMaximization" << ends; if (config.getValue(rname.str(), rclass.str(), b)) @@ -1202,6 +1192,7 @@ void BScreen::load() { resource.full_max = false; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "focusNewWindows" << ends; rclass << rscreen.str() << "FocusNewWindows" << ends; if (config.getValue(rname.str(), rclass.str(), b)) @@ -1210,6 +1201,7 @@ void BScreen::load() { resource.focus_new = false; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "focusLastWindow" << ends; rclass << rscreen.str() << "FocusLastWindow" << ends; if (config.getValue(rname.str(), rclass.str(), b)) @@ -1218,6 +1210,7 @@ void BScreen::load() { resource.focus_last = false; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "rowPlacementDirection" << ends; rclass << rscreen.str() << "RowPlacementDirection" << ends; if (config.getValue(rname.str(), rclass.str(), s)) { @@ -1229,6 +1222,7 @@ void BScreen::load() { resource.row_direction = LeftRight; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "colPlacementDirection" << ends; rclass << rscreen.str() << "ColPlacementDirection" << ends; if (config.getValue(rname.str(), rclass.str(), s)) { @@ -1240,23 +1234,25 @@ void BScreen::load() { resource.col_direction = TopBottom; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "workspaces" << ends; rclass << rscreen.str() << "Workspaces" << ends; - if (config.getValue(rname.str(), rclass.str(), l)) + if (config.getValue(rname.str(), rclass.str(), l)) { resource.workspaces = l; - else + } else resource.workspaces = 1; removeWorkspaceNames(); rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); 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 - string name(tmp, it); // name = s[tmp:it] + std::string name(tmp, it); // name = s[tmp:it] addWorkspaceName(name.c_str()); if (it == end) break; @@ -1265,6 +1261,7 @@ void BScreen::load() { } rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "focusModel" << ends; rclass << rscreen.str() << "FocusModel" << ends; if (config.getValue(rname.str(), rclass.str(), s)) { @@ -1285,6 +1282,7 @@ void BScreen::load() { } rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "windowZones" << ends; rclass << rscreen.str() << "WindowZones" << ends; if (config.getValue(rname.str(), rclass.str(), l)) @@ -1293,6 +1291,7 @@ void BScreen::load() { resource.zones = 4; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "windowPlacement" << ends; rclass << rscreen.str() << "WindowPlacement" << ends; if (config.getValue(rname.str(), rclass.str(), s)) { @@ -1313,6 +1312,7 @@ void BScreen::load() { #ifdef HAVE_STRFTIME rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "strftimeFormat" << ends; rclass << rscreen.str() << "StrftimeFormat" << ends; @@ -1325,6 +1325,7 @@ void BScreen::load() { resource.strftime_format = bstrdup("%I:%M %p"); #else // !HAVE_STRFTIME rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "dateFormat" << ends; rclass << rscreen.str() << "DateFormat" << ends; if (config.getValue(rname.str(), rclass.str(), s)) { @@ -1336,6 +1337,7 @@ void BScreen::load() { resource.date_format = B_AmericanDate; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "clockFormat" << ends; rclass << rscreen.str() << "ClockFormat" << ends; if (config.getValue(rname.str(), rclass.str(), l)) { @@ -1348,6 +1350,7 @@ void BScreen::load() { #endif // HAVE_STRFTIME rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "edgeSnapThreshold" << ends; rclass << rscreen.str() << "EdgeSnapThreshold" << ends; if (config.getValue(rname.str(), rclass.str(), l)) @@ -1356,14 +1359,16 @@ void BScreen::load() { resource.edge_snap_threshold = 4; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "imageDither" << ends; rclass << rscreen.str() << "ImageDither" << ends; if (config.getValue(rname.str(), rclass.str(), b)) - resource.image_dither = b; + image_control->setDither(b); else - resource.image_dither = true; + image_control->setDither(true); rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "rootCommand" << ends; rclass << rscreen.str() << "RootCommand" << ends; @@ -1376,6 +1381,7 @@ void BScreen::load() { resource.root_command = NULL; rname.seekp(0); rclass.seekp(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); rname << rscreen.str() << "opaqueMove" << ends; rclass << rscreen.str() << "OpaqueMove" << ends; if (config.getValue(rname.str(), rclass.str(), b)) @@ -1384,8 +1390,7 @@ void BScreen::load() { resource.opaque_move = false; rscreen.rdbuf()->freeze(0); - rname.rdbuf()->freeze(0); - rclass.rdbuf()->freeze(0); + rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0); } void BScreen::reconfigure(void) { @@ -1539,14 +1544,12 @@ void BScreen::reconfigure(void) { slit->reconfigure(); #endif // SLIT - LinkedListIterator 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 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(); } @@ -1561,8 +1564,7 @@ void BScreen::rereadMenu(void) { void BScreen::removeWorkspaceNames(void) { - while (workspaceNames->count()) - delete [] workspaceNames->remove(0); + workspaceNames.clear(); } @@ -1585,7 +1587,7 @@ void BScreen::LoadStyle(void) { } } - string s; + std::string s; long l; // load fonts/fontsets @@ -1834,7 +1836,7 @@ void BScreen::LoadStyle(void) { // 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; @@ -1847,7 +1849,7 @@ void BScreen::LoadStyle(void) { 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; @@ -1855,7 +1857,7 @@ void BScreen::LoadStyle(void) { 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; @@ -1886,9 +1888,9 @@ void BScreen::addIcon(OpenboxWindow *w) { 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(); @@ -1898,29 +1900,31 @@ void BScreen::addIcon(OpenboxWindow *w) { void BScreen::removeIcon(OpenboxWindow *w) { if (! w) return; - iconList->remove(w->getWindowNumber()); + iconList.remove(w); iconmenu->remove(w->getWindowNumber()); iconmenu->update(); - LinkedListIterator 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(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu(), @@ -1931,15 +1935,15 @@ int BScreen::addWorkspace(void) { 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); @@ -1949,14 +1953,17 @@ int BScreen::removeLastWorkspace(void) { workspacemenu->remove(wkspc->getWorkspaceID() + 2); workspacemenu->update(); - workspacesList->remove(wkspc); + workspacesList.pop_back(); delete wkspc; + + setWorkspaceCount(workspaceCount()-1); + saveWorkspaceNames(); toolbar->reconfigure(); updateNetizenWorkspaceCount(); - return workspacesList->count(); + return workspacesList.size(); } @@ -1972,8 +1979,7 @@ void BScreen::changeWorkspaceID(int id) { 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); @@ -1984,9 +1990,9 @@ void BScreen::changeWorkspaceID(int 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(); } } @@ -1995,16 +2001,16 @@ void BScreen::changeWorkspaceID(int id) { void BScreen::addNetizen(Netizen *n) { - netizenList->insert(n); + netizenList.push_back(n); n->sendWorkspaceCount(); n->sendCurrentWorkspace(); - LinkedListIterator 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()) ? @@ -2014,88 +2020,87 @@ void BScreen::addNetizen(Netizen *n) { void BScreen::removeNetizen(Window w) { - LinkedListIterator it(netizenList); - int i = 0; + netList::iterator it; - for (Netizen *n = it.current(); n; it++, i++, n = it.current()) - if (n->getWindowID() == w) { - Netizen *tmp = netizenList->remove(i); + for (it = netizenList.begin(); it != netizenList.end(); ++it) + if ((*it)->getWindowID() == w) { + Netizen *tmp = *it; + netizenList.erase(it); delete tmp; - break; } } void BScreen::updateNetizenCurrentWorkspace(void) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendCurrentWorkspace(); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendCurrentWorkspace(); } void BScreen::updateNetizenWorkspaceCount(void) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWorkspaceCount(); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWorkspaceCount(); } void BScreen::updateNetizenWindowFocus(void) { Window f = ((openbox.focusedWindow()) ? openbox.focusedWindow()->getClientWindow() : None); - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowFocus(f); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowFocus(f); } void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowAdd(w, p); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowAdd(w, p); } void BScreen::updateNetizenWindowDel(Window w) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowDel(w); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowDel(w); } void BScreen::updateNetizenWindowRaise(Window w) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowRaise(w); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowRaise(w); } void BScreen::updateNetizenWindowLower(Window w) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowLower(w); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowLower(w); } void BScreen::updateNetizenConfigNotify(XEvent *e) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendConfigNotify(e); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendConfigNotify(e); } void BScreen::raiseWindows(Window *workspace_stack, int num) { Window *session_stack = new - Window[(num + workspacesList->count() + rootmenuList->count() + 13)]; + Window[(num + workspacesList.size() + rootmenuList.size() + 13)]; int i = 0, k = num; XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID()); *(session_stack + i++) = iconmenu->getWindowID(); - LinkedListIterator 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(); @@ -2113,9 +2118,9 @@ void BScreen::raiseWindows(Window *workspace_stack, int num) { toolbar->getMenu()->getPlacementmenu()->getWindowID(); *(session_stack + i++) = toolbar->getMenu()->getWindowID(); - LinkedListIterator rit(rootmenuList); - for (Rootmenu *tmp = rit.current(); tmp; rit++, tmp = rit.current()) - *(session_stack + i++) = tmp->getWindowID(); + menuList::iterator rit; + for (rit = rootmenuList.begin(); rit != rootmenuList.end(); ++rit) + *(session_stack + i++) = (*rit)->getWindowID(); *(session_stack + i++) = rootmenu->getWindowID(); if (toolbar->onTop()) @@ -2136,19 +2141,14 @@ void BScreen::raiseWindows(Window *workspace_stack, int num) { 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(); } @@ -2259,9 +2259,7 @@ void BScreen::raiseFocus(void) { void BScreen::InitMenu(void) { if (rootmenu) { - while (rootmenuList->count()) - rootmenuList->remove(0); - + rootmenuList.clear(); while (rootmenu->getCount()) rootmenu->remove(0); } else { @@ -2563,7 +2561,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { parseMenuFile(file, submenu); submenu->update(); menu->insert(label, submenu); - rootmenuList->insert(submenu); + rootmenuList.push_back(submenu); } break; @@ -2689,7 +2687,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { if (newmenu) { stylesmenu->setLabel(label); menu->insert(label, stylesmenu); - rootmenuList->insert(stylesmenu); + rootmenuList.push_back(stylesmenu); } openbox.setMenuFilename(stylesdir); @@ -2739,14 +2737,11 @@ void BScreen::shutdown(void) { XSelectInput(getBaseDisplay().getXDisplay(), getRootWindow(), NoEventMask); XSync(getBaseDisplay().getXDisplay(), False); - LinkedListIterator 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();