Changed icon list signal in BScreen to use the new signal system
@@ -1,6 +1,10 @@
(Format: Year/Month/Day) Changes for 1.1.2 *08/09/21: + * Changed icon list signal in BScreen to use the new signal system + (Henrik) + ClientMenu.hh/cc, Workspace.hh/cc, FbCommands.cc, MenuCreator.cc, + Screen.hh/cc * Changed client list signal in BScreen to use the new signal system (Henrik) Screen.hh/cc, FocusControl.cc, fluxbox.hh/cc
@@ -1,5 +1,5 @@
// ClientMenu.hh -// Copyright (c) 2007 Fluxbox Team (fluxgen at fluxbox dot org) +// Copyright (c) 2007-2008 Fluxbox Team (fluxgen at fluxbox dot org) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"),@@ -28,6 +28,7 @@ #include "WindowCmd.hh"
#include <X11/keysym.h> #include "FbTk/MenuItem.hh" +#include "FbTk/MemFun.hh" namespace { // anonymous@@ -79,14 +80,16 @@
}; // end anonymous namespace ClientMenu::ClientMenu(BScreen &screen, Focusables &clients, - FbTk::Subject *refresh): + bool listen_for_iconlist_changes): FbMenu(screen.menuTheme(), screen.imageControl(), *screen.layerManager().getLayer(Layer::MENU)), - m_list(clients), - m_refresh_sig(refresh) { + m_list(clients) { + + if (listen_for_iconlist_changes) { + m_slots.join(screen.iconListSig(), + FbTk::MemFun(*this, &ClientMenu::updateClientList)); + } - if (refresh) - refresh->attach(this); refreshMenu(); }@@ -116,9 +119,7 @@ updateMenu();
} void ClientMenu::update(FbTk::Subject *subj) { - if (subj == m_refresh_sig) - refreshMenu(); - else if (subj && typeid(*subj) == typeid(Focusable::FocusSubject)) { + if (subj && typeid(*subj) == typeid(Focusable::FocusSubject)) { Focusable::FocusSubject *fsubj = static_cast<Focusable::FocusSubject *>(subj); Focusable &win = fsubj->win();
@@ -1,5 +1,5 @@
// ClientMenu.hh -// Copyright (c) 2007 Fluxbox Team (fluxgen at fluxbox dot org) +// Copyright (c) 2007-2008 Fluxbox Team (fluxgen at fluxbox dot org) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"),@@ -24,6 +24,8 @@ #define CLIENTMENU_HH
#include "FbMenu.hh" +#include "FbTk/Signal.hh" + class BScreen; class FluxboxWindow; /**@@ -38,19 +40,24 @@
/** * @param screen the screen to show this menu on * @param client a list of clients to show in this menu - * @param refresh the refresh subject to listen to + * @param listen_for_iconlist_changes Listen for list changes from the \c screen. */ ClientMenu(BScreen &screen, - Focusables &clients, FbTk::Subject *refresh); + Focusables &clients, bool listen_for_iconlist_changes); -private: /// refresh the entire menu void refreshMenu(); +private: + + void updateClientList(BScreen& screen) { + refreshMenu(); + } + /// called when receiving a subject signal void update(FbTk::Subject *subj); Focusables &m_list; ///< clients in the menu - FbTk::Subject *m_refresh_sig; ///< signal to listen to + FbTk::SignalTracker m_slots; ///< track all the slots }; #endif // CLIENTMENU_HH
@@ -1,5 +1,5 @@
// FbCommands.cc for Fluxbox -// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) +// Copyright (c) 2003 - 2008 Henrik Kinnunen (fluxgen at fluxbox dot org) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"),@@ -340,7 +340,8 @@ if (typeid(**it) == typeid(FluxboxWindow) && m_pat.match(**it))
m_list.push_back(static_cast<FluxboxWindow *>(*it)); } - m_menu.reset(new ClientMenu(*screen, m_list, 0)); + m_menu.reset(new ClientMenu(*screen, m_list, + false)); // dont listen to list changes ::showMenu(*screen, *m_menu.get()); }
@@ -1,5 +1,5 @@
// MenuCreator.cc for Fluxbox -// Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org) +// Copyright (c) 2004-2008 Henrik Kinnunen (fluxgen at fluxbox dot org) // and Simon Bowden (rathnor at users.sourceforge.net) // // Permission is hereby granted, free of charge, to any person obtaining a@@ -415,7 +415,7 @@ if (screen == 0)
return 0; if (type == "iconmenu") return new ClientMenu(*screen, screen->iconList(), - &screen->iconListSig()); + true); // listen to icon list changes else if (type == "workspacemenu") return new WorkspaceMenu(*screen);
@@ -339,7 +339,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
const string &screenname, const string &altscreenname, int scrn, int num_layers) : - m_iconlist_sig(*this), // icon list signal m_workspace_area_sig(*this), // workspace area signal m_focusedwindow_sig(*this), // focused window signal m_reconfigure_sig(*this), // reconfigure signal@@ -1034,7 +1033,7 @@
m_icon_list.push_back(w); // notify listeners - m_iconlist_sig.notify(); + m_iconlist_sig.emit(*this); }@@ -1049,7 +1048,7 @@ // no need to send iconlist signal if we didn't
// change the iconlist if (erase_it != m_icon_list.end()) { iconList().erase(erase_it); - m_iconlist_sig.notify(); + m_iconlist_sig.emit(*this); } }@@ -1072,7 +1071,7 @@
focusControl().removeClient(client); if (client.fbwindow() && client.fbwindow()->isIconic()) - iconListSig().notify(); + iconListSig().emit(*this); using namespace FbTk;
@@ -213,7 +213,7 @@ typedef FbTk::Signal<void, BScreen&> ScreenSignal;
/// client list signal ScreenSignal &clientListSig() { return m_clientlist_sig; } /// icon list sig - FbTk::Subject &iconListSig() { return m_iconlist_sig; } + ScreenSignal &iconListSig() { return m_iconlist_sig; } /// workspace count signal ScreenSignal &workspaceCountSig() { return m_workspacecount_sig; } /// workspace names signal@@ -493,12 +493,12 @@
const Strut* availableWorkspaceArea(int head) const; ScreenSubject - m_iconlist_sig, ///< notify if a window gets iconified/deiconified m_workspace_area_sig, ///< workspace area changed signal m_focusedwindow_sig, ///< focused window signal m_reconfigure_sig, ///< reconfigure signal m_resize_sig; ///< resize signal + ScreenSignal m_iconlist_sig; ///< notify if a window gets iconified/deiconified ScreenSignal m_clientlist_sig; ///< client signal ScreenSignal m_bg_change_sig; ///< background change signal ScreenSignal m_workspacecount_sig; ///< workspace count signal
@@ -1,5 +1,5 @@
// Workspace.cc for Fluxbox -// Copyright (c) 2001 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) +// Copyright (c) 2001 - 2008 Henrik Kinnunen (fluxgen at fluxbox dot org) // // Workspace.cc for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)@@ -34,6 +34,7 @@
#include "FbTk/I18n.hh" #include "FbTk/StringUtil.hh" #include "FbTk/FbString.hh" +#include "FbTk/MemFun.hh" // use GNU extensions #ifndef _GNU_SOURCE@@ -70,13 +71,17 @@ #endif // DEBUG
Workspace::Workspace(BScreen &scrn, const string &name, unsigned int id): m_screen(scrn), - m_clientmenu(scrn, m_windowlist, &m_clientlist_sig), + m_clientmenu(scrn, m_windowlist, false), m_name(name), m_id(id) { + + m_clientlist_sig.connect(FbTk::MemFun(m_clientmenu, + &ClientMenu::refreshMenu)); menu().setInternalMenu(); setName(name); + }@@ -91,7 +96,7 @@
w.setWorkspace(m_id); m_windowlist.push_back(&w); - m_clientlist_sig.notify(); + m_clientlist_sig.emit(); }@@ -108,7 +113,7 @@ if (w->isFocused() && still_alive)
FocusControl::unfocusWindow(w->winClient(), true, true); m_windowlist.remove(w); - m_clientlist_sig.notify(); + m_clientlist_sig.emit(); return m_windowlist.size(); }@@ -190,5 +195,5 @@ }
} void Workspace::updateClientmenu() { - m_clientlist_sig.notify(); + m_clientlist_sig.emit(); }
@@ -1,5 +1,5 @@
// Workspace.hh for Fluxbox -// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) +// Copyright (c) 2002 - 2008 Henrik Kinnunen (fluxgen at fluxbox dot org) // // Workspace.hh for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)@@ -28,6 +28,7 @@
#include "ClientMenu.hh" #include "FbTk/NotCopyable.hh" +#include "FbTk/Signal.hh" #include <string> #include <list>@@ -84,7 +85,7 @@
BScreen &m_screen; Windows m_windowlist; - FbTk::Subject m_clientlist_sig; + FbTk::Signal<void> m_clientlist_sig; ClientMenu m_clientmenu; std::string m_name; ///< name of this workspace