diff options
author | todd | 2007-06-27 13:28:22 +0000 |
---|---|---|
committer | todd | 2007-06-27 13:28:22 +0000 |
commit | 87387d9bcaf92813d3dd4ed8e389aa98725f3b19 (patch) | |
tree | 476b140e8a7449689c82a95b2d55fad4064a1499 | |
parent | d159196cb5b6b857a36ebbc97e19e6205ab1c98d (diff) | |
download | cwm-87387d9bcaf92813d3dd4ed8e389aa98725f3b19.tar.gz |
implement keyboard initiated movement of windows
enhanced version of diff originally from niallo@
man bits from niallo@
ok niallo@ japser@
Diffstat (limited to '')
-rw-r--r-- | calmwm.h | 8 | ||||
-rw-r--r-- | conf.c | 23 | ||||
-rw-r--r-- | cwm.1 | 9 | ||||
-rw-r--r-- | kbfunc.c | 42 |
4 files changed, 78 insertions, 4 deletions
@@ -4,7 +4,7 @@ * Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org> * All rights reserved. * - * $Id: calmwm.h,v 1.7 2007/06/26 19:34:26 niallo Exp $ + * $Id: calmwm.h,v 1.8 2007/06/27 13:28:22 todd Exp $ */ #ifndef _CALMWM_H_ @@ -204,6 +204,11 @@ enum kbtype { KB__LAST }; +#define CWM_BIGMOVE 0x1000 +enum directions { + CWM_UP=0, CWM_DOWN, CWM_LEFT, CWM_RIGHT, +}; + #define KBFLAG_NEEDCLIENT 0x01 #define KBFLAG_FINDCLIENT 0x02 @@ -426,6 +431,7 @@ void kbfunc_client_prevgroup(struct client_ctx *, void *); void kbfunc_client_nogroup(struct client_ctx *, void *); void kbfunc_client_maximize(struct client_ctx *, void *); void kbfunc_client_vmaximize(struct client_ctx *, void *); +void kbfunc_client_move(struct client_ctx *, void *); void kbfunc_menu_search(struct client_ctx *, void *); void kbfunc_exec(struct client_ctx *, void *); void kbfunc_ssh(struct client_ctx *, void *); @@ -4,7 +4,7 @@ * Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org> * All rights reserved. * - * $Id: conf.c,v 1.7 2007/06/26 19:34:26 niallo Exp $ + * $Id: conf.c,v 1.8 2007/06/27 13:28:22 todd Exp $ */ #include "headers.h" @@ -20,6 +20,7 @@ #define CONF_MAX_WINTITLE 256 #define CONF_IGNORECASE 0x01 + /* * Match a window. */ @@ -237,6 +238,26 @@ conf_setup(struct conf *c) XK_f, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0); conf_bindkey(c, kbfunc_client_vmaximize, XK_equal, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0); + conf_bindkey(c, kbfunc_client_move, + XK_k, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_UP); + conf_bindkey(c, kbfunc_client_move, + XK_j, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN); + conf_bindkey(c, kbfunc_client_move, + XK_l, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT); + conf_bindkey(c, kbfunc_client_move, + XK_h, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT); + conf_bindkey(c, kbfunc_client_move, + XK_K, Mod1Mask, KBFLAG_NEEDCLIENT, + (void *)(CWM_UP|CWM_BIGMOVE)); + conf_bindkey(c, kbfunc_client_move, + XK_J, Mod1Mask, KBFLAG_NEEDCLIENT, + (void *)(CWM_DOWN|CWM_BIGMOVE)); + conf_bindkey(c, kbfunc_client_move, + XK_L, Mod1Mask, KBFLAG_NEEDCLIENT, + (void *)(CWM_RIGHT|CWM_BIGMOVE)); + conf_bindkey(c, kbfunc_client_move, + XK_H, Mod1Mask, KBFLAG_NEEDCLIENT, + (void *)(CWM_LEFT|CWM_BIGMOVE)); } snprintf(dir_settings, sizeof(dir_settings), @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwm.1,v 1.7 2007/06/26 19:34:26 niallo Exp $ +.\" $OpenBSD: cwm.1,v 1.8 2007/06/27 13:28:22 todd Exp $ .\" .\" The following requests are required for all man pages. .Dd July 10, 2004 @@ -126,6 +126,13 @@ font string .Ar fontname the default font. .El +.Sh WINDOW MOVEMENT +.Nm +windows can be moved with the use of the keyboard through Vi-like bindings. +M-[hjkl] moves the current window a small amount, while M-shift-[hjkl] moves +the current window a larger amount. +For example, to move the current window to the left a small amount, press M-h. +To move the current window down by a larger amount, press M-shift-j. .Sh SEARCH .Nm features the ability to search for windows by their current title, old @@ -4,7 +4,7 @@ * Copyright (c) 2004 Martin Murray <mmurray@monkey.org> * All rights reserved. * - * $Id: kbfunc.c,v 1.5 2007/06/26 19:34:26 niallo Exp $ + * $Id: kbfunc.c,v 1.6 2007/06/27 13:28:22 todd Exp $ */ #include <paths.h> @@ -14,6 +14,7 @@ #define KNOWN_HOSTS ".ssh/known_hosts" #define HASH_MARKER "|1|" +#define MOVE_AMOUNT 10 void kbfunc_client_lower(struct client_ctx *cc, void *arg) @@ -28,6 +29,45 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg) } void +kbfunc_client_move(struct client_ctx *cc, void *arg) +{ + int x,y,flags,amt; + u_int mx,my; + + mx = my = 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; + 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_search(struct client_ctx *scratch, void *arg) { struct menu_q menuq; |