aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2005-05-02 12:10:01 (GMT)
committerfluxgen <fluxgen>2005-05-02 12:10:01 (GMT)
commitdce0e2e40c9fed226139c3def26e423b75c6bb9c (patch)
tree55784f6a6c526ebf06fb0a116b74efbf0b9ca66a /src
parent6b943ec69ada6ba8c7b0a8305f048df8ef07f961 (diff)
downloadfluxbox-dce0e2e40c9fed226139c3def26e423b75c6bb9c.zip
fluxbox-dce0e2e40c9fed226139c3def26e423b75c6bb9c.tar.bz2
using Select2nd
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc35
-rw-r--r--src/Window.cc162
-rw-r--r--src/fluxbox.cc38
-rw-r--r--src/fluxbox.hh6
4 files changed, 124 insertions, 117 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index b83296e..36ab193 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -69,6 +69,8 @@
69#include "FbTk/ImageControl.hh" 69#include "FbTk/ImageControl.hh"
70#include "FbTk/EventManager.hh" 70#include "FbTk/EventManager.hh"
71#include "FbTk/Transparent.hh" 71#include "FbTk/Transparent.hh"
72#include "FbTk/Select2nd.hh"
73#include "FbTk/Compose.hh"
72 74
73//use GNU extensions 75//use GNU extensions
74#ifndef _GNU_SOURCE 76#ifndef _GNU_SOURCE
@@ -830,16 +832,17 @@ void BScreen::removeClient(WinClient &client) {
830 for_each(getWorkspacesList().begin(), getWorkspacesList().end(), 832 for_each(getWorkspacesList().begin(), getWorkspacesList().end(),
831 mem_fun(&Workspace::updateClientmenu)); 833 mem_fun(&Workspace::updateClientmenu));
832 834
835 using namespace FbTk;
836
833 // remove any grouping this is expecting 837 // remove any grouping this is expecting
834 Groupables::iterator it = m_expecting_groups.begin(); 838 Groupables::iterator erase_it = find_if(m_expecting_groups.begin(),
835 Groupables::iterator it_end = m_expecting_groups.end(); 839 m_expecting_groups.end(),
836 for (; it != it_end; ++it) { 840 Compose(bind2nd(equal_to<WinClient *>(), &client),
837 if (it->second == &client) { 841 Select2nd<Groupables::value_type>()));
838 m_expecting_groups.erase(it); 842
839 // it should only be in there a maximum of once 843 if (erase_it != m_expecting_groups.end())
840 break; 844 m_expecting_groups.erase(erase_it);
841 } 845
842 }
843 // the client could be on icon menu so we update it 846 // the client could be on icon menu so we update it
844 //!! TODO: check this with the new icon menu 847 //!! TODO: check this with the new icon menu
845 // updateIconMenu(); 848 // updateIconMenu();
@@ -1711,14 +1714,12 @@ void BScreen::addConfigMenu(const char *label, FbTk::Menu &menu) {
1711} 1714}
1712 1715
1713void BScreen::removeConfigMenu(FbTk::Menu &menu) { 1716void BScreen::removeConfigMenu(FbTk::Menu &menu) {
1714 Configmenus::iterator it = m_configmenu_list.begin(); 1717 Configmenus::iterator erase_it = find_if(m_configmenu_list.begin(),
1715 Configmenus::iterator it_end = m_configmenu_list.end(); 1718 m_configmenu_list.end(),
1716 for (; it != it_end; ++it) { 1719 FbTk::Compose(bind2nd(equal_to<FbTk::Menu *>(), &menu),
1717 if (it->second == &menu) { 1720 FbTk::Select2nd<Configmenus::value_type>()));
1718 m_configmenu_list.erase(it); 1721 if (erase_it != m_configmenu_list.end())
1719 break; 1722 m_configmenu_list.erase(erase_it);
1720 }
1721 }
1722 setupConfigmenu(*m_configmenu.get()); 1723 setupConfigmenu(*m_configmenu.get());
1723 1724
1724} 1725}
diff --git a/src/Window.cc b/src/Window.cc
index 50b6f53..02a9d7f 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -45,6 +45,7 @@
45#include "FbTk/EventManager.hh" 45#include "FbTk/EventManager.hh"
46#include "FbTk/KeyUtil.hh" 46#include "FbTk/KeyUtil.hh"
47#include "FbTk/SimpleCommand.hh" 47#include "FbTk/SimpleCommand.hh"
48#include "FbTk/Select2nd.hh"
48 49
49#ifdef HAVE_CONFIG_H 50#ifdef HAVE_CONFIG_H
50#include "config.h" 51#include "config.h"
@@ -81,15 +82,18 @@
81#include <algorithm> 82#include <algorithm>
82 83
83using namespace std; 84using namespace std;
85using namespace FbTk;
84 86
85namespace { 87namespace {
86 88
87void grabButton(Display *display, unsigned int button, 89void grabButton(unsigned int button,
88 Window window, Cursor cursor) { 90 Window window, Cursor cursor) {
89 91
90 const int numlock = FbTk::KeyUtil::instance().numlock(); 92 static Display *display = App::instance()->display();
91 const int capslock = FbTk::KeyUtil::instance().capslock(); 93
92 const int scrolllock = FbTk::KeyUtil::instance().scrolllock(); 94 const int numlock = KeyUtil::instance().numlock();
95 const int capslock = KeyUtil::instance().capslock();
96 const int scrolllock = KeyUtil::instance().scrolllock();
93 97
94 // Grab with Mod1 and with all lock modifiers 98 // Grab with Mod1 and with all lock modifiers
95 // (num, scroll and caps) 99 // (num, scroll and caps)
@@ -863,8 +867,8 @@ bool FluxboxWindow::removeClient(WinClient &client) {
863WinClient *FluxboxWindow::findClient(Window win) { 867WinClient *FluxboxWindow::findClient(Window win) {
864 ClientList::iterator it = find_if(clientList().begin(), 868 ClientList::iterator it = find_if(clientList().begin(),
865 clientList().end(), 869 clientList().end(),
866 FbTk::Compose(bind2nd(equal_to<Window>(), win), 870 Compose(bind2nd(equal_to<Window>(), win),
867 mem_fun(&WinClient::window))); 871 mem_fun(&WinClient::window)));
868 return (it == clientList().end() ? 0 : *it); 872 return (it == clientList().end() ? 0 : *it);
869} 873}
870 874
@@ -941,74 +945,77 @@ void FluxboxWindow::moveClientRight() {
941//std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { 945//std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) {
942FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) { 946FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) {
943 947
944 int dest_x=0, dest_y=0; 948 int dest_x = 0, dest_y = 0;
945 Window labelbutton=0; 949 Window labelbutton = 0;
946 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 950 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
947 parent().window(), frame().label().window(), 951 parent().window(), frame().label().window(),
948 x,y, &dest_x, &dest_y, 952 x, y, &dest_x, &dest_y,
949 &labelbutton)) 953 &labelbutton))
950 return m_clientlist.end(); 954 return m_clientlist.end();
951 Client2ButtonMap::iterator it = m_labelbuttons.begin(); 955
952 Client2ButtonMap::iterator it_end = m_labelbuttons.end(); 956 Client2ButtonMap::iterator it = m_labelbuttons.begin();
953 //find the label button to move next to 957 Client2ButtonMap::iterator it_end = m_labelbuttons.end();
954 for(; it!=it_end; it++) { 958 // find the label button to move next to
955 if( (*it).second->window()==labelbutton) 959 for (; it != it_end; it++) {
956 break; 960 if ((*it).second->window() == labelbutton)
957 } 961 break;
958 //label button not found 962 }
959 if(it==it_end) { 963
960 return m_clientlist.end(); 964 // label button not found
961 } 965 if (it == m_labelbuttons.end())
962 Window child_return=0; 966 return m_clientlist.end();
963 //make x and y relative to our labelbutton 967
964 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 968 Window child_return=0;
965 frame().label().window(),labelbutton, 969 // make x and y relative to our labelbutton
966 dest_x,dest_y, &x, &y, 970 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
967 &child_return)) 971 frame().label().window(), labelbutton,
968 return m_clientlist.end(); 972 dest_x, dest_y, &x, &y,
969 ClientList::iterator client = find(m_clientlist.begin(), 973 &child_return))
970 m_clientlist.end(), 974 return m_clientlist.end();
971 it->first); 975
972 if(x>(*it).second->width()/2) 976 ClientList::iterator client = find(m_clientlist.begin(),
973 client++; 977 m_clientlist.end(),
974 return client; 978 it->first);
975 979 if (x > (*it).second->width() / 2)
980 client++;
981
982 return client;
976 983
977} 984}
978 985
979 986
980 987
981void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { 988void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) {
982 int dest_x=0, dest_y=0; 989 int dest_x = 0, dest_y = 0;
983 Window labelbutton=0; 990 Window labelbutton = 0;
984 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 991 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
985 parent().window(), frame().label().window(), 992 parent().window(), frame().label().window(),
986 x,y, &dest_x, &dest_y, 993 x, y, &dest_x, &dest_y,
987 &labelbutton)) 994 &labelbutton))
988 return; 995 return;
989 Client2ButtonMap::iterator it = m_labelbuttons.begin(); 996 Client2ButtonMap::iterator it = m_labelbuttons.begin();
990 Client2ButtonMap::iterator it_end = m_labelbuttons.end(); 997 Client2ButtonMap::iterator it_end = m_labelbuttons.end();
991 //find the label button to move next to 998 //find the label button to move next to
992 for(; it!=it_end; it++) { 999 for (; it != it_end; it++) {
993 if( (*it).second->window()==labelbutton) 1000 if ((*it).second->window() == labelbutton)
994 break; 1001 break;
995 } 1002 }
996 //label button not found 1003
997 if(it==it_end) { 1004 // label button not found
998 return; 1005 if (it == it_end)
999 } 1006 return;
1000 Window child_return=0; 1007
1001 //make x and y relative to our labelbutton 1008 Window child_return = 0;
1002 if(!XTranslateCoordinates(FbTk::App::instance()->display(), 1009 //make x and y relative to our labelbutton
1003 frame().label().window(),labelbutton, 1010 if (!XTranslateCoordinates(FbTk::App::instance()->display(),
1004 dest_x,dest_y, &x, &y, 1011 frame().label().window(), labelbutton,
1005 &child_return)) 1012 dest_x, dest_y, &x, &y,
1006 return; 1013 &child_return))
1007 if(x>(*it).second->width()/2) { 1014 return;
1008 moveClientRightOf(win, *it->first); 1015 if (x > (*it).second->width() / 2)
1009 } else { 1016 moveClientRightOf(win, *it->first);
1010 moveClientLeftOf(win, *it->first); 1017 else
1011 } 1018 moveClientLeftOf(win, *it->first);
1012 1019
1013} 1020}
1014 1021
@@ -1154,7 +1161,7 @@ void FluxboxWindow::grabButtons() {
1154 GrabModeAsync, None, frame().theme().moveCursor()); 1161 GrabModeAsync, None, frame().theme().moveCursor());
1155 1162
1156 //----grab with "all" modifiers 1163 //----grab with "all" modifiers
1157 grabButton(display, Button1, frame().window().window(), frame().theme().moveCursor()); 1164 grabButton(Button1, frame().window().window(), frame().theme().moveCursor());
1158 1165
1159 XGrabButton(display, Button2, Mod1Mask, frame().window().window(), True, 1166 XGrabButton(display, Button2, Mod1Mask, frame().window().window(), True,
1160 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); 1167 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
@@ -1164,7 +1171,7 @@ void FluxboxWindow::grabButtons() {
1164 GrabModeAsync, None, None); 1171 GrabModeAsync, None, None);
1165 1172
1166 //---grab with "all" modifiers 1173 //---grab with "all" modifiers
1167 grabButton(display, Button3, frame().window().window(), None); 1174 grabButton(Button3, frame().window().window(), None);
1168 } 1175 }
1169} 1176}
1170 1177
@@ -3772,14 +3779,13 @@ void FluxboxWindow::addExtraMenu(const char *label, FbTk::Menu *menu) {
3772} 3779}
3773 3780
3774void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) { 3781void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) {
3775 ExtraMenus::iterator it = m_extramenus.begin(); 3782 ExtraMenus::iterator it = find_if(m_extramenus.begin(),
3776 ExtraMenus::iterator it_end = m_extramenus.end(); 3783 m_extramenus.end(),
3777 for (; it != it_end; ++it) { 3784 Compose(bind2nd(equal_to<Menu *>(), menu),
3778 if (it->second == menu) { 3785 Select2nd<ExtraMenus::value_type>()));
3779 m_extramenus.erase(it); 3786 if (it != m_extramenus.end())
3780 break; 3787 m_extramenus.erase(it);
3781 } 3788
3782 }
3783 setupMenu(); 3789 setupMenu();
3784} 3790}
3785 3791
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index ce3161a..cd289ed 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -51,6 +51,8 @@
51#include "FbTk/SimpleCommand.hh" 51#include "FbTk/SimpleCommand.hh"
52#include "FbTk/CompareEqual.hh" 52#include "FbTk/CompareEqual.hh"
53#include "FbTk/Transparent.hh" 53#include "FbTk/Transparent.hh"
54#include "FbTk/Select2nd.hh"
55#include "FbTk/Compose.hh"
54 56
55//Use GNU extensions 57//Use GNU extensions
56#ifndef _GNU_SOURCE 58#ifndef _GNU_SOURCE
@@ -1329,11 +1331,13 @@ BScreen *Fluxbox::searchScreen(Window window) {
1329 1331
1330AtomHandler* Fluxbox::getAtomHandler(const std::string &name) { 1332AtomHandler* Fluxbox::getAtomHandler(const std::string &name) {
1331 if ( name != "" ) { 1333 if ( name != "" ) {
1332 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1334 using namespace FbTk;
1333 it != m_atomhandler.end(); it++ ) { 1335 AtomHandlerContainerIt it = find_if(m_atomhandler.begin(),
1334 if ( name == (*it).second ) 1336 m_atomhandler.end(),
1335 return (*it).first; 1337 Compose(bind2nd(equal_to<string>(), name),
1336 } 1338 Select2nd<AtomHandlerContainer::value_type>()));
1339 if (it != m_atomhandler.end())
1340 return (*it).first;
1337 } 1341 }
1338 return 0; 1342 return 0;
1339} 1343}
@@ -1342,7 +1346,6 @@ void Fluxbox::addAtomHandler(AtomHandler *atomh, const std::string &name) {
1342} 1346}
1343 1347
1344void Fluxbox::removeAtomHandler(AtomHandler *atomh) { 1348void Fluxbox::removeAtomHandler(AtomHandler *atomh) {
1345
1346 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1349 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1347 it != m_atomhandler.end(); 1350 it != m_atomhandler.end();
1348 ++it) { 1351 ++it) {
@@ -1354,11 +1357,11 @@ void Fluxbox::removeAtomHandler(AtomHandler *atomh) {
1354} 1357}
1355 1358
1356WinClient *Fluxbox::searchWindow(Window window) { 1359WinClient *Fluxbox::searchWindow(Window window) {
1357 std::map<Window, WinClient *>::iterator it = m_window_search.find(window); 1360 WinClientMap::iterator it = m_window_search.find(window);
1358 if (it != m_window_search.end()) 1361 if (it != m_window_search.end())
1359 return it->second; 1362 return it->second;
1360 1363
1361 std::map<Window, FluxboxWindow *>::iterator git = m_window_search_group.find(window); 1364 WindowMap::iterator git = m_window_search_group.find(window);
1362 return git == m_window_search_group.end() ? 0 : &git->second->winClient(); 1365 return git == m_window_search_group.end() ? 0 : &git->second->winClient();
1363} 1366}
1364 1367
@@ -1806,18 +1809,13 @@ void Fluxbox::setFocusedWindow(WinClient *client) {
1806 1809
1807 if (m_focused_window != 0) { 1810 if (m_focused_window != 0) {
1808 // check if m_focused_window is valid 1811 // check if m_focused_window is valid
1809 bool found = false; 1812 WinClientMap::iterator it = find_if(m_window_search.begin(),
1810 std::map<Window, WinClient *>::iterator it = m_window_search.begin(); 1813 m_window_search.end(),
1811 std::map<Window, WinClient *>::iterator it_end = m_window_search.end(); 1814 Compose(bind2nd(equal_to<WinClient *>(), m_focused_window),
1812 for (; it != it_end; ++it) { 1815 Select2nd<WinClientMap::value_type>()));
1813 if (it->second == m_focused_window) { 1816
1814 // we found it, end loop 1817 // if not found...
1815 found = true; 1818 if (it == m_window_search.end()) {
1816 break;
1817 }
1818 }
1819
1820 if (!found) {
1821 m_focused_window = 0; 1819 m_focused_window = 0;
1822 } else { 1820 } else {
1823 old_client = m_focused_window; 1821 old_client = m_focused_window;
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index a995bd5..f96e7eb 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -273,8 +273,10 @@ private:
273 FbTk::Resource<time_t> m_rc_auto_raise_delay; 273 FbTk::Resource<time_t> m_rc_auto_raise_delay;
274 FbTk::Resource<bool> m_rc_use_mod1; /// temporary!, to disable mod1 for resize/move 274 FbTk::Resource<bool> m_rc_use_mod1; /// temporary!, to disable mod1 for resize/move
275 275
276 std::map<Window, WinClient *> m_window_search; 276 typedef std::map<Window, WinClient *> WinClientMap;
277 std::map<Window, FluxboxWindow *> m_window_search_group; 277 WinClientMap m_window_search;
278 typedef std::map<Window, FluxboxWindow *> WindowMap;
279 WindowMap m_window_search_group;
278 // A window is the group leader, which can map to several 280 // A window is the group leader, which can map to several
279 // WinClients in the group, it is *not* fluxbox's concept of groups 281 // WinClients in the group, it is *not* fluxbox's concept of groups
280 // See ICCCM section 4.1.11 282 // See ICCCM section 4.1.11