aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroga2007-11-07 21:58:03 +0000
committeroga2007-11-07 21:58:03 +0000
commitbf37283aceddf2b27feccf302522a03aa9cb439e (patch)
treeadc09bcd4d086dccad92550ee3e89a6f1826fe13
parent151a94964ddadf0a0093bd4ac9f2a02cecaf553d (diff)
downloadcwm-bf37283aceddf2b27feccf302522a03aa9cb439e.tar.gz
Add support to cwm for resizing the windows using Control-Meta-[hjkl].
Please note that this remaps Control-Meta-L (label) to Control-Meta-N (name). ok jasper@, todd@.
Diffstat (limited to '')
-rw-r--r--calmwm.h3
-rw-r--r--conf.c30
-rw-r--r--cwm.110
-rw-r--r--kbfunc.c47
4 files changed, 82 insertions, 8 deletions
diff --git a/calmwm.h b/calmwm.h
index 7d15b82..7382835 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
* All rights reserved.
*
- * $Id: calmwm.h,v 1.8 2007/06/27 13:28:22 todd Exp $
+ * $Id: calmwm.h,v 1.9 2007/11/07 21:58:03 oga Exp $
*/
#ifndef _CALMWM_H_
@@ -432,6 +432,7 @@ 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_client_resize(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 *);
diff --git a/conf.c b/conf.c
index 05bc9d2..044d204 100644
--- a/conf.c
+++ b/conf.c
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
* All rights reserved.
*
- * $Id: conf.c,v 1.8 2007/06/27 13:28:22 todd Exp $
+ * $Id: conf.c,v 1.9 2007/11/07 21:58:03 oga Exp $
*/
#include "headers.h"
@@ -204,7 +204,7 @@ conf_setup(struct conf *c)
XK_Tab, Mod1Mask, 0, 0);
conf_bindkey(c, kbfunc_client_rcycle,
XK_Tab, Mod1Mask|ShiftMask, 0, 0);
- conf_bindkey(c, kbfunc_client_label, XK_l,
+ conf_bindkey(c, kbfunc_client_label, XK_n,
ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
conf_bindkey(c, kbfunc_client_delete, XK_x,
ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
@@ -258,7 +258,31 @@ conf_setup(struct conf *c)
conf_bindkey(c, kbfunc_client_move,
XK_H, Mod1Mask, KBFLAG_NEEDCLIENT,
(void *)(CWM_LEFT|CWM_BIGMOVE));
- }
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_k, ControlMask|Mod1Mask,
+ KBFLAG_NEEDCLIENT, (void *)CWM_UP);
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_j, ControlMask|Mod1Mask,
+ KBFLAG_NEEDCLIENT, (void *)CWM_DOWN);
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_l, ControlMask|Mod1Mask,
+ KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT);
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_h, ControlMask|Mod1Mask,
+ KBFLAG_NEEDCLIENT, (void *)CWM_LEFT);
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_K, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT,
+ (void *)(CWM_UP|CWM_BIGMOVE));
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_J, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT,
+ (void *)(CWM_DOWN|CWM_BIGMOVE));
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_L, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT,
+ (void *)(CWM_RIGHT|CWM_BIGMOVE));
+ conf_bindkey(c, kbfunc_client_resize,
+ XK_H, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT,
+ (void *)(CWM_LEFT|CWM_BIGMOVE));
+ }
snprintf(dir_settings, sizeof(dir_settings),
"%s/.calmwm/.settings", home);
diff --git a/cwm.1 b/cwm.1
index 82650a0..13baa78 100644
--- a/cwm.1
+++ b/cwm.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cwm.1,v 1.10 2007/10/07 16:56:21 ian Exp $
+.\" $OpenBSD: cwm.1,v 1.11 2007/11/07 21:58:03 oga Exp $
.\"
.\" The following requests are required for all man pages.
.Dd June 29, 2007
@@ -63,7 +63,7 @@ Raise current window.
Search for windows.
.It Ic C-/
Search for applications.
-.It Ic C-M-l
+.It Ic C-M-n
Label current window.
.It Ic M-Tab
Cycle through currently visible windows.
@@ -133,13 +133,17 @@ The default behavior for new windows is to not assign any group.
This changes the default behavior to assigning the currrently selected
group to any newly created windows.
.El
-.Sh WINDOW MOVEMENT
+.Sh WINDOW MOVEMENT AND RESIZING
.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.
+.Pp
+Similarly, windows may be resized with the same keybindings with the addition
+of the Control key. C-M-[hjkl] resizes the window a small amount and C-M-shift-[hjkl]
+resizes by a larger increment.
.Sh SEARCH
.Nm
features the ability to search for windows by their current title,
diff --git a/kbfunc.c b/kbfunc.c
index ca2e13b..f784c26 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Martin Murray <mmurray@monkey.org>
* All rights reserved.
*
- * $Id: kbfunc.c,v 1.7 2007/09/06 06:01:14 jasper Exp $
+ * $Id: kbfunc.c,v 1.8 2007/11/07 21:58:03 oga Exp $
*/
#include <paths.h>
@@ -67,6 +67,51 @@ kbfunc_client_move(struct client_ctx *cc, void *arg)
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) {
+ 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.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_client_search(struct client_ctx *scratch, void *arg)
{