summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FocusableList.cc14
-rw-r--r--src/FocusableList.hh5
-rw-r--r--src/Screen.cc3
-rw-r--r--src/Screen.hh4
-rw-r--r--src/SendToMenu.cc7
-rw-r--r--src/SendToMenu.hh2
-rw-r--r--src/WorkspaceMenu.cc35
-rw-r--r--src/WorkspaceMenu.hh4
-rw-r--r--src/WorkspaceNameTool.cc11
-rw-r--r--src/WorkspaceNameTool.hh7
-rw-r--r--src/fluxbox.cc22
-rw-r--r--src/fluxbox.hh2
12 files changed, 75 insertions, 41 deletions
diff --git a/src/FocusableList.cc b/src/FocusableList.cc
index 094a9b5..b06faac 100644
--- a/src/FocusableList.cc
+++ b/src/FocusableList.cc
@@ -28,6 +28,7 @@
28#include "Window.hh" 28#include "Window.hh"
29 29
30#include "FbTk/StringUtil.hh" 30#include "FbTk/StringUtil.hh"
31#include "FbTk/MemFun.hh"
31 32
32#include <vector> 33#include <vector>
33 34
@@ -95,8 +96,10 @@ void FocusableList::init() {
95 m_parent->attachChild(*this); 96 m_parent->attachChild(*this);
96 97
97 // TODO: can't handle (head=[mouse]) yet 98 // TODO: can't handle (head=[mouse]) yet
98 if (m_pat->dependsOnCurrentWorkspace()) 99 if (m_pat->dependsOnCurrentWorkspace()) {
99 m_screen.currentWorkspaceSig().attach(this); 100 join(m_screen.currentWorkspaceSig(),
101 FbTk::MemFun(*this, &FocusableList::workspaceChanged));
102 }
100 if (m_pat->dependsOnFocusedWindow()) 103 if (m_pat->dependsOnFocusedWindow())
101 m_screen.focusedWindowSig().attach(this); 104 m_screen.focusedWindowSig().attach(this);
102} 105}
@@ -147,8 +150,7 @@ void FocusableList::update(FbTk::Subject *subj) {
147 if (insertFromParent(*win)) 150 if (insertFromParent(*win))
148 m_ordersig.notify(win); 151 m_ordersig.notify(win);
149 } 152 }
150 } else if (subj == &m_screen.currentWorkspaceSig() || 153 } else if (subj == &m_screen.focusedWindowSig())
151 subj == &m_screen.focusedWindowSig())
152 reset(); 154 reset();
153} 155}
154 156
@@ -309,3 +311,7 @@ void FocusableList::attachChild(FocusableList &child) const {
309 m_resetsig.attach(&child); 311 m_resetsig.attach(&child);
310 m_ordersig.attach(&child); 312 m_ordersig.attach(&child);
311} 313}
314
315void FocusableList::workspaceChanged(BScreen &screen) {
316 reset();
317}
diff --git a/src/FocusableList.hh b/src/FocusableList.hh
index a72e2f0..1dd8437 100644
--- a/src/FocusableList.hh
+++ b/src/FocusableList.hh
@@ -25,6 +25,7 @@
25#include "FbTk/NotCopyable.hh" 25#include "FbTk/NotCopyable.hh"
26#include "FbTk/Observer.hh" 26#include "FbTk/Observer.hh"
27#include "FbTk/Subject.hh" 27#include "FbTk/Subject.hh"
28#include "FbTk/Signal.hh"
28 29
29#include "ClientPattern.hh" 30#include "ClientPattern.hh"
30 31
@@ -35,7 +36,8 @@
35class BScreen; 36class BScreen;
36class Focusable; 37class Focusable;
37 38
38class FocusableList: public FbTk::Observer, private FbTk::NotCopyable { 39class FocusableList: public FbTk::Observer, private FbTk::NotCopyable,
40 private FbTk::SignalTracker {
39public: 41public:
40 typedef std::list<Focusable *> Focusables; 42 typedef std::list<Focusable *> Focusables;
41 43
@@ -110,6 +112,7 @@ private:
110 void detachSignals(Focusable &win); 112 void detachSignals(Focusable &win);
111 void reset(); 113 void reset();
112 void attachChild(FocusableList &child) const; 114 void attachChild(FocusableList &child) const;
115 void workspaceChanged(BScreen& screen);
113 116
114 std::auto_ptr<ClientPattern> m_pat; 117 std::auto_ptr<ClientPattern> m_pat;
115 const FocusableList *m_parent; 118 const FocusableList *m_parent;
diff --git a/src/Screen.cc b/src/Screen.cc
index 83bc92e..06f3146 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -343,7 +343,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
343 m_iconlist_sig(*this), // icon list signal 343 m_iconlist_sig(*this), // icon list signal
344 m_workspacenames_sig(*this), // workspace names signal 344 m_workspacenames_sig(*this), // workspace names signal
345 m_workspace_area_sig(*this), // workspace area signal 345 m_workspace_area_sig(*this), // workspace area signal
346 m_currentworkspace_sig(*this), // current workspace signal
347 m_focusedwindow_sig(*this), // focused window signal 346 m_focusedwindow_sig(*this), // focused window signal
348 m_reconfigure_sig(*this), // reconfigure signal 347 m_reconfigure_sig(*this), // reconfigure signal
349 m_resize_sig(*this), 348 m_resize_sig(*this),
@@ -1199,7 +1198,7 @@ void BScreen::changeWorkspaceID(unsigned int id, bool revert) {
1199 1198
1200 FbTk::App::instance()->sync(false); 1199 FbTk::App::instance()->sync(false);
1201 1200
1202 m_currentworkspace_sig.notify(); 1201 m_currentworkspace_sig.emit(*this);
1203 1202
1204 // do this after atom handlers, so scripts can access new workspace number 1203 // do this after atom handlers, so scripts can access new workspace number
1205 Fluxbox::instance()->keys()->doAction(FocusIn, 0, 0, Keys::ON_DESKTOP); 1204 Fluxbox::instance()->keys()->doAction(FocusIn, 0, 0, Keys::ON_DESKTOP);
diff --git a/src/Screen.hh b/src/Screen.hh
index 3f57c22..bbfe70b 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -220,7 +220,7 @@ public:
220 /// workspace area signal 220 /// workspace area signal
221 FbTk::Subject &workspaceAreaSig() { return m_workspace_area_sig; } 221 FbTk::Subject &workspaceAreaSig() { return m_workspace_area_sig; }
222 /// current workspace signal 222 /// current workspace signal
223 FbTk::Subject &currentWorkspaceSig() { return m_currentworkspace_sig; } 223 FbTk::Signal<void, BScreen&> &currentWorkspaceSig() { return m_currentworkspace_sig; }
224 /// focused window signal 224 /// focused window signal
225 FbTk::Subject &focusedWindowSig() { return m_focusedwindow_sig; } 225 FbTk::Subject &focusedWindowSig() { return m_focusedwindow_sig; }
226 /// reconfigure signal 226 /// reconfigure signal
@@ -496,13 +496,13 @@ private:
496 m_iconlist_sig, ///< notify if a window gets iconified/deiconified 496 m_iconlist_sig, ///< notify if a window gets iconified/deiconified
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
500 m_focusedwindow_sig, ///< focused window signal 499 m_focusedwindow_sig, ///< focused window signal
501 m_reconfigure_sig, ///< reconfigure signal 500 m_reconfigure_sig, ///< reconfigure signal
502 m_resize_sig, ///< resize signal 501 m_resize_sig, ///< resize signal
503 m_bg_change_sig; ///< background change signal 502 m_bg_change_sig; ///< background change signal
504 503
505 FbTk::Signal<void, BScreen&> m_workspacecount_sig; ///< workspace count signal 504 FbTk::Signal<void, BScreen&> m_workspacecount_sig; ///< workspace count signal
505 FbTk::Signal<void, BScreen&> m_currentworkspace_sig; ///< current workspace signal
506 FbTk::MultLayers m_layermanager; 506 FbTk::MultLayers m_layermanager;
507 507
508 bool root_colormap_installed, managed; 508 bool root_colormap_installed, managed;
diff --git a/src/SendToMenu.cc b/src/SendToMenu.cc
index 397ec81..ac7612b 100644
--- a/src/SendToMenu.cc
+++ b/src/SendToMenu.cc
@@ -58,11 +58,14 @@ SendToMenu::SendToMenu(BScreen &screen):
58 m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu); 58 m_rebuildObs = makeObserver(*this, &SendToMenu::rebuildMenu);
59 59
60 screen.workspaceNamesSig().attach(m_rebuildObs); 60 screen.workspaceNamesSig().attach(m_rebuildObs);
61 screen.currentWorkspaceSig().attach(m_rebuildObs); 61
62 // setup new signal system
63 join( screen.currentWorkspaceSig(),
64 FbTk::MemFun(*this, &SendToMenu::rebuildMenuForScreen));
62 65
63 // setup new signal system 66 // setup new signal system
64 join( screen.workspaceCountSig(), 67 join( screen.workspaceCountSig(),
65 FbTk::MemFun(*this, &SendToMenu::workspaceCountChange) ); 68 FbTk::MemFun(*this, &SendToMenu::rebuildMenuForScreen));
66 69
67 // no title for this menu, it should be a submenu in the window menu. 70 // no title for this menu, it should be a submenu in the window menu.
68 disableTitle(); 71 disableTitle();
diff --git a/src/SendToMenu.hh b/src/SendToMenu.hh
index 1582dd5..a217b5f 100644
--- a/src/SendToMenu.hh
+++ b/src/SendToMenu.hh
@@ -46,7 +46,7 @@ public:
46 void show(); 46 void show();
47private: 47private:
48 /// workspace count changed on screen 48 /// workspace count changed on screen
49 void workspaceCountChange( BScreen& screen ) { 49 void rebuildMenuForScreen( BScreen& screen ) {
50 rebuildMenu(); 50 rebuildMenu();
51 } 51 }
52 52
diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc
index 33cfb7f..dd7b96e 100644
--- a/src/WorkspaceMenu.cc
+++ b/src/WorkspaceMenu.cc
@@ -83,24 +83,26 @@ void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) {
83 updateMenu(-1); 83 updateMenu(-1);
84} 84}
85 85
86void WorkspaceMenu::workspaceChanged(BScreen& screen) {
87 FbTk::MenuItem *item = 0;
88 for (unsigned int i = 0; i < screen.numberOfWorkspaces(); ++i) {
89 item = find(i + IDX_AFTER_ICONS);
90 if (item && item->isSelected()) {
91 setItemSelected(i + IDX_AFTER_ICONS, false);
92 updateMenu(i + IDX_AFTER_ICONS);
93 break;
94 }
95 }
96 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
97 updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS);
98}
99
86void WorkspaceMenu::update(FbTk::Subject *subj) { 100void WorkspaceMenu::update(FbTk::Subject *subj) {
87 101
88 if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) { 102 if (subj != 0 && typeid(*subj) == typeid(BScreen::ScreenSubject)) {
89 BScreen::ScreenSubject &screen_subj = *static_cast<BScreen::ScreenSubject *>(subj); 103 BScreen::ScreenSubject &screen_subj = *static_cast<BScreen::ScreenSubject *>(subj);
90 BScreen &screen = screen_subj.screen(); 104 BScreen &screen = screen_subj.screen();
91 if (subj == &screen.currentWorkspaceSig()) { 105 if ( subj == &screen.workspaceNamesSig() ) {
92 FbTk::MenuItem *item = 0;
93 for (unsigned int i = 0; i < screen.numberOfWorkspaces(); ++i) {
94 item = find(i + IDX_AFTER_ICONS);
95 if (item && item->isSelected()) {
96 setItemSelected(i + IDX_AFTER_ICONS, false);
97 updateMenu(i + IDX_AFTER_ICONS);
98 break;
99 }
100 }
101 setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
102 updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS);
103 } else if ( subj == &screen.workspaceNamesSig() ) {
104 workspaceInfoChanged( screen ); 106 workspaceInfoChanged( screen );
105 } 107 }
106 } else { 108 } else {
@@ -109,12 +111,13 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
109} 111}
110 112
111void WorkspaceMenu::init(BScreen &screen) { 113void WorkspaceMenu::init(BScreen &screen) {
112 screen.currentWorkspaceSig().attach(this);
113 114
114 screen.workspaceNamesSig().attach(this); 115 screen.workspaceNamesSig().attach(this);
115 116
116 join( screen.workspaceCountSig(), 117 join(screen.currentWorkspaceSig(),
117 FbTk::MemFun( *this, &WorkspaceMenu::workspaceInfoChanged ) ); 118 FbTk::MemFun(*this, &WorkspaceMenu::workspaceChanged));
119 join(screen.workspaceCountSig(),
120 FbTk::MemFun(*this, &WorkspaceMenu::workspaceInfoChanged));
118 121
119 using namespace FbTk; 122 using namespace FbTk;
120 _FB_USES_NLS; 123 _FB_USES_NLS;
diff --git a/src/WorkspaceMenu.hh b/src/WorkspaceMenu.hh
index e8a671d..19cf0f8 100644
--- a/src/WorkspaceMenu.hh
+++ b/src/WorkspaceMenu.hh
@@ -45,7 +45,9 @@ private:
45 void init(BScreen &screen); 45 void init(BScreen &screen);
46 /// Called when workspace info was changed 46 /// Called when workspace info was changed
47 /// ( number of workspace, workspace names etc ) 47 /// ( number of workspace, workspace names etc )
48 void workspaceInfoChanged( BScreen& screen ); 48 void workspaceInfoChanged(BScreen& screen);
49 /// Called when workspace was switched.
50 void workspaceChanged(BScreen& screen);
49}; 51};
50 52
51#endif // WORKSPACEMENU_HH 53#endif // WORKSPACEMENU_HH
diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc
index 6c73df5..b6afad8 100644
--- a/src/WorkspaceNameTool.cc
+++ b/src/WorkspaceNameTool.cc
@@ -27,6 +27,7 @@
27#include "Workspace.hh" 27#include "Workspace.hh"
28 28
29#include "FbTk/ImageControl.hh" 29#include "FbTk/ImageControl.hh"
30#include "FbTk/MemFun.hh"
30 31
31#include <algorithm> 32#include <algorithm>
32 33
@@ -43,7 +44,10 @@ WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent,
43 44
44 // setup signals 45 // setup signals
45 screen.workspaceNamesSig().attach(this); 46 screen.workspaceNamesSig().attach(this);
46 screen.currentWorkspaceSig().attach(this); 47
48 join(screen.currentWorkspaceSig(),
49 FbTk::MemFun(*this, &WorkspaceNameTool::updateForScreen));
50
47 theme.reconfigSig().attach(this); 51 theme.reconfigSig().attach(this);
48} 52}
49 53
@@ -67,8 +71,11 @@ void WorkspaceNameTool::moveResize(int x, int y,
67} 71}
68 72
69void WorkspaceNameTool::update(FbTk::Subject *subj) { 73void WorkspaceNameTool::update(FbTk::Subject *subj) {
74 updateForScreen(m_screen);
75}
70 76
71 m_button.setText(m_screen.currentWorkspace()->name()); 77void WorkspaceNameTool::updateForScreen(BScreen &screen) {
78 m_button.setText(screen.currentWorkspace()->name());
72 if (m_button.width() != width()) { 79 if (m_button.width() != width()) {
73 resize(width(), height()); 80 resize(width(), height());
74 resizeSig().notify(); 81 resizeSig().notify();
diff --git a/src/WorkspaceNameTool.hh b/src/WorkspaceNameTool.hh
index 0bdb528..bd034b7 100644
--- a/src/WorkspaceNameTool.hh
+++ b/src/WorkspaceNameTool.hh
@@ -27,6 +27,7 @@
27 27
28#include "FbTk/TextButton.hh" 28#include "FbTk/TextButton.hh"
29#include "FbTk/Observer.hh" 29#include "FbTk/Observer.hh"
30#include "FbTk/Signal.hh"
30 31
31class BScreen; 32class BScreen;
32class ToolTheme; 33class ToolTheme;
@@ -35,7 +36,8 @@ namespace FbTk {
35template <class T> class ThemeProxy; 36template <class T> class ThemeProxy;
36} 37}
37 38
38class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer { 39class WorkspaceNameTool: public ToolbarItem, public FbTk::Observer,
40 private FbTk::SignalTracker {
39public: 41public:
40 WorkspaceNameTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy<ToolTheme> &theme, BScreen &screen); 42 WorkspaceNameTool(const FbTk::FbWindow &parent, FbTk::ThemeProxy<ToolTheme> &theme, BScreen &screen);
41 virtual ~WorkspaceNameTool(); 43 virtual ~WorkspaceNameTool();
@@ -59,6 +61,9 @@ public:
59 void parentMoved() { m_button.parentMoved(); } 61 void parentMoved() { m_button.parentMoved(); }
60 62
61private: 63private:
64 /// Called when workspace changed on \c screen
65 void updateForScreen(BScreen &screen);
66
62 void renderTheme(unsigned char alpha); 67 void renderTheme(unsigned char alpha);
63 void reRender(); 68 void reRender();
64 void updateSizing(); 69 void updateSizing();
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 9e62ac3..acbb55d 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -453,14 +453,16 @@ void Fluxbox::initScreen(BScreen *screen) {
453 screen->initWindows(); 453 screen->initWindows();
454 454
455 // attach screen signals to this 455 // attach screen signals to this
456 screen->currentWorkspaceSig().attach(this);
457 screen->focusedWindowSig().attach(this); 456 screen->focusedWindowSig().attach(this);
458 screen->workspaceNamesSig().attach(this); 457 screen->workspaceNamesSig().attach(this);
459 screen->workspaceAreaSig().attach(this); 458 screen->workspaceAreaSig().attach(this);
460 screen->clientListSig().attach(this); 459 screen->clientListSig().attach(this);
461 460
462 join( screen->workspaceCountSig(), 461 join(screen->currentWorkspaceSig(),
463 FbTk::MemFun( *this, &Fluxbox::workspaceCountChanged ) ); 462 FbTk::MemFun(*this, &Fluxbox::workspaceChanged));
463
464 join(screen->workspaceCountSig(),
465 FbTk::MemFun(*this, &Fluxbox::workspaceCountChanged));
464 466
465 // initiate atomhandler for screen specific stuff 467 // initiate atomhandler for screen specific stuff
466 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 468 for (AtomHandlerContainerIt it= m_atomhandler.begin();
@@ -1106,12 +1108,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1106 if ((*it).first->update()) 1108 if ((*it).first->update())
1107 (*it).first->updateWorkspaceNames(screen); 1109 (*it).first->updateWorkspaceNames(screen);
1108 } 1110 }
1109 } else if ((&(screen.currentWorkspaceSig())) == changedsub) {
1110 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1111 it != m_atomhandler.end(); ++it) {
1112 if ((*it).first->update())
1113 (*it).first->updateCurrentWorkspace(screen);
1114 }
1115 } else if ((&(screen.focusedWindowSig())) == changedsub) { 1111 } else if ((&(screen.focusedWindowSig())) == changedsub) {
1116 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1112 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1117 it != m_atomhandler.end(); it++) { 1113 it != m_atomhandler.end(); it++) {
@@ -1526,3 +1522,11 @@ void Fluxbox::workspaceCountChanged( BScreen& screen ) {
1526 (*it).first->updateWorkspaceCount(screen); 1522 (*it).first->updateWorkspaceCount(screen);
1527 } 1523 }
1528} 1524}
1525
1526void Fluxbox::workspaceChanged( BScreen& screen ) {
1527 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1528 it != m_atomhandler.end(); ++it) {
1529 if ((*it).first->update())
1530 (*it).first->updateCurrentWorkspace(screen);
1531 }
1532}
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 8478833..36208b6 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -203,6 +203,8 @@ private:
203 203
204 /// Called when workspace count on a specific screen changed. 204 /// Called when workspace count on a specific screen changed.
205 void workspaceCountChanged( BScreen& screen ); 205 void workspaceCountChanged( BScreen& screen );
206 /// Called when workspace was switched
207 void workspaceChanged(BScreen& screen);
206 208
207 std::auto_ptr<FbAtoms> m_fbatoms; 209 std::auto_ptr<FbAtoms> m_fbatoms;
208 210