all repos — fluxbox @ dce0e2e40c9fed226139c3def26e423b75c6bb9c

custom fork of the fluxbox windowmanager

using Select2nd
fluxgen fluxgen
commit

dce0e2e40c9fed226139c3def26e423b75c6bb9c

parent

6b943ec69ada6ba8c7b0a8305f048df8ef07f961

4 files changed, 124 insertions(+), 117 deletions(-)

jump to
M src/Screen.ccsrc/Screen.cc

@@ -69,6 +69,8 @@ #include "FbTk/StringUtil.hh"

#include "FbTk/ImageControl.hh" #include "FbTk/EventManager.hh" #include "FbTk/Transparent.hh" +#include "FbTk/Select2nd.hh" +#include "FbTk/Compose.hh" //use GNU extensions #ifndef _GNU_SOURCE

@@ -830,16 +832,17 @@

for_each(getWorkspacesList().begin(), getWorkspacesList().end(), mem_fun(&Workspace::updateClientmenu)); + using namespace FbTk; + // remove any grouping this is expecting - Groupables::iterator it = m_expecting_groups.begin(); - Groupables::iterator it_end = m_expecting_groups.end(); - for (; it != it_end; ++it) { - if (it->second == &client) { - m_expecting_groups.erase(it); - // it should only be in there a maximum of once - break; - } - } + Groupables::iterator erase_it = find_if(m_expecting_groups.begin(), + m_expecting_groups.end(), + Compose(bind2nd(equal_to<WinClient *>(), &client), + Select2nd<Groupables::value_type>())); + + if (erase_it != m_expecting_groups.end()) + m_expecting_groups.erase(erase_it); + // the client could be on icon menu so we update it //!! TODO: check this with the new icon menu // updateIconMenu();

@@ -1711,14 +1714,12 @@ setupConfigmenu(*m_configmenu.get());

} void BScreen::removeConfigMenu(FbTk::Menu &menu) { - Configmenus::iterator it = m_configmenu_list.begin(); - Configmenus::iterator it_end = m_configmenu_list.end(); - for (; it != it_end; ++it) { - if (it->second == &menu) { - m_configmenu_list.erase(it); - break; - } - } + Configmenus::iterator erase_it = find_if(m_configmenu_list.begin(), + m_configmenu_list.end(), + FbTk::Compose(bind2nd(equal_to<FbTk::Menu *>(), &menu), + FbTk::Select2nd<Configmenus::value_type>())); + if (erase_it != m_configmenu_list.end()) + m_configmenu_list.erase(erase_it); setupConfigmenu(*m_configmenu.get()); }
M src/Window.ccsrc/Window.cc

@@ -45,6 +45,7 @@ #include "FbTk/Compose.hh"

#include "FbTk/EventManager.hh" #include "FbTk/KeyUtil.hh" #include "FbTk/SimpleCommand.hh" +#include "FbTk/Select2nd.hh" #ifdef HAVE_CONFIG_H #include "config.h"

@@ -81,15 +82,18 @@ #include <functional>

#include <algorithm> using namespace std; +using namespace FbTk; namespace { -void grabButton(Display *display, unsigned int button, +void grabButton(unsigned int button, Window window, Cursor cursor) { - const int numlock = FbTk::KeyUtil::instance().numlock(); - const int capslock = FbTk::KeyUtil::instance().capslock(); - const int scrolllock = FbTk::KeyUtil::instance().scrolllock(); + static Display *display = App::instance()->display(); + + const int numlock = KeyUtil::instance().numlock(); + const int capslock = KeyUtil::instance().capslock(); + const int scrolllock = KeyUtil::instance().scrolllock(); // Grab with Mod1 and with all lock modifiers // (num, scroll and caps)

@@ -863,8 +867,8 @@ /// returns WinClient of window we're searching for

WinClient *FluxboxWindow::findClient(Window win) { ClientList::iterator it = find_if(clientList().begin(), clientList().end(), - FbTk::Compose(bind2nd(equal_to<Window>(), win), - mem_fun(&WinClient::window))); + Compose(bind2nd(equal_to<Window>(), win), + mem_fun(&WinClient::window))); return (it == clientList().end() ? 0 : *it); }

@@ -941,74 +945,77 @@

