Changed current workspace signal in BScreen to use the new signal system

This commit is contained in:
Henrik Kinnunen 2008-09-21 13:44:48 +02:00
parent f5113e2ec1
commit 86819abab9
13 changed files with 80 additions and 41 deletions

View file

@ -1,5 +1,10 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 1.1.2 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: *08/09/18:
* Changed workspace count signal in BScreen to use the new signal * Changed workspace count signal in BScreen to use the new signal
system. (Henrik) system. (Henrik)

View file

@ -28,6 +28,7 @@
#include "Window.hh" #include "Window.hh"
#include "FbTk/StringUtil.hh" #include "FbTk/StringUtil.hh"
#include "FbTk/MemFun.hh"
#include <vector> #include <vector>
@ -95,8 +96,10 @@ void FocusableList::init() {
m_parent->attachChild(*this); m_parent->attachChild(*this);
// TODO: can't handle (head=[mouse]) yet // TODO: can't handle (head=[mouse]) yet
if (m_pat->dependsOnCurrentWorkspace()) if (m_pat->dependsOnCurrentWorkspace()) {
m_screen.currentWorkspaceSig().attach(this); join(m_screen.currentWorkspaceSig(),
FbTk::MemFun(*this, &FocusableList::workspaceChanged));
}
if (m_pat->dependsOnFocusedWindow()) if (m_pat->dependsOnFocusedWindow())
m_screen.focusedWindowSig().attach(this); m_screen.focusedWindowSig().attach(this);
} }
@ -147,8 +150,7 @@ void FocusableList::update(FbTk::Subject *subj) {
if (insertFromParent(*win)) if (insertFromParent(*win))
m_ordersig.notify(win); m_ordersig.notify(win);
} }
} else if (subj == &m_screen.currentWorkspaceSig() || } else if (subj == &m_screen.focusedWindowSig())
subj == &m_screen.focusedWindowSig())
reset(); reset();
} }
@ -309,3 +311,7 @@ void FocusableList::attachChild(FocusableList &child) const {
m_resetsig.attach(&child); m_resetsig.attach(&child);
m_ordersig.attach(&child); m_ordersig.attach(&child);
} }
void FocusableList::workspaceChanged(BScreen &screen) {
reset();
}

View file

