Convert FluxboxWindow::stateSig to FbTk::Signal
@@ -93,7 +93,7 @@ join(client.focusSig(), MemFun(*this, &AttentionNoticeHandler::windowFocusChanged));
// update _NET_WM_STATE atom if (client.fbwindow()) - client.fbwindow()->stateSig().notify(); + client.fbwindow()->stateSig().emit(*client.fbwindow()); } void AttentionNoticeHandler::windowFocusChanged(Focusable& win) {@@ -113,7 +113,7 @@
// update _NET_WM_STATE atom if the window is not dead FluxboxWindow *fbwin = win.fbwindow(); if (fbwin && ! died) - fbwin->stateSig().notify(); + fbwin->stateSig().emit(*fbwin); }
@@ -271,12 +271,14 @@ if(fbwin) {
tracker->join(fbwin->workspaceSig(), MemFun(*this, &FocusableList::windowUpdated) ); + tracker->join(fbwin->stateSig(), + MemFun(*this, &FocusableList::windowUpdated) + ); } } if (!fbwin) return; - fbwin->stateSig().attach(this); fbwin->layerSig().attach(this); // TODO: can't watch (head=...) yet }@@ -289,7 +291,6 @@ // detach various signals for matching
FluxboxWindow *fbwin = win.fbwindow(); if (!fbwin) return; - fbwin->stateSig().detach(this); fbwin->layerSig().detach(this); // TODO: can't watch (head=...) yet }
@@ -48,7 +48,7 @@
join(theme.reconfigSig(), FbTk::MemFun(*this, &WinButton::updateAll)); if (buttontype == MENUICON) - update(0); + updateAll(); } void WinButton::exposeEvent(XExposeEvent &event) {@@ -316,7 +316,3 @@ }
clear(); } - -void WinButton::update(FbTk::Subject *subj) { - updateAll(); -}
@@ -36,7 +36,7 @@ template <class T> class ThemeProxy;
} /// 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: /// draw type for the button enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON};@@ -57,7 +57,6 @@ Pixmap getBackgroundPixmap() const;
Pixmap getPressedPixmap() const; /// override for redrawing void clear(); - void update(FbTk::Subject *subj); void updateAll(); private: void drawType();
@@ -260,7 +260,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client):
Focusable(client.screen(), this), oplock(false), m_hintsig(*this), - m_statesig(*this), m_layersig(*this), m_creation_time(0), moving(false), resizing(false),@@ -625,7 +624,7 @@
// 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 // affected clients if possible - m_statesig.notify(); + m_statesig.emit(*this); m_workspacesig.emit(*this); m_layersig.notify();@@ -1336,7 +1335,7 @@ if (isIconic()) // no need to iconify if we're already
return; m_state.iconic = true; - m_statesig.notify(); + m_statesig.emit(*this); hide(true);@@ -1365,7 +1364,7 @@
// reassociate first, so it gets removed from screen's icon list screen().reassociateWindow(this, m_workspace_number, false); m_state.iconic = false; - m_statesig.notify(); + m_statesig.emit(*this); // deiconify all transients ClientList::iterator client_it = clientList().begin();@@ -1418,7 +1417,7 @@ m_old_layernum = layerNum();
m_state.fullscreen = true; frame().applyState(); - setFullscreenLayer(); // calls stateSig().notify() + setFullscreenLayer(); // calls stateSig().emit() if (!isFocused()) { join(screen().focusedWindowSig(), FbTk::MemFun(*this, &FluxboxWindow::focusedWindowChanged));@@ -1430,7 +1429,7 @@ m_state.fullscreen = false;
frame().applyState(); moveToLayer(m_old_layernum); - stateSig().notify(); + stateSig().emit(*this); } attachWorkAreaSig();@@ -1448,7 +1447,7 @@ moveToLayer(::ResourceLayer::ABOVE_DOCK);
} else { moveToLayer(::ResourceLayer::DESKTOP); } - stateSig().notify(); + stateSig().emit(*this); }@@ -1483,7 +1482,7 @@ stopResizing();
if (isShaded()) { // do not call ::shade() here to trigger frame().applyState() and - // stateSig().notfiy() only once + // stateSig().emit() only once m_state.shaded = false; }@@ -1493,7 +1492,7 @@
attachWorkAreaSig(); // notify listeners that we changed state - stateSig().notify(); + stateSig().emit(*this); } void FluxboxWindow::disableMaximization() {@@ -1504,7 +1503,7 @@ // position after maximization is disabled
m_state.saveGeometry(frame().x(), frame().y(), frame().width(), frame().height()); frame().applyState(); - stateSig().notify(); + stateSig().emit(*this); }@@ -1560,7 +1559,7 @@ if (!m_initialized)
return; frame().applyState(); - stateSig().notify(); + stateSig().emit(*this); // TODO: this should set IconicState, but then we can't focus the window }@@ -1584,7 +1583,7 @@
m_state.stuck = !m_state.stuck; if (m_initialized) { - stateSig().notify(); + stateSig().emit(*this); // notify since some things consider "stuck" to be a pseudo-workspace m_workspacesig.emit(*this); }@@ -1726,13 +1725,13 @@
void FluxboxWindow::setFocusHidden(bool value) { m_state.focus_hidden = value; if (m_initialized) - m_statesig.notify(); + m_statesig.emit(*this); } void FluxboxWindow::setIconHidden(bool value) { m_state.icon_hidden = value; if (m_initialized) - m_statesig.notify(); + m_statesig.emit(*this); }@@ -2843,7 +2842,7 @@ // if Head has been changed we want it to redraw by current state
if (m_state.maximized || m_state.fullscreen) { frame().applyState(); attachWorkAreaSig(); - stateSig().notify(); + stateSig().emit(*this); } }@@ -3581,7 +3580,8 @@ frame().titlebar(),
0, 0, 10, 10); winbtn->setOnClick(close_cmd); - stateSig().attach(winbtn); + winbtn->join(stateSig(), + FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll)); } break; case WinButton::STICK:@@ -3592,7 +3592,8 @@ dir[i],
frame().titlebar(), 0, 0, 10, 10); - stateSig().attach(winbtn); + winbtn->join(stateSig(), + FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll)); winbtn->setOnClick(stick_cmd); } break;@@ -3603,7 +3604,8 @@ screen().pressedWinButtonTheme(),
dir[i], frame().titlebar(), 0, 0, 10, 10); - stateSig().attach(winbtn); + winbtn->join(stateSig(), + FbTk::MemFunIgnoreArgs(*winbtn, &WinButton::updateAll)); winbtn->setOnClick(shade_cmd); } break;@@ -3749,7 +3751,7 @@ // if Head has been changed we want it to redraw by current state
if (m_state.maximized || m_state.fullscreen) { frame().applyState(); attachWorkAreaSig(); - stateSig().notify(); + stateSig().emit(*this); } }
@@ -458,8 +458,7 @@ /**
@name signals @{ */ - FbTk::Subject &stateSig() { return m_statesig; } - const FbTk::Subject &stateSig() const { return m_statesig; } + FbTk::Signal<FluxboxWindow &> &stateSig() { return m_statesig; } FbTk::Subject &layerSig() { return m_layersig; } const FbTk::Subject &layerSig() const { return m_layersig; } FbTk::Subject &hintSig() { return m_hintsig; }@@ -541,9 +540,8 @@
// state and hint signals WinSubject m_hintsig, - m_statesig, m_layersig; - FbTk::Signal<FluxboxWindow &> m_workspacesig; + FbTk::Signal<FluxboxWindow &> m_workspacesig, m_statesig; time_t m_creation_time;
@@ -952,30 +952,7 @@ Focusable::FocusSubject *winsub = dynamic_cast<Focusable::FocusSubject *>(changedsub);
fbwin = winsub->win().fbwindow(); } - if (fbwin && &fbwin->stateSig() == changedsub) { // state 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 + if (fbwin && &fbwin->layerSig() == changedsub) { // layer signal STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update), CallMemFunWithRefArg<AtomHandler, FluxboxWindow&, void>(&AtomHandler::updateLayer, *fbwin)); }@@ -1025,9 +1002,31 @@ STLUtil::forAllIf(m_atomhandler, mem_fun(&AtomHandler::update),
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) { win.hintSig().attach(this); - win.stateSig().attach(this); + join(win.stateSig(), FbTk::MemFun(*this, &Fluxbox::windowStateChanged)); join(win.workspaceSig(), FbTk::MemFun(*this, &Fluxbox::windowWorkspaceChanged)); win.layerSig().attach(this); join(win.dieSig(), FbTk::MemFun(*this, &Fluxbox::windowDied));
@@ -223,6 +223,8 @@ /// Called when a client (WinClient) dies
void clientDied(Focusable &focusable); /// Called when a window changes workspace void windowWorkspaceChanged(FluxboxWindow &win); + /// Called when a window changes state + void windowStateChanged(FluxboxWindow &win); std::auto_ptr<FbAtoms> m_fbatoms;