all repos — openbox @ 105e3524a3f6b526d54ecc761a6e6c91b04f3949

openbox fork - make it a bit more like ryudo

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.
Dana Jansens danakj@orodu.net
commit

105e3524a3f6b526d54ecc761a6e6c91b04f3949

parent

8be4541461ba04f41eb5c40852be351f35fa18ee

3 files changed, 72 insertions(+), 18 deletions(-)

jump to
M src/client.ccsrc/client.cc

@@ -234,7 +234,7 @@ // _functions &= ~Func_Close;

} } - // XXX: changeAllowedActions(); + changeAllowedActions(); }

@@ -901,7 +901,14 @@ }

#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 @@ XResizeWindow(**otk::display, _window, w, h);

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

} +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 @@ // 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); + 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) {
M src/client.hhsrc/client.hh

@@ -367,6 +367,8 @@ void updateTransientFor();

//! 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();

@@ -377,7 +379,29 @@ @param shade true if the window should be shaded; false if it should be

unshaded. */ 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 @@ 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 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;
M src/openbox_wrap.ccsrc/openbox_wrap.cc

@@ -9197,13 +9197,11 @@ ob::Client *arg1 = (ob::Client *) 0 ;

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;