all repos — fluxbox @ 86819abab91cf3ea20540278d00bad6a6b86d4b0

custom fork of the fluxbox windowmanager

Changed current workspace signal in BScreen to use the new signal system
Henrik Kinnunen fluxgen@fluxbox.org
commit

86819abab91cf3ea20540278d00bad6a6b86d4b0

parent

f5113e2ec1743d76ac414a020f617917c7933bb7

M ChangeLogChangeLog

@@ -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)
M src/FocusableList.ccsrc/FocusableList.cc

@@ -28,6 +28,7 @@ #include "WinClient.hh"

#include "Window.hh" #include "FbTk/StringUtil.hh" +#include "FbTk/MemFun.hh" #include <vector>

@@ -95,8 +96,10 @@ addMatching();

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 @@ return;

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 @@ m_removesig.attach(&child);

m_resetsig.attach(&child); m_ordersig.attach(&child); } + +void FocusableList::workspaceChanged(BScreen &screen) { + reset(); +}
M src/FocusableList.hhsrc/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<Focusable *> Focusables;

@@ -110,6 +112,7 @@ void attachSignals(Focusable &win);

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;
M src/Screen.ccsrc/Screen.cc

@@ -343,7 +343,6 @@ m_clientlist_sig(*this), // client signal

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 @@ old->hideAll(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 Fluxbox::instance()->keys()->doAction(FocusIn, 0, 0, Keys::ON_DESKTOP);
M src/Screen.hhsrc/Screen.hh

@@ -220,7 +220,7 @@ FbTk::Subject &workspaceNamesSig() { return m_workspacenames_sig; }

/// workspace area signal FbTk::Subject &workspaceAreaSig() { return m_workspace_area_sig; } /// current workspace signal - FbTk::Subject &currentWorkspaceSig() { return m_currentworkspace_sig; } + FbTk::Signal<void, BScreen&> &currentWorkspaceSig() { return m_currentworkspace_sig; } /// focused window signal FbTk::Subject &focusedWindowSig() { return m_focusedwindow_sig; } /// reconfigure signal

@@ -496,13 +496,13 @@ m_clientlist_sig, ///< client signal

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;
M src/SendToMenu.ccsrc/SendToMenu.cc

@@ -58,11 +58,14 @@ // current workspace signal

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();
M src/SendToMenu.hhsrc/SendToMenu.hh

@@ -46,7 +46,7 @@ /// @see FbTk::Menu

void show(); private: /// workspace count changed on screen - void workspaceCountChange( BScreen& screen ) { + void rebuildMenuForScreen( BScreen& screen ) { rebuildMenu(); }
M src/WorkspaceMenu.ccsrc/WorkspaceMenu.cc

@@ -83,24 +83,26 @@

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::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;
M src/WorkspaceMenu.hhsrc/WorkspaceMenu.hh

@@ -45,7 +45,9 @@ /// initialize menu for the screen

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
M src/WorkspaceNameTool.ccsrc/WorkspaceNameTool.cc

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

#include "Workspace.hh" #include "FbTk/ImageControl.hh" +#include "FbTk/MemFun.hh" #include <algorithm>

@@ -43,7 +44,10 @@ m_button.setText(m_screen.currentWorkspace()->name());

// 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 @@ m_button.moveResize(x, y, width, height);

} 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();
M src/WorkspaceNameTool.hhsrc/WorkspaceNameTool.hh

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

#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 @@

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();
M src/fluxbox.ccsrc/fluxbox.cc

@@ -453,14 +453,16 @@

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 @@ it != m_atomhandler.end(); ++it) {

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 @@ if ((*it).first->update())

(*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); + } +}
M src/fluxbox.hhsrc/fluxbox.hh

@@ -203,6 +203,8 @@ void handleClientMessage(XClientMessageEvent &ce);

/// 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;