aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-19 06:46:21 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-19 06:46:21 (GMT)
commite3a2c56252914aa98ee7566563dc0b2884f90986 (patch)
tree99f991f1ae6f81b3d0bf19df52e621f2fc2b8861
parent0ef76292c5447127dc3fd39d6272f6d88a63d145 (diff)
downloadfluxbox_paul-e3a2c56252914aa98ee7566563dc0b2884f90986.zip
fluxbox_paul-e3a2c56252914aa98ee7566563dc0b2884f90986.tar.bz2
compile fix: use 'CallMemFunWithRefArg' instead of bind2nd(mem_fun(), *foo)
g++-4.1 does not like parts of 12e1ef78265a621dc51f7b9af245d81431835dcc, calling std::bind2nd(std::mem_fun(func), ref_arg) lead to a bunch of error: forming reference to reference type 'XYZ' in order to avoid switching either back to the old for-loops or boost::bind or to enforce a newer compiler (eg, g++-4.4) to the users a new helper functor was created: 'CallMemFunWithRefArg' this commit also fixes a little copy and paste error introduced in 12e1ef782, 'AtomHandler::updateClientClose' was called instead of 'AtomHandler::updateWorkspace'.
-rw-r--r--src/fluxbox.cc81
1 files changed, 65 insertions, 16 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index ac18281..9f2f5c1 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -180,6 +180,49 @@ int handleXErrors(Display *d, XErrorEvent *e) {
180 return False; 180 return False;
181} 181}
182 182
183
184
185/* functor to call a memberfunction with by a reference argument
186 other places needs this helper as well it should be moved
187 to FbTk/
188
189 g++-4.1 does not like to work with:
190
191 struct Bar;
192 struct Foo {
193 void foo(Bar&);
194 };
195
196 Bar bar;
197 bind2nd(mem_fun(&F::foo), bar);
198
199 it complaints about not beeing able to store a reference to
200 a reference (Bar&&).
201
202 'CallMemFunWithRefArg' makes g++-4.1 happy without
203 having to consider switching over to boost::bind() or enforcing
204 a newer compiler.
205 */
206template <typename Type, typename ArgType, typename ResultType>
207struct CallMemFunWithRefArg : std::unary_function<Type, ResultType> {
208
209 explicit CallMemFunWithRefArg(ResultType (Type::*func)(ArgType), ArgType arg) :
210 m_arg(arg),
211 m_func(func) { }
212
213 ResultType operator()(Type p) const {
214 (p.*m_func)(m_arg);
215 }
216
217 ResultType operator()(Type* p) const {
218 (*p.*m_func)(m_arg);
219 }
220
221 ArgType m_arg;
222 ResultType (Type::*m_func)(ArgType);
223};
224
225
183} // end anonymous 226} // end anonymous
184 227
185//static singleton var 228//static singleton var
@@ -459,7 +502,9 @@ void Fluxbox::initScreen(BScreen *screen) {
459 FbTk::MemFun(*this, &Fluxbox::workspaceCountChanged)); 502 FbTk::MemFun(*this, &Fluxbox::workspaceCountChanged));
460 503
461 // initiate atomhandler for screen specific stuff 504 // initiate atomhandler for screen specific stuff
462 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::initForScreen), *screen)); 505 STLUtil::forAll(m_atomhandler,
506 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::initForScreen, *screen));
507 //STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::initForScreen), *screen));
463 508
464 FocusControl::revertFocus(*screen); // make sure focus style is correct 509 FocusControl::revertFocus(*screen); // make sure focus style is correct
465 510
@@ -912,7 +957,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
912 957
913 if (fbwin && &fbwin->stateSig() == changedsub) { // state signal 958 if (fbwin && &fbwin->stateSig() == changedsub) { // state signal
914 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 959 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
915 bind2nd(mem_fun(&AtomHandler::updateState), *fbwin)); 960 CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateState, *fbwin));
916 961
917 // if window changed to iconic state 962 // if window changed to iconic state
918 // add to icon list 963 // add to icon list
@@ -935,10 +980,10 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
935 } 980 }
936 } else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal 981 } else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal
937 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 982 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
938 bind2nd(mem_fun(&AtomHandler::updateLayer), *fbwin)); 983 CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, *fbwin));
939 } else if (fbwin && &fbwin->dieSig() == changedsub) { // window death signal 984 } else if (fbwin && &fbwin->dieSig() == changedsub) { // window death signal
940 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 985 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
941 bind2nd(mem_fun(&AtomHandler::updateFrameClose), *fbwin)); 986 CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateFrameClose, *fbwin));
942 987
943 // make sure each workspace get this 988 // make sure each workspace get this
944 BScreen &scr = fbwin->screen(); 989 BScreen &scr = fbwin->screen();
@@ -947,10 +992,10 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
947 FocusControl::setFocusedFbWindow(0); 992 FocusControl::setFocusedFbWindow(0);
948 } else if (fbwin && &fbwin->workspaceSig() == changedsub) { // workspace signal 993 } else if (fbwin && &fbwin->workspaceSig() == changedsub) { // workspace signal
949 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 994 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
950 bind2nd(mem_fun(&AtomHandler::updateClientClose), *fbwin)); 995 CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateWorkspace, *fbwin));
951 } else if (client && &client->dieSig() == changedsub) { // client death 996 } else if (client && &client->dieSig() == changedsub) { // client death
952 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 997 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
953 bind2nd(mem_fun(&AtomHandler::updateClientClose), *client)); 998 CallMemFunWithRefArg<AtomHandler, WinClient&, void>(&AtomHandler::updateClientClose, *client));
954 999
955 BScreen &screen = client->screen(); 1000 BScreen &screen = client->screen();
956 1001
@@ -979,12 +1024,15 @@ void Fluxbox::attachSignals(FluxboxWindow &win) {
979 win.workspaceSig().attach(this); 1024 win.workspaceSig().attach(this);
980 win.layerSig().attach(this); 1025 win.layerSig().attach(this);
981 win.dieSig().attach(this); 1026 win.dieSig().attach(this);
982 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::setupFrame), win)); 1027 STLUtil::forAll(m_atomhandler,
1028 bind2nd(mem_fun(&AtomHandler::setupFrame), win));
1029 // CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::setupFrame, win));
983} 1030}
984 1031
985void Fluxbox::attachSignals(WinClient &winclient) { 1032void Fluxbox::attachSignals(WinClient &winclient) {
986 winclient.dieSig().attach(this); 1033 winclient.dieSig().attach(this);
987 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::setupClient), winclient)); 1034 STLUtil::forAll(m_atomhandler,
1035 CallMemFunWithRefArg<AtomHandler, WinClient&, void>(&AtomHandler::setupClient, winclient));
988} 1036}
989 1037
990BScreen *Fluxbox::searchScreen(Window window) { 1038BScreen *Fluxbox::searchScreen(Window window) {
@@ -1129,7 +1177,7 @@ void Fluxbox::save_rc() {
1129 1177
1130 XrmDatabase old_rc = XrmGetFileDatabase(dbfile.c_str()); 1178 XrmDatabase old_rc = XrmGetFileDatabase(dbfile.c_str());
1131 1179
1132 XrmMergeDatabases(new_rc, &old_rc); //merge database together 1180 XrmMergeDatabases(new_rc, &old_rc);
1133 XrmPutFileDatabase(old_rc, dbfile.c_str()); 1181 XrmPutFileDatabase(old_rc, dbfile.c_str());
1134 XrmDestroyDatabase(old_rc); 1182 XrmDestroyDatabase(old_rc);
1135 1183
@@ -1152,7 +1200,7 @@ string Fluxbox::getDefaultDataFilename(const char *name) const {
1152/// loads resources 1200/// loads resources
1153void Fluxbox::load_rc() { 1201void Fluxbox::load_rc() {
1154 _FB_USES_NLS; 1202 _FB_USES_NLS;
1155 //get resource filename 1203
1156 string dbfile(getRcFilename()); 1204 string dbfile(getRcFilename());
1157 1205
1158 if (!dbfile.empty()) { 1206 if (!dbfile.empty()) {
@@ -1318,27 +1366,28 @@ bool Fluxbox::validateClient(const WinClient *client) const {
1318} 1366}
1319 1367
1320void Fluxbox::updateFrameExtents(FluxboxWindow &win) { 1368void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
1321 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::updateFrameExtents), win)); 1369 STLUtil::forAll(m_atomhandler,
1370 CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateFrameExtents, win));
1322} 1371}
1323 1372
1324void Fluxbox::workspaceCountChanged( BScreen& screen ) { 1373void Fluxbox::workspaceCountChanged( BScreen& screen ) {
1325 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1374 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1326 bind2nd(mem_fun(&AtomHandler::updateWorkspaceCount), screen)); 1375 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateWorkspaceCount, screen));
1327} 1376}
1328 1377
1329void Fluxbox::workspaceChanged( BScreen& screen ) { 1378void Fluxbox::workspaceChanged( BScreen& screen ) {
1330 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1379 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1331 bind2nd(mem_fun(&AtomHandler::updateCurrentWorkspace), screen)); 1380 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateCurrentWorkspace, screen));
1332} 1381}
1333 1382
1334void Fluxbox::workspaceNamesChanged(BScreen &screen) { 1383void Fluxbox::workspaceNamesChanged(BScreen &screen) {
1335 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1384 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1336 bind2nd(mem_fun(&AtomHandler::updateWorkspaceNames), screen)); 1385 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateWorkspaceNames, screen));
1337} 1386}
1338 1387
1339void Fluxbox::clientListChanged(BScreen &screen) { 1388void Fluxbox::clientListChanged(BScreen &screen) {
1340 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1389 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1341 bind2nd(mem_fun(&AtomHandler::updateClientList), screen)); 1390 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateClientList, screen));
1342} 1391}
1343 1392
1344void Fluxbox::focusedWindowChanged(BScreen &screen, 1393void Fluxbox::focusedWindowChanged(BScreen &screen,
@@ -1353,6 +1402,6 @@ void Fluxbox::focusedWindowChanged(BScreen &screen,
1353 1402
1354void Fluxbox::workspaceAreaChanged(BScreen &screen) { 1403void Fluxbox::workspaceAreaChanged(BScreen &screen) {
1355 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1404 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1356 bind2nd(mem_fun(&AtomHandler::updateWorkarea), screen)); 1405 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateWorkarea, screen));
1357} 1406}
1358 1407