X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fscreen.cc;h=0c90d747b9de86e63eeef0121e4e17fa0076b0c4;hb=22b5d6458e3001a7bd930bf3491bf7fcd26ac3ce;hp=dfcc8375d055613f2cfb6749f2e166ac5a252405;hpb=f305e7f18dd9745e99518da7ca70183c3084a991;p=chaz%2Fopenbox diff --git a/src/screen.cc b/src/screen.cc index dfcc8375..0c90d747 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -111,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; @@ -397,13 +403,13 @@ void Screen::changeSupportedAtoms() otk::Property::atoms.net_client_list_stacking, otk::Property::atoms.net_desktop_names, otk::Property::atoms.net_close_window, + otk::Property::atoms.net_desktop_layout, + otk::Property::atoms.net_showing_desktop, otk::Property::atoms.net_wm_name, otk::Property::atoms.net_wm_visible_name, otk::Property::atoms.net_wm_icon_name, otk::Property::atoms.net_wm_visible_icon_name, -/* otk::Property::atoms.net_wm_desktop, -*/ otk::Property::atoms.net_wm_strut, otk::Property::atoms.net_wm_window_type, otk::Property::atoms.net_wm_window_type_desktop, @@ -878,6 +884,41 @@ void Screen::installColormap(bool install) const XUninstallColormap(**otk::display, _info->colormap()); } +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) { + 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) { @@ -912,6 +953,8 @@ void Screen::clientMessageHandler(const XClientMessageEvent &e) changeDesktop(e.data.l[0]); } else if (e.message_type == otk::Property::atoms.net_number_of_desktops) { changeNumDesktops(e.data.l[0]); + } else if (e.message_type == otk::Property::atoms.net_showing_desktop) { + showDesktop(e.data.l[0] != 0); } } @@ -929,8 +972,11 @@ void Screen::mapRequestHandler(const XMapRequestEvent &e) #ifdef DEBUG printf("DEBUG: MAP REQUEST CAUGHT IN SCREEN. IGNORED.\n"); #endif - } else + } else { + if (_showing_desktop) + showDesktop(false); // leave showing-the-desktop mode manageWindow(e.window); + } } }