vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi guys, The previous diffs to cwm to allow moving windows with the keyboard were great. I got very annoyed that the same thing didn't work with resizing, So here's a patch to fix that. C-M-[hjkl] resizes instead of moving, with C-M-shift-[hjkl] resizing by a larger increment. This did conflict with the keybinding for adding a label (C-M-l), so i've moved it to C-M-n (mnemonic is `name'). There were some basic problems with deciding how to move the mouse cursor so that it stayed within the window. Since no way seemed best, this patch just moves the mouse to the new center of the window. I suppose this should have gone upstream. However, since the previous patches haven't been added to cwm (AFAIK) I thought it was better to provide them here. The patch (resize.diff) is inline at the end of this mail. Any comments? Also i've noticed that due to the choice of amount for resizing/moving it is impossible to place something precisely, for example at the corner of the screen. The obvious fix for this is found in amount.diff at the end of this email. This of course makes the fine-moving fairly slow. I suppose it's a question of taste. Thirdly, i've noticed a lack of documentation for the ability to change the keybindings. I found the code to do it when I was looking at the code. I've yet to document this, or test the existing code, however, first the new functions (for example the ssh completion, moving and resizing functions) would need to be addeed to the keybindings structure (with suitable names). Would there be interest in a diff that fixed those issues and attempted to document the feature? Patches follow. Cheers, Owain ---- Resize.diff ----- (generated with cvs diff -u) Index: calmwm.h ================================================== ================= RCS file: /cvs/xenocara/app/cwm/calmwm.h,v retrieving revision 1.8 diff -u -p -r1.8 calmwm.h --- calmwm.h 27 Jun 2007 13:28:22 -0000 1.8 +++ calmwm.h 4 Sep 2007 17:27:15 -0000 @@ -432,6 +432,7 @@ void kbfunc_client_nogroup(struct client 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 *); Index: conf.c ================================================== ================= RCS file: /cvs/xenocara/app/cwm/conf.c,v retrieving revision 1.8 diff -u -p -r1.8 conf.c --- conf.c 27 Jun 2007 13:28:22 -0000 1.8 +++ conf.c 4 Sep 2007 17:27:16 -0000 @@ -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,6 +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), Index: cwm.1 ================================================== ================= RCS file: /cvs/xenocara/app/cwm/cwm.1,v retrieving revision 1.9 diff -u -p -r1.9 cwm.1 --- cwm.1 29 Jun 2007 21:10:37 -0000 1.9 +++ cwm.1 4 Sep 2007 17:27:17 -0000 @@ -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 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, Index: kbfunc.c ================================================== ================= RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v retrieving revision 1.6 diff -u -p -r1.6 kbfunc.c --- kbfunc.c 27 Jun 2007 13:28:22 -0000 1.6 +++ kbfunc.c 4 Sep 2007 17:27:21 -0000 @@ -67,6 +67,51 @@ kbfunc_client_move(struct client_ctx *cc 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 promblematic. 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) { ------amount.diff ----------------- --- kbfunc.c.orig Tue Sep 4 18:35:54 2007 +++ kbfunc.c Tue Sep 4 18:36:08 2007 @@ -14,7 +14,7 @@ #define KNOWN_HOSTS ".ssh/known_hosts" #define HASH_MARKER "|1|" -#define MOVE_AMOUNT 10 +#define MOVE_AMOUNT 1 void kbfunc_client_lower(struct client_ctx *cc, void *arg) -- Committees have become so important nowadays that subcommittees have to be appointed to do the work. |