all repos — fluxbox @ 2f4db57898920a3f17eaaa2586a39dad76d5c7e8

custom fork of the fluxbox windowmanager

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

2f4db57898920a3f17eaaa2586a39dad76d5c7e8

parent

e4d4717703b365bc14f189bf36b3edb1e4430b90

M ChangeLogChangeLog

@@ -1,6 +1,9 @@

(Format: Year/Month/Day) Changes for 1.1.2: *08/09/18: + * Changed workspace count signal in BScreen to use the new signal + system. (Henrik) + Screen.cc/hh, SendToMenu.cc/hh, fluxbox.hh/cc, WorkspaceMenu.cc/hh * Added new Signal/Slot system to FbTk (Henrik) This is suppose to replace the obsolete Subject/Observer classes. FbTk/Signal.hh, FbTk/Slot.hh, FbTk/MemFun.hh, tests/testSignals.cc
M src/Screen.ccsrc/Screen.cc

@@ -341,7 +341,6 @@ const string &altscreenname,

int scrn, int num_layers) : m_clientlist_sig(*this), // client signal m_iconlist_sig(*this), // icon list signal - m_workspacecount_sig(*this), // workspace count signal m_workspacenames_sig(*this), // workspace names signal m_workspace_area_sig(*this), // workspace area signal m_currentworkspace_sig(*this), // current workspace signal

@@ -1110,7 +1109,7 @@ m_workspacenames_sig.notify();

} saveWorkspaces(m_workspaces_list.size()); - workspaceCountSig().notify(); + workspaceCountSig().emit( *this ); return m_workspaces_list.size();

@@ -1140,7 +1139,7 @@ //remove last workspace

m_workspaces_list.pop_back(); saveWorkspaces(m_workspaces_list.size()); - workspaceCountSig().notify(); + workspaceCountSig().emit( *this ); // must be deleted after we send notify!! // so we dont get bad pointers somewhere // while processing the notify signal
M src/Screen.hhsrc/Screen.hh

@@ -39,6 +39,7 @@ #include "FbTk/Subject.hh"

#include "FbTk/MultLayers.hh" #include "FbTk/NotCopyable.hh" #include "FbTk/Observer.hh" +#include "FbTk/Signal.hh" #include <X11/Xresource.h>

@@ -213,7 +214,7 @@ FbTk::Subject &clientListSig() { return m_clientlist_sig; }

/// icon list sig FbTk::Subject &iconListSig() { return m_iconlist_sig; } /// workspace count signal - FbTk::Subject &workspaceCountSig() { return m_workspacecount_sig; } + FbTk::Signal<void, BScreen&> &workspaceCountSig() { return m_workspacecount_sig; } /// workspace names signal FbTk::Subject &workspaceNamesSig() { return m_workspacenames_sig; } /// workspace area signal

@@ -493,7 +494,6 @@

ScreenSubject m_clientlist_sig, ///< client signal m_iconlist_sig, ///< notify if a window gets iconified/deiconified - m_workspacecount_sig, ///< workspace count signal m_workspacenames_sig, ///< workspace names signal m_workspace_area_sig, ///< workspace area changed signal m_currentworkspace_sig, ///< current workspace signal

@@ -502,6 +502,7 @@ 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::MultLayers m_layermanager; bool root_colormap_installed, managed;
M src/SendToMenu.ccsrc/SendToMenu.cc

@@ -31,6 +31,7 @@

#include "FbTk/MultiButtonMenuItem.hh" #include "FbTk/Command.hh" #include "FbTk/SimpleObserver.hh" +#include "FbTk/MemFun.hh" class SendToCmd: public FbTk::Command<void> { public:

@@ -55,9 +56,14 @@ // workspace count signal

// workspace names signal // current workspace signal m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu); - screen.workspaceCountSig().attach(m_rebuildObs); + screen.workspaceNamesSig().attach(m_rebuildObs); screen.currentWorkspaceSig().attach(m_rebuildObs); + + // setup new signal system + join( screen.workspaceCountSig(), + FbTk::MemFun(*this, &SendToMenu::workspaceCountChange) ); + // no title for this menu, it should be a submenu in the window menu. disableTitle(); // setup menu items
M src/SendToMenu.hhsrc/SendToMenu.hh

@@ -25,6 +25,8 @@ #define SENDTOMENU_HH

#include "FbMenu.hh" +#include "FbTk/Signal.hh" + namespace FbTk { class Observer; }