@ -25,6 +25,7 @@
#include "FbTk/NotCopyable.hh" #include "FbTk/NotCopyable.hh"
#include "FbTk/Observer.hh" #include "FbTk/Observer.hh"
#include "FbTk/Subject.hh" #include "FbTk/Subject.hh"
#include "FbTk/Signal.hh"
#include "ClientPattern.hh" #include "ClientPattern.hh"
@ -35,7 +36,8 @@
class BScreen; class BScreen;
class Focusable; class Focusable;
class FocusableList: public FbTk::Observer, private FbTk::NotCopyable { class FocusableList: public FbTk::Observer, private FbTk::NotCopyable,
private FbTk::SignalTracker {
public: public:
typedef std::list<Focusable *> Focusables; typedef std::list<Focusable *> Focusables;
@ -110,6 +112,7 @@ private:
void detachSignals(Focusable &win); void detachSignals(Focusable &win);
void reset(); void reset();
void attachChild(FocusableList &child) const; void attachChild(FocusableList &child) const;
void workspaceChanged(BScreen& screen);
std::auto_ptr<ClientPattern> m_pat; std::auto_ptr<ClientPattern> m_pat;
const FocusableList *m_parent; const FocusableList *m_parent;

View file

@ -343,7 +343,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
m_iconlist_sig(*this), // icon list signal m_iconlist_sig(*this), // icon list signal
m_workspacenames_sig(*this), // workspace names signal m_workspacenames_sig(*this), // workspace names signal
m_workspace_area_sig(*this), // workspace area signal m_workspace_area_sig(*this), // workspace area signal
m_currentworkspace_sig(*this), // current workspace signal
m_focusedwindow_sig(*this), // focused window signal m_focusedwindow_sig(*this), // focused window signal
m_reconfigure_sig(*this), // reconfigure signal m_reconfigure_sig(*this), // reconfigure signal
m_resize_sig(*this), m_resize_sig(*this),
@ -1199,7 +1198,7 @@ void BScreen::changeWorkspaceID(unsigned int id, bool revert) {
FbTk::App::instance()->sync(false); 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 // do this after atom handlers, so scripts can access new workspace number
Fluxbox::instance()->keys()->doAction(FocusIn, 0, 0, Keys::ON_DESKTOP); Fluxbox::instance()->keys()->doAction(FocusIn, 0, 0, Keys::ON_DESKTOP);

View file

@ -220,7 +220,7 @@ public:
/// workspace area signal /// workspace area signal
FbTk::Subject &workspaceAreaSig() { return m_workspace_area_sig; } FbTk::Subject &workspaceAreaSig() { return m_workspace_area_sig; }
/// current workspace signal /// current workspace signal
FbTk::Subject &currentWorkspaceSig() { return m_currentworkspace_sig; } FbTk::Signal<void, BScreen&> &currentWorkspaceSig() { return m_currentworkspace_sig; }
/// focused window signal /// focused window signal
FbTk::Subject &focusedWindowSig() { return m_focusedwindow_sig; } FbTk::Subject &focusedWindowSig() { return m_focusedwindow_sig; }
/// reconfigure signal /// reconfigure signal
@ -496,13 +496,13 @@ private:
m_iconlist_sig, ///< notify if a window gets iconified/deiconified m_iconlist_sig, ///< notify if a window gets iconified/deiconified
m_workspacenames_sig, ///< workspace names signal m_workspacenames_sig, ///< workspace names signal
m_workspace_area_sig, ///< workspace area changed signal m_workspace_area_sig, ///< workspace area changed signal
m_currentworkspace_sig, ///< current workspace signal
m_focusedwindow_sig, ///< focused window signal m_focusedwindow_sig, ///< focused window signal
m_reconfigure_sig, ///< reconfigure signal m_reconfigure_sig, ///< reconfigure signal
m_resize_sig, ///< resize signal m_resize_sig, ///< resize signal
m_bg_change_sig; ///< background change signal m_bg_change_sig; ///< background change signal
FbTk::Signal<void, BScreen&> m_workspacecount_sig; ///< workspace count signal FbTk::Signal<void, BScreen&> m_workspacecount_sig; ///< workspace count signal
FbTk::Signal<void, BScreen&> m_currentworkspace_sig; ///< current workspace signal
FbTk::MultLayers m_layermanager; FbTk::MultLayers m_layermanager;
bool root_colormap_installed, managed; bool root_colormap_installed, managed;

View file

@ -58,11 +58,14 @@ SendToMenu::SendToMenu(BScreen &screen):
m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu); m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu);
screen.workspaceNamesSig().attach(m_rebuildObs); 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 // setup new signal system
join( screen.workspaceCountSig(), 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. // no title for this menu, it should be a submenu in the window menu.
disableTitle(); disableTitle();

View file

@ -46,7 +46,7 @@ public:
void show(); void show();
private: private:
/// workspace count changed on screen /// workspace count changed on screen
void workspaceCountChange( BScreen& screen ) { void rebuildMenuForScreen( BScreen& screen ) {
rebuildMenu(); rebuildMenu();
} }

View file

@ -83,24 +83,26 @@ void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) {
updateMenu(-1); 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) { void WorkspaceMenu::update(FbTk::Subject *subj) {
if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) { if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) {
BScreen::ScreenSubject &screen_subj = *static_cast<BScreen::ScreenSubject *>(subj); BScreen::ScreenSubject &screen_subj = *static_cast<BScreen::ScreenSubject *>(subj);
BScreen &screen = screen_subj.screen(); BScreen &screen = screen_subj.screen();
if (subj == &screen.currentWorkspaceSig()) { if ( subj == &screen.workspaceNamesSig() ) {
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() ) {
workspaceInfoChanged( screen ); workspaceInfoChanged( screen );
} }
} else { } else {
@ -109,12 +111,13 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
} }
void WorkspaceMenu::init(BScreen &screen) { void WorkspaceMenu::init(BScreen &screen) {
screen.currentWorkspaceSig().attach(this);
screen.workspaceNamesSig().attach(this); screen.workspaceNamesSig().attach(this);
join( screen.workspaceCountSig(), join(screen.currentWorkspaceSig(),
FbTk::MemFun( *this, &WorkspaceMenu::workspaceInfoChanged ) ); FbTk::MemFun(*this, &WorkspaceMenu::workspaceChanged));
join(screen.workspaceCountSig(),
FbTk::MemFun(*this, &WorkspaceMenu::workspaceInfoChanged));
using namespace FbTk; using namespace FbTk;
_FB_USES_NLS; _FB_USES_NLS;

View file

@ -45,7 +45,9 @@ private:
void init(BScreen &screen); void init(BScreen &screen);
/// Called when workspace info was changed /// Called when workspace info was changed
/// ( number of workspace, workspace names etc ) /// ( 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 #endif // WORKSPACEMENU_HH

View file

@ -27,6 +27,7 @@
#include "Workspace.hh" #include "Workspace.hh"
#include "FbTk/ImageControl.hh" #include "FbTk/ImageControl.hh"
#include "FbTk/MemFun.hh"
#include <algorithm> #include <algorithm>
@ -43,7 +44,10 @@ WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent,
// setup signals // setup signals
screen.workspaceNamesSig().attach(this); screen.workspaceNamesSig().attach(this);
screen.currentWorkspaceSig().attach(this);
join(screen.currentWorkspaceSig(),
FbTk::MemFun(*this, &WorkspaceNameTool::updateForScreen));
theme.reconfigSig().attach(this); theme.reconfigSig().attach(this);
} }
@ -67,8 +71,11 @@ void WorkspaceNameTool::moveResize(int x, int y,
} }
void WorkspaceNameTool::update(FbTk::Subject *subj) { 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()) { if (m_button.width() != width()) {
resize(width(), height()); resize(width(), height());
resizeSig().notify(); resizeSig().notify();

View file

@ -27,6 +27,7 @@
#include "FbTk/TextButton.hh" #include "FbTk/TextButton.hh"
#include "FbTk/Observer.hh" #include "FbTk/Observer.hh"
#include "FbTk/Signal.hh"
class BScreen; class BScreen;
class ToolTheme; class ToolTheme;
@ -35,7 +36,8 @@ namespace FbTk {
template <class T> class ThemeProxy; template <class T> class ThemeProxy;
} }
class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer { class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer,
private FbTk::SignalTracker {
public: public:
WorkspaceNameTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy<ToolTheme> &theme, BScreen &screen); WorkspaceNameTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy<ToolTheme> &theme, BScreen &screen);
virtual ~WorkspaceNameTool(); virtual ~WorkspaceNameTool();
@ -59,6 +61,9 @@ public:
void parentMoved() { m_button.parentMoved(); } void parentMoved() { m_button.parentMoved(); }
private: private:
/// Called when workspace changed on \c screen
void updateForScreen(BScreen &screen);
void renderTheme(unsigned char alpha); void renderTheme(unsigned char alpha);
void reRender(); void reRender();
void updateSizing(); void updateSizing();

View file

@ -453,14 +453,16 @@ void Fluxbox::initScreen(BScreen *screen) {
screen->initWindows(); screen->initWindows();
// attach screen signals to this // attach screen signals to this
screen->currentWorkspaceSig().attach(this);
screen->focusedWindowSig().attach(this); screen->focusedWindowSig().attach(this);
screen->workspaceNamesSig().attach(this); screen->workspaceNamesSig().attach(this);
screen->workspaceAreaSig().attach(this); screen->workspaceAreaSig().attach(this);
screen->clientListSig().attach(this); screen->clientListSig().attach(this);
join( screen->workspaceCountSig(), join(screen->currentWorkspaceSig(),
FbTk::MemFun( *this, &Fluxbox::workspaceCountChanged ) ); FbTk::MemFun(*this, &Fluxbox::workspaceChanged));
join(screen->workspaceCountSig(),
FbTk::MemFun(*this, &Fluxbox::workspaceCountChanged));
// initiate atomhandler for screen specific stuff // initiate atomhandler for screen specific stuff
for (AtomHandlerContainerIt it= m_atomhandler.begin(); for (AtomHandlerContainerIt it= m_atomhandler.begin();
@ -1106,12 +1108,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
if ((*it).first->update()) if ((*it).first->update())
(*it).first->updateWorkspaceNames(screen); (*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) { } else if ((&(screen.focusedWindowSig())) == changedsub) {
for (AtomHandlerContainerIt it= m_atomhandler.begin(); for (AtomHandlerContainerIt it= m_atomhandler.begin();
it != m_atomhandler.end(); it++) { it != m_atomhandler.end(); it++) {
@ -1526,3 +1522,11 @@ void Fluxbox::workspaceCountChanged( BScreen& screen ) {
(*it).first->updateWorkspaceCount(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);
}
}

View file

@ -203,6 +203,8 @@ private:
/// Called when workspace count on a specific screen changed. /// Called when workspace count on a specific screen changed.
void workspaceCountChanged( BScreen& screen ); void workspaceCountChanged( BScreen& screen );
/// Called when workspace was switched
void workspaceChanged(BScreen& screen);
std::auto_ptr<FbAtoms> m_fbatoms; std::auto_ptr<FbAtoms> m_fbatoms;