all repos — fluxbox @ 6a0280aa4d8b468617a7dd5f7a6523d0422364e8

custom fork of the fluxbox windowmanager

Convert FluxboxWindow::layerSig to FbTk::Signal
Pavel Labath pavelo@centrum.sk
commit

6a0280aa4d8b468617a7dd5f7a6523d0422364e8

parent

e53d14e9102270a1682a88c29161580ccbf0c20a

6 files changed, 33 insertions(+), 85 deletions(-)

jump to
M src/FocusableList.ccsrc/FocusableList.cc

@@ -107,17 +107,6 @@ FbTk::MemFun(*this, &FocusableList::focusedWindowChanged));

} } -void FocusableList::update(FbTk::Subject *subj) { - if (subj == 0 || m_screen.isShuttingdown()) - return; - - if (typeid(*subj) == typeid(FluxboxWindow::WinSubject)) { - FluxboxWindow::WinSubject *fsubj = - static_cast<FluxboxWindow::WinSubject *>(subj); - windowUpdated(fsubj->win()); - } -} - void FocusableList::windowUpdated(FluxboxWindow &fbwin) { if (m_screen.isShuttingdown()) return;

@@ -243,7 +232,7 @@ void FocusableList::remove(Focusable &win) {

// if the window isn't already in this list, we could send a bad signal bool contained = contains(win); - detachSignals(win); + m_signal_map.erase(&win); if (!contained) { return; }

@@ -257,50 +246,30 @@ }

#include "Debug.hh" void FocusableList::attachSignals(Focusable &win) { - if (m_parent) { - FluxboxWindow *fbwin = win.fbwindow(); + if (m_parent == NULL) + return; - // attach various signals for matching - FbTk::RefCount<FbTk::SignalTracker> &tracker = m_signal_map[&win]; - if (! tracker) { - // we have not attached to this window yet - 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) - ); - tracker->join(fbwin->stateSig(), - MemFun(*this, &FocusableList::windowUpdated) - ); - } - } - - if (!fbwin) - return; - fbwin->layerSig().attach(this); - // TODO: can't watch (head=...) yet - } -} + FluxboxWindow *fbwin = win.fbwindow(); -void FocusableList::detachSignals(Focusable &win) { - m_signal_map.erase(&win); - if (m_parent) { - // detach various signals for matching - FluxboxWindow *fbwin = win.fbwindow(); - if (!fbwin) - return; - fbwin->layerSig().detach(this); - // TODO: can't watch (head=...) yet + // attach various signals for matching + FbTk::RefCount<FbTk::SignalTracker> &tracker = m_signal_map[&win]; + if (! tracker) { + // we have not attached to this window yet + 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)); + tracker->join(fbwin->stateSig(), MemFun(*this, &FocusableList::windowUpdated)); + tracker->join(fbwin->layerSig(), MemFun(*this, &FocusableList::windowUpdated)); + // TODO: can't watch (head=...) yet + } } } void FocusableList::reset() { - while (!m_list.empty()) { - detachSignals(*m_list.back()); - m_list.pop_back(); - } + m_signal_map.clear(); + m_list.clear(); m_pat->resetMatches(); if (m_parent) addMatching();
M src/FocusableList.hhsrc/FocusableList.hh

@@ -39,7 +39,7 @@ class Focusable;

class WinClient; class FluxboxWindow; -class FocusableList: public FbTk::Observer, private FbTk::NotCopyable, +class FocusableList: private FbTk::NotCopyable, private FbTk::SignalTracker { public: typedef std::list<Focusable *> Focusables;

@@ -57,8 +57,6 @@ const std::string pat);

static void parseArgs(const std::string &in, int &opts, std::string &out); static const FocusableList *getListFromOptions(BScreen &scr, int opts); - - void update(FbTk::Subject *subj); /// functions for modifying the list contents void pushFront(Focusable &win);

@@ -94,7 +92,6 @@ void addMatching();

void checkUpdate(Focusable &win); bool insertFromParent(Focusable &win); void attachSignals(Focusable &win); - void detachSignals(Focusable &win); void reset(); void attachChild(FocusableList &child) const; void workspaceChanged(BScreen &screen);
M src/Window.ccsrc/Window.cc

@@ -260,7 +260,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client):

Focusable(client.screen(), this), oplock(false), m_hintsig(*this), - m_layersig(*this), m_creation_time(0), moving(false), resizing(false), m_initialized(false),

