Convert FluxboxWindow::stateSig to FbTk::Signal
This commit is contained in:
parent
ad0951ca53
commit
e53d14e910
8 changed files with 56 additions and 59 deletions
|
@ -93,7 +93,7 @@ void AttentionNoticeHandler::addAttention(Focusable &client) {
|
|||
|
||||
// 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 @@ void AttentionNoticeHandler::updateWindow(Focusable& win, bool died) {
|
|||
// 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 @@ void FocusableList::attachSignals(Focusable &win) {
|
|||
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 @@ void FocusableList::detachSignals(Focusable &win) {
|
|||
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 @@ WinButton::WinButton(FluxboxWindow &listen_to,
|
|||
join(theme.reconfigSig(), FbTk::MemFun(*this, &WinButton::updateAll));
|
||||
|
||||
if (buttontype == MENUICON)
|
||||
update(0);
|
||||
updateAll();
|
||||
}
|
||||
|
||||
void WinButton::exposeEvent(XExposeEvent &event) {
|
||||
|
@ -316,7 +316,3 @@ void WinButton::updateAll() {
|
|||
|
||||
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 @@ public:
|
|||
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 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
|
|||
// 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 @@ void FluxboxWindow::iconify() {
|
|||
return;
|
||||
|
||||
m_state.iconic = true;
|
||||
m_statesig.notify();
|
||||
m_statesig.emit(*this);
|
||||
|
||||
hide(true);
|
||||
|
||||
|
@ -1365,7 +1364,7 @@ void FluxboxWindow::deiconify(bool do_raise) {
|
|||
// 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 @@ void FluxboxWindow::setFullscreen(bool flag) {
|
|||
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 @@ void FluxboxWindow::setFullscreen(bool flag) {
|
|||
frame().applyState();
|
||||
|
||||
moveToLayer(m_old_layernum);
|
||||
stateSig().notify();
|
||||
stateSig().emit(*this);
|
||||
}
|
||||
|
||||
attachWorkAreaSig();
|
||||
|
@ -1448,7 +1447,7 @@ void FluxboxWindow::setFullscreenLayer() {
|
|||
} else {
|
||||
moveToLayer(::ResourceLayer::DESKTOP);
|
||||
}
|
||||
stateSig().notify();
|
||||
stateSig().emit(*this);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1483,7 +1482,7 @@ void FluxboxWindow::setMaximizedState(int type) {
|
|||
|
||||
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 @@ void FluxboxWindow::setMaximizedState(int type) {
|
|||
attachWorkAreaSig();
|
||||
|
||||
// notify listeners that we changed state
|
||||
stateSig().notify();
|
||||
stateSig().emit(*this);
|
||||
}
|
||||
|
||||
void FluxboxWindow::disableMaximization() {
|
||||
|
@ -1504,7 +1503,7 @@ void FluxboxWindow::disableMaximization() {
|
|||
m_state.saveGeometry(frame().x(), frame().y(),
|
||||
frame().width(), frame().height());
|
||||
frame().applyState();
|
||||
stateSig().notify();
|
||||
stateSig().emit(*this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1560,7 +1559,7 @@ void FluxboxWindow::shade() {
|
|||
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 @@ void FluxboxWindow::stick() {
|
|||
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::moveToLayer(int layernum, bool force) {
|
|||
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 @@ void FluxboxWindow::stopMoving(bool interrupted) {
|
|||
if (m_state.maximized || m_state.fullscreen) {
|
||||
frame().applyState();
|
||||
attachWorkAreaSig();
|
||||
stateSig().notify();
|
||||
stateSig().emit(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3581,7 +3580,8 @@ void FluxboxWindow::updateButtons() {
|
|||
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 @@ void FluxboxWindow::updateButtons() {
|
|||
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 @@ void FluxboxWindow::updateButtons() {
|
|||
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 @@ void FluxboxWindow::setOnHead(int head) {
|
|||
if (m_state.maximized || m_state.fullscreen) {
|
||||
frame().applyState();
|
||||
attachWorkAreaSig();
|
||||
stateSig().notify();
|
||||
stateSig().emit(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -458,8 +458,7 @@ public:
|
|||
@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 @@ private:
|
|||
|
||||
// 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 @@ void Fluxbox::update(FbTk::Subject *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 @@ void Fluxbox::windowWorkspaceChanged(FluxboxWindow &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) {
|
||||
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 @@ private:
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue