X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclient.cc;h=e55f681f58a7edaba152905dd4f23d8908f3fe30;hb=a7ccc544500fe84e707f6e511261276b819d8906;hp=572c383aecb15d5f2410164c834f877f0349454e;hpb=3f784100ab51dce9e33652a9dd867140dd04a4aa;p=chaz%2Fopenbox diff --git a/src/client.cc b/src/client.cc index 572c383a..e55f681f 100644 --- a/src/client.cc +++ b/src/client.cc @@ -49,6 +49,10 @@ Client::Client(int screen, Window window) _layer = Layer_Normal; // default to not urgent _urgent = false; + // not positioned unless specified + _positioned = false; + // nothing is disabled unless specified + _disabled_decorations = 0; getArea(); getDesktop(); @@ -115,6 +119,21 @@ Client::~Client() } +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; +} + + void Client::getGravity() { XWindowAttributes wattrib; @@ -201,8 +220,8 @@ void Client::setupDecorAndFunctions() _functions |= Func_Close; } - if (_min_size.x() > _max_size.x() || _min_size.y() > _max_size.y()) { - _decorations &= ~Decor_Maximize; + if (!(_min_size.x() < _max_size.x() || _min_size.y() < _max_size.y())) { + _decorations &= ~(Decor_Maximize | Decor_Handle); _functions &= ~(Func_Resize | Func_Maximize); } @@ -271,7 +290,30 @@ void Client::setupDecorAndFunctions() } } + // finally, user specified disabled decorations are applied to subtract + // decorations + if (_disabled_decorations & Decor_Titlebar) + _decorations &= ~Decor_Titlebar; + if (_disabled_decorations & Decor_Handle) + _decorations &= ~Decor_Handle; + if (_disabled_decorations & Decor_Border) + _decorations &= ~Decor_Border; + if (_disabled_decorations & Decor_Iconify) + _decorations &= ~Decor_Iconify; + if (_disabled_decorations & Decor_Maximize) + _decorations &= ~Decor_Maximize; + if (_disabled_decorations & Decor_AllDesktops) + _decorations &= ~Decor_AllDesktops; + if (_disabled_decorations & Decor_Close) + _decorations &= ~Decor_Close; + changeAllowedActions(); + + if (frame) { + frame->adjustSize(); // change the decors on the frame + frame->adjustPosition(); // with more/less decorations, we may need to be + // moved + } } @@ -590,8 +632,11 @@ void Client::updateStrut() _strut.right = data[1]; _strut.top = data[2]; _strut.bottom = data[3]; - - openbox->screen(_screen)->updateStrut(); + + // updating here is pointless while we're being mapped cuz we're not in + // the screen's client list yet + if (frame) + openbox->screen(_screen)->updateStrut(); } delete [] data; @@ -636,6 +681,9 @@ void Client::updateTransientFor() 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; @@ -658,7 +706,6 @@ void Client::propertyHandler(const XPropertyEvent &e) getType(); calcLayer(); // type may have changed, so update the layer setupDecorAndFunctions(); - frame->adjustSize(); // this updates the frame for any new decor settings } else if (e.atom == otk::Property::atoms.net_wm_name || e.atom == otk::Property::atoms.wm_name) @@ -671,7 +718,6 @@ void Client::propertyHandler(const XPropertyEvent &e) else if (e.atom == otk::Property::atoms.wm_protocols) { updateProtocols(); setupDecorAndFunctions(); - frame->adjustSize(); // update the decorations } else if (e.atom == otk::Property::atoms.net_wm_strut) updateStrut(); @@ -910,6 +956,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; if (e.message_type == otk::Property::atoms.wm_change_state) { @@ -1299,6 +1348,13 @@ void Client::fullscreen(bool fs) } +void Client::disableDecorations(DecorationFlags flags) +{ + _disabled_decorations = flags; + setupDecorAndFunctions(); +} + + bool Client::focus() { // won't try focus if the client doesn't want it, or if the window isn't @@ -1343,6 +1399,7 @@ bool Client::focus() XSendEvent(**otk::display, _window, False, NoEventMask, &ce); } + XSync(**otk::display, False); return true; }