Changed current workspace signal in BScreen to use the new signal system
This commit is contained in:
parent
f5113e2ec1
commit
86819abab9
13 changed files with 80 additions and 41 deletions
|
@ -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)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "Window.hh"
|
||||
|
||||
#include "FbTk/StringUtil.hh"
|
||||
#include "FbTk/MemFun.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<Focusable *> Focusables;
|
||||
|
||||
|
@ -110,6 +112,7 @@ private:
|
|||
void detachSignals(Focusable &win);
|
||||
void reset();
|
||||
void attachChild(FocusableList &child) const;
|
||||
void workspaceChanged(BScreen& screen);
|
||||
|
||||
std::auto_ptr<ClientPattern> m_pat;
|
||||
const FocusableList *m_parent;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<void, BScreen&> ¤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<void, BScreen&> m_workspacecount_sig; ///< workspace count signal
|
||||
FbTk::Signal<void, BScreen&> m_currentworkspace_sig; ///< current workspace signal
|
||||
FbTk::MultLayers m_layermanager;
|
||||
|
||||
bool root_colormap_installed, managed;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
void show();
|
||||
private:
|
||||
/// workspace count changed on screen
|
||||
void workspaceCountChange( BScreen& screen ) {
|
||||
void rebuildMenuForScreen( BScreen& screen ) {
|
||||
rebuildMenu();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<BScreen::ScreenSubject *>(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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Workspace.hh"
|
||||
|
||||
#include "FbTk/ImageControl.hh"
|
||||
#include "FbTk/MemFun.hh"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -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();
|
||||
|
|
|
@ -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 T> 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<ToolTheme> &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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<FbAtoms> m_fbatoms;
|
||||
|
||||
|
|
Loading…
Reference in a new issue