aboutsummaryrefslogtreecommitdiff
path: root/src/AttentionNoticeHandler.cc
diff options
context:
space:
mode:
authormarkt <markt>2006-06-24 18:19:49 (GMT)
committermarkt <markt>2006-06-24 18:19:49 (GMT)
commita23ad6719725a0290d01ac4bba0ce1905b2069d7 (patch)
treeb3997c14a601117cc2c613e2a8bb79cc6a6a1c4b /src/AttentionNoticeHandler.cc
parent0b730c76b10babe20738067ae7aec5a102d451fe (diff)
downloadfluxbox-a23ad6719725a0290d01ac4bba0ce1905b2069d7.zip
fluxbox-a23ad6719725a0290d01ac4bba0ce1905b2069d7.tar.bz2
Make Urgency Hint flash the correct WinClient's tab.
Diffstat (limited to 'src/AttentionNoticeHandler.cc')
-rw-r--r--src/AttentionNoticeHandler.cc46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/AttentionNoticeHandler.cc b/src/AttentionNoticeHandler.cc
index 7cc2760..e2881af 100644
--- a/src/AttentionNoticeHandler.cc
+++ b/src/AttentionNoticeHandler.cc
@@ -23,7 +23,7 @@
23 23
24#include "AttentionNoticeHandler.hh" 24#include "AttentionNoticeHandler.hh"
25 25
26#include "Window.hh" 26#include "WinClient.hh"
27#include "Screen.hh" 27#include "Screen.hh"
28#include "STLUtil.hh" 28#include "STLUtil.hh"
29 29
@@ -34,14 +34,16 @@
34namespace { 34namespace {
35class ToggleFrameFocusCmd: public FbTk::Command { 35class ToggleFrameFocusCmd: public FbTk::Command {
36public: 36public:
37 ToggleFrameFocusCmd(FluxboxWindow &win): 37 ToggleFrameFocusCmd(WinClient &client):
38 m_win(win) {} 38 m_client(client) {}
39 void execute() { 39 void execute() {
40 m_win.frame().setFocus( ! m_win.frame().focused() ); 40 m_state ^= true;
41 m_win.attentionSig().notify(); 41 m_client.fbwindow()->setLabelButtonFocus(m_client, m_state);
42 m_client.fbwindow()->setAttentionState(m_state);
42 } 43 }
43private: 44private:
44 FluxboxWindow& m_win; 45 WinClient& m_client;
46 bool m_state;
45}; 47};
46 48
47} // end anonymous namespace 49} // end anonymous namespace
@@ -51,27 +53,27 @@ AttentionNoticeHandler::~AttentionNoticeHandler() {
51 STLUtil::destroyAndClearSecond(m_attentions); 53 STLUtil::destroyAndClearSecond(m_attentions);
52} 54}
53 55
54void AttentionNoticeHandler::addAttention(FluxboxWindow &win) { 56void AttentionNoticeHandler::addAttention(WinClient &client) {
55 // no need to add already focused window 57 // no need to add already active client
56 if (win.isFocused()) 58 if (client.fbwindow()->isFocused() && &client.fbwindow()->winClient() == &client)
57 return; 59 return;
58 60
59 // Already have a notice for it? 61 // Already have a notice for it?
60 NoticeMap::iterator it = m_attentions.find(&win); 62 NoticeMap::iterator it = m_attentions.find(&client);
61 if (it != m_attentions.end()) { 63 if (it != m_attentions.end()) {
62 return; 64 return;
63 } 65 }
64 66
65 using namespace FbTk; 67 using namespace FbTk;
66 68
67 ResourceManager &res = win.screen().resourceManager(); 69 ResourceManager &res = client.screen().resourceManager();
68 std::string res_name = win.screen().name() + ".demandsAttentionTimeout"; 70 std::string res_name = client.screen().name() + ".demandsAttentionTimeout";
69 std::string res_alt_name = win.screen().name() + ".DemandsAttentionTimeout"; 71 std::string res_alt_name = client.screen().name() + ".DemandsAttentionTimeout";
70 Resource<int> *timeout_res = dynamic_cast<Resource<int>* >(res.findResource(res_name)); 72 Resource<int> *timeout_res = dynamic_cast<Resource<int>* >(res.findResource(res_name));
71 if (timeout_res == 0) { 73 if (timeout_res == 0) {
72 // no resource, create one and add it to managed resources 74 // no resource, create one and add it to managed resources
73 timeout_res = new FbTk::Resource<int>(res, 500, res_name, res_alt_name); 75 timeout_res = new FbTk::Resource<int>(res, 500, res_name, res_alt_name);
74 win.screen().addManagedResource(timeout_res); 76 client.screen().addManagedResource(timeout_res);
75 } 77 }
76 // disable if timeout is zero 78 // disable if timeout is zero
77 if (**timeout_res == 0) 79 if (**timeout_res == 0)
@@ -82,25 +84,25 @@ void AttentionNoticeHandler::addAttention(FluxboxWindow &win) {
82 timeval timeout; 84 timeval timeout;
83 timeout.tv_sec = 0; 85 timeout.tv_sec = 0;
84 timeout.tv_usec = **timeout_res * 1000; 86 timeout.tv_usec = **timeout_res * 1000;
85 RefCount<Command> cmd(new ToggleFrameFocusCmd(win)); 87 RefCount<Command> cmd(new ToggleFrameFocusCmd(client));
86 timer->setCommand(cmd); 88 timer->setCommand(cmd);
87 timer->setTimeout(timeout); 89 timer->setTimeout(timeout);
88 timer->fireOnce(false); // will repeat until window has focus 90 timer->fireOnce(false); // will repeat until window has focus
89 timer->start(); 91 timer->start();
90 92
91 m_attentions[&win] = timer; 93 m_attentions[&client] = timer;
92 // attach signals that will make notice go away 94 // attach signals that will make notice go away
93 win.dieSig().attach(this); 95 client.dieSig().attach(this);
94 win.focusSig().attach(this); 96 client.focusSig().attach(this);
95} 97}
96 98
97void AttentionNoticeHandler::update(FbTk::Subject *subj) { 99void AttentionNoticeHandler::update(FbTk::Subject *subj) {
98 100
99 // all signals results in destruction of the notice 101 // all signals results in destruction of the notice
100 102
101 FluxboxWindow::WinSubject *winsubj = 103 WinClient::WinClientSubj *winsubj =
102 static_cast<FluxboxWindow::WinSubject*>(subj); 104 static_cast<WinClient::WinClientSubj *>(subj);
103 delete m_attentions[&winsubj->win()]; 105 delete m_attentions[&winsubj->winClient()];
104 m_attentions.erase(&winsubj->win()); 106 m_attentions.erase(&winsubj->winClient());
105} 107}
106 108