From f7d7dfd2a8047207dbe90bc77592c25acf4ca15c Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 29 Apr 2011 10:52:28 +0200 Subject: Convert FbTk::Theme::reconfigSig and friends to the new Signal system I removed the const versions of reconfigSig() in the process since FbTk::Signal has no const methods anyway. --- src/ButtonTheme.hh | 3 +-- src/ClientMenu.hh | 1 + src/ClockTool.cc | 11 ++++++----- src/ClockTool.hh | 9 +++++---- src/FbTk/Menu.cc | 4 ++-- src/FbTk/Menu.hh | 3 +++ src/FbTk/MenuTheme.hh | 3 +-- src/FbTk/Theme.cc | 2 +- src/FbTk/Theme.hh | 11 ++++------- src/FbWinFrameTheme.hh | 3 +-- src/FocusableTheme.hh | 18 ++++++++++-------- src/GenericTool.cc | 5 +++-- src/GenericTool.hh | 7 ++++--- src/IconbarTheme.hh | 3 +-- src/IconbarTool.cc | 21 ++++++++++----------- src/IconbarTool.hh | 3 +++ src/RootTheme.hh | 3 +-- src/Screen.cc | 8 +++----- src/Screen.hh | 9 +++------ src/Slit.cc | 10 +++------- src/Slit.hh | 1 - src/SlitTheme.hh | 3 +-- src/SystemTray.cc | 6 ++---- src/SystemTray.hh | 6 ------ src/ToolTheme.hh | 4 +--- src/Toolbar.cc | 2 +- src/ToolbarTheme.hh | 3 +-- src/WinButton.cc | 3 ++- src/WinButtonTheme.hh | 3 +-- src/Window.cc | 12 +++++++----- src/Window.hh | 2 ++ src/WorkspaceNameTheme.hh | 3 +-- src/WorkspaceNameTool.cc | 14 +++++--------- src/WorkspaceNameTool.hh | 8 ++------ 34 files changed, 92 insertions(+), 115 deletions(-) diff --git a/src/ButtonTheme.hh b/src/ButtonTheme.hh index 95a4e32..77cc159 100644 --- a/src/ButtonTheme.hh +++ b/src/ButtonTheme.hh @@ -43,8 +43,7 @@ public: int scale() const { return *m_scale; } // scale factor for inside objects const std::string &name() { return m_name; } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual ButtonTheme &operator *() { return *this; } virtual const ButtonTheme &operator *() const { return *this; } diff --git a/src/ClientMenu.hh b/src/ClientMenu.hh index 4b5cedb..6b59e71 100644 --- a/src/ClientMenu.hh +++ b/src/ClientMenu.hh @@ -25,6 +25,7 @@ #include "FbMenu.hh" #include "FbTk/Signal.hh" +#include "FbTk/Subject.hh" class BScreen; class FluxboxWindow; diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 257058f..6642985 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -28,6 +28,7 @@ #include "CommandDialog.hh" #include "fluxbox.hh" +#include "FbTk/MemFun.hh" #include "FbTk/SimpleCommand.hh" #include "FbTk/ImageControl.hh" #include "FbTk/TextUtils.hh" @@ -168,7 +169,7 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent, screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat"), m_stringconvertor(FbTk::StringConvertor::ToFbString) { // attach signals - theme.reconfigSig().attach(this); + m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &ClockTool::themeReconfigured)); std::string time_locale = setlocale(LC_TIME, NULL); size_t pos = time_locale.find('.'); @@ -197,7 +198,7 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent, menu.insert(_FB_XTEXT(Toolbar, ClockEditFormat, "Edit Clock Format", "edit Clock Format") , editformat_cmd); - update(0); + themeReconfigured(); } ClockTool::~ClockTool() { @@ -233,10 +234,10 @@ void ClockTool::hide() { void ClockTool::setTimeFormat(const std::string &format) { *m_timeformat = format; - update(0); + themeReconfigured(); } -void ClockTool::update(FbTk::Subject *subj) { +void ClockTool::themeReconfigured() { updateTime(); // + 2 to make the entire text fit inside @@ -316,7 +317,7 @@ void ClockTool::updateTime() { void ClockTool::updateSizing() { m_button.setBorderWidth(m_theme->border().width()); // resizes if new timeformat - update(0); + themeReconfigured(); } void ClockTool::reRender() { diff --git a/src/ClockTool.hh b/src/ClockTool.hh index d2b9dca..4f89b36 100644 --- a/src/ClockTool.hh +++ b/src/ClockTool.hh @@ -26,8 +26,8 @@ #include "ToolbarItem.hh" +#include "FbTk/Signal.hh" #include "FbTk/TextButton.hh" -#include "FbTk/Observer.hh" #include "FbTk/Resource.hh" #include "FbTk/Timer.hh" #include "FbTk/FbString.hh" @@ -37,12 +37,11 @@ class BScreen; namespace FbTk { class ImageControl; -class Subject; class Menu; template class ThemeProxy; } -class ClockTool:public ToolbarItem, public FbTk::Observer { +class ClockTool:public ToolbarItem { public: ClockTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy &theme, BScreen &screen, FbTk::Menu &menu); @@ -68,7 +67,7 @@ public: private: void updateTime(); - void update(FbTk::Subject *subj); + void themeReconfigured(); void renderTheme(int alpha); void reRender(); void updateSizing(); @@ -83,6 +82,8 @@ private: FbTk::Resource m_timeformat; FbTk::StringConvertor m_stringconvertor; + + FbTk::SignalTracker m_tracker; }; #endif // CLOCKTOOL_HH diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 48636ce..da5760d 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -36,6 +36,7 @@ #include "MenuItem.hh" #include "MenuSeparator.hh" #include "ImageControl.hh" +#include "MemFun.hh" #include "MenuTheme.hh" #include "App.hh" #include "EventManager.hh" @@ -121,7 +122,7 @@ Menu::Menu(FbTk::ThemeProxy &tm, ImageControl &imgctrl): m_hide_timer.fireOnce(true); // make sure we get updated when the theme is reloaded - tm.reconfigSig().attach(this); + m_tracker.join(tm.reconfigSig(), MemFun(*this, &Menu::themeReconfigured)); m_title_vis = true; @@ -1244,7 +1245,6 @@ void Menu::update(FbTk::Subject *subj) { reconfigure(); } - void Menu::setScreen(int x, int y, int w, int h) { m_screen_x = x; m_screen_y = y; diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index f3ec820..7b59cf7 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -195,6 +195,7 @@ private: void closeMenu(); void startHide(); void stopHide(); + void themeReconfigured() { update(NULL); } FbTk::ThemeProxy &m_theme; Menu *m_parent; @@ -261,6 +262,8 @@ private: bool m_need_update; Timer m_submenu_timer; Timer m_hide_timer; + + SignalTracker m_tracker; }; } // end namespace FbTk diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh index eb19798..b575860 100644 --- a/src/FbTk/MenuTheme.hh +++ b/src/FbTk/MenuTheme.hh @@ -130,8 +130,7 @@ public: m_hl_selected_pixmap->pixmap().dontFree(); } - virtual Subject &reconfigSig() { return Theme::reconfigSig(); } - virtual const Subject &reconfigSig() const { return Theme::reconfigSig(); } + virtual Signal &reconfigSig() { return Theme::reconfigSig(); } virtual MenuTheme &operator *() { return *this; } virtual const MenuTheme &operator *() const { return *this; } diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index c92e563..c252275 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc @@ -56,7 +56,7 @@ struct LoadThemeHelper { ThemeManager::ThemeList::iterator it = tmlist.begin(); ThemeManager::ThemeList::iterator it_end = tmlist.end(); for (; it != it_end; ++it) { - (*it)->reconfigSig().notify(); + (*it)->reconfigSig().emit(); } } diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index c331ba5..c700f9b 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh @@ -26,8 +26,8 @@ #ifndef FBTK_THEME_HH #define FBTK_THEME_HH +#include "Signal.hh" #include "XrmDatabaseHelper.hh" -#include "Subject.hh" #include #include @@ -107,15 +107,13 @@ public: template void remove(ThemeItem &item); virtual bool fallback(ThemeItem_base &) { return false; } - FbTk::Subject &reconfigSig() { return m_reconfig_sig; } - const FbTk::Subject &reconfigSig() const { return m_reconfig_sig; } - + Signal &reconfigSig() { return m_reconfig_sig; } private: const int m_screen_num; ItemList m_themeitems; - FbTk::Subject m_reconfig_sig; + Signal m_reconfig_sig; }; /// Proxy interface for themes, so they can be substituted dynamically @@ -124,8 +122,7 @@ class ThemeProxy { public: virtual ~ThemeProxy() { } - virtual Subject &reconfigSig() = 0; - virtual const Subject &reconfigSig() const = 0; + virtual Signal &reconfigSig() = 0; virtual BaseTheme &operator *() = 0; virtual const BaseTheme &operator *() const = 0; diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index 3c28cbd..613c66a 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -79,8 +79,7 @@ public: IconbarTheme &iconbarTheme() { return m_iconbar_theme; } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual FbWinFrameTheme &operator *() { return *this; } virtual const FbWinFrameTheme &operator *() const { return *this; } diff --git a/src/FocusableTheme.hh b/src/FocusableTheme.hh index cc14e62..6643b43 100644 --- a/src/FocusableTheme.hh +++ b/src/FocusableTheme.hh @@ -34,12 +34,15 @@ public: FocusableTheme(Focusable &win, FbTk::ThemeProxy &focused, FbTk::ThemeProxy &unfocused): m_win(win), m_focused_theme(focused), m_unfocused_theme(unfocused) { - // relay focus signal to reconfig signal - FbTk::relaySignal(m_signals, m_win.focusSig(), m_reconfig_sig); + + m_signals.join(m_win.focusSig(), + FbTk::MemFunIgnoreArgs(m_reconfig_sig, &FbTk::Signal::emit)); m_win.attentionSig().attach(this); - m_focused_theme.reconfigSig().attach(this); - m_unfocused_theme.reconfigSig().attach(this); + m_signals.join(m_focused_theme.reconfigSig(), + FbTk::MemFun(m_reconfig_sig, &FbTk::Signal::emit)); + m_signals.join(m_unfocused_theme.reconfigSig(), + FbTk::MemFun(m_reconfig_sig, &FbTk::Signal::emit)); } Focusable &win() { return m_win; } @@ -51,8 +54,7 @@ public: FbTk::ThemeProxy &unfocusedTheme() { return m_unfocused_theme; } const FbTk::ThemeProxy &unfocusedTheme() const { return m_unfocused_theme; } - FbTk::Subject &reconfigSig() { return m_reconfig_sig; } - const FbTk::Subject &reconfigSig() const { return m_reconfig_sig; } + FbTk::Signal &reconfigSig() { return m_reconfig_sig; } virtual BaseTheme &operator *() { return (m_win.isFocused() || m_win.getAttentionState()) ? @@ -64,11 +66,11 @@ public: } private: - void update(FbTk::Subject *subj) { m_reconfig_sig.notify(); } + void update(FbTk::Subject *subj) { m_reconfig_sig.emit(); } Focusable &m_win; FbTk::ThemeProxy &m_focused_theme, &m_unfocused_theme; - FbTk::Subject m_reconfig_sig; + FbTk::Signal m_reconfig_sig; FbTk::SignalTracker m_signals; }; diff --git a/src/GenericTool.cc b/src/GenericTool.cc index 41388ce..f589f4c 100644 --- a/src/GenericTool.cc +++ b/src/GenericTool.cc @@ -21,6 +21,7 @@ #include "GenericTool.hh" #include "FbTk/FbWindow.hh" +#include "FbTk/MemFun.hh" #include "ToolTheme.hh" #include @@ -31,7 +32,7 @@ GenericTool::GenericTool(FbTk::FbWindow *new_window, ToolbarItem::Type type, m_window(new_window), m_theme(theme) { - theme.reconfigSig().attach(this); + m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &GenericTool::themeReconfigured)); if (new_window == 0) throw std::string("GenericTool: Error! Tried to create a tool with window = 0"); @@ -80,7 +81,7 @@ void GenericTool::renderTheme(int alpha) { m_window->clear(); } -void GenericTool::update(FbTk::Subject *subj) { +void GenericTool::themeReconfigured() { m_window->clear(); } diff --git a/src/GenericTool.hh b/src/GenericTool.hh index 5d7c8d4..72ff462 100644 --- a/src/GenericTool.hh +++ b/src/GenericTool.hh @@ -25,7 +25,7 @@ #include "ToolbarItem.hh" #include "FbTk/NotCopyable.hh" -#include "FbTk/Observer.hh" +#include "FbTk/Signal.hh" #include @@ -37,7 +37,7 @@ template class ThemeProxy; } /// helper class for simple tools, i.e buttons etc -class GenericTool: public ToolbarItem, public FbTk::Observer, private FbTk::NotCopyable { +class GenericTool: public ToolbarItem, private FbTk::NotCopyable { public: GenericTool(FbTk::FbWindow *new_window, ToolbarItem::Type type, FbTk::ThemeProxy &theme); @@ -63,10 +63,11 @@ protected: virtual void renderTheme(int alpha); private: - void update(FbTk::Subject *subj); + void themeReconfigured(); std::auto_ptr m_window; FbTk::ThemeProxy &m_theme; + FbTk::SignalTracker m_tracker; }; #endif // GENERICTOOL_HH diff --git a/src/IconbarTheme.hh b/src/IconbarTheme.hh index e4b3c8b..f43a915 100644 --- a/src/IconbarTheme.hh +++ b/src/IconbarTheme.hh @@ -41,8 +41,7 @@ public: const FbTk::Texture &texture() const { return *m_texture; } const FbTk::Texture &emptyTexture() const { return *m_empty_texture; } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual IconbarTheme &operator *() { return *this; } virtual const IconbarTheme &operator *() const { return *this; } diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 28e4aeb..42817c5 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -291,10 +291,12 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, menu.insert(m_menu.label().logical(), &m_menu); // setup signals - theme.reconfigSig().attach(this); - focused_theme.reconfigSig().attach(this); - unfocused_theme.reconfigSig().attach(this); - setMode(*m_rc_mode); + m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &IconbarTool::themeReconfigured)); + m_tracker.join(focused_theme.reconfigSig(), + FbTk::MemFun(*this, &IconbarTool::themeReconfigured)); + m_tracker.join(unfocused_theme.reconfigSig(), + FbTk::MemFun(*this, &IconbarTool::themeReconfigured)); + themeReconfigured(); } IconbarTool::~IconbarTool() { @@ -383,6 +385,10 @@ unsigned int IconbarTool::borderWidth() const { return m_icon_container.borderWidth(); } +void IconbarTool::themeReconfigured() { + setMode(*m_rc_mode); +} + void IconbarTool::update(FbTk::Subject *subj) { // ignore updates if we're shutting down if (m_screen.isShuttingdown()) { @@ -396,13 +402,6 @@ void IconbarTool::update(FbTk::Subject *subj) { *m_rc_client_width = FbTk::Util::clamp(*m_rc_client_width, 10, 400); m_icon_container.setMaxSizePerClient(*m_rc_client_width); - if (subj == &m_focused_theme.reconfigSig() || - subj == &m_unfocused_theme.reconfigSig() || - subj == &m_theme.reconfigSig()) { - setMode(*m_rc_mode); - return; - } - // lock graphic update m_icon_container.setUpdateLock(true); diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index cb8304f..92fbe63 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -95,12 +95,15 @@ private: /// add icons to the list void updateList(); + void themeReconfigured(); + BScreen &m_screen; FbTk::Container m_icon_container; IconbarTheme &m_theme; FbTk::ThemeProxy &m_focused_theme, &m_unfocused_theme; FbTk::CachedPixmap m_empty_pm; ///< pixmap for empty container + FbTk::SignalTracker m_tracker; std::auto_ptr m_winlist; IconMap m_icons; diff --git a/src/RootTheme.hh b/src/RootTheme.hh index 0867430..6485448 100644 --- a/src/RootTheme.hh +++ b/src/RootTheme.hh @@ -48,8 +48,7 @@ public: GC opGC() const { return m_opgc.gc(); } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual RootTheme &operator *() { return *this; } virtual const RootTheme &operator *() const { return *this; } diff --git a/src/Screen.cc b/src/Screen.cc index a8eca72..ce1f8ed 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -435,7 +435,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm, m_menutheme->setDelay(*resource.menu_delay); - focusedWinFrameTheme()->reconfigSig().attach(this);// for geom window + m_tracker.join(focusedWinFrameTheme()->reconfigSig(), + FbTk::MemFun(*this, &BScreen::focusedWinFrameThemeReconfigured)); renderGeomWindow(); @@ -749,10 +750,7 @@ unsigned int BScreen::maxBottom(int head) const { return doFullMax() ? height() : height() - availableWorkspaceArea(head)->bottom(); } -void BScreen::update(FbTk::Subject *subj) { - // for now we're only listening to the theme sig, so no object check - // if another signal is added later, will need to differentiate here - +void BScreen::focusedWinFrameThemeReconfigured() { renderGeomWindow(); renderPosWindow(); diff --git a/src/Screen.hh b/src/Screen.hh index 729461a..4d1d933 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -75,7 +75,6 @@ class Menu; class ImageControl; class LayerItem; class FbWindow; -class Subject; } @@ -83,8 +82,7 @@ class Subject; /** Create workspaces, handles switching between workspaces and windows */ -class BScreen: public FbTk::EventHandler, public FbTk::Observer, - private FbTk::NotCopyable { +class BScreen: public FbTk::EventHandler, private FbTk::NotCopyable { public: typedef std::list Icons; @@ -220,9 +218,6 @@ public: ScreenSignal &bgChangeSig() { return m_bg_change_sig; } //@} - /// called when the screen receives a signal from a subject - void update(FbTk::Subject *subj); - void propertyNotify(Atom atom); void keyPressEvent(XKeyEvent &ke); void keyReleaseEvent(XKeyEvent &ke); @@ -476,9 +471,11 @@ private: void setupConfigmenu(FbTk::Menu &menu); void renderGeomWindow(); void renderPosWindow(); + void focusedWinFrameThemeReconfigured(); const Strut* availableWorkspaceArea(int head) const; + FbTk::SignalTracker m_tracker; ScreenSubject m_reconfigure_sig; ///< reconfigure signal diff --git a/src/Slit.cc b/src/Slit.cc index ef1564a..f3e24a9 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -263,13 +263,13 @@ Slit::Slit(BScreen &scr, FbTk::Layer &layer, const char *filename) _FB_USES_NLS; // attach to theme and root window change signal - theme().reconfigSig().attach(this); + join(theme().reconfigSig(), FbTk::MemFun(*this, &Slit::reconfigure)); join(scr.resizeSig(), FbTk::MemFun(*this, &Slit::screenSizeChanged)); join(scr.bgChangeSig(), - FbTk::MemFun(*this, &Slit::updateForScreen)); + FbTk::MemFunIgnoreArgs(*this, &Slit::reconfigure)); scr.reconfigureSig().attach(this); // if alpha changed (we disablethis signal when we get theme change sig) @@ -1042,12 +1042,8 @@ void Slit::screenSizeChanged(BScreen &screen) { #endif // XINERAMA } -void Slit::updateForScreen(BScreen &screen) { - reconfigure(); -} - void Slit::update(FbTk::Subject*) { - updateForScreen(screen()); + reconfigure(); } void Slit::clearWindow() { diff --git a/src/Slit.hh b/src/Slit.hh index 7f2729d..2f2eac8 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -134,7 +134,6 @@ public: private: /// Called when screen has changed void screenSizeChanged(BScreen &screen); - void updateForScreen(BScreen &screen); void updateAlpha(); void clearWindow(); diff --git a/src/SlitTheme.hh b/src/SlitTheme.hh index d6b410b..5a1b9d1 100644 --- a/src/SlitTheme.hh +++ b/src/SlitTheme.hh @@ -38,8 +38,7 @@ public: int borderWidth() const { return *m_border_width; } int bevelWidth() const { return *m_bevel_width; } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual SlitTheme &operator *() { return *this; } virtual const SlitTheme &operator *() const { return *this; } diff --git a/src/SystemTray.cc b/src/SystemTray.cc index a8c4d5d..66e350f 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.cc @@ -25,7 +25,6 @@ #include "FbTk/ImageControl.hh" #include "FbTk/TextUtils.hh" #include "FbTk/MemFun.hh" -#include "FbTk/SimpleObserver.hh" #include "AtomHandler.hh" #include "fluxbox.hh" @@ -167,11 +166,10 @@ SystemTray::SystemTray(const FbTk::FbWindow& parent, FbTk::EventManager::instance()->add(*this, m_window); FbTk::EventManager::instance()->add(*this, m_selection_owner); // setup signals - m_observer.reset(makeObserver(*this, &SystemTray::update)); - m_theme->reconfigSig().attach(m_observer.get()); + join(m_theme->reconfigSig(), FbTk::MemFun(*this, &SystemTray::update)); join(screen.bgChangeSig(), - FbTk::MemFun(*this, &SystemTray::updateForScreen)); + FbTk::MemFunIgnoreArgs(*this, &SystemTray::update)); Fluxbox* fluxbox = Fluxbox::instance(); diff --git a/src/SystemTray.hh b/src/SystemTray.hh index 3209790..d92e437 100644 --- a/src/SystemTray.hh +++ b/src/SystemTray.hh @@ -40,7 +40,6 @@ class AtomHandler; namespace FbTk { template class ThemeProxy; -class Observer; } class SystemTray: public ToolbarItem, public FbTk::EventHandler, @@ -89,10 +88,6 @@ public: static Atom getXEmbedInfoAtom(); private: - /// Called when an update for a screen is needed. - void updateForScreen(BScreen &screen) { - update(); - } void update(); typedef std::list ClientList; @@ -116,7 +111,6 @@ private: // gaim/pidgin seems to barf if the selection is not an independent window. // I suspect it's an interacton with parent relationship and gdk window caching. FbTk::FbWindow m_selection_owner; - std::auto_ptr m_observer; }; #endif // SYSTEMTRAY_HH diff --git a/src/ToolTheme.hh b/src/ToolTheme.hh index 693aac6..8daad7d 100644 --- a/src/ToolTheme.hh +++ b/src/ToolTheme.hh @@ -23,7 +23,6 @@ #ifndef TOOLTHEME_HH #define TOOLTHEME_HH - #include "FbTk/TextTheme.hh" #include "FbTk/BorderTheme.hh" #include "FbTk/Texture.hh" @@ -44,8 +43,7 @@ public: int alpha() const { return m_alpha; } void setAlpha(int alpha) { m_alpha = alpha; } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual ToolTheme &operator *() { return *this; } virtual const ToolTheme &operator *() const { return *this; } diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 471f5ec..1778a02 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -231,8 +231,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::Layer &layer, size_t width): m_observers.push_back(makeObserver(*this, &Toolbar::rearrangeItems)); // we need to get notified when the theme is reloaded m_observers.push_back(makeObserver(*this, &Toolbar::reconfigure)); - m_theme.reconfigSig().attach(m_observers.back()); screen().reconfigureSig().attach(m_observers.back()); // get this on antialias change + m_signal_tracker.join(m_theme.reconfigSig(), FbTk::MemFun(*this, &Toolbar::reconfigure)); // listen to screen size changes m_signal_tracker.join(screen().resizeSig(), diff --git a/src/ToolbarTheme.hh b/src/ToolbarTheme.hh index 077198f..dbb6786 100644 --- a/src/ToolbarTheme.hh +++ b/src/ToolbarTheme.hh @@ -44,8 +44,7 @@ public: int height() const { return *m_height; } int buttonSize() const { return *m_button_size; } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual ToolbarTheme &operator *() { return *this; } virtual const ToolbarTheme &operator *() const { return *this; } diff --git a/src/WinButton.cc b/src/WinButton.cc index 9ecbb9c..22fe29c 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc @@ -44,7 +44,8 @@ WinButton::WinButton(FluxboxWindow &listen_to, m_theme(theme), m_pressed_theme(pressed), m_icon_pixmap(0), m_icon_mask(0), overrode_bg(false), overrode_pressed(false) { - theme.reconfigSig().attach(this); + + join(theme.reconfigSig(), FbTk::MemFun(*this, &WinButton::updateAll)); if (buttontype == MENUICON) update(0); diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh index 5436237..f7f2337 100644 --- a/src/WinButtonTheme.hh +++ b/src/WinButtonTheme.hh @@ -65,8 +65,7 @@ public: FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; } const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual WinButtonTheme &operator *() { return *this; } virtual const WinButtonTheme &operator *() const { return *this; } diff --git a/src/Window.cc b/src/Window.cc index 369b480..756c358 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -291,7 +291,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client): m_parent(client.screen().rootWindow()), m_resize_corner(RIGHTBOTTOM) { - m_theme.reconfigSig().attach(this); + join(m_theme.reconfigSig(), FbTk::MemFun(*this, &FluxboxWindow::themeReconfigured)); m_frame.frameExtentSig().attach(this); init(); @@ -2682,15 +2682,17 @@ void FluxboxWindow::setTitle(const std::string& title, Focusable &client) { } void FluxboxWindow::update(FbTk::Subject *subj) { - if (subj == &m_theme.reconfigSig()) { - frame().applyDecorations(); - sendConfigureNotify(); - } else if (m_initialized && subj == &m_frame.frameExtentSig()) { + if (m_initialized && subj == &m_frame.frameExtentSig()) { Fluxbox::instance()->updateFrameExtents(*this); sendConfigureNotify(); } } +void FluxboxWindow::themeReconfigured() { + frame().applyDecorations(); + sendConfigureNotify(); +} + void FluxboxWindow::workspaceAreaChanged(BScreen &screen) { frame().applyState(); } diff --git a/src/Window.hh b/src/Window.hh index 8f599a4..cbbb817 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -492,6 +492,8 @@ private: void updateClientLeftWindow(); void grabButtons(); + void themeReconfigured(); + /** * Calculates insertition position in the list by * using pixel position x and y. diff --git a/src/WorkspaceNameTheme.hh b/src/WorkspaceNameTheme.hh index e90ef01..0096682 100644 --- a/src/WorkspaceNameTheme.hh +++ b/src/WorkspaceNameTheme.hh @@ -49,8 +49,7 @@ public: return ToolTheme::fallback(item); } - virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } - virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + virtual FbTk::Signal &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual WorkspaceNameTheme &operator *() { return *this; } virtual const WorkspaceNameTheme &operator *() const { return *this; } diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index 3a4b275..6451a0a 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc @@ -44,11 +44,11 @@ WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, // setup signals join(screen.currentWorkspaceSig(), - FbTk::MemFun(*this, &WorkspaceNameTool::updateForScreen)); + FbTk::MemFunIgnoreArgs(*this, &WorkspaceNameTool::update)); join(screen.workspaceNamesSig(), - FbTk::MemFun(*this, &WorkspaceNameTool::updateForScreen)); + FbTk::MemFunIgnoreArgs(*this, &WorkspaceNameTool::update)); - theme.reconfigSig().attach(this); + join(theme.reconfigSig(), FbTk::MemFun(*this, &WorkspaceNameTool::update)); } WorkspaceNameTool::~WorkspaceNameTool() { @@ -70,12 +70,8 @@ void WorkspaceNameTool::moveResize(int x, int y, m_button.moveResize(x, y, width, height); } -void WorkspaceNameTool::update(FbTk::Subject *subj) { - updateForScreen(m_screen); -} - -void WorkspaceNameTool::updateForScreen(BScreen &screen) { - m_button.setText(screen.currentWorkspace()->name()); +void WorkspaceNameTool::update() { + m_button.setText(m_screen.currentWorkspace()->name()); if (m_button.width() != width()) { resize(width(), height()); resizeSig().notify(); diff --git a/src/WorkspaceNameTool.hh b/src/WorkspaceNameTool.hh index de95663..195dc1f 100644 --- a/src/WorkspaceNameTool.hh +++ b/src/WorkspaceNameTool.hh @@ -26,7 +26,6 @@ #include "ToolbarItem.hh" #include "FbTk/TextButton.hh" -#include "FbTk/Observer.hh" #include "FbTk/Signal.hh" class BScreen; @@ -36,8 +35,7 @@ namespace FbTk { template class ThemeProxy; } -class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer, - private FbTk::SignalTracker { +class WorkspaceNameTool: public ToolbarItem, private FbTk::SignalTracker { public: WorkspaceNameTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy &theme, BScreen &screen); virtual ~WorkspaceNameTool(); @@ -53,7 +51,6 @@ public: unsigned int height() const; unsigned int borderWidth() const; - void update(FbTk::Subject *subj); FbTk::Button &button() { return m_button; } const FbTk::Button &button() const { return m_button; } void setOrientation(FbTk::Orientation orient); @@ -61,8 +58,7 @@ public: void parentMoved() { m_button.parentMoved(); } private: - /// Called when workspace changed on \c screen - void updateForScreen(BScreen &screen); + void update(); void renderTheme(int alpha); void reRender(); -- cgit v0.11.2