diff options
Diffstat (limited to 'src/AttentionNoticeHandler.cc')
-rw-r--r-- | src/AttentionNoticeHandler.cc | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/AttentionNoticeHandler.cc b/src/AttentionNoticeHandler.cc index 26dd4b5..393e566 100644 --- a/src/AttentionNoticeHandler.cc +++ b/src/AttentionNoticeHandler.cc | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "FbTk/Subject.hh" | 28 | #include "FbTk/Subject.hh" |
29 | #include "FbTk/Timer.hh" | 29 | #include "FbTk/Timer.hh" |
30 | #include "FbTk/Resource.hh" | 30 | #include "FbTk/Resource.hh" |
31 | #include "FbTk/MemFun.hh" | ||
31 | 32 | ||
32 | namespace { | 33 | namespace { |
33 | class ToggleFrameFocusCmd: public FbTk::Command<void> { | 34 | class ToggleFrameFocusCmd: public FbTk::Command<void> { |
@@ -91,30 +92,41 @@ void AttentionNoticeHandler::addAttention(Focusable &client) { | |||
91 | m_attentions[&client] = timer; | 92 | m_attentions[&client] = timer; |
92 | // attach signals that will make notice go away | 93 | // attach signals that will make notice go away |
93 | client.dieSig().attach(this); | 94 | client.dieSig().attach(this); |
94 | client.focusSig().attach(this); | 95 | |
96 | client.focusSig().connect(MemFun(*this, &AttentionNoticeHandler::windowFocusChanged)); | ||
95 | 97 | ||
96 | // update _NET_WM_STATE atom | 98 | // update _NET_WM_STATE atom |
97 | if (client.fbwindow()) | 99 | if (client.fbwindow()) |
98 | client.fbwindow()->stateSig().notify(); | 100 | client.fbwindow()->stateSig().notify(); |
99 | } | 101 | } |
100 | 102 | ||
101 | void AttentionNoticeHandler::update(FbTk::Subject *subj) { | 103 | void AttentionNoticeHandler::windowFocusChanged(Focusable& win) { |
104 | updateWindow(win, false); | ||
105 | } | ||
106 | void AttentionNoticeHandler::removeWindow(Focusable& win) { | ||
107 | updateWindow(win, true); | ||
108 | } | ||
102 | 109 | ||
110 | void AttentionNoticeHandler::update(FbTk::Subject* subj) { | ||
103 | // we need to be able to get the window | 111 | // we need to be able to get the window |
104 | if (!subj || typeid(*subj) != typeid(Focusable::FocusSubject)) | 112 | if (!subj || typeid(*subj) != typeid(Focusable::FocusSubject)) |
105 | return; | 113 | return; |
114 | Focusable::FocusSubject *winsubj = | ||
115 | static_cast<Focusable::FocusSubject *>(subj); | ||
106 | 116 | ||
117 | removeWindow(winsubj->win()); | ||
118 | } | ||
119 | |||
120 | void AttentionNoticeHandler::updateWindow(Focusable& win, bool died) { | ||
107 | // all signals results in destruction of the notice | 121 | // all signals results in destruction of the notice |
108 | 122 | ||
109 | Focusable::FocusSubject *winsubj = | 123 | delete m_attentions[&win]; |
110 | static_cast<Focusable::FocusSubject *>(subj); | 124 | m_attentions.erase(&win); |
111 | delete m_attentions[&winsubj->win()]; | 125 | win.setAttentionState(false); |
112 | m_attentions.erase(&winsubj->win()); | ||
113 | winsubj->win().setAttentionState(false); | ||
114 | 126 | ||
115 | // update _NET_WM_STATE atom | 127 | // update _NET_WM_STATE atom if the window is not dead |
116 | FluxboxWindow *fbwin = winsubj->win().fbwindow(); | 128 | FluxboxWindow *fbwin = win.fbwindow(); |
117 | if (fbwin && winsubj != &winsubj->win().dieSig()) | 129 | if (fbwin && ! died) |
118 | fbwin->stateSig().notify(); | 130 | fbwin->stateSig().notify(); |
119 | 131 | ||
120 | } | 132 | } |