+void Screen::showDesktop(bool show)
+{
+ if (show == _showing_desktop) return; // no change
+
+ // save the window focus, and restore it when leaving the show-desktop mode
+ static Window saved_focus = 0;
+ if (show) {
+ Client *c = openbox->focusedClient();
+ if (c) saved_focus = c->window();
+ }
+
+ _showing_desktop = show;
+
+ std::list<Client*>::iterator it, end = clients.end();
+ for (it = clients.begin(); it != end; ++it) {
+ if ((*it)->type() == Client::Type_Desktop) {
+ if (show)
+ (*it)->focus();
+ } else
+ (*it)->showhide();
+ }
+
+ if (!show) {
+ Client *f = openbox->focusedClient();
+ if (!f || f->type() == Client::Type_Desktop) {
+ Client *c = openbox->findClient(saved_focus);
+ if (c) c->focus();
+ }
+ }
+
+ otk::Property::set(_info->rootWindow(),
+ otk::Property::atoms.net_showing_desktop,
+ otk::Property::atoms.cardinal,
+ show ? 1 : 0);
+}