diff options
-rw-r--r-- | src/fluxbox.cc | 81 |
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 | */ | ||
206 | template <typename Type, typename ArgType, typename ResultType> | ||
207 | struct 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 | ||
985 | void Fluxbox::attachSignals(WinClient &winclient) { | 1032 | void 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 | ||
990 | BScreen *Fluxbox::searchScreen(Window window) { | 1038 | BScreen *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 |
1153 | void Fluxbox::load_rc() { | 1201 | void 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 | ||
1320 | void Fluxbox::updateFrameExtents(FluxboxWindow &win) { | 1368 | void 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 | ||
1324 | void Fluxbox::workspaceCountChanged( BScreen& screen ) { | 1373 | void 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 | ||
1329 | void Fluxbox::workspaceChanged( BScreen& screen ) { | 1378 | void 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 | ||
1334 | void Fluxbox::workspaceNamesChanged(BScreen &screen) { | 1383 | void 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 | ||
1339 | void Fluxbox::clientListChanged(BScreen &screen) { | 1388 | void 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 | ||
1344 | void Fluxbox::focusedWindowChanged(BScreen &screen, | 1393 | void Fluxbox::focusedWindowChanged(BScreen &screen, |
@@ -1353,6 +1402,6 @@ void Fluxbox::focusedWindowChanged(BScreen &screen, | |||
1353 | 1402 | ||
1354 | void Fluxbox::workspaceAreaChanged(BScreen &screen) { | 1403 | void 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 | ||