aboutsummaryrefslogtreecommitdiffstats
path: root/kbfunc.c
diff options
context:
space:
mode:
authoroga2008-06-25 00:52:47 +0000
committeroga2008-06-25 00:52:47 +0000
commit6d790c3918dada5c874b8cabfe1be56fcbd9fd73 (patch)
tree970dd35b57edac09ef037ff38e31c23531d9ffdc /kbfunc.c
parent508680bbb4e47b8b4cdf14d3830e4d39bc68f61f (diff)
downloadcwm-6d790c3918dada5c874b8cabfe1be56fcbd9fd73.tar.gz
Stop keyboard move moving the window utterly off the screen. If that
happens there's no way to get it back. Also, stop resize making a windows size negative or zero. X does not like that one bit. Diff from Martynas. Ok okan@.
Diffstat (limited to 'kbfunc.c')
-rw-r--r--kbfunc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/kbfunc.c b/kbfunc.c
index b3e39c1..73744a2 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: kbfunc.c,v 1.29 2008/06/12 18:32:06 okan Exp $
+ * $Id: kbfunc.c,v 1.30 2008/06/25 00:52:47 oga Exp $
*/
#include <paths.h>
@@ -77,7 +77,17 @@ kbfunc_moveresize(struct client_ctx *cc, void *arg)
switch (flags & typemask) {
case CWM_MOVE:
cc->geom.y += my;
+ if (cc->geom.y + cc->geom.height < 0)
+ cc->geom.y = -cc->geom.height;
+ if (cc->geom.y > cc->sc->ymax)
+ cc->geom.y = cc->sc->ymax;
+
cc->geom.x += mx;
+ if (cc->geom.x + cc->geom.width < 0)
+ cc->geom.x = -cc->geom.width;
+ if (cc->geom.x > cc->sc->xmax)
+ cc->geom.x = cc->sc->xmax;
+
client_move(cc);
xu_ptr_getpos(cc->pwin, &x, &y);
cc->ptr.y = y + my;
@@ -85,8 +95,10 @@ kbfunc_moveresize(struct client_ctx *cc, void *arg)
client_ptrwarp(cc);
break;
case CWM_RESIZE:
- cc->geom.height += my;
- cc->geom.width += mx;
+ if ((cc->geom.height += my) < 1)
+ cc->geom.height = 1;
+ if ((cc->geom.width += mx) < 1)
+ cc->geom.width = 1;
client_resize(cc);
/* Make sure the pointer stays within the window. */