diff options
Diffstat (limited to 'src/WorkspaceMenu.cc')
-rw-r--r-- | src/WorkspaceMenu.cc | 35 |
1 files changed, 19 insertions, 16 deletions
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 | ||
86 | void 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 | |||
86 | void WorkspaceMenu::update(FbTk::Subject *subj) { | 100 | void 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 | ||
111 | void WorkspaceMenu::init(BScreen &screen) { | 113 | void 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; |