diff options
Diffstat (limited to 'src/Workspace.cc')
-rw-r--r-- | src/Workspace.cc | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc index 83db8ef..236aadb 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc | |||
@@ -67,7 +67,14 @@ | |||
67 | #include <iostream> | 67 | #include <iostream> |
68 | #include <iterator> | 68 | #include <iterator> |
69 | 69 | ||
70 | using namespace std; | 70 | using std::string; |
71 | using std::vector; | ||
72 | using std::ifstream; | ||
73 | |||
74 | #ifdef DEBUG | ||
75 | using std::cerr; | ||
76 | using std::endl; | ||
77 | #endif // DEBUG | ||
71 | 78 | ||
72 | namespace { // anonymous | 79 | namespace { // anonymous |
73 | 80 | ||
@@ -75,7 +82,7 @@ int countTransients(const WinClient &client) { | |||
75 | if (client.transientList().empty()) | 82 | if (client.transientList().empty()) |
76 | return 0; | 83 | return 0; |
77 | // now go throu the entire tree and count transients | 84 | // now go throu the entire tree and count transients |
78 | size_t ret = client.transientList().size(); | 85 | size_t ret = client.transientList().size(); |
79 | WinClient::TransientList::const_iterator it = client.transientList().begin(); | 86 | WinClient::TransientList::const_iterator it = client.transientList().begin(); |
80 | WinClient::TransientList::const_iterator it_end = client.transientList().end(); | 87 | WinClient::TransientList::const_iterator it_end = client.transientList().end(); |
81 | for (; it != it_end; ++it) | 88 | for (; it != it_end; ++it) |
@@ -89,7 +96,7 @@ public: | |||
89 | ClientMenuItem(WinClient &client): | 96 | ClientMenuItem(WinClient &client): |
90 | FbTk::MenuItem(client.title().c_str(), &client.screen().windowMenu()), | 97 | FbTk::MenuItem(client.title().c_str(), &client.screen().windowMenu()), |
91 | m_client(client) { | 98 | m_client(client) { |
92 | 99 | ||
93 | } | 100 | } |
94 | FbTk::Menu *submenu() { return &m_client.screen().windowMenu(); } | 101 | FbTk::Menu *submenu() { return &m_client.screen().windowMenu(); } |
95 | const FbTk::Menu *submenu() const { return &m_client.screen().windowMenu(); } | 102 | const FbTk::Menu *submenu() const { return &m_client.screen().windowMenu(); } |
@@ -123,14 +130,14 @@ public: | |||
123 | win.raiseAndFocus(); | 130 | win.raiseAndFocus(); |
124 | } | 131 | } |
125 | 132 | ||
126 | const std::string &label() const { return m_client.title(); } | 133 | const string &label() const { return m_client.title(); } |
127 | bool isSelected() const { | 134 | bool isSelected() const { |
128 | if (m_client.fbwindow() == 0) | 135 | if (m_client.fbwindow() == 0) |
129 | return false; | 136 | return false; |
130 | if (m_client.fbwindow()->isFocused() == false) | 137 | if (m_client.fbwindow()->isFocused() == false) |
131 | return false; | 138 | return false; |
132 | return (&(m_client.fbwindow()->winClient()) == &m_client); | 139 | return (&(m_client.fbwindow()->winClient()) == &m_client); |
133 | 140 | ||
134 | } | 141 | } |
135 | private: | 142 | private: |
136 | WinClient &m_client; | 143 | WinClient &m_client; |
@@ -140,8 +147,8 @@ private: | |||
140 | 147 | ||
141 | Workspace::GroupList Workspace::m_groups; | 148 | Workspace::GroupList Workspace::m_groups; |
142 | 149 | ||
143 | Workspace::Workspace(BScreen &scrn, FbTk::MultLayers &layermanager, | 150 | Workspace::Workspace(BScreen &scrn, FbTk::MultLayers &layermanager, |
144 | const std::string &name, unsigned int id): | 151 | const string &name, unsigned int id): |
145 | m_screen(scrn), | 152 | m_screen(scrn), |
146 | m_clientmenu(scrn.menuTheme(), scrn.imageControl(), | 153 | m_clientmenu(scrn.menuTheme(), scrn.imageControl(), |
147 | *scrn.layerManager().getLayer(Layer::MENU)), | 154 | *scrn.layerManager().getLayer(Layer::MENU)), |
@@ -174,9 +181,9 @@ void Workspace::addWindow(FluxboxWindow &w, bool place) { | |||
174 | updateClientmenu(); | 181 | updateClientmenu(); |
175 | 182 | ||
176 | if (!w.isStuck()) { | 183 | if (!w.isStuck()) { |
177 | FluxboxWindow::ClientList::iterator client_it = | 184 | FluxboxWindow::ClientList::iterator client_it = |
178 | w.clientList().begin(); | 185 | w.clientList().begin(); |
179 | FluxboxWindow::ClientList::iterator client_it_end = | 186 | FluxboxWindow::ClientList::iterator client_it_end = |
180 | w.clientList().end(); | 187 | w.clientList().end(); |
181 | for (; client_it != client_it_end; ++client_it) | 188 | for (; client_it != client_it_end; ++client_it) |
182 | screen().updateNetizenWindowAdd((*client_it)->window(), m_id); | 189 | screen().updateNetizenWindowAdd((*client_it)->window(), m_id); |
@@ -185,7 +192,7 @@ void Workspace::addWindow(FluxboxWindow &w, bool place) { | |||
185 | } | 192 | } |
186 | 193 | ||
187 | // still_alive is true if the window will continue to exist after | 194 | // still_alive is true if the window will continue to exist after |
188 | // this event. Particularly, this isn't the removeWindow for | 195 | // this event. Particularly, this isn't the removeWindow for |
189 | // the destruction of the window. Because if so, the focus revert | 196 | // the destruction of the window. Because if so, the focus revert |
190 | // is done in another place | 197 | // is done in another place |
191 | int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { | 198 | int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { |
@@ -198,9 +205,9 @@ int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { | |||
198 | 205 | ||
199 | if (w->isFocused() && still_alive) | 206 | if (w->isFocused() && still_alive) |
200 | FocusControl::unfocusWindow(w->winClient(), true, true); | 207 | FocusControl::unfocusWindow(w->winClient(), true, true); |
201 | 208 | ||
202 | // we don't remove it from the layermanager, as it may be being moved | 209 | // we don't remove it from the layermanager, as it may be being moved |
203 | Windows::iterator erase_it = remove(m_windowlist.begin(), | 210 | Windows::iterator erase_it = remove(m_windowlist.begin(), |
204 | m_windowlist.end(), w); | 211 | m_windowlist.end(), w); |
205 | if (erase_it != m_windowlist.end()) | 212 | if (erase_it != m_windowlist.end()) |
206 | m_windowlist.erase(erase_it); | 213 | m_windowlist.erase(erase_it); |
@@ -208,9 +215,9 @@ int Workspace::removeWindow(FluxboxWindow *w, bool still_alive) { | |||
208 | updateClientmenu(); | 215 | updateClientmenu(); |
209 | 216 | ||
210 | if (!w->isStuck()) { | 217 | if (!w->isStuck()) { |
211 | FluxboxWindow::ClientList::iterator client_it = | 218 | FluxboxWindow::ClientList::iterator client_it = |
212 | w->clientList().begin(); | 219 | w->clientList().begin(); |
213 | FluxboxWindow::ClientList::iterator client_it_end = | 220 | FluxboxWindow::ClientList::iterator client_it_end = |
214 | w->clientList().end(); | 221 | w->clientList().end(); |
215 | for (; client_it != client_it_end; ++client_it) | 222 | for (; client_it != client_it_end; ++client_it) |
216 | screen().updateNetizenWindowDel((*client_it)->window()); | 223 | screen().updateNetizenWindowDel((*client_it)->window()); |
@@ -308,8 +315,8 @@ bool Workspace::checkGrouping(FluxboxWindow &win) { | |||
308 | #ifdef DEBUG | 315 | #ifdef DEBUG |
309 | cerr<<__FILE__<<" check group with : "<<(*wit)->winClient().getWMClassName()<<endl; | 316 | cerr<<__FILE__<<" check group with : "<<(*wit)->winClient().getWMClassName()<<endl; |
310 | #endif // DEBUG | 317 | #endif // DEBUG |
311 | if (find_if((*g).begin(), | 318 | if (find_if((*g).begin(), |
312 | (*g).end(), | 319 | (*g).end(), |
313 | FindInGroup(*(*wit))) != (*g).end()) { | 320 | FindInGroup(*(*wit))) != (*g).end()) { |
314 | // make sure the window is groupable | 321 | // make sure the window is groupable |
315 | // and don't group with ourself | 322 | // and don't group with ourself |
@@ -321,9 +328,9 @@ bool Workspace::checkGrouping(FluxboxWindow &win) { | |||
321 | (*wit)->attachClient(win.winClient()); | 328 | (*wit)->attachClient(win.winClient()); |
322 | (*wit)->raise(); | 329 | (*wit)->raise(); |
323 | return true; // grouping done | 330 | return true; // grouping done |
324 | 331 | ||
325 | } | 332 | } |
326 | 333 | ||
327 | } | 334 | } |
328 | 335 | ||
329 | } | 336 | } |
@@ -333,7 +340,7 @@ bool Workspace::checkGrouping(FluxboxWindow &win) { | |||
333 | return false; | 340 | return false; |
334 | } | 341 | } |
335 | 342 | ||
336 | bool Workspace::loadGroups(const std::string &filename) { | 343 | bool Workspace::loadGroups(const string &filename) { |
337 | string real_filename = FbTk::StringUtil::expandFilename(filename); | 344 | string real_filename = FbTk::StringUtil::expandFilename(filename); |
338 | FbTk::StringUtil::removeTrailingWhitespace(real_filename); | 345 | FbTk::StringUtil::removeTrailingWhitespace(real_filename); |
339 | ifstream infile(real_filename.c_str()); | 346 | ifstream infile(real_filename.c_str()); |
@@ -350,7 +357,7 @@ bool Workspace::loadGroups(const std::string &filename) { | |||
350 | FbTk::StringUtil::stringtok(names, line); | 357 | FbTk::StringUtil::stringtok(names, line); |
351 | m_groups.push_back(names); | 358 | m_groups.push_back(names); |
352 | } | 359 | } |
353 | 360 | ||
354 | return true; | 361 | return true; |
355 | } | 362 | } |
356 | 363 | ||
@@ -359,18 +366,18 @@ void Workspace::update(FbTk::Subject *subj) { | |||
359 | } | 366 | } |
360 | 367 | ||
361 | 368 | ||
362 | void Workspace::setName(const std::string &name) { | 369 | void Workspace::setName(const string &name) { |
363 | if (!name.empty() && name != "") { | 370 | if (!name.empty() && name != "") { |
364 | m_name = name; | 371 | m_name = name; |
365 | } else { //if name == 0 then set default name from nls | 372 | } else { //if name == 0 then set default name from nls |
366 | _FB_USES_NLS; | 373 | _FB_USES_NLS; |
367 | char tname[128]; | 374 | char tname[128]; |
368 | sprintf(tname, | 375 | sprintf(tname, |
369 | _FB_XTEXT(Workspace, DefaultNameFormat, | 376 | _FB_XTEXT(Workspace, DefaultNameFormat, |
370 | "Workspace %d", "Default workspace names, with a %d for the workspace number").c_str(), | 377 | "Workspace %d", "Default workspace names, with a %d for the workspace number").c_str(), |
371 | m_id + 1); //m_id starts at 0 | 378 | m_id + 1); //m_id starts at 0 |
372 | } | 379 | } |
373 | 380 | ||
374 | screen().updateWorkspaceNamesAtom(); | 381 | screen().updateWorkspaceNamesAtom(); |
375 | 382 | ||
376 | menu().setLabel(m_name); | 383 | menu().setLabel(m_name); |
@@ -386,21 +393,21 @@ void Workspace::shutdown() { | |||
386 | // note: when the window dies it'll remove it self from the list | 393 | // note: when the window dies it'll remove it self from the list |
387 | while (!m_windowlist.empty()) { | 394 | while (!m_windowlist.empty()) { |
388 | //delete window (the window removes it self from m_windowlist) | 395 | //delete window (the window removes it self from m_windowlist) |
389 | delete m_windowlist.back(); | 396 | delete m_windowlist.back(); |
390 | } | 397 | } |
391 | } | 398 | } |
392 | 399 | ||
393 | void Workspace::updateClientmenu() { | 400 | void Workspace::updateClientmenu() { |
394 | // remove all items and then add them again | 401 | // remove all items and then add them again |
395 | menu().removeAll(); | 402 | menu().removeAll(); |
396 | // for each fluxboxwindow add every client in them to our clientlist | 403 | // for each fluxboxwindow add every client in them to our clientlist |
397 | Windows::iterator win_it = m_windowlist.begin(); | 404 | Windows::iterator win_it = m_windowlist.begin(); |
398 | Windows::iterator win_it_end = m_windowlist.end(); | 405 | Windows::iterator win_it_end = m_windowlist.end(); |
399 | for (; win_it != win_it_end; ++win_it) { | 406 | for (; win_it != win_it_end; ++win_it) { |
400 | // add every client in this fluxboxwindow to menu | 407 | // add every client in this fluxboxwindow to menu |
401 | FluxboxWindow::ClientList::iterator client_it = | 408 | FluxboxWindow::ClientList::iterator client_it = |
402 | (*win_it)->clientList().begin(); | 409 | (*win_it)->clientList().begin(); |
403 | FluxboxWindow::ClientList::iterator client_it_end = | 410 | FluxboxWindow::ClientList::iterator client_it_end = |
404 | (*win_it)->clientList().end(); | 411 | (*win_it)->clientList().end(); |
405 | for (; client_it != client_it_end; ++client_it) | 412 | for (; client_it != client_it_end; ++client_it) |
406 | menu().insert(new ClientMenuItem(*(*client_it))); | 413 | menu().insert(new ClientMenuItem(*(*client_it))); |
@@ -411,7 +418,7 @@ void Workspace::updateClientmenu() { | |||
411 | 418 | ||
412 | void Workspace::placeWindow(FluxboxWindow &win) { | 419 | void Workspace::placeWindow(FluxboxWindow &win) { |
413 | int place_x, place_y; | 420 | int place_x, place_y; |
414 | // we ignore the return value, | 421 | // we ignore the return value, |
415 | // the screen placement strategy is guaranteed to succeed. | 422 | // the screen placement strategy is guaranteed to succeed. |
416 | screen().placementStrategy().placeWindow(m_windowlist, | 423 | screen().placementStrategy().placeWindow(m_windowlist, |
417 | win, | 424 | win, |