all repos — fluxbox @ e1b0decf559113b43162d9e54bdbf75ee1d80b1f

custom fork of the fluxbox windowmanager

Convert Focusable::attentionSig to FbTk::Signal
Pavel Labath pavelo@centrum.sk
commit

e1b0decf559113b43162d9e54bdbf75ee1d80b1f

parent

2073ae12a4e633d18f49559111131fffbc495dbd

4 files changed, 10 insertions(+), 47 deletions(-)

jump to
M src/Focusable.hhsrc/Focusable.hh

@@ -24,7 +24,6 @@ #define FOCUSABLE_HH

#include "FbTk/PixmapWithMask.hh" #include "FbTk/ITypeAheadable.hh" -#include "FbTk/Subject.hh" #include "FbTk/Signal.hh" #include "FbTk/FbString.hh"

@@ -41,7 +40,7 @@ Focusable(BScreen &scr, FluxboxWindow *fbwin = 0):

m_screen(scr), m_fbwin(fbwin), m_instance_name("fluxbox"), m_class_name("fluxbox"), m_focused(false), m_attention_state(false), - m_attentionsig(*this), + m_attentionsig(), m_focussig(), m_diesig(), m_titlesig() { }

@@ -62,7 +61,7 @@ /// @return true if icon button should appear focused

bool getAttentionState() const { return m_attention_state; } /// @set the attention state virtual void setAttentionState(bool value) { - m_attention_state = value; attentionSig().notify(); + m_attention_state = value; attentionSig().emit(*this); } /// @return the screen in which this object resides

@@ -101,19 +100,6 @@ /// @return title string

virtual const FbTk::BiDiString &title() const { return m_title; } /// @return type ahead string const std::string &iTypeString() const { return title().logical(); } - /** - * Signaling object to attatch observers to. - */ - class FocusSubject: public FbTk::Subject { - public: - explicit FocusSubject(Focusable &w):m_win(w) { } - /// @return context focusable for this signal - Focusable &win() { return m_win; } - /// @return context focusable for this signal - const Focusable &win() const { return m_win; } - private: - Focusable &m_win; //< the context - }; /** @name signals

@@ -126,8 +112,7 @@ /// Used for both title and icon changes.

const TitleSignal &titleSig() const { return m_titlesig; } FbTk::Signal<Focusable&> &focusSig() { return m_focussig; } FbTk::Signal<Focusable&> &dieSig() { return m_diesig; } - FbTk::Subject &attentionSig() { return m_attentionsig; } - const FbTk::Subject &attentionSig() const { return m_attentionsig; } + FbTk::Signal<Focusable&> &attentionSig() { return m_attentionsig; } /** @} */ // end group signals /// Notify any listeners that the focus changed for this window.

@@ -147,10 +132,9 @@ bool m_focused; //< whether or not it has focus

bool m_attention_state; //< state of icon button while demanding attention FbTk::PixmapWithMask m_icon; //< icon pixmap with mask - // state and hint signals - FocusSubject m_attentionsig; private: + FbTk::Signal<Focusable&> m_attentionsig; FbTk::Signal<Focusable&> m_focussig; FbTk::Signal<Focusable&> m_diesig; TitleSignal m_titlesig;
M src/FocusableTheme.hhsrc/FocusableTheme.hh

@@ -23,13 +23,11 @@ #ifndef FOCUSABLETHEME_HH

#define FOCUSABLETHEME_HH #include "Focusable.hh" -#include "FbTk/Observer.hh" #include "FbTk/Theme.hh" #include "FbTk/RelaySignal.hh" template <typename BaseTheme> -class FocusableTheme: public FbTk::ThemeProxy<BaseTheme>, - private FbTk::Observer { +class FocusableTheme: public FbTk::ThemeProxy<BaseTheme> { public: FocusableTheme(Focusable &win, FbTk::ThemeProxy<BaseTheme> &focused, FbTk::ThemeProxy<BaseTheme> &unfocused):

@@ -37,8 +35,8 @@ m_win(win), m_focused_theme(focused), m_unfocused_theme(unfocused) {

m_signals.join(m_win.focusSig(), FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit)); - - m_win.attentionSig().attach(this); + m_signals.join(m_win.attentionSig(), + FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal<>::emit)); m_signals.join(m_focused_theme.reconfigSig(), FbTk::MemFun(m_reconfig_sig, &FbTk::Signal<>::emit)); m_signals.join(m_unfocused_theme.reconfigSig(),

@@ -66,8 +64,6 @@ *m_focused_theme : *m_unfocused_theme;

} private: - void update(FbTk::Subject *subj) { m_reconfig_sig.emit(); } - Focusable &m_win; FbTk::ThemeProxy<BaseTheme> &m_focused_theme, &m_unfocused_theme; FbTk::Signal<> m_reconfig_sig;
M src/IconButton.ccsrc/IconButton.cc

@@ -61,7 +61,8 @@

m_signals.join(m_win.focusSig(), MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); - m_win.attentionSig().attach(this); + m_signals.join(m_win.attentionSig(), + MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); FbTk::EventManager::instance()->add(*this, m_icon_window);

@@ -248,22 +249,6 @@ refreshEverything(true);

if (m_has_tooltip) showTooltip(); -} - -void IconButton::update(FbTk::Subject *subj) { - // if the window's focus state changed, we need to update the background - if (subj == &m_win.attentionSig()) { - reconfigAndClear(); - return; - } - - // we got signal that either title or - // icon pixmap was updated, - // so we refresh everything - // if the title was changed AND the mouse is over *this, - // update the tooltip - - refreshEverything(subj != 0); } void IconButton::setupWindow() {
M src/IconButton.hhsrc/IconButton.hh

@@ -27,7 +27,6 @@ #include "FocusableTheme.hh"

#include "FbTk/CachedPixmap.hh" #include "FbTk/FbPixmap.hh" -#include "FbTk/Observer.hh" #include "FbTk/TextButton.hh" #include "FbTk/Signal.hh"

@@ -37,7 +36,7 @@ namespace FbTk {

template <class T> class ThemeProxy; } -class IconButton: public FbTk::TextButton, public FbTk::Observer { +class IconButton: public FbTk::TextButton { public: IconButton(const FbTk::FbWindow &parent, FbTk::ThemeProxy<IconbarTheme> &focused_theme,

@@ -58,7 +57,6 @@ void resize(unsigned int width, unsigned int height);

void reconfigTheme(); - void update(FbTk::Subject *subj); void setPixmap(bool use); Focusable &win() { return m_win; }