@@ -35,7 +37,7 @@ /**

* Creates the "send to menu". * Displays all the workspaces for which the current window can be sent to. */ -class SendToMenu:public FbMenu { +class SendToMenu:public FbMenu, private FbTk::SignalTracker { public: /// @param screen the screen on which this menu should be created on. explicit SendToMenu(BScreen &screen);

@@ -43,6 +45,11 @@ virtual ~SendToMenu();

/// @see FbTk::Menu void show(); private: + /// workspace count changed on screen + void workspaceCountChange( BScreen& screen ) { + rebuildMenu(); + } + /// Rebuild the menu from scratch. void rebuildMenu(); /// listens to signals that makes this instance need to rebuild menu
M src/WorkspaceMenu.ccsrc/WorkspaceMenu.cc

@@ -36,6 +36,7 @@ #include "FbTk/RefCount.hh"

#include "FbTk/MenuItem.hh" #include "FbTk/MenuSeparator.hh" #include "FbTk/MultiButtonMenuItem.hh" +#include "FbTk/MemFun.hh" #include <typeinfo>

@@ -61,6 +62,27 @@

init(screen); } +void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) { + while (numberOfItems() > NR_STATIC_ITEMS) { + remove(IDX_AFTER_ICONS); + } + // for each workspace add workspace name and it's menu + // to our workspace menu + for (size_t workspace = 0; workspace < screen.numberOfWorkspaces(); + ++workspace) { + Workspace *wkspc = screen.getWorkspace(workspace); + wkspc->menu().setInternalMenu(); + FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5, + wkspc->name().c_str(), + &wkspc->menu()); + FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); + mb_menu->setCommand(3, jump_cmd); + insert(mb_menu, workspace + IDX_AFTER_ICONS); + } + + updateMenu(-1); +} + void WorkspaceMenu::update(FbTk::Subject *subj) { if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) {

@@ -78,26 +100,8 @@ }

} setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); - } else if (subj == &screen.workspaceCountSig() || - subj == &screen.workspaceNamesSig()) { - while (numberOfItems() > NR_STATIC_ITEMS) { - remove(IDX_AFTER_ICONS); - } - // for each workspace add workspace name and it's menu - // to our workspace menu - for (size_t workspace = 0; workspace < screen.numberOfWorkspaces(); - ++workspace) { - Workspace *wkspc = screen.getWorkspace(workspace); - wkspc->menu().setInternalMenu(); - FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5, - wkspc->name().c_str(), - &wkspc->menu()); - FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); - mb_menu->setCommand(3, jump_cmd); - insert(mb_menu, workspace + IDX_AFTER_ICONS); - } - - updateMenu(-1); + } else if ( subj == &screen.workspaceNamesSig() ) { + workspaceInfoChanged( screen ); } } else { FbTk::Menu::update(subj);

@@ -106,8 +110,12 @@ }

void WorkspaceMenu::init(BScreen &screen) { screen.currentWorkspaceSig().attach(this); - screen.workspaceCountSig().attach(this); + screen.workspaceNamesSig().attach(this); + + join( screen.workspaceCountSig(), + FbTk::MemFun( *this, &WorkspaceMenu::workspaceInfoChanged ) ); + using namespace FbTk; _FB_USES_NLS;
M src/WorkspaceMenu.hhsrc/WorkspaceMenu.hh

@@ -23,6 +23,7 @@ #ifndef WORKSPACEMENU_HH

#define WORKSPACEMENU_HH #include "FbMenu.hh" +#include "FbTk/Signal.hh" class BScreen;

@@ -33,7 +34,7 @@ * such as new/delete workspace and edit

* workspace name. * It also contains client menus for all clients. */ -class WorkspaceMenu: public FbMenu { +class WorkspaceMenu: public FbMenu, private FbTk::SignalTracker { public: explicit WorkspaceMenu(BScreen &screen); virtual ~WorkspaceMenu() { }

@@ -42,6 +43,9 @@ void update(FbTk::Subject *subj);

private: /// 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 ); }; #endif // WORKSPACEMENU_HH
M src/fluxbox.ccsrc/fluxbox.cc

@@ -53,6 +53,7 @@ #include "FbTk/Transparent.hh"

#include "FbTk/Select2nd.hh" #include "FbTk/Compose.hh" #include "FbTk/KeyUtil.hh" +#include "FbTk/MemFun.hh" //Use GNU extensions #ifndef _GNU_SOURCE

@@ -452,10 +453,12 @@

// attach screen signals to this screen->currentWorkspaceSig().attach(this); screen->focusedWindowSig().attach(this); - screen->workspaceCountSig().attach(this); screen->workspaceNamesSig().attach(this); screen->workspaceAreaSig().attach(this); screen->clientListSig().attach(this); + + join( screen->workspaceCountSig(), + FbTk::MemFun( *this, &Fluxbox::workspaceCountChanged ) ); // initiate atomhandler for screen specific stuff for (AtomHandlerContainerIt it= m_atomhandler.begin();

@@ -1095,13 +1098,7 @@ screen.removeClient(*client);

} else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) { BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub); BScreen &screen = subj->screen(); - if ((&(screen.workspaceCountSig())) == changedsub) { - for (AtomHandlerContainerIt it= m_atomhandler.begin(); - it != m_atomhandler.end(); ++it) { - if ((*it).first->update()) - (*it).first->updateWorkspaceCount(screen); - } - } else if ((&(screen.workspaceNamesSig())) == changedsub) { + if ((&(screen.workspaceNamesSig())) == changedsub) { for (AtomHandlerContainerIt it= m_atomhandler.begin(); it != m_atomhandler.end(); ++it) { if ((*it).first->update())

@@ -1519,3 +1516,11 @@ for (; it != it_end; ++it ) {

(*it).first->updateFrameExtents(win); } } + +void Fluxbox::workspaceCountChanged( BScreen& screen ) { + for (AtomHandlerContainerIt it= m_atomhandler.begin(); + it != m_atomhandler.end(); ++it) { + if ((*it).first->update()) + (*it).first->updateWorkspaceCount(screen); + } +}
M src/fluxbox.hhsrc/fluxbox.hh

@@ -30,6 +30,8 @@ #include "FbTk/Resource.hh"

#include "FbTk/Timer.hh" #include "FbTk/Observer.hh" #include "FbTk/SignalHandler.hh" +#include "FbTk/Signal.hh" + #include "AttentionNoticeHandler.hh" #include <X11/Xresource.h>

@@ -74,7 +76,8 @@ singleton type

*/ class Fluxbox : public FbTk::App, public FbTk::SignalEventHandler, - public FbTk::Observer { + public FbTk::Observer, + private FbTk::SignalTracker { public: Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rcfilename = 0, bool xsync = false);

@@ -197,6 +200,9 @@

void setupConfigFiles(); void handleUnmapNotify(XUnmapEvent &ue); void handleClientMessage(XClientMessageEvent &ce); + + /// Called when workspace count on a specific screen changed. + void workspaceCountChanged( BScreen& screen ); std::auto_ptr<FbAtoms> m_fbatoms;