Convert FluxboxWindow::stateSig to FbTk::Signal

This commit is contained in:
Pavel Labath 2011-05-06 20:28:44 +02:00
parent ad0951ca53
commit e53d14e910
8 changed files with 56 additions and 59 deletions

View file

@ -93,7 +93,7 @@ void AttentionNoticeHandler::addAttention(Focusable &client) {
// update _NET_WM_STATE atom // update _NET_WM_STATE atom
if (client.fbwindow()) if (client.fbwindow())
client.fbwindow()->stateSig().notify(); client.fbwindow()->stateSig().emit(*client.fbwindow());
} }
void AttentionNoticeHandler::windowFocusChanged(Focusable& win) { void AttentionNoticeHandler::windowFocusChanged(Focusable& win) {
@ -113,7 +113,7 @@ void AttentionNoticeHandler::updateWindow(Focusable& win, bool died) {
// update _NET_WM_STATE atom if the window is not dead // update _NET_WM_STATE atom if the window is not dead
FluxboxWindow *fbwin = win.fbwindow(); FluxboxWindow *fbwin = win.fbwindow();
if (fbwin && ! died) if (fbwin && ! died)
fbwin->stateSig().notify(); fbwin->stateSig().emit(*fbwin);
} }

View file

@ -271,12 +271,14 @@ void FocusableList::attachSignals(Focusable &win) {
tracker->join(fbwin->workspaceSig(), tracker->join(fbwin->workspaceSig(),
MemFun(*this, &FocusableList::windowUpdated) MemFun(*this, &FocusableList::windowUpdated)
); );
tracker->join(fbwin->stateSig(),
MemFun(*this, &FocusableList::windowUpdated)
);
} }
} }
if (!fbwin) if (!fbwin)
return; return;
fbwin->stateSig().attach(this);
fbwin->layerSig().attach(this); fbwin->layerSig().attach(this);
// TODO: can't watch (head=...) yet // TODO: can't watch (head=...) yet
} }
@ -289,7 +291,6 @@ void FocusableList::detachSignals(Focusable &win) {
FluxboxWindow *fbwin = win.fbwindow(); FluxboxWindow *fbwin = win.fbwindow();
if (!fbwin) if (!fbwin)
return; return;
fbwin->stateSig().detach(this);
fbwin->layerSig().detach(this); fbwin->layerSig().detach(this);
// TODO: can't watch (head=...) yet // TODO: can't watch (head=...) yet
} }

View file

@ -48,7 +48,7 @@ WinButton::WinButton(FluxboxWindow &listen_to,
join(theme.reconfigSig(), FbTk::MemFun(*this, &WinButton::updateAll)); join(theme.reconfigSig(), FbTk::MemFun(*this, &WinButton::updateAll));
if (buttontype == MENUICON) if (buttontype == MENUICON)
update(0); updateAll();
} }
void WinButton::exposeEvent(XExposeEvent &event) { void WinButton::exposeEvent(XExposeEvent &event) {
@ -316,7 +316,3 @@ void WinButton::updateAll() {
clear(); clear();
} }
void WinButton::update(FbTk::Subject *subj) {
updateAll();
}

View file

@ -36,7 +36,7 @@ template <class T> class ThemeProxy;
} }
/// draws and handles basic window button graphic /// draws and handles basic window button graphic
class WinButton:public FbTk::Button, public FbTk::Observer, public FbTk::SignalTracker { class WinButton:public FbTk::Button, public FbTk::SignalTracker {
public: public:
/// draw type for the button /// draw type for the button
enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON}; enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON};
@ -57,7 +57,6 @@ public:
Pixmap getPressedPixmap() const; Pixmap getPressedPixmap() const;
/// override for redrawing /// override for redrawing
void clear(); void clear();
void update(FbTk::Subject *subj);
void updateAll(); void updateAll();
private: private:
void drawType(); void drawType();

View file

