X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fscreen.cc;h=f5cc00922125f9068040504c56bf4ad456531913;hb=0e06aab5321d461b30af232d88f9f0da381bf27d;hp=3a064560f72dc1aba2961ea61271ecc6c6a5f7c4;hpb=265cf6c9478860336816570a141198d9257a27a1;p=chaz%2Fopenbox diff --git a/src/screen.cc b/src/screen.cc index 3a064560..f5cc0092 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -44,8 +44,6 @@ Screen::Screen(int screen) assert(screen >= 0); assert(screen < ScreenCount(**otk::display)); _info = otk::display->screenInfo(screen); - _showing_desktop = false; - ::running = false; XErrorHandler old = XSetErrorHandler(::anotherWMRunning); XSelectInput(**otk::display, _info->rootWindow(), @@ -113,6 +111,12 @@ Screen::Screen(int screen) changeDesktop(0); // set the hint + // don't start in showing-desktop mode + _showing_desktop = false; + otk::Property::set(_info->rootWindow(), + otk::Property::atoms.net_showing_desktop, + otk::Property::atoms.cardinal, 0); + // create the window which gets focus when no clients get it XSetWindowAttributes attr; attr.override_redirect = true; @@ -863,6 +867,11 @@ void Screen::setDesktopName(unsigned int i, const otk::ustring &name) otk::Property::utf8, newnames); } +otk::ustring Screen::desktopName(unsigned int i) const +{ + if (i >= _num_desktops) return ""; + return _desktop_names[i]; +} const otk::Rect& Screen::area(unsigned int desktop) const { assert(desktop < _num_desktops || desktop == 0xffffffff); @@ -884,10 +893,36 @@ 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; + ClientList::iterator it, end = clients.end(); - for (it = clients.begin(); it != end; ++it) - (*it)->showhide(); + 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); } void Screen::propertyHandler(const XPropertyEvent &e)