X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclient.cc;h=80bab9db978fc06425a0d3a93e27ee3c1ac9b051;hb=ee896d9d664b6076635da98dced82b8b3258cebe;hp=f770fecd9f842c6625ed89ced3a03ddaef487f46;hpb=73f6bb1a7b6bb5f8b9cf22587722d713a1f15b59;p=chaz%2Fopenbox diff --git a/src/client.cc b/src/client.cc index f770fecd..80bab9db 100644 --- a/src/client.cc +++ b/src/client.cc @@ -23,10 +23,16 @@ extern "C" { namespace ob { OBClient::OBClient(int screen, Window window) - : _screen(screen), _window(window) + : otk::OtkEventHandler(), + _screen(screen), _window(window) { + assert(screen >= 0); assert(window); + Openbox::instance->registerHandler(_window, this); + + ignore_unmaps = 0; + // update EVERYTHING the first time!! // the state is kinda assumed to be normal. is this right? XXX @@ -272,7 +278,10 @@ void OBClient::getMwmHints() void OBClient::getArea() { XWindowAttributes wattrib; - assert(XGetWindowAttributes(otk::OBDisplay::display, _window, &wattrib)); + Status ret; + + ret = XGetWindowAttributes(otk::OBDisplay::display, _window, &wattrib); + assert(ret != BadWindow); _area.setRect(wattrib.x, wattrib.y, wattrib.width, wattrib.height); _border_width = wattrib.border_width; @@ -489,10 +498,23 @@ void OBClient::updateClass() } -void OBClient::update(const XPropertyEvent &e) +void OBClient::propertyHandler(const XPropertyEvent &e) { + otk::OtkEventHandler::propertyHandler(e); + const otk::OBProperty *property = Openbox::instance->property(); + // compress changes to a single property into a single change + XEvent ce; + while (XCheckTypedEvent(otk::OBDisplay::display, e.type, &ce)) { + // XXX: it would be nice to compress ALL changes to a property, not just + // changes in a row without other props between. + if (ce.xproperty.atom != e.atom) { + XPutBackEvent(otk::OBDisplay::display, &ce); + break; + } + } + if (e.atom == XA_WM_NORMAL_HINTS) updateNormalHints(); else if (e.atom == XA_WM_HINTS) @@ -637,25 +659,61 @@ void OBClient::setState(StateAction action, long data1, long data2) } -void OBClient::update(const XClientMessageEvent &e) +void OBClient::clientMessageHandler(const XClientMessageEvent &e) { + otk::OtkEventHandler::clientMessageHandler(e); + if (e.format != 32) return; const otk::OBProperty *property = Openbox::instance->property(); - if (e.message_type == property->atom(otk::OBProperty::wm_change_state)) - setWMState(e.data.l[0]); - else if (e.message_type == - property->atom(otk::OBProperty::net_wm_desktop)) - setDesktop(e.data.l[0]); + if (e.message_type == property->atom(otk::OBProperty::wm_change_state)) { + // compress changes into a single change + bool compress = false; + XEvent ce; + while (XCheckTypedEvent(otk::OBDisplay::display, e.type, &ce)) { + // XXX: it would be nice to compress ALL messages of a type, not just + // messages in a row without other message types between. + if (ce.xclient.message_type != e.message_type) { + XPutBackEvent(otk::OBDisplay::display, &ce); + break; + } + compress = true; + } + if (compress) + setWMState(ce.xclient.data.l[0]); // use the found event + else + setWMState(e.data.l[0]); // use the original event + } else if (e.message_type == + property->atom(otk::OBProperty::net_wm_desktop)) { + // compress changes into a single change + bool compress = false; + XEvent ce; + while (XCheckTypedEvent(otk::OBDisplay::display, e.type, &ce)) { + // XXX: it would be nice to compress ALL messages of a type, not just + // messages in a row without other message types between. + if (ce.xclient.message_type != e.message_type) { + XPutBackEvent(otk::OBDisplay::display, &ce); + break; + } + compress = true; + } + if (compress) + setDesktop(e.data.l[0]); // use the found event + else + setDesktop(e.data.l[0]); // use the original event + } else if (e.message_type == property->atom(otk::OBProperty::net_wm_state)) + // can't compress these setState((StateAction)e.data.l[0], e.data.l[1], e.data.l[2]); } #if defined(SHAPE) || defined(DOXYGEN_IGNORE) -void OBClient::update(const XShapeEvent &e) +void OBClient::shapeHandler(const XShapeEvent &e) { + otk::OtkEventHandler::shapeHandler(e); + _shaped = e.shaped; } #endif