X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclient.cc;h=e626081ce19e871a2fe37e25653f5f257ee69ed0;hb=1161a90a70b21d3064a9dee62c72dd4be3025ada;hp=07d754624ad29aacbb4b635d52d54e3548ec6572;hpb=52cb7bd11ed83a57c4c1affcdac8a1f7d68ae551;p=chaz%2Fopenbox diff --git a/src/client.cc b/src/client.cc index 07d75462..e626081c 100644 --- a/src/client.cc +++ b/src/client.cc @@ -26,6 +26,7 @@ namespace ob { OBClient::OBClient(int screen, Window window) : otk::OtkEventHandler(), + OBWidget(OBWidget::Type_Client), frame(0), _screen(screen), _window(window) { assert(screen >= 0); @@ -39,6 +40,8 @@ OBClient::OBClient(int screen, Window window) _wmstate = NormalState; // no default decors or functions, each has to be enabled _decorations = _functions = 0; + // start unfocused + _focused = false; getArea(); getDesktop(); @@ -459,6 +462,9 @@ void OBClient::updateTitle() if (_title.empty()) _title = _("Unnamed Window"); + + if (frame) + frame->setTitle(_title); } @@ -673,8 +679,6 @@ void OBClient::toggleClientBorder(bool addborder) case NorthWestGravity: case WestGravity: case SouthWestGravity: - if (addborder) x += _border_width; - else x -= _border_width; break; case NorthEastGravity: case EastGravity: @@ -687,8 +691,6 @@ void OBClient::toggleClientBorder(bool addborder) case NorthWestGravity: case NorthGravity: case NorthEastGravity: - if (addborder) y += _border_width; - else y -= _border_width; break; case SouthWestGravity: case SouthGravity: @@ -777,6 +779,11 @@ 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()) { @@ -833,8 +840,87 @@ void OBClient::move(int x, int y) } +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); +} + + +bool OBClient::focus() +{ + if (!_can_focus || _focused) return false; + + XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime); + return true; +} + + +void OBClient::unfocus() +{ + if (!_focused) return; + + assert(Openbox::instance->focusedClient() == this); + Openbox::instance->setFocusedClient(0); +} + + +void OBClient::focusHandler(const XFocusChangeEvent &e) +{ +#ifdef DEBUG + printf("FocusIn for 0x%lx\n", e.window); +#endif // DEBUG + + OtkEventHandler::focusHandler(e); + + frame->focus(); + _focused = true; + + Openbox::instance->setFocusedClient(this); +} + + +void OBClient::unfocusHandler(const XFocusChangeEvent &e) +{ +#ifdef DEBUG + printf("FocusOut for 0x%lx\n", e.window); +#endif // DEBUG + + OtkEventHandler::unfocusHandler(e); + + frame->unfocus(); + _focused = false; + + if (Openbox::instance->focusedClient() == this) { + printf("UNFOCUSED!\n"); + Openbox::instance->setFocusedClient(this); + } +} + + void OBClient::configureRequestHandler(const XConfigureRequestEvent &e) { +#ifdef DEBUG + printf("ConfigureRequest for 0x%lx\n", e.window); +#endif // DEBUG + OtkEventHandler::configureRequestHandler(e); // XXX: if we are iconic (or shaded? (fvwm does that)) ignore the event @@ -921,4 +1007,26 @@ void OBClient::destroyHandler(const XDestroyWindowEvent &e) } +void OBClient::reparentHandler(const XReparentEvent &e) +{ + // this is when the client is first taken captive in the frame + if (e.parent == frame->plate()) return; + +#ifdef DEBUG + printf("ReparentNotify for 0x%lx\n", e.window); +#endif // DEBUG + + OtkEventHandler::reparentHandler(e); + + /* + This event is quite rare and is usually handled in unmapHandler. + However, if the window is unmapped when the reparent event occurs, + the window manager never sees it because an unmap event is not sent + to an already unmapped window. + */ + + // this deletes us etc + Openbox::instance->screen(_screen)->unmanageWindow(this); +} + }