//std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { - int dest_x=0, dest_y=0; - Window labelbutton=0; - if(!XTranslateCoordinates(FbTk::App::instance()->display(), - parent().window(), frame().label().window(), - x,y, &dest_x, &dest_y, - &labelbutton)) - return m_clientlist.end(); - Client2ButtonMap::iterator it = m_labelbuttons.begin(); - Client2ButtonMap::iterator it_end = m_labelbuttons.end(); - //find the label button to move next to - for(; it!=it_end; it++) { - if( (*it).second->window()==labelbutton) - break; - } - //label button not found - if(it==it_end) { - return m_clientlist.end(); - } - Window child_return=0; - //make x and y relative to our labelbutton - if(!XTranslateCoordinates(FbTk::App::instance()->display(), - frame().label().window(),labelbutton, - dest_x,dest_y, &x, &y, - &child_return)) - return m_clientlist.end(); - ClientList::iterator client = find(m_clientlist.begin(), - m_clientlist.end(), - it->first); - if(x>(*it).second->width()/2) - client++; - return client; - + int dest_x = 0, dest_y = 0; + Window labelbutton = 0; + if (!XTranslateCoordinates(FbTk::App::instance()->display(), + parent().window(), frame().label().window(), + x, y, &dest_x, &dest_y, + &labelbutton)) + return m_clientlist.end(); + + Client2ButtonMap::iterator it = m_labelbuttons.begin(); + Client2ButtonMap::iterator it_end = m_labelbuttons.end(); + // find the label button to move next to + for (; it != it_end; it++) { + if ((*it).second->window() == labelbutton) + break; + } + + // label button not found + if (it == m_labelbuttons.end()) + return m_clientlist.end(); + + Window child_return=0; + // make x and y relative to our labelbutton + if (!XTranslateCoordinates(FbTk::App::instance()->display(), + frame().label().window(), labelbutton, + dest_x, dest_y, &x, &y, + &child_return)) + return m_clientlist.end(); + + ClientList::iterator client = find(m_clientlist.begin(), + m_clientlist.end(), + it->first); + if (x > (*it).second->width() / 2) + client++; + + return client; } void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { - int dest_x=0, dest_y=0; - Window labelbutton=0; - if(!XTranslateCoordinates(FbTk::App::instance()->display(), - parent().window(), frame().label().window(), - x,y, &dest_x, &dest_y, - &labelbutton)) - return; - Client2ButtonMap::iterator it = m_labelbuttons.begin(); - Client2ButtonMap::iterator it_end = m_labelbuttons.end(); - //find the label button to move next to - for(; it!=it_end; it++) { - if( (*it).second->window()==labelbutton) - break; - } - //label button not found - if(it==it_end) { - return; - } - Window child_return=0; - //make x and y relative to our labelbutton - if(!XTranslateCoordinates(FbTk::App::instance()->display(), - frame().label().window(),labelbutton, - dest_x,dest_y, &x, &y, - &child_return)) - return; - if(x>(*it).second->width()/2) { - moveClientRightOf(win, *it->first); - } else { - moveClientLeftOf(win, *it->first); - } + int dest_x = 0, dest_y = 0; + Window labelbutton = 0; + if (!XTranslateCoordinates(FbTk::App::instance()->display(), + parent().window(), frame().label().window(), + x, y, &dest_x, &dest_y, + &labelbutton)) + return; + Client2ButtonMap::iterator it = m_labelbuttons.begin(); + Client2ButtonMap::iterator it_end = m_labelbuttons.end(); + //find the label button to move next to + for (; it != it_end; it++) { + if ((*it).second->window() == labelbutton) + break; + } + + // label button not found + if (it == it_end) + return; + + Window child_return = 0; + //make x and y relative to our labelbutton + if (!XTranslateCoordinates(FbTk::App::instance()->display(), + frame().label().window(), labelbutton, + dest_x, dest_y, &x, &y, + &child_return)) + return; + if (x > (*it).second->width() / 2) + moveClientRightOf(win, *it->first); + else + moveClientLeftOf(win, *it->first); }

@@ -1154,7 +1161,7 @@ ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,

GrabModeAsync, None, frame().theme().moveCursor()); //----grab with "all" modifiers - grabButton(display, Button1, frame().window().window(), frame().theme().moveCursor()); + grabButton(Button1, frame().window().window(), frame().theme().moveCursor()); XGrabButton(display, Button2, Mod1Mask, frame().window().window(), True, ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);

