Convert FluxboxWindow::layerSig to FbTk::Signal
This commit is contained in:
parent
e53d14e910
commit
6a0280aa4d
6 changed files with 33 additions and 85 deletions
|
@ -107,17 +107,6 @@ void FocusableList::init() {
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ void FocusableList::updateTitle(Focusable& win) {
|
|||
#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)
|
||||
);
|
||||
}
|
||||
FluxboxWindow *fbwin = win.fbwindow();
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
if (!fbwin)
|
||||
return;
|
||||
fbwin->layerSig().attach(this);
|
||||
// TODO: can't watch (head=...) yet
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -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;
|
||||
|
@ -58,8 +58,6 @@ public:
|
|||
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);
|
||||
void pushBack(Focusable &win);
|
||||
|
@ -94,7 +92,6 @@ private:
|
|||
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);
|
||||
|
|
|
@ -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 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
|
|||
// 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 @@ void FluxboxWindow::setLayerNum(int layernum) {
|
|||
|
||||
if (m_initialized) {
|
||||
fbdbg<<this<<" notify layer signal"<<endl;
|
||||
m_layersig.notify();
|
||||
m_layersig.emit(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -459,8 +459,7 @@ public:
|
|||
@{
|
||||
*/
|
||||
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 @@ private:
|
|||
|
||||
|
||||
// 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;
|
||||
|
||||
|
|
|
@ -940,24 +940,6 @@ void Fluxbox::handleSignal(int signum) {
|
|||
}
|
||||
|
||||
|
||||
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 @@ void Fluxbox::windowStateChanged(FluxboxWindow &win) {
|
|||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
|
|
@ -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 @@ class FbAtoms;
|
|||
*/
|
||||
class Fluxbox : public FbTk::App,
|
||||
public FbTk::SignalEventHandler,
|
||||
public FbTk::Observer,
|
||||
private FbTk::SignalTracker {
|
||||
public:
|
||||
Fluxbox(int argc, char **argv,
|
||||
|
@ -156,7 +154,6 @@ public:
|
|||
|
||||
/// 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 @@ private:
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue