+void OBClient::resize(Corner anchor, int w, int h)
+{
+ w -= _base_size.x();
+ h -= _base_size.y();
+
+ // for interactive resizing. have to move half an increment in each
+ // direction.
+ w += _size_inc.x() / 2;
+ h += _size_inc.y() / 2;
+
+ // is the window resizable? if it is not, then don't check its sizes, the
+ // client can do what it wants and the user can't change it anyhow
+ if (_min_size.x() <= _max_size.x() && _min_size.y() <= _max_size.y()) {
+ // smaller than min size or bigger than max size?
+ if (w < _min_size.x()) w = _min_size.x();
+ else if (w > _max_size.x()) w = _max_size.x();
+ if (h < _min_size.y()) h = _min_size.y();
+ else if (h > _max_size.y()) h = _max_size.y();
+ }
+
+ // keep to the increments
+ w /= _size_inc.x();
+ h /= _size_inc.y();
+
+ // store the logical size
+ _logical_size.setPoint(w, h);
+
+ w *= _size_inc.x();
+ h *= _size_inc.y();
+
+ w += _base_size.x();
+ h += _base_size.y();
+
+ int x = _area.x(), y = _area.y();
+ switch (anchor) {
+ case TopLeft:
+ break;
+ case TopRight:
+ x -= w - _area.width();
+ break;
+ case BottomLeft:
+ y -= h - _area.height();
+ break;
+ case BottomRight:
+ x -= w - _area.width();
+ y -= h - _area.height();
+ break;
+ }
+
+ _area.setSize(w, h);
+ XResizeWindow(otk::OBDisplay::display, _window, w, h);
+
+ // resize the frame to match the request
+ frame->adjustSize();
+ move(x, y);
+}
+
+
+void OBClient::move(int x, int y)
+{
+ _area.setPos(x, y);
+ // move the frame to be in the requested position
+ frame->adjustPosition();
+}
+
+
+void OBClient::close()
+{
+ XEvent ce;
+ const otk::OBProperty *property = Openbox::instance->property();
+
+ if (!(_functions & Func_Close)) return;
+
+ // XXX: itd be cool to do timeouts and shit here for killing the client's
+ // process off
+
+ ce.xclient.type = ClientMessage;
+ ce.xclient.message_type = property->atom(otk::OBProperty::wm_protocols);
+ ce.xclient.display = otk::OBDisplay::display;
+ ce.xclient.window = _window;
+ ce.xclient.format = 32;
+ ce.xclient.data.l[0] = property->atom(otk::OBProperty::wm_delete_window);
+ ce.xclient.data.l[1] = CurrentTime;
+ ce.xclient.data.l[2] = 0l;
+ ce.xclient.data.l[3] = 0l;
+ ce.xclient.data.l[4] = 0l;
+ XSendEvent(otk::OBDisplay::display, _window, False, NoEventMask, &ce);
+}
+
+
+void OBClient::changeState()
+{
+ const otk::OBProperty *property = Openbox::instance->property();
+
+ unsigned long state[2];
+ state[0] = _wmstate;
+ state[1] = None;
+ property->set(_window, otk::OBProperty::wm_state, otk::OBProperty::wm_state,
+ state, 2);
+
+ Atom netstate[10];
+ int num = 0;
+ if (_modal)
+ netstate[num++] = property->atom(otk::OBProperty::net_wm_state_modal);
+ if (_shaded)
+ netstate[num++] = property->atom(otk::OBProperty::net_wm_state_shaded);
+ if (_iconic)
+ netstate[num++] = property->atom(otk::OBProperty::net_wm_state_hidden);
+ if (_skip_taskbar)
+ netstate[num++] =
+ property->atom(otk::OBProperty::net_wm_state_skip_taskbar);
+ if (_skip_pager)
+ netstate[num++] = property->atom(otk::OBProperty::net_wm_state_skip_pager);
+ if (_fullscreen)
+ netstate[num++] = property->atom(otk::OBProperty::net_wm_state_fullscreen);
+ if (_max_vert)
+ netstate[num++] =
+ property->atom(otk::OBProperty::net_wm_state_maximized_vert);
+ if (_max_horz)
+ netstate[num++] =
+ property->atom(otk::OBProperty::net_wm_state_maximized_horz);
+ if (_above)
+ netstate[num++] = property->atom(otk::OBProperty::net_wm_state_above);
+ if (_below)
+ netstate[num++] = property->atom(otk::OBProperty::net_wm_state_below);
+ property->set(_window, otk::OBProperty::net_wm_state,
+ otk::OBProperty::Atom_Atom, netstate, num);
+
+}
+
+void OBClient::shade(bool shade)
+{
+ if (shade == _shaded) return; // already done
+
+ _wmstate = shade ? IconicState : NormalState;
+ _shaded = shade;
+ changeState();
+ frame->adjustSize();
+}
+
+
+bool OBClient::focus()
+{
+ if (!(_can_focus || _focus_notify) || _focused) return false;
+
+ if (_can_focus)
+ XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime);
+
+ if (_focus_notify) {
+ XEvent ce;
+ const otk::OBProperty *property = Openbox::instance->property();
+
+ ce.xclient.type = ClientMessage;
+ ce.xclient.message_type = property->atom(otk::OBProperty::wm_protocols);
+ ce.xclient.display = otk::OBDisplay::display;
+ ce.xclient.window = _window;
+ ce.xclient.format = 32;
+ ce.xclient.data.l[0] = property->atom(otk::OBProperty::wm_take_focus);
+ ce.xclient.data.l[1] = Openbox::instance->lastTime();
+ ce.xclient.data.l[2] = 0l;
+ ce.xclient.data.l[3] = 0l;
+ ce.xclient.data.l[4] = 0l;
+ XSendEvent(otk::OBDisplay::display, _window, False, NoEventMask, &ce);
+ }
+
+ return true;
+}
+
+
+void OBClient::unfocus()
+{
+ if (!_focused) return;
+
+ assert(Openbox::instance->focusedClient() == this);
+ Openbox::instance->setFocusedClient(0);
+}
+
+
+void OBClient::focusHandler(const XFocusChangeEvent &e)