+void Client::resize(Corner anchor, int w, int h, int x, int y)
+{
+ 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();
+
+ if (x == INT_MIN || y == INT_MIN) {
+ 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::Display::display, _window, w, h);
+
+ // resize the frame to match the request
+ frame->adjustSize();
+ move(x, y);
+}
+
+
+void Client::move(int x, int y)
+{
+ _area.setPos(x, y);
+
+ // move the frame to be in the requested position
+ if (frame) { // this can be called while mapping, before frame exists
+ frame->adjustPosition();
+
+ // send synthetic configure notify (we don't need to if we aren't mapped
+ // yet)
+ XEvent event;
+ event.type = ConfigureNotify;
+ event.xconfigure.display = otk::Display::display;
+ event.xconfigure.event = _window;
+ event.xconfigure.window = _window;
+ event.xconfigure.x = x;
+ event.xconfigure.y = y;
+ event.xconfigure.width = _area.width();
+ event.xconfigure.height = _area.height();
+ event.xconfigure.border_width = _border_width;
+ event.xconfigure.above = frame->window();
+ event.xconfigure.override_redirect = False;
+ XSendEvent(event.xconfigure.display, event.xconfigure.window, False,
+ StructureNotifyMask, &event);
+ }
+}
+
+
+void Client::close()
+{
+ XEvent ce;
+ const otk::Property *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
+ // like... if the window is around after 5 seconds, then the close button
+ // turns a nice red, and if this function is called again, the client is
+ // explicitly killed.
+
+ ce.xclient.type = ClientMessage;
+ ce.xclient.message_type = property->atom(otk::Property::wm_protocols);
+ ce.xclient.display = otk::Display::display;
+ ce.xclient.window = _window;
+ ce.xclient.format = 32;
+ ce.xclient.data.l[0] = property->atom(otk::Property::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::Display::display, _window, false, NoEventMask, &ce);
+}
+
+
+void Client::changeState()
+{
+ const otk::Property *property = Openbox::instance->property();
+
+ unsigned long state[2];
+ state[0] = _wmstate;
+ state[1] = None;
+ property->set(_window, otk::Property::wm_state, otk::Property::wm_state,
+ state, 2);
+
+ Atom netstate[10];
+ int num = 0;
+ if (_modal)
+ netstate[num++] = property->atom(otk::Property::net_wm_state_modal);
+ if (_shaded)
+ netstate[num++] = property->atom(otk::Property::net_wm_state_shaded);
+ if (_iconic)
+ netstate[num++] = property->atom(otk::Property::net_wm_state_hidden);
+ if (_skip_taskbar)
+ netstate[num++] =
+ property->atom(otk::Property::net_wm_state_skip_taskbar);
+ if (_skip_pager)
+ netstate[num++] = property->atom(otk::Property::net_wm_state_skip_pager);
+ if (_fullscreen)
+ netstate[num++] = property->atom(otk::Property::net_wm_state_fullscreen);
+ if (_max_vert)
+ netstate[num++] =
+ property->atom(otk::Property::net_wm_state_maximized_vert);
+ if (_max_horz)
+ netstate[num++] =
+ property->atom(otk::Property::net_wm_state_maximized_horz);
+ if (_above)
+ netstate[num++] = property->atom(otk::Property::net_wm_state_above);
+ if (_below)
+ netstate[num++] = property->atom(otk::Property::net_wm_state_below);
+ property->set(_window, otk::Property::net_wm_state,
+ otk::Property::Atom_Atom, netstate, num);
+
+ calcLayer();
+}
+
+
+void Client::shade(bool shade)
+{
+ if (shade == _shaded) return; // already done
+
+ _wmstate = shade ? IconicState : NormalState;
+ _shaded = shade;
+ changeState();
+ frame->adjustSize();
+}
+
+
+bool Client::focus() const