From 86819abab91cf3ea20540278d00bad6a6b86d4b0 Mon Sep 17 00:00:00 2001 From: Henrik Kinnunen Date: Sun, 21 Sep 2008 13:44:48 +0200 Subject: Changed current workspace signal in BScreen to use the new signal system --- ChangeLog | 5 +++++ src/FocusableList.cc | 14 ++++++++++---- src/FocusableList.hh | 5 ++++- src/Screen.cc | 3 +-- src/Screen.hh | 4 ++-- src/SendToMenu.cc | 7 +++++-- src/SendToMenu.hh | 2 +- src/WorkspaceMenu.cc | 35 +++++++++++++++++++---------------- src/WorkspaceMenu.hh | 4 +++- src/WorkspaceNameTool.cc | 11 +++++++++-- src/WorkspaceNameTool.hh | 7 ++++++- src/fluxbox.cc | 22 +++++++++++++--------- src/fluxbox.hh | 2 ++ 13 files changed, 80 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index a888269..0bd3700 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ (Format: Year/Month/Day) Changes for 1.1.2 +*08/09/21: + * Changed current workspace signal in Bscreen to use the new signal + system (Henrik) + FocusableList.hh/cc, Screen.hh/cc, SendToMenu.hh/cc, + WorkspaceMenu.hh/cc, WorkspaceNameTool.hh/cc, fluxbox.hh/cc *08/09/18: * Changed workspace count signal in BScreen to use the new signal system. (Henrik) diff --git a/src/FocusableList.cc b/src/FocusableList.cc index 094a9b5..b06faac 100644 --- a/src/FocusableList.cc +++ b/src/FocusableList.cc @@ -28,6 +28,7 @@ #include "Window.hh" #include "FbTk/StringUtil.hh" +#include "FbTk/MemFun.hh" #include @@ -95,8 +96,10 @@ void FocusableList::init() { m_parent->attachChild(*this); // TODO: can't handle (head=[mouse]) yet - if (m_pat->dependsOnCurrentWorkspace()) - m_screen.currentWorkspaceSig().attach(this); + if (m_pat->dependsOnCurrentWorkspace()) { + join(m_screen.currentWorkspaceSig(), + FbTk::MemFun(*this, &FocusableList::workspaceChanged)); + } if (m_pat->dependsOnFocusedWindow()) m_screen.focusedWindowSig().attach(this); } @@ -147,8 +150,7 @@ void FocusableList::update(FbTk::Subject *subj) { if (insertFromParent(*win)) m_ordersig.notify(win); } - } else if (subj == &m_screen.currentWorkspaceSig() || - subj == &m_screen.focusedWindowSig()) + } else if (subj == &m_screen.focusedWindowSig()) reset(); } @@ -309,3 +311,7 @@ void FocusableList::attachChild(FocusableList &child) const { m_resetsig.attach(&child); m_ordersig.attach(&child); } + +void FocusableList::workspaceChanged(BScreen &screen) { + reset(); +} diff --git a/src/FocusableList.hh b/src/FocusableList.hh index a72e2f0..1dd8437 100644 --- a/src/FocusableList.hh +++ b/src/FocusableList.hh @@ -25,6 +25,7 @@ #include "FbTk/NotCopyable.hh" #include "FbTk/Observer.hh" #include "FbTk/Subject.hh" +#include "FbTk/Signal.hh" #include "ClientPattern.hh" @@ -35,7 +36,8 @@ class BScreen; class Focusable; -class FocusableList: public FbTk::Observer, private FbTk::NotCopyable { +class FocusableList: public FbTk::Observer, private FbTk::NotCopyable, + private FbTk::SignalTracker { public: typedef std::list Focusables; @@ -110,6 +112,7 @@ private: void detachSignals(Focusable &win); void reset(); void attachChild(FocusableList &child) const; + void workspaceChanged(BScreen& screen); std::auto_ptr m_pat; const FocusableList *m_parent; diff --git a/src/Screen.cc b/src/Screen.cc index 83bc92e..06f3146 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -343,7 +343,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm, m_iconlist_sig(*this), // icon list signal m_workspacenames_sig(*this), // workspace names signal m_workspace_area_sig(*this), // workspace area signal - m_currentworkspace_sig(*this), // current workspace signal m_focusedwindow_sig(*this), // focused window signal m_reconfigure_sig(*this), // reconfigure signal m_resize_sig(*this), @@ -1199,7 +1198,7 @@ void BScreen::changeWorkspaceID(unsigned int id, bool revert) { FbTk::App::instance()->sync(false); - m_currentworkspace_sig.notify(); + m_currentworkspace_sig.emit(*this); // do this after atom handlers, so scripts can access new workspace number Fluxbox::instance()->keys()->doAction(FocusIn, 0, 0, Keys::ON_DESKTOP); diff --git a/src/Screen.hh b/src/Screen.hh index 3f57c22..bbfe70b 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -220,7 +220,7 @@ public: /// workspace area signal FbTk::Subject &workspaceAreaSig() { return m_workspace_area_sig; } /// current workspace signal - FbTk::Subject ¤tWorkspaceSig() { return m_currentworkspace_sig; } + FbTk::Signal ¤tWorkspaceSig() { return m_currentworkspace_sig; } /// focused window signal FbTk::Subject &focusedWindowSig() { return m_focusedwindow_sig; } /// reconfigure signal @@ -496,13 +496,13 @@ private: m_iconlist_sig, ///< notify if a window gets iconified/deiconified m_workspacenames_sig, ///< workspace names signal m_workspace_area_sig, ///< workspace area changed signal - m_currentworkspace_sig, ///< current workspace signal m_focusedwindow_sig, ///< focused window signal m_reconfigure_sig, ///< reconfigure signal m_resize_sig, ///< resize signal m_bg_change_sig; ///< background change signal FbTk::Signal m_workspacecount_sig; ///< workspace count signal + FbTk::Signal m_currentworkspace_sig; ///< current workspace signal FbTk::MultLayers m_layermanager; bool root_colormap_installed, managed; diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc index 397ec81..ac7612b 100644 --- a/src/SendToMenu.cc +++ b/src/SendToMenu.cc @@ -58,11 +58,14 @@ SendToMenu::SendToMenu(BScreen &screen): m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu); screen.workspaceNamesSig().attach(m_rebuildObs); - screen.currentWorkspaceSig().attach(m_rebuildObs); + + // setup new signal system + join( screen.currentWorkspaceSig(), + FbTk::MemFun(*this, &SendToMenu::rebuildMenuForScreen)); // setup new signal system join( screen.workspaceCountSig(), - FbTk::MemFun(*this, &SendToMenu::workspaceCountChange) ); + FbTk::MemFun(*this, &SendToMenu::rebuildMenuForScreen)); // no title for this menu, it should be a submenu in the window menu. disableTitle(); diff --git a/src/SendToMenu.hh b/src/SendToMenu.hh index 1582dd5..a217b5f 100644 --- a/src/SendToMenu.hh +++ b/src/SendToMenu.hh @@ -46,7 +46,7 @@ public: void show(); private: /// workspace count changed on screen - void workspaceCountChange( BScreen& screen ) { + void rebuildMenuForScreen( BScreen& screen ) { rebuildMenu(); } diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc index 33cfb7f..dd7b96e 100644 --- a/src/WorkspaceMenu.cc +++ b/src/WorkspaceMenu.cc @@ -83,24 +83,26 @@ void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) { updateMenu(-1); } +void WorkspaceMenu::workspaceChanged(BScreen& screen) { + FbTk::MenuItem *item = 0; + for (unsigned int i = 0; i < screen.numberOfWorkspaces(); ++i) { + item = find(i + IDX_AFTER_ICONS); + if (item && item->isSelected()) { + setItemSelected(i + IDX_AFTER_ICONS, false); + updateMenu(i + IDX_AFTER_ICONS); + break; + } + } + setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); + updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); +} + void WorkspaceMenu::update(FbTk::Subject *subj) { if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) { BScreen::ScreenSubject &screen_subj = *static_cast(subj); BScreen &screen = screen_subj.screen(); - if (subj == &screen.currentWorkspaceSig()) { - FbTk::MenuItem *item = 0; - for (unsigned int i = 0; i < screen.numberOfWorkspaces(); ++i) { - item = find(i + IDX_AFTER_ICONS); - if (item && item->isSelected()) { - setItemSelected(i + IDX_AFTER_ICONS, false); - updateMenu(i + IDX_AFTER_ICONS); - break; - } - } - setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); - updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); - } else if ( subj == &screen.workspaceNamesSig() ) { + if ( subj == &screen.workspaceNamesSig() ) { workspaceInfoChanged( screen ); } } else { @@ -109,12 +111,13 @@ void WorkspaceMenu::update(FbTk::Subject *subj) { } void WorkspaceMenu::init(BScreen &screen) { - screen.currentWorkspaceSig().attach(this); screen.workspaceNamesSig().attach(this); - join( screen.workspaceCountSig(), - FbTk::MemFun( *this, &WorkspaceMenu::workspaceInfoChanged ) ); + join(screen.currentWorkspaceSig(), + FbTk::MemFun(*this, &WorkspaceMenu::workspaceChanged)); + join(screen.workspaceCountSig(), + FbTk::MemFun(*this, &WorkspaceMenu::workspaceInfoChanged)); using namespace FbTk; _FB_USES_NLS; diff --git a/src/WorkspaceMenu.hh b/src/WorkspaceMenu.hh index e8a671d..19cf0f8 100644 --- a/src/WorkspaceMenu.hh +++ b/src/WorkspaceMenu.hh @@ -45,7 +45,9 @@ private: void init(BScreen &screen); /// Called when workspace info was changed /// ( number of workspace, workspace names etc ) - void workspaceInfoChanged( BScreen& screen ); + void workspaceInfoChanged(BScreen& screen); + /// Called when workspace was switched. + void workspaceChanged(BScreen& screen); }; #endif // WORKSPACEMENU_HH diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index 6c73df5..b6afad8 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc @@ -27,6 +27,7 @@ #include "Workspace.hh" #include "FbTk/ImageControl.hh" +#include "FbTk/MemFun.hh" #include @@ -43,7 +44,10 @@ WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, // setup signals screen.workspaceNamesSig().attach(this); - screen.currentWorkspaceSig().attach(this); + + join(screen.currentWorkspaceSig(), + FbTk::MemFun(*this, &WorkspaceNameTool::updateForScreen)); + theme.reconfigSig().attach(this); } @@ -67,8 +71,11 @@ void WorkspaceNameTool::moveResize(int x, int y, } void WorkspaceNameTool::update(FbTk::Subject *subj) { + updateForScreen(m_screen); +} - m_button.setText(m_screen.currentWorkspace()->name()); +void WorkspaceNameTool::updateForScreen(BScreen &screen) { + m_button.setText(screen.currentWorkspace()->name()); if (m_button.width() != width()) { resize(width(), height()); resizeSig().notify(); diff --git a/src/WorkspaceNameTool.hh b/src/WorkspaceNameTool.hh index 0bdb528..bd034b7 100644 --- a/src/WorkspaceNameTool.hh +++ b/src/WorkspaceNameTool.hh @@ -27,6 +27,7 @@ #include "FbTk/TextButton.hh" #include "FbTk/Observer.hh" +#include "FbTk/Signal.hh" class BScreen; class ToolTheme; @@ -35,7 +36,8 @@ namespace FbTk { template class ThemeProxy; } -class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer { +class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer, + private FbTk::SignalTracker { public: WorkspaceNameTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy &theme, BScreen &screen); virtual ~WorkspaceNameTool(); @@ -59,6 +61,9 @@ public: void parentMoved() { m_button.parentMoved(); } private: + /// Called when workspace changed on \c screen + void updateForScreen(BScreen &screen); + void renderTheme(unsigned char alpha); void reRender(); void updateSizing(); diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 9e62ac3..acbb55d 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -453,14 +453,16 @@ void Fluxbox::initScreen(BScreen *screen) { screen->initWindows(); // attach screen signals to this - screen->currentWorkspaceSig().attach(this); screen->focusedWindowSig().attach(this); screen->workspaceNamesSig().attach(this); screen->workspaceAreaSig().attach(this); screen->clientListSig().attach(this); - join( screen->workspaceCountSig(), - FbTk::MemFun( *this, &Fluxbox::workspaceCountChanged ) ); + join(screen->currentWorkspaceSig(), + FbTk::MemFun(*this, &Fluxbox::workspaceChanged)); + + join(screen->workspaceCountSig(), + FbTk::MemFun(*this, &Fluxbox::workspaceCountChanged)); // initiate atomhandler for screen specific stuff for (AtomHandlerContainerIt it= m_atomhandler.begin(); @@ -1106,12 +1108,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) { if ((*it).first->update()) (*it).first->updateWorkspaceNames(screen); } - } else if ((&(screen.currentWorkspaceSig())) == changedsub) { - for (AtomHandlerContainerIt it= m_atomhandler.begin(); - it != m_atomhandler.end(); ++it) { - if ((*it).first->update()) - (*it).first->updateCurrentWorkspace(screen); - } } else if ((&(screen.focusedWindowSig())) == changedsub) { for (AtomHandlerContainerIt it= m_atomhandler.begin(); it != m_atomhandler.end(); it++) { @@ -1526,3 +1522,11 @@ void Fluxbox::workspaceCountChanged( BScreen& screen ) { (*it).first->updateWorkspaceCount(screen); } } + +void Fluxbox::workspaceChanged( BScreen& screen ) { + for (AtomHandlerContainerIt it= m_atomhandler.begin(); + it != m_atomhandler.end(); ++it) { + if ((*it).first->update()) + (*it).first->updateCurrentWorkspace(screen); + } +} diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 8478833..36208b6 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -203,6 +203,8 @@ private: /// Called when workspace count on a specific screen changed. void workspaceCountChanged( BScreen& screen ); + /// Called when workspace was switched + void workspaceChanged(BScreen& screen); std::auto_ptr m_fbatoms; -- cgit v0.11.2