@ -260,7 +260,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client):
Focusable(client.screen(), this), Focusable(client.screen(), this),
oplock(false), oplock(false),
m_hintsig(*this), m_hintsig(*this),
m_statesig(*this),
m_layersig(*this), m_layersig(*this),
m_creation_time(0), m_creation_time(0),
moving(false), resizing(false), moving(false), resizing(false),
@ -625,7 +624,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
// make sure that the state etc etc is updated for the new client // make sure that the state etc etc is updated for the new client
// TODO: one day these should probably be neatened to only act on the // TODO: one day these should probably be neatened to only act on the
// affected clients if possible // affected clients if possible
m_statesig.notify(); m_statesig.emit(*this);
m_workspacesig.emit(*this); m_workspacesig.emit(*this);
m_layersig.notify(); m_layersig.notify();
@ -1336,7 +1335,7 @@ void FluxboxWindow::iconify() {
return; return;
m_state.iconic = true; m_state.iconic = true;
m_statesig.notify(); m_statesig.emit(*this);
hide(true); hide(true);
@ -1365,7 +1364,7 @@ void FluxboxWindow::deiconify(bool do_raise) {
// reassociate first, so it gets removed from screen's icon list // reassociate first, so it gets removed from screen's icon list
screen().reassociateWindow(this, m_workspace_number, false); screen().reassociateWindow(this, m_workspace_number, false);
m_state.iconic = false; m_state.iconic = false;
m_statesig.notify(); m_statesig.emit(*this);
// deiconify all transients // deiconify all transients
ClientList::iterator client_it = clientList().begin(); ClientList::iterator client_it = clientList().begin();
@ -1418,7 +1417,7 @@ void FluxboxWindow::setFullscreen(bool flag) {
m_state.fullscreen = true; m_state.fullscreen = true;
frame().applyState(); frame().applyState();
setFullscreenLayer(); // calls stateSig().notify() setFullscreenLayer(); // calls stateSig().emit()
if (!isFocused()) { if (!isFocused()) {
join(screen().focusedWindowSig(), join(screen().focusedWindowSig(),
FbTk::MemFun(*this, &FluxboxWindow::focusedWindowChanged)); FbTk::MemFun(*this, &FluxboxWindow::focusedWindowChanged));
@ -1430,7 +1429,7 @@ void FluxboxWindow::setFullscreen(bool flag) {
frame().applyState(); frame().applyState();
moveToLayer(m_old_layernum); moveToLayer(m_old_layernum);
stateSig().notify(); stateSig().emit(*this);
} }
attachWorkAreaSig(); attachWorkAreaSig();
@ -1448,7 +1447,7 @@ void FluxboxWindow::setFullscreenLayer() {
} else { } else {
moveToLayer(::ResourceLayer::DESKTOP); moveToLayer(::ResourceLayer::DESKTOP);
} }
stateSig().notify(); stateSig().emit(*this);
} }
@ -1483,7 +1482,7 @@ void FluxboxWindow::setMaximizedState(int type) {
if (isShaded()) { if (isShaded()) {
// do not call ::shade() here to trigger frame().applyState() and // do not call ::shade() here to trigger frame().applyState() and
// stateSig().notfiy() only once // stateSig().emit() only once
m_state.shaded = false; m_state.shaded = false;
} }
@ -1493,7 +1492,7 @@ void FluxboxWindow::setMaximizedState(int type) {
attachWorkAreaSig(); attachWorkAreaSig();
// notify listeners that we changed state // notify listeners that we changed state
stateSig().notify(); stateSig().emit(*this);
} }
void FluxboxWindow::disableMaximization() { void FluxboxWindow::disableMaximization() {
@ -1504,7 +1503,7 @@ void FluxboxWindow::disableMaximization() {
m_state.saveGeometry(frame().x(), frame().y(), m_state.saveGeometry(frame().x(), frame().y(),
frame().width(), frame().height()); frame().width(), frame().height());
frame().applyState(); frame().applyState();
stateSig().notify(); stateSig().emit(*this);
} }
@ -1560,7 +1559,7 @@ void FluxboxWindow::shade() {
return; return;
frame().applyState(); frame().applyState();
stateSig().notify(); stateSig().emit(*this);
// TODO: this should set IconicState, but then we can't focus the window // TODO: this should set IconicState, but then we can't focus the window
} }
@ -1584,7 +1583,7 @@ void FluxboxWindow::stick() {
m_state.stuck = !m_state.stuck; m_state.stuck = !m_state.stuck;
if (m_initialized) { if (m_initialized) {
stateSig().notify(); stateSig().emit(*this);
// notify since some things consider "stuck" to be a pseudo-workspace // notify since some things consider "stuck" to be a pseudo-workspace
m_workspacesig.emit(*this); m_workspacesig.emit(*this);
} }
@ -1726,13 +1725,13 @@ void FluxboxWindow::moveToLayer(int layernum, bool force) {
void FluxboxWindow::setFocusHidden(bool value) { void FluxboxWindow::setFocusHidden(bool value) {
m_state.focus_hidden = value; m_state.focus_hidden = value;
if (m_initialized) if (m_initialized)
m_statesig.notify(); m_statesig.emit(*this);
} }
void FluxboxWindow::setIconHidden(bool value) { void FluxboxWindow::setIconHidden(bool value) {
m_state.icon_hidden = value; m_state.icon_hidden = value;
if (m_initialized) if (m_initialized)
m_statesig.notify(); m_statesig.emit(*this);
} }
@ -2843,7 +2842,7 @@ void FluxboxWindow::stopMoving(bool interrupted) {
if (m_state.maximized || m_state.fullscreen) { if (m_state.maximized || m_state.fullscreen) {
frame().applyState(); frame().applyState();
attachWorkAreaSig(); attachWorkAreaSig();
stateSig().notify(); stateSig().emit(*this);
} }
} }
@ -3581,7 +3580,8 @@ void FluxboxWindow::updateButtons() {
0, 0, 10, 10); 0, 0, 10, 10);
winbtn->setOnClick(close_cmd); winbtn->setOnClick(close_cmd);
stateSig().attach(winbtn); winbtn->join(stateSig(),
FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll));
} }
break; break;
case WinButton::STICK: case WinButton::STICK:
@ -3592,7 +3592,8 @@ void FluxboxWindow::updateButtons() {
frame().titlebar(), frame().titlebar(),
0, 0, 10, 10); 0, 0, 10, 10);
stateSig().attach(winbtn); winbtn->join(stateSig(),
FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll));
winbtn->setOnClick(stick_cmd); winbtn->setOnClick(stick_cmd);
} }
break; break;
@ -3603,7 +3604,8 @@ void FluxboxWindow::updateButtons() {
dir[i], dir[i],
frame().titlebar(), frame().titlebar(),
0, 0, 10, 10); 0, 0, 10, 10);
stateSig().attach(winbtn); winbtn->join(stateSig(),
FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll));
winbtn->setOnClick(shade_cmd); winbtn->setOnClick(shade_cmd);
} }
break; break;
@ -3749,7 +3751,7 @@ void FluxboxWindow::setOnHead(int head) {
if (m_state.maximized || m_state.fullscreen) { if (m_state.maximized || m_state.fullscreen) {
frame().applyState(); frame().applyState();
attachWorkAreaSig(); attachWorkAreaSig();
stateSig().notify(); stateSig().emit(*this);
} }
} }

