X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;ds=inline;f=src%2FScreen.cc;h=29a7a69d5f95309793913084a9de53b85a38078c;hb=a0dbb0e13f19ac4cc2dddf3d94723174971df6d2;hp=3e7df54b4b5f7ad3aceb2f2092bfb8d70090c658;hpb=098fae70a6d8d15877938080437f0fc20f52bbf5;p=chaz%2Fopenbox diff --git a/src/Screen.cc b/src/Screen.cc index 3e7df54b..29a7a69d 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -32,7 +32,6 @@ #include #include -#include #include "i18n.h" #include "openbox.h" @@ -237,8 +236,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), workspaceNames = new LinkedList; workspacesList = new LinkedList; - rootmenuList = new LinkedList; - netizenList = new LinkedList; iconList = new LinkedList; image_control = @@ -405,15 +402,14 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), for (int i = 0; i < resource.workspaces; ++i) { wkspc = new Workspace(*this, workspacesList->count()); workspacesList->insert(wkspc); - saveWorkspaceNames(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu()); } } else { wkspc = new Workspace(*this, workspacesList->count()); workspacesList->insert(wkspc); - saveWorkspaceNames(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu()); } + saveWorkspaceNames(); workspacemenu->insert(i18n->getMessage(IconSet, IconIcons, "Icons"), iconmenu); @@ -486,9 +482,8 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), } } - if (! resource.sloppy_focus) - XSetInputFocus(getBaseDisplay().getXDisplay(), toolbar->getWindowID(), - RevertToParent, CurrentTime); + XSetInputFocus(getBaseDisplay().getXDisplay(), + PointerRoot, None, CurrentTime); XFree(children); XFlush(getBaseDisplay().getXDisplay()); @@ -509,14 +504,14 @@ BScreen::~BScreen(void) { while (workspacesList->count()) delete workspacesList->remove(0); - while (rootmenuList->count()) - rootmenuList->remove(0); + while (!rootmenuList.empty()) + rootmenuList.erase(rootmenuList.begin()); while (iconList->count()) delete iconList->remove(0); - while (netizenList->count()) - delete netizenList->remove(0); + while (!netizenList.empty()) + netizenList.erase(netizenList.begin()); #ifdef HAVE_STRFTIME if (resource.strftime_format) @@ -537,9 +532,7 @@ BScreen::~BScreen(void) { delete workspacesList; delete workspaceNames; - delete rootmenuList; delete iconList; - delete netizenList; if (resource.wstyle.fontset) XFreeFontSet(getBaseDisplay().getXDisplay(), resource.wstyle.fontset); @@ -699,7 +692,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 +789,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 +808,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 +837,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); @@ -955,11 +948,10 @@ void BScreen::setAutoRaise(bool a) { void BScreen::setImageDither(bool d, bool reconfig) { - resource.image_dither = d; image_control->setDither(d); 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); @@ -1134,7 +1126,7 @@ void BScreen::saveWorkspaceNames() { if (w != NULL) { names << w->getName(); if (i < resource.workspaces-1) - names << ','; + names << ","; } } names << ends; @@ -1148,7 +1140,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,7 +1155,7 @@ 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); @@ -1172,9 +1164,10 @@ void BScreen::save() { setHideToolbar(resource.hide_toolbar); } + void BScreen::load() { ostrstream rscreen, rname, rclass; - string s; + std::string s; bool b; long l; rscreen << "session.screen" << getScreenNumber() << '.' << ends; @@ -1194,6 +1187,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 +1196,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 +1205,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 +1214,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 +1226,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,15 +1238,17 @@ 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)) { @@ -1256,7 +1256,7 @@ void BScreen::load() { while(1) { 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 +1265,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 +1286,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 +1295,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 +1316,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 +1329,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 +1341,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 +1354,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 +1363,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 +1385,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 +1394,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) { @@ -1585,7 +1594,7 @@ void BScreen::LoadStyle(void) { } } - string s; + std::string s; long l; // load fonts/fontsets @@ -1921,6 +1930,7 @@ OpenboxWindow *BScreen::getIcon(int index) { int BScreen::addWorkspace(void) { Workspace *wkspc = new Workspace(*this, workspacesList->count()); workspacesList->insert(wkspc); + setWorkspaceCount(workspaceCount()+1); saveWorkspaceNames(); workspacemenu->insert(wkspc->getName(), wkspc->getMenu(), @@ -1951,6 +1961,8 @@ int BScreen::removeLastWorkspace(void) { workspacesList->remove(wkspc); delete wkspc; + setWorkspaceCount(workspaceCount()-1); + saveWorkspaceNames(); toolbar->reconfigure(); @@ -1995,7 +2007,7 @@ void BScreen::changeWorkspaceID(int id) { void BScreen::addNetizen(Netizen *n) { - netizenList->insert(n); + netizenList.push_back(n); n->sendWorkspaceCount(); n->sendCurrentWorkspace(); @@ -2014,80 +2026,79 @@ void BScreen::addNetizen(Netizen *n) { void BScreen::removeNetizen(Window w) { - LinkedListIterator it(netizenList); + netList::iterator it; int i = 0; - 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->count() + rootmenuList.size() + 13)]; int i = 0, k = num; XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID()); @@ -2113,9 +2124,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()) @@ -2259,8 +2270,8 @@ void BScreen::raiseFocus(void) { void BScreen::InitMenu(void) { if (rootmenu) { - while (rootmenuList->count()) - rootmenuList->remove(0); + while (!rootmenuList.empty()) + rootmenuList.erase(rootmenuList.begin()); while (rootmenu->getCount()) rootmenu->remove(0); @@ -2563,7 +2574,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 +2700,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);