X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fscreen.cc;h=6eaa5cc577190461a0ca2fd6022b5705ddfe758e;hb=8cbabdcb93a61110a111f77d6f0f51cf3f6dd834;hp=b556e7acdc3e02d4b1868d753f8c74180d9c3d56;hpb=81c164bbf9ed2462e5f9fb7599fa6f0279a087fa;p=chaz%2Fopenbox diff --git a/src/screen.cc b/src/screen.cc index b556e7ac..6eaa5cc5 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -2,6 +2,16 @@ #include "config.h" +#include "screen.hh" +#include "client.hh" +#include "openbox.hh" +#include "frame.hh" +#include "bindings.hh" +#include "python.hh" +#include "otk/display.hh" +#include "otk/property.hh" +#include "otk/util.hh" + extern "C" { #ifdef HAVE_UNISTD_H # include @@ -12,15 +22,6 @@ extern "C" { #define _(str) gettext(str) } -#include "screen.hh" -#include "client.hh" -#include "openbox.hh" -#include "frame.hh" -#include "bindings.hh" -#include "python.hh" -#include "otk/display.hh" -#include "otk/property.hh" - #include #include #include @@ -66,23 +67,11 @@ Screen::Screen(int screen) XDefineCursor(**otk::display, _info->rootWindow(), openbox->cursors().session); - // XXX: initialize the screen's style - /* - otk::ustring stylepath; - python_get_string("THEME", &stylepath); - otk::Configuration sconfig(false); - sconfig.setFile(otk::expandTilde(stylepath.c_str())); - if (!sconfig.load()) { - sconfig.setFile(otk::expandTilde(DEFAULTSTYLE)); - if (!sconfig.load()) { - printf(_("Unable to load default style: %s. Aborting.\n"), DEFAULTSTYLE); - ::exit(1); - } - } - _style.load(sconfig); - */ - otk::display->renderControl(_number)-> - drawRoot(*otk::RenderStyle::style(_number)->rootColor()); + // initialize the screen's style + otk::RenderStyle::setStyle(_number, _config.theme); + // draw the root window + otk::bexec("obsetroot " + otk::RenderStyle::style(_number)->rootArgs(), + _info->displayString()); // set up notification of netwm support changeSupportedAtoms(); @@ -95,22 +84,24 @@ Screen::Screen(int screen) otk::Property::atoms.cardinal, geometry, 2); // Set the net_desktop_names property - std::vector names; - python_get_stringlist("DESKTOP_NAMES", &names); otk::Property::set(_info->rootWindow(), otk::Property::atoms.net_desktop_names, - otk::Property::utf8, names); + otk::Property::utf8, _config.desktop_names); // the above set() will cause the updateDesktopNames to fire right away so // we have a list of desktop names _desktop = 0; - - if (!python_get_long("NUMBER_OF_DESKTOPS", (long*)&_num_desktops)) - _num_desktops = 1; - changeNumDesktops(_num_desktops); // set the hint + + changeNumDesktops(_config.num_desktops); // set the hint 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 +388,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, @@ -680,7 +671,7 @@ void Screen::unmanageWindow(Client *client) client->_modal = false; // unfocus the client (calls the focus callbacks) - client->unfocus(); + if (client->focused()) client->unfocus(); #ifdef DEBUG printf("Unmanaged window 0x%lx frame 0x%lx\n", client->window(), framewin); @@ -745,9 +736,6 @@ void Screen::raiseWindow(Client *client) const ClientList::iterator end = _stacking.end(); // the stacking list is from highest to lowest -// for (;it != end, ++it) { -// if ((*it)->layer() <= client->layer() && m != *it) break; -// } for (; it != end && ((*it)->layer() > client->layer() || m == *it); ++it); /* @@ -864,6 +852,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); @@ -881,6 +874,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) { @@ -915,6 +943,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); } } @@ -932,8 +962,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); + } } }