diff options
Diffstat (limited to 'src/WorkspaceCmd.cc')
-rw-r--r-- | src/WorkspaceCmd.cc | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc index aba5914..ef7d992 100644 --- a/src/WorkspaceCmd.cc +++ b/src/WorkspaceCmd.cc | |||
@@ -173,7 +173,8 @@ FbTk::Command<void> *parseWindowList(const string &command, | |||
173 | else if (command == "prevgroup") { | 173 | else if (command == "prevgroup") { |
174 | opts |= FocusableList::LIST_GROUPS; | 174 | opts |= FocusableList::LIST_GROUPS; |
175 | return new PrevWindowCmd(opts, pat); | 175 | return new PrevWindowCmd(opts, pat); |
176 | } | 176 | } else if (command == "arrangewindows") |
177 | return new ArrangeWindowsCmd(pat); | ||
177 | return 0; | 178 | return 0; |
178 | } | 179 | } |
179 | 180 | ||
@@ -182,6 +183,7 @@ REGISTER_COMMAND_PARSER(nextwindow, parseWindowList, void); | |||
182 | REGISTER_COMMAND_PARSER(nextgroup, parseWindowList, void); | 183 | REGISTER_COMMAND_PARSER(nextgroup, parseWindowList, void); |
183 | REGISTER_COMMAND_PARSER(prevwindow, parseWindowList, void); | 184 | REGISTER_COMMAND_PARSER(prevwindow, parseWindowList, void); |
184 | REGISTER_COMMAND_PARSER(prevgroup, parseWindowList, void); | 185 | REGISTER_COMMAND_PARSER(prevgroup, parseWindowList, void); |
186 | REGISTER_COMMAND_PARSER(arrangewindows, parseWindowList, void); | ||
185 | 187 | ||
186 | }; // end anonymous namespace | 188 | }; // end anonymous namespace |
187 | 189 | ||
@@ -353,8 +355,6 @@ void JumpToWorkspaceCmd::execute() { | |||
353 | } | 355 | } |
354 | } | 356 | } |
355 | 357 | ||
356 | REGISTER_COMMAND(arrangewindows, ArrangeWindowsCmd, void); | ||
357 | |||
358 | /** | 358 | /** |
359 | try to arrange the windows on the current workspace in a 'clever' way. | 359 | try to arrange the windows on the current workspace in a 'clever' way. |
360 | we take the shaded-windows and put them ontop of the workspace and put the | 360 | we take the shaded-windows and put them ontop of the workspace and put the |
@@ -366,9 +366,8 @@ void ArrangeWindowsCmd::execute() { | |||
366 | return; | 366 | return; |
367 | 367 | ||
368 | Workspace *space = screen->currentWorkspace(); | 368 | Workspace *space = screen->currentWorkspace(); |
369 | size_t win_count = space->windowList().size(); | ||
370 | 369 | ||
371 | if (win_count == 0) | 370 | if (space->windowList().empty()) |
372 | return; | 371 | return; |
373 | 372 | ||
374 | // TODO: choice between | 373 | // TODO: choice between |
@@ -382,20 +381,19 @@ void ArrangeWindowsCmd::execute() { | |||
382 | Workspace::Windows shaded_windows; | 381 | Workspace::Windows shaded_windows; |
383 | for(win = space->windowList().begin(); win != space->windowList().end(); win++) { | 382 | for(win = space->windowList().begin(); win != space->windowList().end(); win++) { |
384 | int winhead = screen->getHead((*win)->fbWindow()); | 383 | int winhead = screen->getHead((*win)->fbWindow()); |
385 | if (winhead == head || winhead == 0) { | 384 | if ((winhead == head || winhead == 0) && m_pat.match(**win)) { |
386 | if (!(*win)->isShaded()) | 385 | if ((*win)->isShaded()) |
387 | normal_windows.push_back(*win); | ||
388 | else | ||
389 | shaded_windows.push_back(*win); | 386 | shaded_windows.push_back(*win); |
387 | else | ||
388 | normal_windows.push_back(*win); | ||
390 | } | 389 | } |
391 | } | 390 | } |
392 | 391 | ||
393 | // to arrange only shaded windows is a bit pointless imho (mathias) | 392 | // to arrange only shaded windows is a bit pointless imho (mathias) |
394 | if (normal_windows.size() == 0) | 393 | size_t win_count = normal_windows.size(); |
394 | if (win_count == 0) | ||
395 | return; | 395 | return; |
396 | 396 | ||
397 | win_count = normal_windows.size(); | ||
398 | |||
399 | const unsigned int max_width = screen->maxRight(head) - screen->maxLeft(head); | 397 | const unsigned int max_width = screen->maxRight(head) - screen->maxLeft(head); |
400 | unsigned int max_height = screen->maxBottom(head) - screen->maxTop(head); | 398 | unsigned int max_height = screen->maxBottom(head) - screen->maxTop(head); |
401 | 399 | ||
@@ -486,12 +484,27 @@ void ShowDesktopCmd::execute() { | |||
486 | if (screen == 0) | 484 | if (screen == 0) |
487 | return; | 485 | return; |
488 | 486 | ||
487 | unsigned int count = 0; | ||
489 | Workspace::Windows windows(screen->currentWorkspace()->windowList()); | 488 | Workspace::Windows windows(screen->currentWorkspace()->windowList()); |
490 | Workspace::Windows::iterator it = windows.begin(), | 489 | Workspace::Windows::iterator it = windows.begin(), |
491 | it_end = windows.end(); | 490 | it_end = windows.end(); |
492 | for (; it != it_end; ++it) { | 491 | for (; it != it_end; ++it) { |
493 | if ((*it)->getWindowType() != Focusable::TYPE_DESKTOP) | 492 | if ((*it)->getWindowType() != Focusable::TYPE_DESKTOP) { |
494 | (*it)->iconify(); | 493 | (*it)->iconify(); |
494 | count++; | ||
495 | } | ||
496 | } | ||
497 | |||
498 | if (count == 0) { | ||
499 | BScreen::Icons icon_list = screen->iconList(); | ||
500 | BScreen::Icons::iterator icon_it = icon_list.begin(); | ||
501 | BScreen::Icons::iterator itend = icon_list.end(); | ||
502 | unsigned int space = screen->currentWorkspaceID(); | ||
503 | |||
504 | for (; icon_it != itend; ++icon_it) { | ||
505 | if ((*icon_it)->isStuck() || (*icon_it)->workspaceNumber() == space) | ||
506 | (*icon_it)->deiconify(); | ||
507 | } | ||
495 | } | 508 | } |
496 | } | 509 | } |
497 | 510 | ||