@@ -1164,7 +1171,7 @@ ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,

GrabModeAsync, None, None); //---grab with "all" modifiers - grabButton(display, Button3, frame().window().window(), None); + grabButton(Button3, frame().window().window(), None); } }

@@ -3772,14 +3779,13 @@ setupMenu();

} void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) { - ExtraMenus::iterator it = m_extramenus.begin(); - ExtraMenus::iterator it_end = m_extramenus.end(); - for (; it != it_end; ++it) { - if (it->second == menu) { - m_extramenus.erase(it); - break; - } - } + ExtraMenus::iterator it = find_if(m_extramenus.begin(), + m_extramenus.end(), + Compose(bind2nd(equal_to<Menu *>(), menu), + Select2nd<ExtraMenus::value_type>())); + if (it != m_extramenus.end()) + m_extramenus.erase(it); + setupMenu(); }
M src/fluxbox.ccsrc/fluxbox.cc

@@ -51,6 +51,8 @@ #include "FbTk/RefCount.hh"

#include "FbTk/SimpleCommand.hh" #include "FbTk/CompareEqual.hh" #include "FbTk/Transparent.hh" +#include "FbTk/Select2nd.hh" +#include "FbTk/Compose.hh" //Use GNU extensions #ifndef _GNU_SOURCE

@@ -1329,11 +1331,13 @@

AtomHandler* Fluxbox::getAtomHandler(const std::string &name) { if ( name != "" ) { - for (AtomHandlerContainerIt it= m_atomhandler.begin(); - it != m_atomhandler.end(); it++ ) { - if ( name == (*it).second ) - return (*it).first; - } + using namespace FbTk; + AtomHandlerContainerIt it = find_if(m_atomhandler.begin(), + m_atomhandler.end(), + Compose(bind2nd(equal_to<string>(), name), + Select2nd<AtomHandlerContainer::value_type>())); + if (it != m_atomhandler.end()) + return (*it).first; } return 0; }

@@ -1342,7 +1346,6 @@ m_atomhandler[atomh]= name;;

} void Fluxbox::removeAtomHandler(AtomHandler *atomh) { - for (AtomHandlerContainerIt it= m_atomhandler.begin(); it != m_atomhandler.end(); ++it) {

@@ -1354,11 +1357,11 @@ }

} WinClient *Fluxbox::searchWindow(Window window) { - std::map<Window, WinClient *>::iterator it = m_window_search.find(window); + WinClientMap::iterator it = m_window_search.find(window); if (it != m_window_search.end()) return it->second; - std::map<Window, FluxboxWindow *>::iterator git = m_window_search_group.find(window); + WindowMap::iterator git = m_window_search_group.find(window); return git == m_window_search_group.end() ? 0 : &git->second->winClient(); }

@@ -1806,18 +1809,13 @@ WinClient *old_client = 0;

if (m_focused_window != 0) { // check if m_focused_window is valid - bool found = false; - std::map<Window, WinClient *>::iterator it = m_window_search.begin(); - std::map<Window, WinClient *>::iterator it_end = m_window_search.end(); - for (; it != it_end; ++it) { - if (it->second == m_focused_window) { - // we found it, end loop - found = true; - break; - } - } - - if (!found) { + WinClientMap::iterator it = find_if(m_window_search.begin(), + m_window_search.end(), + Compose(bind2nd(equal_to<WinClient *>(), m_focused_window), + Select2nd<WinClientMap::value_type>())); + + // if not found... + if (it == m_window_search.end()) { m_focused_window = 0; } else { old_client = m_focused_window;
M src/fluxbox.hhsrc/fluxbox.hh

@@ -273,8 +273,10 @@ FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;

FbTk::Resource<time_t> m_rc_auto_raise_delay; FbTk::Resource<bool> m_rc_use_mod1; /// temporary!, to disable mod1 for resize/move - std::map<Window, WinClient *> m_window_search; - std::map<Window, FluxboxWindow *> m_window_search_group; + typedef std::map<Window, WinClient *> WinClientMap; + WinClientMap m_window_search; + typedef std::map<Window, FluxboxWindow *> WindowMap; + WindowMap m_window_search_group; // A window is the group leader, which can map to several // WinClients in the group, it is *not* fluxbox's concept of groups // See ICCCM section 4.1.11