@@ -626,7 +625,7 @@ // TODO: one day these should probably be neatened to only act on the

// affected clients if possible m_statesig.emit(*this); m_workspacesig.emit(*this); - m_layersig.notify(); + m_layersig.emit(*this); if (was_focused) { // don't ask me why, but client doesn't seem to keep focus in new window

@@ -1545,7 +1544,7 @@ m_state.layernum = layernum;

if (m_initialized) { fbdbg<<this<<" notify layer signal"<<endl; - m_layersig.notify(); + m_layersig.emit(*this); } }
M src/Window.hhsrc/Window.hh

@@ -459,8 +459,7 @@ @name signals

@{ */ FbTk::Signal<FluxboxWindow &> &stateSig() { return m_statesig; } - FbTk::Subject &layerSig() { return m_layersig; } - const FbTk::Subject &layerSig() const { return m_layersig; } + FbTk::Signal<FluxboxWindow &> &layerSig() { return m_layersig; } FbTk::Subject &hintSig() { return m_hintsig; } const FbTk::Subject &hintSig() const { return m_hintsig; } FbTk::Signal<FluxboxWindow &> &workspaceSig() { return m_workspacesig; }

@@ -539,9 +538,8 @@ void workspaceAreaChanged(BScreen &screen);

// state and hint signals - WinSubject m_hintsig, - m_layersig; - FbTk::Signal<FluxboxWindow &> m_workspacesig, m_statesig; + WinSubject m_hintsig; + FbTk::Signal<FluxboxWindow &> m_workspacesig, m_statesig, m_layersig; time_t m_creation_time;
M src/fluxbox.ccsrc/fluxbox.cc

@@ -940,24 +940,6 @@ }

} -void Fluxbox::update(FbTk::Subject *changedsub) { - //TODO: fix signaling, this does not look good - FluxboxWindow *fbwin = 0; - - if (typeid(*changedsub) == typeid(FluxboxWindow::WinSubject)) { - FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub); - fbwin = &winsub->win(); - } else if (typeid(*changedsub) == typeid(Focusable::FocusSubject)) { - Focusable::FocusSubject *winsub = dynamic_cast<Focusable::FocusSubject *>(changedsub); - fbwin = winsub->win().fbwindow(); - } - - if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal - STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), - CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, *fbwin)); - } -} - void Fluxbox::windowDied(Focusable &focusable) { FluxboxWindow *fbwin = focusable.fbwindow();

@@ -1024,11 +1006,15 @@ scr.reassociateWindow(&win, scr.currentWorkspaceID(), true);

} } +void Fluxbox::windowLayerChanged(FluxboxWindow &win) { + STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), + CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, win)); +} + void Fluxbox::attachSignals(FluxboxWindow &win) { - win.hintSig().attach(this); join(win.stateSig(), FbTk::MemFun(*this, &Fluxbox::windowStateChanged)); join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged)); - win.layerSig().attach(this); + join(win.layerSig(), FbTk::MemFun(*this, &Fluxbox::windowLayerChanged)); join(win.dieSig(), FbTk::MemFun(*this, &Fluxbox::windowDied)); STLUtil::forAll(m_atomhandler, CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::setupFrame, win));
M src/fluxbox.hhsrc/fluxbox.hh

@@ -28,7 +28,6 @@

#include "FbTk/App.hh" #include "FbTk/Resource.hh" #include "FbTk/Timer.hh" -#include "FbTk/Observer.hh" #include "FbTk/SignalHandler.hh" #include "FbTk/Signal.hh"

@@ -76,7 +75,6 @@ singleton type

*/ class Fluxbox : public FbTk::App, public FbTk::SignalEventHandler, - public FbTk::Observer, private FbTk::SignalTracker { public: Fluxbox(int argc, char **argv,

@@ -156,7 +154,6 @@ void reconfigure();

/// handle any system signal sent to the application void handleSignal(int signum); - void update(FbTk::Subject *changed); /// todo, remove this. just temporary void updateFrameExtents(FluxboxWindow &win);

@@ -225,6 +222,8 @@ /// Called when a window changes workspace

void windowWorkspaceChanged(FluxboxWindow &win); /// Called when a window changes state void windowStateChanged(FluxboxWindow &win); + /// Called when a window layer changes + void windowLayerChanged(FluxboxWindow &win); std::auto_ptr<FbAtoms> m_fbatoms;