make ShowDesktop and Deiconify commands maintain focus order

This commit is contained in:
Mark Tiefenbruck 2008-08-23 05:44:11 -07:00
parent e3fb16c993
commit 6875a611dc

View file

@ -488,28 +488,33 @@ void ShowDesktopCmd::execute() {
if (screen == 0) if (screen == 0)
return; return;
// iconify windows in focus order, so it gets restored properly
const std::list<Focusable *> wins =
screen->focusControl().focusedOrderWinList().clientList();
std::list<Focusable *>::const_iterator it = wins.begin(),
it_end = wins.end();
unsigned int space = screen->currentWorkspaceID();
unsigned int count = 0; unsigned int count = 0;
Workspace::Windows windows(screen->currentWorkspace()->windowList());
Workspace::Windows::iterator it = windows.begin(),
it_end = windows.end();
for (; it != it_end; ++it) { for (; it != it_end; ++it) {
if ((*it)->layerNum() < Layer::DESKTOP) { if (!(*it)->fbwindow()->isIconic() && ((*it)->fbwindow()->isStuck() ||
(*it)->iconify(); (*it)->fbwindow()->workspaceNumber() == space) &&
(*it)->fbwindow()->layerNum() < Layer::DESKTOP) {
(*it)->fbwindow()->iconify();
count++; count++;
} }
} }
if (count == 0) { if (count == 0) {
BScreen::Icons icon_list = screen->iconList(); BScreen::Icons icon_list = screen->iconList();
BScreen::Icons::iterator icon_it = icon_list.begin(); BScreen::Icons::reverse_iterator iconit = icon_list.rbegin();
BScreen::Icons::iterator itend = icon_list.end(); BScreen::Icons::reverse_iterator itend= icon_list.rend();
unsigned int space = screen->currentWorkspaceID(); for(; iconit != itend; iconit++) {
if ((*iconit)->workspaceNumber() == space || (*iconit)->isStuck())
for (; icon_it != itend; ++icon_it) { (*iconit)->deiconify(false);
if ((*icon_it)->isStuck() || (*icon_it)->workspaceNumber() == space)
(*icon_it)->deiconify();
} }
} } else
FocusControl::revertFocus(*screen);
} }
REGISTER_COMMAND(closeallwindows, CloseAllWindowsCmd, void); REGISTER_COMMAND(closeallwindows, CloseAllWindowsCmd, void);