allow for the client to be validated. don't manage override_redirect windows. don't manage windows for whome get attributes fails. validate the client before managing it. validate the client in functions that query stuff off it: propertyHandler and clientMessageHandler
Dana Jansens danakj@orodu.net
2 files changed,
31 insertions(+),
0 deletions(-)
M
src/client.cc
→
src/client.cc
@@ -49,6 +49,8 @@ // pick a layer to start from
_layer = Layer_Normal; // default to not urgent _urgent = false; + // not positioned unless specified + _positioned = false; getArea(); getDesktop();@@ -112,6 +114,21 @@ // bad, since we will no longer be managing the window on restart
if (_iconic) XMapWindow(**otk::display, _window); } +} + + +bool Client::validate() const +{ + XSync(**otk::display, false); // get all events on the server + + XEvent e; + if (XCheckTypedWindowEvent(**otk::display, _window, DestroyNotify, &e) || + XCheckTypedWindowEvent(**otk::display, _window, UnmapNotify, &e)) { + XPutBackEvent(**otk::display, &e); + return false; + } + + return true; }@@ -636,6 +653,9 @@
void Client::propertyHandler(const XPropertyEvent &e) { otk::EventHandler::propertyHandler(e); + + // validate cuz we query stuff off the client here + if (!validate()) return; // compress changes to a single property into a single change XEvent ce;@@ -909,6 +929,9 @@
void Client::clientMessageHandler(const XClientMessageEvent &e) { otk::EventHandler::clientMessageHandler(e); + + // validate cuz we query stuff off the client here + if (!validate()) return; if (e.format != 32) return;
M
src/client.hh
→
src/client.hh
@@ -602,6 +602,14 @@
//! Remove focus from the client window void unfocus() const; + //! Validate client, by making sure no Destroy or Unmap events exist in + //! the event queue for the window. + /*! + @return true if the client is valid; false if the client has already + been unmapped/destroyed, and so is invalid. + */ + bool validate() const; + virtual void focusHandler(const XFocusChangeEvent &e); virtual void unfocusHandler(const XFocusChangeEvent &e); virtual void propertyHandler(const XPropertyEvent &e);