diff options
Diffstat (limited to 'kbfunc.c')
-rw-r--r-- | kbfunc.c | 125 |
1 files changed, 37 insertions, 88 deletions
@@ -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.21 2008/04/15 21:20:56 oga Exp $ + * $Id: kbfunc.c,v 1.22 2008/04/16 13:47:29 oga Exp $ */ #include <paths.h> @@ -41,9 +41,12 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg) client_raise(cc); } +#define typemask (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE) +#define movemask (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT) void -kbfunc_client_move(struct client_ctx *cc, void *arg) +kbfunc_moveresize(struct client_ctx *cc, void *arg) { + struct screen_ctx *sc = screen_current(); int x,y,flags,amt; u_int mx,my; @@ -57,47 +60,7 @@ kbfunc_client_move(struct client_ctx *cc, void *arg) amt = amt*10; } - switch (flags) { - case CWM_UP: - my -= amt; - break; - case CWM_DOWN: - my += amt; - break; - case CWM_RIGHT: - mx += amt; - break; - case CWM_LEFT: - mx -= amt; - break; - } - - cc->geom.y += my; - cc->geom.x += mx; - client_move(cc); - xu_ptr_getpos(cc->pwin, &x, &y); - cc->ptr.y = y + my; - cc->ptr.x = x + mx; - client_ptrwarp(cc); -} - -void -kbfunc_client_resize(struct client_ctx *cc, void *arg) -{ - int flags,mx,my; - u_int amt; - - mx = my = 0; - - flags = (int)arg; - amt = MOVE_AMOUNT; - - if (flags & CWM_BIGMOVE) { - flags -= CWM_BIGMOVE; - amt = amt*10; - } - - switch (flags) { + switch (flags & movemask) { case CWM_UP: my -= amt; break; @@ -111,56 +74,42 @@ kbfunc_client_resize(struct client_ctx *cc, void *arg) mx -= amt; break; } - - cc->geom.height += my; - cc->geom.width += mx; - client_resize(cc); - - /* - * Moving the cursor while resizing is problematic. Just place - * it in the middle of the window. - */ - cc->ptr.x = -1; - cc->ptr.y = -1; - client_ptrwarp(cc); -} - -void -kbfunc_ptrmove(struct client_ctx *cc, void *arg) -{ - int px,py,mx,my,flags,amt; - struct screen_ctx *sc = screen_current(); - my = mx = 0; - - flags = (int)arg; - amt = MOVE_AMOUNT; - - if (flags & CWM_BIGMOVE) { - flags -= CWM_BIGMOVE; - amt = amt * 10; - } - switch (flags) { - case CWM_UP: - my -= amt; - break; - case CWM_DOWN: - my += amt; + switch (flags & typemask) { + case CWM_MOVE: + cc->geom.y += my; + cc->geom.x += mx; + client_move(cc); + xu_ptr_getpos(cc->pwin, &x, &y); + cc->ptr.y = y + my; + cc->ptr.x = x + mx; + client_ptrwarp(cc); break; - case CWM_RIGHT: - mx += amt; + case CWM_RESIZE: + cc->geom.height += my; + cc->geom.width += mx; + client_resize(cc); + + /* + * Moving the cursor while resizing is problematic. Just place + * it in the middle of the window. + */ + cc->ptr.x = -1; + cc->ptr.y = -1; + client_ptrwarp(cc); break; - case CWM_LEFT: - mx -= amt; + case CWM_PTRMOVE: + if (cc) { + xu_ptr_getpos(cc->pwin, &x, &y); + xu_ptr_setpos(cc->pwin, x + mx, y + my); + } else { + xu_ptr_getpos(sc->rootwin, &x, &y); + xu_ptr_setpos(sc->rootwin, x + mx, y + my); + } break; + default: + warnx("invalid flags passed to kbfunc_client_moveresize"); } - if (cc) { - xu_ptr_getpos(cc->pwin, &px, &py); - xu_ptr_setpos(cc->pwin, px + mx, py + my); - } else { - xu_ptr_getpos(sc->rootwin, &px, &py); - xu_ptr_setpos(sc->rootwin, px + mx, py + my); - } } void |