Changed workspace count signal in BScreen to use the new signal system.
This commit is contained in:
parent
e4d4717703
commit
2f4db57898
9 changed files with 77 additions and 38 deletions
|
@ -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
|
||||
|
|
|
@ -341,7 +341,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
|
|||
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 @@ int BScreen::addWorkspace() {
|
|||
}
|
||||
|
||||
saveWorkspaces(m_workspaces_list.size());
|
||||
workspaceCountSig().notify();
|
||||
workspaceCountSig().emit( *this );
|
||||
|
||||
return m_workspaces_list.size();
|
||||
|
||||
|
@ -1140,7 +1139,7 @@ int BScreen::removeLastWorkspace() {
|
|||
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
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "FbTk/MultLayers.hh"
|
||||
#include "FbTk/NotCopyable.hh"
|
||||
#include "FbTk/Observer.hh"
|
||||
#include "FbTk/Signal.hh"
|
||||
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
|
@ -213,7 +214,7 @@ public:
|
|||
/// 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 @@ private:
|
|||
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 @@ private:
|
|||
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;
|
||||
|
|
|
@ -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 @@ SendToMenu::SendToMenu(BScreen &screen):
|
|||
// 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
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "FbMenu.hh"
|
||||
|
||||
#include "FbTk/Signal.hh"
|
||||
|
||||
namespace FbTk {
|
||||
class Observer;
|
||||
}
|
||||
|
@ -35,7 +37,7 @@ class BScreen;
|
|||
* 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 @@ public:
|
|||
/// @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
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "FbTk/MenuItem.hh"
|
||||
#include "FbTk/MenuSeparator.hh"
|
||||
#include "FbTk/MultiButtonMenuItem.hh"
|
||||
#include "FbTk/MemFun.hh"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
|
@ -61,6 +62,27 @@ WorkspaceMenu::WorkspaceMenu(BScreen &screen):
|
|||
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 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
|
|||
}
|
||||
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::update(FbTk::Subject *subj) {
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define WORKSPACEMENU_HH
|
||||
|
||||
#include "FbMenu.hh"
|
||||
#include "FbTk/Signal.hh"
|
||||
|
||||
class BScreen;
|
||||
|
||||
|
@ -33,7 +34,7 @@ class BScreen;
|
|||
* 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 @@ public:
|
|||
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
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "FbTk/Select2nd.hh"
|
||||
#include "FbTk/Compose.hh"
|
||||
#include "FbTk/KeyUtil.hh"
|
||||
#include "FbTk/MemFun.hh"
|
||||
|
||||
//Use GNU extensions
|
||||
#ifndef _GNU_SOURCE
|
||||
|
@ -452,11 +453,13 @@ void Fluxbox::initScreen(BScreen *screen) {
|
|||
// 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();
|
||||
it != m_atomhandler.end();
|
||||
|
@ -1095,13 +1098,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
|
|||
} 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 @@ void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
|
|||
(*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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#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 @@ class FbAtoms;
|
|||
*/
|
||||
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);
|
||||
|
@ -198,6 +201,9 @@ private:
|
|||
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;
|
||||
|
||||
FbTk::ResourceManager m_resourcemanager, &m_screen_rm;
|
||||
|
|
Loading…
Reference in a new issue