configure request optimizations

This commit is contained in:
Dana Jansens 2003-01-04 07:24:40 +00:00
parent 8735c12d96
commit a6f5b33ad9
3 changed files with 42 additions and 25 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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;