diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-05-06 20:26:20 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-05-10 11:00:46 (GMT) |
commit | 6a0280aa4d8b468617a7dd5f7a6523d0422364e8 (patch) | |
tree | e85f742583d112f8d970c0523537aacdb1926726 | |
parent | e53d14e9102270a1682a88c29161580ccbf0c20a (diff) | |
download | fluxbox_paul-6a0280aa4d8b468617a7dd5f7a6523d0422364e8.zip fluxbox_paul-6a0280aa4d8b468617a7dd5f7a6523d0422364e8.tar.bz2 |
Convert FluxboxWindow::layerSig to FbTk::Signal
-rw-r--r-- | src/FocusableList.cc | 71 | ||||
-rw-r--r-- | src/FocusableList.hh | 5 | ||||
-rw-r--r-- | src/Window.cc | 5 | ||||
-rw-r--r-- | src/Window.hh | 8 | ||||
-rw-r--r-- | src/fluxbox.cc | 26 | ||||
-rw-r--r-- | src/fluxbox.hh | 5 |
6 files changed, 34 insertions, 86 deletions
diff --git a/src/FocusableList.cc b/src/FocusableList.cc index 0368442..77ff247 100644 --- a/src/FocusableList.cc +++ b/src/FocusableList.cc | |||
@@ -107,17 +107,6 @@ void FocusableList::init() { | |||
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | void FocusableList::update(FbTk::Subject *subj) { | ||
111 | if (subj == 0 || m_screen.isShuttingdown()) | ||
112 | return; | ||
113 | |||
114 | if (typeid(*subj) == typeid(FluxboxWindow::WinSubject)) { | ||
115 | FluxboxWindow::WinSubject *fsubj = | ||
116 | static_cast<FluxboxWindow::WinSubject *>(subj); | ||
117 | windowUpdated(fsubj->win()); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | void FocusableList::windowUpdated(FluxboxWindow &fbwin) { | 110 | void FocusableList::windowUpdated(FluxboxWindow &fbwin) { |
122 | if (m_screen.isShuttingdown()) | 111 | if (m_screen.isShuttingdown()) |
123 | return; | 112 | return; |
@@ -243,7 +232,7 @@ void FocusableList::remove(Focusable &win) { | |||
243 | // if the window isn't already in this list, we could send a bad signal | 232 | // if the window isn't already in this list, we could send a bad signal |
244 | bool contained = contains(win); | 233 | bool contained = contains(win); |
245 | 234 | ||
246 | detachSignals(win); | 235 | m_signal_map.erase(&win); |
247 | if (!contained) { | 236 | if (!contained) { |
248 | return; | 237 | return; |
249 | } | 238 | } |
@@ -257,50 +246,30 @@ void FocusableList::updateTitle(Focusable& win) { | |||
257 | #include "Debug.hh" | 246 | #include "Debug.hh" |
258 | 247 | ||
259 | void FocusableList::attachSignals(Focusable &win) { | 248 | void FocusableList::attachSignals(Focusable &win) { |
260 | if (m_parent) { | 249 | if (m_parent == NULL) |
261 | FluxboxWindow *fbwin = win.fbwindow(); | 250 | return; |
262 | |||
263 | // attach various signals for matching | ||
264 | FbTk::RefCount<FbTk::SignalTracker> &tracker = m_signal_map[&win]; | ||
265 | if (! tracker) { | ||
266 | // we have not attached to this window yet | ||
267 | tracker = new SignalTracker; | ||
268 | tracker->join(win.titleSig(), MemFunSelectArg1(*this, &FocusableList::updateTitle)); | ||
269 | tracker->join(win.dieSig(), MemFun(*this, &FocusableList::remove)); | ||
270 | if(fbwin) { | ||
271 | tracker->join(fbwin->workspaceSig(), | ||
272 | MemFun(*this, &FocusableList::windowUpdated) | ||
273 | ); | ||
274 | tracker->join(fbwin->stateSig(), | ||
275 | MemFun(*this, &FocusableList::windowUpdated) | ||
276 | ); | ||
277 | } | ||
278 | } | ||
279 | |||
280 | if (!fbwin) | ||
281 | return; | ||
282 | fbwin->layerSig().attach(this); | ||
283 | // TODO: can't watch (head=...) yet | ||
284 | } | ||
285 | } | ||
286 | 251 | ||
287 | void FocusableList::detachSignals(Focusable &win) { | 252 | FluxboxWindow *fbwin = win.fbwindow(); |
288 | m_signal_map.erase(&win); | 253 | |
289 | if (m_parent) { | 254 | // attach various signals for matching |
290 | // detach various signals for matching | 255 | FbTk::RefCount<FbTk::SignalTracker> &tracker = m_signal_map[&win]; |
291 | FluxboxWindow *fbwin = win.fbwindow(); | 256 | if (! tracker) { |
292 | if (!fbwin) | 257 | // we have not attached to this window yet |
293 | return; | 258 | tracker = new SignalTracker; |
294 | fbwin->layerSig().detach(this); | 259 | tracker->join(win.titleSig(), MemFunSelectArg1(*this, &FocusableList::updateTitle)); |
295 | // TODO: can't watch (head=...) yet | 260 | tracker->join(win.dieSig(), MemFun(*this, &FocusableList::remove)); |
261 | if(fbwin) { | ||
262 | tracker->join(fbwin->workspaceSig(), MemFun(*this, &FocusableList::windowUpdated)); | ||
263 | tracker->join(fbwin->stateSig(), MemFun(*this, &FocusableList::windowUpdated)); | ||
264 | tracker->join(fbwin->layerSig(), MemFun(*this, &FocusableList::windowUpdated)); | ||
265 | // TODO: can't watch (head=...) yet | ||
266 | } | ||
296 | } | 267 | } |
297 | } | 268 | } |
298 | 269 | ||
299 | void FocusableList::reset() { | 270 | void FocusableList::reset() { |
300 | while (!m_list.empty()) { | 271 | m_signal_map.clear(); |
301 | detachSignals(*m_list.back()); | 272 | m_list.clear(); |
302 | m_list.pop_back(); | ||
303 | } | ||
304 | m_pat->resetMatches(); | 273 | m_pat->resetMatches(); |
305 | if (m_parent) | 274 | if (m_parent) |
306 | addMatching(); | 275 | addMatching(); |
diff --git a/src/FocusableList.hh b/src/FocusableList.hh index af73e3e..aea7909 100644 --- a/src/FocusableList.hh +++ b/src/FocusableList.hh | |||
@@ -39,7 +39,7 @@ class Focusable; | |||
39 | class WinClient; | 39 | class WinClient; |
40 | class FluxboxWindow; | 40 | class FluxboxWindow; |
41 | 41 | ||
42 | class FocusableList: public FbTk::Observer, private FbTk::NotCopyable, | 42 | class FocusableList: private FbTk::NotCopyable, |
43 | private FbTk::SignalTracker { | 43 | private FbTk::SignalTracker { |
44 | public: | 44 | public: |
45 | typedef std::list<Focusable *> Focusables; | 45 | typedef std::list<Focusable *> Focusables; |
@@ -58,8 +58,6 @@ public: | |||
58 | static void parseArgs(const std::string &in, int &opts, std::string &out); | 58 | static void parseArgs(const std::string &in, int &opts, std::string &out); |
59 | static const FocusableList *getListFromOptions(BScreen &scr, int opts); | 59 | static const FocusableList *getListFromOptions(BScreen &scr, int opts); |
60 | 60 | ||
61 | void update(FbTk::Subject *subj); | ||
62 | |||
63 | /// functions for modifying the list contents | 61 | /// functions for modifying the list contents |
64 | void pushFront(Focusable &win); | 62 | void pushFront(Focusable &win); |
65 | void pushBack(Focusable &win); | 63 | void pushBack(Focusable &win); |
@@ -94,7 +92,6 @@ private: | |||
94 | void checkUpdate(Focusable &win); | 92 | void checkUpdate(Focusable &win); |
95 | bool insertFromParent(Focusable &win); | 93 | bool insertFromParent(Focusable &win); |
96 | void attachSignals(Focusable &win); | 94 | void attachSignals(Focusable &win); |
97 | void detachSignals(Focusable &win); | ||
98 | void reset(); | 95 | void reset(); |
99 | void attachChild(FocusableList &child) const; | 96 | void attachChild(FocusableList &child) const; |
100 | void workspaceChanged(BScreen &screen); | 97 | void workspaceChanged(BScreen &screen); |
diff --git a/src/Window.cc b/src/Window.cc index c43ab36..11d46bc 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -260,7 +260,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client): | |||
260 | Focusable(client.screen(), this), | 260 | Focusable(client.screen(), this), |
261 | oplock(false), | 261 | oplock(false), |
262 | m_hintsig(*this), | 262 | m_hintsig(*this), |
263 | m_layersig(*this), | ||
264 | m_creation_time(0), | 263 | m_creation_time(0), |
265 | moving(false), resizing(false), | 264 | moving(false), resizing(false), |
266 | m_initialized(false), | 265 | m_initialized(false), |
@@ -626,7 +625,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
626 | // affected clients if possible | 625 | // affected clients if possible |
627 | m_statesig.emit(*this); | 626 | m_statesig.emit(*this); |
628 | m_workspacesig.emit(*this); | 627 | m_workspacesig.emit(*this); |
629 | m_layersig.notify(); | 628 | m_layersig.emit(*this); |
630 | 629 | ||
631 | if (was_focused) { | 630 | if (was_focused) { |
632 | // don't ask me why, but client doesn't seem to keep focus in new window | 631 | // don't ask me why, but client doesn't seem to keep focus in new window |
@@ -1545,7 +1544,7 @@ void FluxboxWindow::setLayerNum(int layernum) { | |||
1545 | 1544 | ||
1546 | if (m_initialized) { | 1545 | if (m_initialized) { |
1547 | fbdbg<<this<<" notify layer signal"<<endl; | 1546 | fbdbg<<this<<" notify layer signal"<<endl; |
1548 | m_layersig.notify(); | 1547 | m_layersig.emit(*this); |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1551 | 1550 | ||
diff --git a/src/Window.hh b/src/Window.hh index 26ae4ef..73b6338 100644 --- a/src/Window.hh +++ b/src/Window.hh | |||
@@ -459,8 +459,7 @@ public: | |||
459 | @{ | 459 | @{ |
460 | */ | 460 | */ |
461 | FbTk::Signal<FluxboxWindow &> &stateSig() { return m_statesig; } | 461 | FbTk::Signal<FluxboxWindow &> &stateSig() { return m_statesig; } |
462 | FbTk::Subject &layerSig() { return m_layersig; } | 462 | FbTk::Signal<FluxboxWindow &> &layerSig() { return m_layersig; } |
463 | const FbTk::Subject &layerSig() const { return m_layersig; } | ||
464 | FbTk::Subject &hintSig() { return m_hintsig; } | 463 | FbTk::Subject &hintSig() { return m_hintsig; } |
465 | const FbTk::Subject &hintSig() const { return m_hintsig; } | 464 | const FbTk::Subject &hintSig() const { return m_hintsig; } |
466 | FbTk::Signal<FluxboxWindow &> &workspaceSig() { return m_workspacesig; } | 465 | FbTk::Signal<FluxboxWindow &> &workspaceSig() { return m_workspacesig; } |
@@ -539,9 +538,8 @@ private: | |||
539 | 538 | ||
540 | 539 | ||
541 | // state and hint signals | 540 | // state and hint signals |
542 | WinSubject m_hintsig, | 541 | WinSubject m_hintsig; |
543 | m_layersig; | 542 | FbTk::Signal<FluxboxWindow &> m_workspacesig, m_statesig, m_layersig; |
544 | FbTk::Signal<FluxboxWindow &> m_workspacesig, m_statesig; | ||
545 | 543 | ||
546 | time_t m_creation_time; | 544 | time_t m_creation_time; |
547 | 545 | ||
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 9c30b03..0dc958d 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -940,24 +940,6 @@ void Fluxbox::handleSignal(int signum) { | |||
940 | } | 940 | } |
941 | 941 | ||
942 | 942 | ||
943 | void Fluxbox::update(FbTk::Subject *changedsub) { | ||
944 | //TODO: fix signaling, this does not look good | ||
945 | FluxboxWindow *fbwin = 0; | ||
946 | |||
947 | if (typeid(*changedsub) == typeid(FluxboxWindow::WinSubject)) { | ||
948 | FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub); | ||
949 | fbwin = &winsub->win(); | ||
950 | } else if (typeid(*changedsub) == typeid(Focusable::FocusSubject)) { | ||
951 | Focusable::FocusSubject *winsub = dynamic_cast<Focusable::FocusSubject *>(changedsub); | ||
952 | fbwin = winsub->win().fbwindow(); | ||
953 | } | ||
954 | |||
955 | if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal | ||
956 | STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), | ||
957 | CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, *fbwin)); | ||
958 | } | ||
959 | } | ||
960 | |||
961 | void Fluxbox::windowDied(Focusable &focusable) { | 943 | void Fluxbox::windowDied(Focusable &focusable) { |
962 | FluxboxWindow *fbwin = focusable.fbwindow(); | 944 | FluxboxWindow *fbwin = focusable.fbwindow(); |
963 | 945 | ||
@@ -1024,11 +1006,15 @@ void Fluxbox::windowStateChanged(FluxboxWindow &win) { | |||
1024 | } | 1006 | } |
1025 | } | 1007 | } |
1026 | 1008 | ||
1009 | void Fluxbox::windowLayerChanged(FluxboxWindow &win) { | ||
1010 | STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), | ||
1011 | CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, win)); | ||
1012 | } | ||
1013 | |||
1027 | void Fluxbox::attachSignals(FluxboxWindow &win) { | 1014 | void Fluxbox::attachSignals(FluxboxWindow &win) { |
1028 | win.hintSig().attach(this); | ||
1029 | join(win.stateSig(), FbTk::MemFun(*this, &Fluxbox::windowStateChanged)); | 1015 | join(win.stateSig(), FbTk::MemFun(*this, &Fluxbox::windowStateChanged)); |
1030 | join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged)); | 1016 | join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged)); |
1031 | win.layerSig().attach(this); | 1017 | join(win.layerSig(), FbTk::MemFun(*this, &Fluxbox::windowLayerChanged)); |
1032 | join(win.dieSig(), FbTk::MemFun(*this, &Fluxbox::windowDied)); | 1018 | join(win.dieSig(), FbTk::MemFun(*this, &Fluxbox::windowDied)); |
1033 | STLUtil::forAll(m_atomhandler, | 1019 | STLUtil::forAll(m_atomhandler, |
1034 | CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::setupFrame, win)); | 1020 | CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::setupFrame, win)); |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index af28ac7..d1e8e93 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "FbTk/App.hh" | 28 | #include "FbTk/App.hh" |
29 | #include "FbTk/Resource.hh" | 29 | #include "FbTk/Resource.hh" |
30 | #include "FbTk/Timer.hh" | 30 | #include "FbTk/Timer.hh" |
31 | #include "FbTk/Observer.hh" | ||
32 | #include "FbTk/SignalHandler.hh" | 31 | #include "FbTk/SignalHandler.hh" |
33 | #include "FbTk/Signal.hh" | 32 | #include "FbTk/Signal.hh" |
34 | 33 | ||
@@ -76,7 +75,6 @@ class FbAtoms; | |||
76 | */ | 75 | */ |
77 | class Fluxbox : public FbTk::App, | 76 | class Fluxbox : public FbTk::App, |
78 | public FbTk::SignalEventHandler, | 77 | public FbTk::SignalEventHandler, |
79 | public FbTk::Observer, | ||
80 | private FbTk::SignalTracker { | 78 | private FbTk::SignalTracker { |
81 | public: | 79 | public: |
82 | Fluxbox(int argc, char **argv, | 80 | Fluxbox(int argc, char **argv, |
@@ -156,7 +154,6 @@ public: | |||
156 | 154 | ||
157 | /// handle any system signal sent to the application | 155 | /// handle any system signal sent to the application |
158 | void handleSignal(int signum); | 156 | void handleSignal(int signum); |
159 | void update(FbTk::Subject *changed); | ||
160 | /// todo, remove this. just temporary | 157 | /// todo, remove this. just temporary |
161 | void updateFrameExtents(FluxboxWindow &win); | 158 | void updateFrameExtents(FluxboxWindow &win); |
162 | 159 | ||
@@ -225,6 +222,8 @@ private: | |||
225 | void windowWorkspaceChanged(FluxboxWindow &win); | 222 | void windowWorkspaceChanged(FluxboxWindow &win); |
226 | /// Called when a window changes state | 223 | /// Called when a window changes state |
227 | void windowStateChanged(FluxboxWindow &win); | 224 | void windowStateChanged(FluxboxWindow &win); |
225 | /// Called when a window layer changes | ||
226 | void windowLayerChanged(FluxboxWindow &win); | ||
228 | 227 | ||
229 | std::auto_ptr<FbAtoms> m_fbatoms; | 228 | std::auto_ptr<FbAtoms> m_fbatoms; |
230 | 229 | ||