From ed53f3c623e7c3ae35672b33ae3b52759dc1a6ed Mon Sep 17 00:00:00 2001 From: Henrik Kinnunen Date: Sun, 21 Sep 2008 20:45:01 +0200 Subject: Changed icon list signal in BScreen to use the new signal system --- ChangeLog | 4 ++++ src/ClientMenu.cc | 19 ++++++++++--------- src/ClientMenu.hh | 17 ++++++++++++----- src/FbCommands.cc | 5 +++-- src/MenuCreator.cc | 4 ++-- src/Screen.cc | 7 +++---- src/Screen.hh | 4 ++-- src/Workspace.cc | 15 ++++++++++----- src/Workspace.hh | 5 +++-- 9 files changed, 49 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c948ee..a2bddf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/ClientMenu.cc b/src/ClientMenu.cc index f5af305..0da3773 100644 --- a/src/ClientMenu.cc +++ b/src/ClientMenu.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 #include "FbTk/MenuItem.hh" +#include "FbTk/MemFun.hh" namespace { // anonymous @@ -79,14 +80,16 @@ private: }; // 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 @@ void ClientMenu::refreshMenu() { } 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(subj); Focusable &win = fsubj->win(); diff --git a/src/ClientMenu.hh b/src/ClientMenu.hh index dd43cbc..f0b6ce4 100644 --- a/src/ClientMenu.hh +++ b/src/ClientMenu.hh @@ -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 @@ #include "FbMenu.hh" +#include "FbTk/Signal.hh" + class BScreen; class FluxboxWindow; /** @@ -38,19 +40,24 @@ public: /** * @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 diff --git a/src/FbCommands.cc b/src/FbCommands.cc index fd3f71e..3c69386 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -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 @@ void ShowClientMenuCmd::execute() { m_list.push_back(static_cast(*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()); } diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 8f9b9a7..7a2e9b4 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -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 @@ FbMenu *MenuCreator::createMenuType(const string &type, int screen_num) { 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); diff --git a/src/Screen.cc b/src/Screen.cc index 2d55b31..8746fd2 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -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 @@ void BScreen::addIcon(FluxboxWindow *w) { m_icon_list.push_back(w); // notify listeners - m_iconlist_sig.notify(); + m_iconlist_sig.emit(*this); } @@ -1049,7 +1048,7 @@ void BScreen::removeIcon(FluxboxWindow *w) { // 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 @@ void BScreen::removeClient(WinClient &client) { focusControl().removeClient(client); if (client.fbwindow() && client.fbwindow()->isIconic()) - iconListSig().notify(); + iconListSig().emit(*this); using namespace FbTk; diff --git a/src/Screen.hh b/src/Screen.hh index 263d4ba..a5e80ee 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -213,7 +213,7 @@ public: /// 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 @@ private: 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 diff --git a/src/Workspace.cc b/src/Workspace.cc index b266d78..ff3b21f 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -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 @@ using std::endl; 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 @@ void Workspace::addWindow(FluxboxWindow &w) { w.setWorkspace(m_id); m_windowlist.push_back(&w); - m_clientlist_sig.notify(); + m_clientlist_sig.emit(); } @@ -108,7 +113,7 @@ int Workspace::removeWindow(FluxboxWindow *w, bool 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::shutdown() { } void Workspace::updateClientmenu() { - m_clientlist_sig.notify(); + m_clientlist_sig.emit(); } diff --git a/src/Workspace.hh b/src/Workspace.hh index a834174..790c4a6 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh @@ -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 #include @@ -84,7 +85,7 @@ private: BScreen &m_screen; Windows m_windowlist; - FbTk::Subject m_clientlist_sig; + FbTk::Signal m_clientlist_sig; ClientMenu m_clientmenu; std::string m_name; ///< name of this workspace -- cgit v0.11.2