From: Dana Jansens Date: Sat, 4 Jan 2003 07:24:40 +0000 (+0000) Subject: configure request optimizations X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=a6f5b33ad90637705af9717c978bf895455c71ba;p=chaz%2Fopenbox configure request optimizations --- diff --git a/src/client.cc b/src/client.cc index 289fcf16..80869e15 100644 --- a/src/client.cc +++ b/src/client.cc @@ -802,7 +802,7 @@ void OBClient::shapeHandler(const XShapeEvent &e) #endif -void OBClient::resize(Corner anchor, int w, int h) +void OBClient::resize(Corner anchor, int w, int h, int x, int y) { w -= _base_size.x(); h -= _base_size.y(); @@ -835,23 +835,27 @@ void OBClient::resize(Corner anchor, int w, int h) 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; + 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 @@ -863,6 +867,7 @@ void OBClient::resize(Corner anchor, int w, int h) void OBClient::move(int x, int y) { _area.setPos(x, y); + // move the frame to be in the requested position frame->adjustPosition(); } @@ -1048,10 +1053,14 @@ void OBClient::configureRequestHandler(const XConfigureRequestEvent &e) corner = TopLeft; } - resize(corner, w, h); - } - - if (e.value_mask & (CWX | CWY)) { + // if moving AND resizing ... + if (e.value_mask & (CWX | CWY)) { + int x = (e.value_mask & CWX) ? e.x : _area.x(); + int y = (e.value_mask & CWY) ? e.y : _area.y(); + resize(corner, w, h, x, y); + } else // if JUST resizing... + resize(corner, w, h); + } else if (e.value_mask & (CWX | CWY)) { // if JUST moving... int x = (e.value_mask & CWX) ? e.x : _area.x(); int y = (e.value_mask & CWY) ? e.y : _area.y(); move(x, y); diff --git a/src/client.hh b/src/client.hh index 927fc2f1..80c6e4ee 100644 --- a/src/client.hh +++ b/src/client.hh @@ -431,11 +431,17 @@ public: //! Resizes the client window, anchoring it in a given corner /*! This also maintains things like the client's minsize, and size increments. - @param anchor The corner to keep in the same position when resizing - @param x The X component of the new size for the client - @param y The Y component of the new size for the client + @param anchor The corner to keep in the same position when resizing. + @param w The width component of the new size for the client. + @param h The height component of the new size for the client. + @param x An optional X coordinate to which the window will be moved + after resizing. + @param y An optional Y coordinate to which the window will be moved + after resizing. + The x and y coordinates must both be sepcified together, or they will have + no effect. When they are specified, the anchor is ignored. */ - void resize(Corner anchor, int x, int y); + void resize(Corner anchor, int w, int h, int x = INT_MIN, int y = INT_MIN); //! Request the client to close its window. void close(); diff --git a/src/openbox_wrap.cc b/src/openbox_wrap.cc index 3a81b9fd..f4212c82 100644 --- a/src/openbox_wrap.cc +++ b/src/openbox_wrap.cc @@ -2282,11 +2282,13 @@ static PyObject *_wrap_OBClient_resize(PyObject *self, PyObject *args) { int arg2 ; int arg3 ; int arg4 ; + int arg5 = (int) INT_MIN ; + int arg6 = (int) INT_MIN ; PyObject * obj0 = 0 ; - if(!PyArg_ParseTuple(args,(char *)"Oiii:OBClient_resize",&obj0,&arg2,&arg3,&arg4)) goto fail; + if(!PyArg_ParseTuple(args,(char *)"Oiii|ii:OBClient_resize",&obj0,&arg2,&arg3,&arg4,&arg5,&arg6)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; - (arg1)->resize((ob::OBClient::Corner )arg2,arg3,arg4); + (arg1)->resize((ob::OBClient::Corner )arg2,arg3,arg4,arg5,arg6); Py_INCREF(Py_None); resultobj = Py_None; return resultobj;