+ } else if (e.message_type ==
+ property->atom(otk::OBProperty::net_close_window)) {
+#ifdef DEBUG
+ printf("net_close_window for 0x%lx\n", _window);
+#endif
+ close();
+ } else if (e.message_type ==
+ property->atom(otk::OBProperty::net_active_window)) {
+#ifdef DEBUG
+ printf("net_active_window for 0x%lx\n", _window);
+#endif
+ focus();
+ Openbox::instance->screen(_screen)->restack(true, this); // raise
+ }
+}
+
+
+#if defined(SHAPE)
+void OBClient::shapeHandler(const XShapeEvent &e)
+{
+ otk::OtkEventHandler::shapeHandler(e);
+
+ _shaped = e.shaped;
+ frame->adjustShape();
+}
+#endif
+
+
+void OBClient::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::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
+ // 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::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);
+
+ calcLayer();
+}
+
+
+void OBClient::setStackLayer(int l)
+{
+ if (l == 0)
+ _above = _below = false; // normal
+ else if (l > 0) {
+ _above = true;
+ _below = false; // above
+ } else {
+ _above = false;
+ _below = true; // below
+ }
+ changeState();