summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-18 20:27:16 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-18 20:27:16 (GMT)
commit2f4db57898920a3f17eaaa2586a39dad76d5c7e8 (patch)
treed107bebec3ddb8800970dfbc482c493d5e0187ab
parente4d4717703b365bc14f189bf36b3edb1e4430b90 (diff)
downloadfluxbox_lack-2f4db57898920a3f17eaaa2586a39dad76d5c7e8.zip
fluxbox_lack-2f4db57898920a3f17eaaa2586a39dad76d5c7e8.tar.bz2
Changed workspace count signal in BScreen to use the new signal system.
-rw-r--r--ChangeLog3
-rw-r--r--src/Screen.cc5
-rw-r--r--src/Screen.hh5
-rw-r--r--src/SendToMenu.cc8
-rw-r--r--src/SendToMenu.hh9
-rw-r--r--src/WorkspaceMenu.cc50
-rw-r--r--src/WorkspaceMenu.hh6
-rw-r--r--src/fluxbox.cc21
-rw-r--r--src/fluxbox.hh8
9 files changed, 77 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index da15ff6..998ead4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.1.2: 2Changes for 1.1.2:
3*08/09/18: 3*08/09/18:
4 * Changed workspace count signal in BScreen to use the new signal
5 system. (Henrik)
6 Screen.cc/hh, SendToMenu.cc/hh, fluxbox.hh/cc, WorkspaceMenu.cc/hh
4 * Added new Signal/Slot system to FbTk (Henrik) 7 * Added new Signal/Slot system to FbTk (Henrik)
5 This is suppose to replace the obsolete Subject/Observer classes. 8 This is suppose to replace the obsolete Subject/Observer classes.
6 FbTk/Signal.hh, FbTk/Slot.hh, FbTk/MemFun.hh, tests/testSignals.cc 9 FbTk/Signal.hh, FbTk/Slot.hh, FbTk/MemFun.hh, tests/testSignals.cc
diff --git a/src/Screen.cc b/src/Screen.cc
index 23bc417..83bc92e 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -341,7 +341,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
341 int scrn, int num_layers) : 341 int scrn, int num_layers) :
342 m_clientlist_sig(*this), // client signal 342 m_clientlist_sig(*this), // client signal
343 m_iconlist_sig(*this), // icon list signal 343 m_iconlist_sig(*this), // icon list signal
344 m_workspacecount_sig(*this), // workspace count signal
345 m_workspacenames_sig(*this), // workspace names signal 344 m_workspacenames_sig(*this), // workspace names signal
346 m_workspace_area_sig(*this), // workspace area signal 345 m_workspace_area_sig(*this), // workspace area signal
347 m_currentworkspace_sig(*this), // current workspace signal 346 m_currentworkspace_sig(*this), // current workspace signal
@@ -1110,7 +1109,7 @@ int BScreen::addWorkspace() {
1110 } 1109 }
1111 1110
1112 saveWorkspaces(m_workspaces_list.size()); 1111 saveWorkspaces(m_workspaces_list.size());
1113 workspaceCountSig().notify(); 1112 workspaceCountSig().emit( *this );
1114 1113
1115 return m_workspaces_list.size(); 1114 return m_workspaces_list.size();
1116 1115
@@ -1140,7 +1139,7 @@ int BScreen::removeLastWorkspace() {
1140 m_workspaces_list.pop_back(); 1139 m_workspaces_list.pop_back();
1141 1140
1142 saveWorkspaces(m_workspaces_list.size()); 1141 saveWorkspaces(m_workspaces_list.size());
1143 workspaceCountSig().notify(); 1142 workspaceCountSig().emit( *this );
1144 // must be deleted after we send notify!! 1143 // must be deleted after we send notify!!
1145 // so we dont get bad pointers somewhere 1144 // so we dont get bad pointers somewhere
1146 // while processing the notify signal 1145 // while processing the notify signal
diff --git a/src/Screen.hh b/src/Screen.hh
index 038570e..3f57c22 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -39,6 +39,7 @@
39#include "FbTk/MultLayers.hh" 39#include "FbTk/MultLayers.hh"
40#include "FbTk/NotCopyable.hh" 40#include "FbTk/NotCopyable.hh"
41#include "FbTk/Observer.hh" 41#include "FbTk/Observer.hh"
42#include "FbTk/Signal.hh"
42 43
43#include <X11/Xresource.h> 44#include <X11/Xresource.h>
44 45
@@ -213,7 +214,7 @@ public:
213 /// icon list sig 214 /// icon list sig
214 FbTk::Subject &iconListSig() { return m_iconlist_sig; } 215 FbTk::Subject &iconListSig() { return m_iconlist_sig; }
215 /// workspace count signal 216 /// workspace count signal
216 FbTk::Subject &workspaceCountSig() { return m_workspacecount_sig; } 217 FbTk::Signal<void, BScreen&> &workspaceCountSig() { return m_workspacecount_sig; }
217 /// workspace names signal 218 /// workspace names signal
218 FbTk::Subject &workspaceNamesSig() { return m_workspacenames_sig; } 219 FbTk::Subject &workspaceNamesSig() { return m_workspacenames_sig; }
219 /// workspace area signal 220 /// workspace area signal
@@ -493,7 +494,6 @@ private:
493 ScreenSubject 494 ScreenSubject
494 m_clientlist_sig, ///< client signal 495 m_clientlist_sig, ///< client signal
495 m_iconlist_sig, ///< notify if a window gets iconified/deiconified 496 m_iconlist_sig, ///< notify if a window gets iconified/deiconified
496 m_workspacecount_sig, ///< workspace count signal
497 m_workspacenames_sig, ///< workspace names signal 497 m_workspacenames_sig, ///< workspace names signal
498 m_workspace_area_sig, ///< workspace area changed signal 498 m_workspace_area_sig, ///< workspace area changed signal
499 m_currentworkspace_sig, ///< current workspace signal 499 m_currentworkspace_sig, ///< current workspace signal
@@ -502,6 +502,7 @@ private:
502 m_resize_sig, ///< resize signal 502 m_resize_sig, ///< resize signal
503 m_bg_change_sig; ///< background change signal 503 m_bg_change_sig; ///< background change signal
504 504
505 FbTk::Signal<void, BScreen&> m_workspacecount_sig; ///< workspace count signal
505 FbTk::MultLayers m_layermanager; 506 FbTk::MultLayers m_layermanager;
506 507
507 bool root_colormap_installed, managed; 508 bool root_colormap_installed, managed;
diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc
index 2362eb2..397ec81 100644
--- a/src/SendToMenu.cc
+++ b/src/SendToMenu.cc
@@ -31,6 +31,7 @@
31#include "FbTk/MultiButtonMenuItem.hh" 31#include "FbTk/MultiButtonMenuItem.hh"
32#include "FbTk/Command.hh" 32#include "FbTk/Command.hh"
33#include "FbTk/SimpleObserver.hh" 33#include "FbTk/SimpleObserver.hh"
34#include "FbTk/MemFun.hh"
34 35
35class SendToCmd: public FbTk::Command<void> { 36class SendToCmd: public FbTk::Command<void> {
36public: 37public:
@@ -55,9 +56,14 @@ SendToMenu::SendToMenu(BScreen &screen):
55 // workspace names signal 56 // workspace names signal
56 // current workspace signal 57 // current workspace signal
57 m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu); 58 m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu);
58 screen.workspaceCountSig().attach(m_rebuildObs); 59
59 screen.workspaceNamesSig().attach(m_rebuildObs); 60 screen.workspaceNamesSig().attach(m_rebuildObs);
60 screen.currentWorkspaceSig().attach(m_rebuildObs); 61 screen.currentWorkspaceSig().attach(m_rebuildObs);
62
63 // setup new signal system
64 join( screen.workspaceCountSig(),
65 FbTk::MemFun(*this, &SendToMenu::workspaceCountChange) );
66
61 // no title for this menu, it should be a submenu in the window menu. 67 // no title for this menu, it should be a submenu in the window menu.
62 disableTitle(); 68 disableTitle();
63 // setup menu items 69 // setup menu items
diff --git a/src/SendToMenu.hh b/src/SendToMenu.hh
index 0f668a9..1582dd5 100644
--- a/src/SendToMenu.hh
+++ b/src/SendToMenu.hh
@@ -25,6 +25,8 @@
25 25
26#include "FbMenu.hh" 26#include "FbMenu.hh"
27 27
28#include "FbTk/Signal.hh"
29
28namespace FbTk { 30namespace FbTk {
29class Observer; 31class Observer;
30} 32}
@@ -35,7 +37,7 @@ class BScreen;
35 * Creates the "send to menu". 37 * Creates the "send to menu".
36 * Displays all the workspaces for which the current window can be sent to. 38 * Displays all the workspaces for which the current window can be sent to.
37 */ 39 */
38class SendToMenu:public FbMenu { 40class SendToMenu:public FbMenu, private FbTk::SignalTracker {
39public: 41public:
40 /// @param screen the screen on which this menu should be created on. 42 /// @param screen the screen on which this menu should be created on.
41 explicit SendToMenu(BScreen &screen); 43 explicit SendToMenu(BScreen &screen);
@@ -43,6 +45,11 @@ public:
43 /// @see FbTk::Menu 45 /// @see FbTk::Menu
44 void show(); 46 void show();
45private: 47private:
48 /// workspace count changed on screen
49 void workspaceCountChange( BScreen& screen ) {
50 rebuildMenu();
51 }
52
46 /// Rebuild the menu from scratch. 53 /// Rebuild the menu from scratch.
47 void rebuildMenu(); 54 void rebuildMenu();
48 /// listens to signals that makes this instance need to rebuild menu 55 /// listens to signals that makes this instance need to rebuild menu
diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc
index 3bef2b6..33cfb7f 100644
--- a/src/WorkspaceMenu.cc
+++ b/src/WorkspaceMenu.cc
@@ -36,6 +36,7 @@
36#include "FbTk/MenuItem.hh" 36#include "FbTk/MenuItem.hh"
37#include "FbTk/MenuSeparator.hh" 37#include "FbTk/MenuSeparator.hh"
38#include "FbTk/MultiButtonMenuItem.hh" 38#include "FbTk/MultiButtonMenuItem.hh"
39#include "FbTk/MemFun.hh"
39 40
40#include <typeinfo> 41#include <typeinfo>
41 42
@@ -61,6 +62,27 @@ WorkspaceMenu::WorkspaceMenu(BScreen &screen):
61 init(screen); 62 init(screen);
62} 63}
63 64
65void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) {
66 while (numberOfItems() > NR_STATIC_ITEMS) {
67 remove(IDX_AFTER_ICONS);
68 }
69 // for each workspace add workspace name and it's menu
70 // to our workspace menu
71 for (size_t workspace = 0; workspace < screen.numberOfWorkspaces();
72 ++workspace) {
73 Workspace *wkspc = screen.getWorkspace(workspace);
74 wkspc->menu().setInternalMenu();
75 FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5,
76 wkspc->name().c_str(),
77 &wkspc->menu());
78 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID()));
79 mb_menu->setCommand(3, jump_cmd);
80 insert(mb_menu, workspace + IDX_AFTER_ICONS);
81 }
82
83 updateMenu(-1);
84}
85
64void WorkspaceMenu::update(FbTk::Subject *subj) { 86void WorkspaceMenu::update(FbTk::Subject *subj) {
65 87
66 if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) { 88 if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) {
@@ -78,26 +100,8 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
78 } 100 }
79 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); 101 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
80 updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); 102 updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS);
81 } else if (subj == &screen.workspaceCountSig() || 103 } else if ( subj == &screen.workspaceNamesSig() ) {
82 subj == &screen.workspaceNamesSig()) { 104 workspaceInfoChanged( screen );
83 while (numberOfItems() > NR_STATIC_ITEMS) {
84 remove(IDX_AFTER_ICONS);
85 }
86 // for each workspace add workspace name and it's menu
87 // to our workspace menu
88 for (size_t workspace = 0; workspace < screen.numberOfWorkspaces();
89 ++workspace) {
90 Workspace *wkspc = screen.getWorkspace(workspace);
91 wkspc->menu().setInternalMenu();
92 FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5,
93 wkspc->name().c_str(),
94 &wkspc->menu());
95 FbTk::RefCount<FbTk::Command<void> > jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID()));
96 mb_menu->setCommand(3, jump_cmd);
97 insert(mb_menu, workspace + IDX_AFTER_ICONS);
98 }
99
100 updateMenu(-1);
101 } 105 }
102 } else { 106 } else {
103 FbTk::Menu::update(subj); 107 FbTk::Menu::update(subj);
@@ -106,8 +110,12 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
106 110
107void WorkspaceMenu::init(BScreen &screen) { 111void WorkspaceMenu::init(BScreen &screen) {
108 screen.currentWorkspaceSig().attach(this); 112 screen.currentWorkspaceSig().attach(this);
109 screen.workspaceCountSig().attach(this); 113
110 screen.workspaceNamesSig().attach(this); 114 screen.workspaceNamesSig().attach(this);
115
116 join( screen.workspaceCountSig(),
117 FbTk::MemFun( *this, &WorkspaceMenu::workspaceInfoChanged ) );
118
111 using namespace FbTk; 119 using namespace FbTk;
112 _FB_USES_NLS; 120 _FB_USES_NLS;
113 121
diff --git a/src/WorkspaceMenu.hh b/src/WorkspaceMenu.hh
index 8591a65..e8a671d 100644
--- a/src/WorkspaceMenu.hh
+++ b/src/WorkspaceMenu.hh
@@ -23,6 +23,7 @@
23#define WORKSPACEMENU_HH 23#define WORKSPACEMENU_HH
24 24
25#include "FbMenu.hh" 25#include "FbMenu.hh"
26#include "FbTk/Signal.hh"
26 27
27class BScreen; 28class BScreen;
28 29
@@ -33,7 +34,7 @@ class BScreen;
33 * workspace name. 34 * workspace name.
34 * It also contains client menus for all clients. 35 * It also contains client menus for all clients.
35 */ 36 */
36class WorkspaceMenu: public FbMenu { 37class WorkspaceMenu: public FbMenu, private FbTk::SignalTracker {
37public: 38public:
38 explicit WorkspaceMenu(BScreen &screen); 39 explicit WorkspaceMenu(BScreen &screen);
39 virtual ~WorkspaceMenu() { } 40 virtual ~WorkspaceMenu() { }
@@ -42,6 +43,9 @@ public:
42private: 43private:
43 /// initialize menu for the screen 44 /// initialize menu for the screen
44 void init(BScreen &screen); 45 void init(BScreen &screen);
46 /// Called when workspace info was changed
47 /// ( number of workspace, workspace names etc )
48 void workspaceInfoChanged( BScreen& screen );
45}; 49};
46 50
47#endif // WORKSPACEMENU_HH 51#endif // WORKSPACEMENU_HH
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 4a223f9..4a7c68d 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -53,6 +53,7 @@
53#include "FbTk/Select2nd.hh" 53#include "FbTk/Select2nd.hh"
54#include "FbTk/Compose.hh" 54#include "FbTk/Compose.hh"
55#include "FbTk/KeyUtil.hh" 55#include "FbTk/KeyUtil.hh"
56#include "FbTk/MemFun.hh"
56 57
57//Use GNU extensions 58//Use GNU extensions
58#ifndef _GNU_SOURCE 59#ifndef _GNU_SOURCE
@@ -452,11 +453,13 @@ void Fluxbox::initScreen(BScreen *screen) {
452 // attach screen signals to this 453 // attach screen signals to this
453 screen->currentWorkspaceSig().attach(this); 454 screen->currentWorkspaceSig().attach(this);
454 screen->focusedWindowSig().attach(this); 455 screen->focusedWindowSig().attach(this);
455 screen->workspaceCountSig().attach(this);
456 screen->workspaceNamesSig().attach(this); 456 screen->workspaceNamesSig().attach(this);
457 screen->workspaceAreaSig().attach(this); 457 screen->workspaceAreaSig().attach(this);
458 screen->clientListSig().attach(this); 458 screen->clientListSig().attach(this);
459 459
460 join( screen->workspaceCountSig(),
461 FbTk::MemFun( *this, &Fluxbox::workspaceCountChanged ) );
462
460 // initiate atomhandler for screen specific stuff 463 // initiate atomhandler for screen specific stuff
461 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 464 for (AtomHandlerContainerIt it= m_atomhandler.begin();
462 it != m_atomhandler.end(); 465 it != m_atomhandler.end();
@@ -1095,13 +1098,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1095 } else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) { 1098 } else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) {
1096 BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub); 1099 BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub);
1097 BScreen &screen = subj->screen(); 1100 BScreen &screen = subj->screen();
1098 if ((&(screen.workspaceCountSig())) == changedsub) { 1101 if ((&(screen.workspaceNamesSig())) == changedsub) {
1099 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1100 it != m_atomhandler.end(); ++it) {
1101 if ((*it).first->update())
1102 (*it).first->updateWorkspaceCount(screen);
1103 }
1104 } else if ((&(screen.workspaceNamesSig())) == changedsub) {
1105 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1102 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1106 it != m_atomhandler.end(); ++it) { 1103 it != m_atomhandler.end(); ++it) {
1107 if ((*it).first->update()) 1104 if ((*it).first->update())
@@ -1519,3 +1516,11 @@ void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
1519 (*it).first->updateFrameExtents(win); 1516 (*it).first->updateFrameExtents(win);
1520 } 1517 }
1521} 1518}
1519
1520void Fluxbox::workspaceCountChanged( BScreen& screen ) {
1521 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1522 it != m_atomhandler.end(); ++it) {
1523 if ((*it).first->update())
1524 (*it).first->updateWorkspaceCount(screen);
1525 }
1526}
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index a6c0b2f..8478833 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -30,6 +30,8 @@
30#include "FbTk/Timer.hh" 30#include "FbTk/Timer.hh"
31#include "FbTk/Observer.hh" 31#include "FbTk/Observer.hh"
32#include "FbTk/SignalHandler.hh" 32#include "FbTk/SignalHandler.hh"
33#include "FbTk/Signal.hh"
34
33#include "AttentionNoticeHandler.hh" 35#include "AttentionNoticeHandler.hh"
34 36
35#include <X11/Xresource.h> 37#include <X11/Xresource.h>
@@ -74,7 +76,8 @@ class FbAtoms;
74*/ 76*/
75class Fluxbox : public FbTk::App, 77class Fluxbox : public FbTk::App,
76 public FbTk::SignalEventHandler, 78 public FbTk::SignalEventHandler,
77 public FbTk::Observer { 79 public FbTk::Observer,
80 private FbTk::SignalTracker {
78public: 81public:
79 Fluxbox(int argc, char **argv, const char * dpy_name= 0, 82 Fluxbox(int argc, char **argv, const char * dpy_name= 0,
80 const char *rcfilename = 0, bool xsync = false); 83 const char *rcfilename = 0, bool xsync = false);
@@ -198,6 +201,9 @@ private:
198 void handleUnmapNotify(XUnmapEvent &ue); 201 void handleUnmapNotify(XUnmapEvent &ue);
199 void handleClientMessage(XClientMessageEvent &ce); 202 void handleClientMessage(XClientMessageEvent &ce);
200 203
204 /// Called when workspace count on a specific screen changed.
205 void workspaceCountChanged( BScreen& screen );
206
201 std::auto_ptr<FbAtoms> m_fbatoms; 207 std::auto_ptr<FbAtoms> m_fbatoms;
202 208
203 FbTk::ResourceManager m_resourcemanager, &m_screen_rm; 209 FbTk::ResourceManager m_resourcemanager, &m_screen_rm;