View file

@ -458,8 +458,7 @@ public:
@name signals @name signals
@{ @{
*/ */
FbTk::Subject &stateSig() { return m_statesig; } FbTk::Signal<FluxboxWindow &> &stateSig() { return m_statesig; }
const FbTk::Subject &stateSig() const { return m_statesig; }
FbTk::Subject &layerSig() { return m_layersig; } FbTk::Subject &layerSig() { return m_layersig; }
const FbTk::Subject &layerSig() const { return m_layersig; } const FbTk::Subject &layerSig() const { return m_layersig; }
FbTk::Subject &hintSig() { return m_hintsig; } FbTk::Subject &hintSig() { return m_hintsig; }
@ -541,9 +540,8 @@ private:
// state and hint signals // state and hint signals
WinSubject m_hintsig, WinSubject m_hintsig,
m_statesig,
m_layersig; m_layersig;
FbTk::Signal<FluxboxWindow &> m_workspacesig; FbTk::Signal<FluxboxWindow &> m_workspacesig, m_statesig;
time_t m_creation_time; time_t m_creation_time;

View file

@ -952,30 +952,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
fbwin = winsub->win().fbwindow(); fbwin = winsub->win().fbwindow();
} }
if (fbwin && &fbwin->stateSig() == changedsub) { // state signal if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal
STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateState, *fbwin));
// if window changed to iconic state
// add to icon list
if (fbwin->isIconic()) {
fbwin->screen().addIcon(fbwin);
Workspace *space = fbwin->screen().getWorkspace(fbwin->workspaceNumber());
if (space != 0)
space->removeWindow(fbwin, true);
}
if (fbwin->isStuck()) {
// if we're sticky then reassociate window
// to all workspaces
BScreen &scr = fbwin->screen();
if (scr.currentWorkspaceID() != fbwin->workspaceNumber()) {
scr.reassociateWindow(fbwin,
scr.currentWorkspaceID(),
true);
}
}
} else if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal
STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, *fbwin)); CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, *fbwin));
} }
@ -1025,9 +1002,31 @@ void Fluxbox::windowWorkspaceChanged(FluxboxWindow &win) {
CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateWorkspace, win)); CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateWorkspace, win));
} }
void Fluxbox::windowStateChanged(FluxboxWindow &win) {
STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateState, win));
// if window changed to iconic state
// add to icon list
if (win.isIconic()) {
win.screen().addIcon(&win);
Workspace *space = win.screen().getWorkspace(win.workspaceNumber());
if (space != 0)
space->removeWindow(&win, true);
}
if (win.isStuck()) {
// if we're sticky then reassociate window
// to all workspaces
BScreen &scr = win.screen();
if (scr.currentWorkspaceID() != win.workspaceNumber())
scr.reassociateWindow(&win, scr.currentWorkspaceID(), true);
}
}
void Fluxbox::attachSignals(FluxboxWindow &win) { void Fluxbox::attachSignals(FluxboxWindow &win) {
win.hintSig().attach(this); win.hintSig().attach(this);
win.stateSig().attach(this); join(win.stateSig(), FbTk::MemFun(*this, &Fluxbox::windowStateChanged));
join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged)); join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged));
win.layerSig().attach(this); win.layerSig().attach(this);
join(win.dieSig(), FbTk::MemFun(*this, &Fluxbox::windowDied)); join(win.dieSig(), FbTk::MemFun(*this, &Fluxbox::windowDied));

View file

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