aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-19 06:48:35 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-19 06:48:35 (GMT)
commite0c440f5993dbc308fcb14daa634c941a0c45ce0 (patch)
treee115d39285d14d1abfbb1763bc559f029928c185 /src
parent0ef76292c5447127dc3fd39d6272f6d88a63d145 (diff)
downloadfluxbox_paul-e0c440f5993dbc308fcb14daa634c941a0c45ce0.zip
fluxbox_paul-e0c440f5993dbc308fcb14daa634c941a0c45ce0.tar.bz2
pushed to early ...
Diffstat (limited to 'src')
-rw-r--r--src/fluxbox.cc80
1 files changed, 64 insertions, 16 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index ac18281..4513c47 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,14 @@ 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 CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::setupFrame, win));
983} 1029}
984 1030
985void Fluxbox::attachSignals(WinClient &winclient) { 1031void Fluxbox::attachSignals(WinClient &winclient) {
986 winclient.dieSig().attach(this); 1032 winclient.dieSig().attach(this);
987 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::setupClient), winclient)); 1033 STLUtil::forAll(m_atomhandler,
1034 CallMemFunWithRefArg<AtomHandler, WinClient&, void>(&AtomHandler::setupClient, winclient));
988} 1035}
989 1036
990BScreen *Fluxbox::searchScreen(Window window) { 1037BScreen *Fluxbox::searchScreen(Window window) {
@@ -1129,7 +1176,7 @@ void Fluxbox::save_rc() {
1129 1176
1130 XrmDatabase old_rc = XrmGetFileDatabase(dbfile.c_str()); 1177 XrmDatabase old_rc = XrmGetFileDatabase(dbfile.c_str());
1131 1178
1132 XrmMergeDatabases(new_rc, &old_rc); //merge database together 1179 XrmMergeDatabases(new_rc, &old_rc);
1133 XrmPutFileDatabase(old_rc, dbfile.c_str()); 1180 XrmPutFileDatabase(old_rc, dbfile.c_str());
1134 XrmDestroyDatabase(old_rc); 1181 XrmDestroyDatabase(old_rc);
1135 1182
@@ -1152,7 +1199,7 @@ string Fluxbox::getDefaultDataFilename(const char *name) const {
1152/// loads resources 1199/// loads resources
1153void Fluxbox::load_rc() { 1200void Fluxbox::load_rc() {
1154 _FB_USES_NLS; 1201 _FB_USES_NLS;
1155 //get resource filename 1202
1156 string dbfile(getRcFilename()); 1203 string dbfile(getRcFilename());
1157 1204
1158 if (!dbfile.empty()) { 1205 if (!dbfile.empty()) {
@@ -1318,27 +1365,28 @@ bool Fluxbox::validateClient(const WinClient *client) const {
1318} 1365}
1319 1366
1320void Fluxbox::updateFrameExtents(FluxboxWindow &win) { 1367void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
1321 STLUtil::forAll(m_atomhandler, bind2nd(mem_fun(&AtomHandler::updateFrameExtents), win)); 1368 STLUtil::forAll(m_atomhandler,
1369 CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateFrameExtents, win));
1322} 1370}
1323 1371
1324void Fluxbox::workspaceCountChanged( BScreen& screen ) { 1372void Fluxbox::workspaceCountChanged( BScreen& screen ) {
1325 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1373 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1326 bind2nd(mem_fun(&AtomHandler::updateWorkspaceCount), screen)); 1374 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateWorkspaceCount, screen));
1327} 1375}
1328 1376
1329void Fluxbox::workspaceChanged( BScreen& screen ) { 1377void Fluxbox::workspaceChanged( BScreen& screen ) {
1330 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1378 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1331 bind2nd(mem_fun(&AtomHandler::updateCurrentWorkspace), screen)); 1379 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateCurrentWorkspace, screen));
1332} 1380}
1333 1381
1334void Fluxbox::workspaceNamesChanged(BScreen &screen) { 1382void Fluxbox::workspaceNamesChanged(BScreen &screen) {
1335 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1383 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1336 bind2nd(mem_fun(&AtomHandler::updateWorkspaceNames), screen)); 1384 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateWorkspaceNames, screen));
1337} 1385}
1338 1386
1339void Fluxbox::clientListChanged(BScreen &screen) { 1387void Fluxbox::clientListChanged(BScreen &screen) {
1340 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1388 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1341 bind2nd(mem_fun(&AtomHandler::updateClientList), screen)); 1389 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateClientList, screen));
1342} 1390}
1343 1391
1344void Fluxbox::focusedWindowChanged(BScreen &screen, 1392void Fluxbox::focusedWindowChanged(BScreen &screen,
@@ -1353,6 +1401,6 @@ void Fluxbox::focusedWindowChanged(BScreen &screen,
1353 1401
1354void Fluxbox::workspaceAreaChanged(BScreen &screen) { 1402void Fluxbox::workspaceAreaChanged(BScreen &screen) {
1355 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), 1403 STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
1356 bind2nd(mem_fun(&AtomHandler::updateWorkarea), screen)); 1404 CallMemFunWithRefArg<AtomHandler, BScreen&, void>(&AtomHandler::updateWorkarea, screen));
1357} 1405}
1358 1406