From f1d41e6afa6eb771dc045bd2a8e34de6d9b9c4a6 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 27 Feb 2004 12:32:54 +0000 Subject: cleaning --- src/Screen.cc | 37 +++++++++++++++---------------------- src/fluxbox.cc | 21 ++++++++++----------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 319852c..8c93a7b 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.267 2004/02/20 09:06:19 fluxgen Exp $ +// $Id: Screen.cc,v 1.268 2004/02/27 12:32:54 fluxgen Exp $ #include "Screen.hh" @@ -641,6 +641,17 @@ BScreen::BScreen(FbTk::ResourceManager &rm, XFlush(disp); } +template +void destroyAndClearList(A &a) { + typedef typename A::iterator iterator; + iterator it = a.begin(); + iterator it_end = a.end(); + for (; it != it_end; ++it) + delete (*it); + + a.clear(); +} + BScreen::~BScreen() { if (! managed) return; @@ -656,27 +667,9 @@ BScreen::~BScreen() { removeWorkspaceNames(); - Workspaces::iterator w_it = m_workspaces_list.begin(); - Workspaces::iterator w_it_end = m_workspaces_list.end(); - for(; w_it != w_it_end; ++w_it) { - delete (*w_it); - } - m_workspaces_list.clear(); - - Icons::iterator i_it = m_icon_list.begin(); - Icons::iterator i_it_end = m_icon_list.end(); - for(; i_it != i_it_end; ++i_it) { - delete (*i_it); - } - m_icon_list.clear(); - - Netizens::iterator n_it = m_netizen_list.begin(); - Netizens::iterator n_it_end = m_netizen_list.end(); - for(; n_it != n_it_end; ++n_it) { - delete (*n_it); - } - - m_netizen_list.clear(); + destroyAndClearList(m_workspaces_list); + destroyAndClearList(m_icon_list); + destroyAndClearList(m_netizen_list); if (hasXinerama() && m_xinerama_headinfo) { delete [] m_xinerama_headinfo; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index b2a1dbb..e6099aa 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.231 2004/02/20 09:29:05 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.232 2004/02/27 12:30:17 fluxgen Exp $ #include "fluxbox.hh" @@ -48,6 +48,7 @@ #include "FbTk/Command.hh" #include "FbTk/RefCount.hh" #include "FbTk/SimpleCommand.hh" +#include "FbTk/CompareEqual.hh" //Use GNU extensions #ifndef _GNU_SOURCE @@ -837,14 +838,11 @@ void Fluxbox::handleEvent(XEvent * const e) { screen_num = XScreenNumberOfScreen(attr.screen); // find screen - ScreenList::iterator screen_it = m_screen_list.begin(); - const ScreenList::iterator screen_it_end = m_screen_list.end(); - for (; screen_it != screen_it_end; ++screen_it) { - if ((*screen_it)->screenNumber() == screen_num) { - screen = (*screen_it); - break; - } - } + ScreenList::iterator screen_it = find_if(m_screen_list.begin(), + m_screen_list.end(), + FbTk::CompareEqual(&BScreen::screenNumber, screen_num)); + if (screen_it != m_screen_list.end()) + screen = *screen_it; } // try with parent if we failed to find screen num if (screen == 0) @@ -1435,11 +1433,12 @@ void Fluxbox::attachSignals(WinClient &winclient) { } BScreen *Fluxbox::searchScreen(Window window) { - ScreenList::iterator it = m_screen_list.begin(); + + ScreenList::iterator it = m_screen_list.begin(); ScreenList::iterator it_end = m_screen_list.end(); for (; it != it_end; ++it) { if (*it && (*it)->rootWindow() == window) - return (*it); + return *it; } return 0; -- cgit v0.11.2