add internal_move/resize and wrap them with move() and resize() which are for user use, and make sure that the window is allowed to be moved/resized.

add the allowed actions hint setting.
This commit is contained in:
Dana Jansens 2003-01-17 07:45:07 +00:00
parent 8be4541461
commit 105e3524a3
3 changed files with 72 additions and 18 deletions

View file

@ -234,7 +234,7 @@ void Client::setupDecorAndFunctions()
}
}
// XXX: changeAllowedActions();
changeAllowedActions();
}
@ -901,7 +901,14 @@ void Client::shapeHandler(const XShapeEvent &e)
#endif
void Client::resize(Corner anchor, int w, int h, int x, int y)
void Client::resize(Corner anchor, int w, int h)
{
if (!(_functions & Func_Resize)) return;
internal_resize(anchor, w, h);
}
void Client::internal_resize(Corner anchor, int w, int h, int x, int y)
{
w -= _base_size.x();
h -= _base_size.y();
@ -963,11 +970,18 @@ void Client::resize(Corner anchor, int w, int h, int x, int y)
// resize the frame to match the request
frame->adjustSize();
move(x, y);
internal_move(x, y);
}
void Client::move(int x, int y)
{
if (!(_functions & Func_Move)) return;
internal_move(x, y);
}
void Client::internal_move(int x, int y)
{
_area.setPos(x, y);
@ -1058,6 +1072,30 @@ void Client::changeState()
}
void Client::changeAllowedActions(void)
{
Atom actions[7];
int num = 0;
actions[num++] = otk::Property::atoms.net_wm_action_shade;
actions[num++] = otk::Property::atoms.net_wm_action_change_desktop;
if (_functions & Func_Close)
actions[num++] = otk::Property::atoms.net_wm_action_close;
if (_functions & Func_Move)
actions[num++] = otk::Property::atoms.net_wm_action_move;
if (_functions & Func_Resize)
actions[num++] = otk::Property::atoms.net_wm_action_resize;
if (_functions & Func_Maximize) {
actions[num++] = otk::Property::atoms.net_wm_action_maximize_horz;
actions[num++] = otk::Property::atoms.net_wm_action_maximize_vert;
}
otk::Property::set(_window, otk::Property::atoms.net_wm_allowed_actions,
otk::Property::atoms.atom, actions, num);
}
void Client::shade(bool shade)
{
if (shade == _shaded) return; // already done
@ -1179,13 +1217,13 @@ void Client::configureRequestHandler(const XConfigureRequestEvent &e)
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);
internal_resize(corner, w, h, x, y);
} else // if JUST resizing...
resize(corner, w, h);
internal_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);
internal_move(x, y);
}
if (e.value_mask & CWStackMode) {

View file

@ -367,6 +367,8 @@ private:
//! Change the client's state hints to match the class' data
void changeState();
//! Change the allowed actions set on the client
void changeAllowedActions();
//! Request the client to close its window.
void close();
@ -378,6 +380,28 @@ private:
*/
void shade(bool shade);
//! Internal version of the Client::move function
/*!
@param x The X coordinate to move to.
@param y The Y coordinate to move to.
*/
void internal_move(int x, int y);
//! Internal version of the Client::resize function
/*!
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 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 internal_resize(Corner anchor, int w, int h,
int x = INT_MIN, int y = INT_MIN);
public:
#ifndef SWIG
//! Constructs a new Client object around a specified window id
@ -510,14 +534,8 @@ BB @param window The window id that the Client class should handle
@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 w, int h, int x = INT_MIN, int y = INT_MIN);
void resize(Corner anchor, int w, int h);
//! Attempt to focus the client window
bool focus() const;

View file

@ -9197,13 +9197,11 @@ static PyObject *_wrap_Client_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|ii:Client_resize",&obj0,&arg2,&arg3,&arg4,&arg5,&arg6)) goto fail;
if(!PyArg_ParseTuple(args,(char *)"Oiii:Client_resize",&obj0,&arg2,&arg3,&arg4)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__Client,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
(arg1)->resize((ob::Client::Corner )arg2,arg3,arg4,arg5,arg6);
(arg1)->resize((ob::Client::Corner )arg2,arg3,arg4);
Py_INCREF(Py_None); resultobj = Py_None;
return resultobj;