X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclient.cc;h=53a6d768eec94a2eeb2bbd94b0606d8a3a81a73a;hb=31d41a7aa60b06caea77d2c20af48e5c54eed600;hp=3dc6237f1a36e2e6cdfa6ae99fb3ec466fda3977;hpb=f78761c8dd185d72d5e7468c58cea3630e78b8e6;p=chaz%2Fopenbox diff --git a/src/client.cc b/src/client.cc index 3dc6237f..53a6d768 100644 --- a/src/client.cc +++ b/src/client.cc @@ -77,6 +77,7 @@ Client::Client(int screen, Window window) updateClass(); updateStrut(); updateIcons(); + updateKwmIcon(); // this makes sure that these windows appear on all desktops if (/*_type == Type_Dock ||*/ _type == Type_Desktop) @@ -575,6 +576,17 @@ void Client::updateWMHints(bool initstate) } else // no group! _group = None; + if (hints->flags & IconPixmapHint) { + updateKwmIcon(); // try get the kwm icon first, this is a fallback only + if (_pixmap_icon == None) { + _pixmap_icon = hints->icon_pixmap; + if (hints->flags & IconMaskHint) + _pixmap_icon_mask = hints->icon_mask; + else + _pixmap_icon_mask = None; + } + } + XFree(hints); } @@ -708,7 +720,6 @@ void Client::updateIcons() unsigned long num = (unsigned) -1; unsigned long *data; unsigned long w, h, i = 0; - bool freeit = false; for (int j = 0; j < _nicons; ++j) delete [] _icons[j].data; @@ -716,38 +727,32 @@ void Client::updateIcons() delete [] _icons; _nicons = 0; - if (!otk::Property::get(_window, otk::Property::atoms.net_wm_icon, + if (otk::Property::get(_window, otk::Property::atoms.net_wm_icon, otk::Property::atoms.cardinal, &num, &data)) { - // use default icon(s) - num = openbox->screen(_screen)->config().icon_length; - data = openbox->screen(_screen)->config().default_icon; - } else - freeit = true; - - // figure out how man valid icons are in here - while (num - i > 2) { - w = data[i++]; - h = data[i++]; - i += w * h; - if (i > num) break; - ++_nicons; - } - - _icons = new Icon[_nicons]; + // figure out how man valid icons are in here + while (num - i > 2) { + w = data[i++]; + h = data[i++]; + i += w * h; + if (i > num) break; + ++_nicons; + } - // store the icons - i = 0; - for (int j = 0; j < _nicons; ++j) { - w = _icons[j].w = data[i++]; + _icons = new Icon[_nicons]; + + // store the icons + i = 0; + for (int j = 0; j < _nicons; ++j) { + w = _icons[j].w = data[i++]; h = _icons[j].h = data[i++]; _icons[j].data = new unsigned long[w * h]; ::memcpy(_icons[j].data, &data[i], w * h * sizeof(unsigned long)); i += w * h; assert(i <= num); - } + } - if (freeit) delete [] data; + } if (_nicons <= 0) { _nicons = 1; @@ -762,6 +767,22 @@ void Client::updateIcons() if (frame) frame->adjustIcon(); } +void Client::updateKwmIcon() +{ + _pixmap_icon = _pixmap_icon_mask = None; + + unsigned long num = 2; + Pixmap *data; + if (otk::Property::get(_window, otk::Property::atoms.kwm_win_icon, + otk::Property::atoms.kwm_win_icon, &num, &data)) { + if (num >= 2) { + _pixmap_icon = data[0]; + _pixmap_icon_mask = data[1]; + } + delete [] data; + } +} + void Client::propertyHandler(const XPropertyEvent &e) { otk::EventHandler::propertyHandler(e); @@ -807,6 +828,8 @@ void Client::propertyHandler(const XPropertyEvent &e) updateStrut(); else if (e.atom == otk::Property::atoms.net_wm_icon) updateIcons(); + else if (e.atom == otk::Property::atoms.kwm_win_icon) + updateKwmIcon(); } void Client::setWMState(long state)