Convert FluxboxWindow::workspaceSig to FbTk::Signal

This commit is contained in:
Pavel Labath 2011-05-06 18:18:20 +02:00
parent ae68b7f7cd
commit 4f89009c9e
6 changed files with 40 additions and 27 deletions

View file

@ -114,16 +114,22 @@ void FocusableList::update(FbTk::Subject *subj) {
if (typeid(*subj) == typeid(FluxboxWindow::WinSubject)) {
FluxboxWindow::WinSubject *fsubj =
static_cast<FluxboxWindow::WinSubject *>(subj);
// we only bind these for matching patterns, so skip finding out signal
FluxboxWindow &fbwin = fsubj->win();
if (m_parent->contains(fbwin))
checkUpdate(fbwin);
std::list<WinClient *> list = fbwin.clientList();
std::list<WinClient *>::iterator it = list.begin(), it_end = list.end();
for (; it != it_end; ++it) {
if (m_parent->contains(**it))
checkUpdate(**it);
}
windowUpdated(fsubj->win());
}
}
void FocusableList::windowUpdated(FluxboxWindow &fbwin) {
if (m_screen.isShuttingdown())
return;
// we only bind these for matching patterns, so skip finding out signal
if (m_parent->contains(fbwin))
checkUpdate(fbwin);
const std::list<WinClient *> &list = fbwin.clientList();
std::list<WinClient *>::const_iterator it = list.begin(), it_end = list.end();
for (; it != it_end; ++it) {
if (m_parent->contains(**it))
checkUpdate(**it);
}
}
@ -252,6 +258,8 @@ void FocusableList::updateTitle(Focusable& win) {
void FocusableList::attachSignals(Focusable &win) {
if (m_parent) {
FluxboxWindow *fbwin = win.fbwindow();
// attach various signals for matching
FbTk::RefCount<FbTk::SignalTracker> &tracker = m_signal_map[&win];
if (! tracker) {
@ -259,12 +267,15 @@ void FocusableList::attachSignals(Focusable &win) {
tracker = new SignalTracker;
tracker->join(win.titleSig(), MemFunSelectArg1(*this, &FocusableList::updateTitle));
tracker->join(win.dieSig(), MemFun(*this, &FocusableList::remove));
if(fbwin) {
tracker->join(fbwin->workspaceSig(),
MemFun(*this, &FocusableList::windowUpdated)
);
}
}
FluxboxWindow *fbwin = win.fbwindow();
if (!fbwin)
return;
fbwin->workspaceSig().attach(this);
fbwin->stateSig().attach(this);
fbwin->layerSig().attach(this);
// TODO: can't watch (head=...) yet
@ -278,7 +289,6 @@ void FocusableList::detachSignals(Focusable &win) {
FluxboxWindow *fbwin = win.fbwindow();
if (!fbwin)
return;
fbwin->workspaceSig().detach(this);
fbwin->stateSig().detach(this);
fbwin->layerSig().detach(this);
// TODO: can't watch (head=...) yet

View file

@ -105,6 +105,7 @@ private:
void parentOrderChanged(Focusable* win);
void parentWindowAdded(Focusable* win);
void parentWindowRemoved(Focusable* win);
void windowUpdated(FluxboxWindow &fbwin);
std::auto_ptr<ClientPattern> m_pat;

View file

@ -262,7 +262,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client):
m_hintsig(*this),
m_statesig(*this),
m_layersig(*this),
m_workspacesig(*this),
m_creation_time(0),
moving(false), resizing(false),
m_initialized(false),
@ -536,7 +535,7 @@ void FluxboxWindow::init() {
setMaximizedState(tmp);
}
m_workspacesig.notify();
m_workspacesig.emit(*this);
struct timeval now;
gettimeofday(&now, NULL);
@ -627,7 +626,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
// TODO: one day these should probably be neatened to only act on the
// affected clients if possible
m_statesig.notify();
m_workspacesig.notify();
m_workspacesig.emit(*this);
m_layersig.notify();
if (was_focused) {
@ -1537,8 +1536,8 @@ void FluxboxWindow::setWorkspace(int n) {
// notify workspace change
if (m_initialized && old_wkspc != m_workspace_number) {
fbdbg<<this<<" notify workspace signal"<<endl;
m_workspacesig.notify();
fbdbg<<this<<" emit workspace signal"<<endl;
m_workspacesig.emit(*this);
}
}
@ -1587,7 +1586,7 @@ void FluxboxWindow::stick() {
if (m_initialized) {
stateSig().notify();
// notify since some things consider "stuck" to be a pseudo-workspace
m_workspacesig.notify();
m_workspacesig.emit(*this);
}
ClientList::iterator client_it = clientList().begin();

View file

@ -464,8 +464,7 @@ public:
const FbTk::Subject &layerSig() const { return m_layersig; }
FbTk::Subject &hintSig() { return m_hintsig; }
const FbTk::Subject &hintSig() const { return m_hintsig; }
FbTk::Subject &workspaceSig() { return m_workspacesig; }
const FbTk::Subject &workspaceSig() const { return m_workspacesig; }
FbTk::Signal<FluxboxWindow &> &workspaceSig() { return m_workspacesig; }
/** @} */ // end group signals
//@}
@ -543,8 +542,8 @@ private:
// state and hint signals
WinSubject m_hintsig,
m_statesig,
m_layersig,
m_workspacesig;
m_layersig;
FbTk::Signal<FluxboxWindow &> m_workspacesig;
time_t m_creation_time;

View file

@ -978,9 +978,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
} else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal
STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, *fbwin));
} else if (fbwin && &fbwin->workspaceSig() == changedsub) { // workspace signal
STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateWorkspace, *fbwin));
}
}
@ -1023,10 +1020,15 @@ void Fluxbox::clientDied(Focusable &focusable) {
screen.removeClient(client);
}
void Fluxbox::windowWorkspaceChanged(FluxboxWindow &win) {
STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateWorkspace, win));
}
void Fluxbox::attachSignals(FluxboxWindow &win) {
win.hintSig().attach(this);
win.stateSig().attach(this);
win.workspaceSig().attach(this);
join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged));
win.layerSig().attach(this);
join(win.dieSig(), FbTk::MemFun(*this, &Fluxbox::windowDied));
STLUtil::forAll(m_atomhandler,

View file

@ -221,6 +221,8 @@ private:
void windowDied(Focusable &focusable);
/// Called when a client (WinClient) dies
void clientDied(Focusable &focusable);
/// Called when a window changes workspace
void windowWorkspaceChanged(FluxboxWindow &win);
std::auto_ptr<FbAtoms> m_fbatoms;