enable pointer movement in cwm via C-<arrowkeys>

looked over by oga@
This commit is contained in:
todd 2007-11-13 23:08:49 +00:00
parent dc39e11ff9
commit 576d299095
4 changed files with 75 additions and 0 deletions

View File

@ -435,6 +435,7 @@ 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_ptrmove(struct client_ctx *, void *);
void kbfunc_ssh(struct client_ctx *, void *);
void kbfunc_term(struct client_ctx *cc, void *arg);
void kbfunc_lock(struct client_ctx *cc, void *arg);

28
conf.c
View File

@ -282,6 +282,26 @@ conf_setup(struct conf *c)
conf_bindkey(c, kbfunc_client_resize,
XK_H, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT,
(void *)(CWM_LEFT|CWM_BIGMOVE));
conf_bindkey(c, kbfunc_ptrmove,
XK_Up, ControlMask, 0, (void *)CWM_UP);
conf_bindkey(c, kbfunc_ptrmove,
XK_Down, ControlMask, 0, (void *)CWM_DOWN);
conf_bindkey(c, kbfunc_ptrmove,
XK_Right, ControlMask, 0, (void *)CWM_RIGHT);
conf_bindkey(c, kbfunc_ptrmove,
XK_Left, ControlMask, 0, (void *)CWM_LEFT);
conf_bindkey(c, kbfunc_ptrmove,
XK_Up, ControlMask|ShiftMask, 0,
(void *)(CWM_UP|CWM_BIGMOVE));
conf_bindkey(c, kbfunc_ptrmove,
XK_Left, ControlMask|ShiftMask, 0,
(void *)(CWM_LEFT|CWM_BIGMOVE));
conf_bindkey(c, kbfunc_ptrmove,
XK_Right, ControlMask|ShiftMask, 0,
(void *)(CWM_RIGHT|CWM_BIGMOVE));
conf_bindkey(c, kbfunc_ptrmove,
XK_Down, ControlMask|ShiftMask, 0,
(void *)(CWM_DOWN|CWM_BIGMOVE));
}
snprintf(dir_settings, sizeof(dir_settings),
@ -392,6 +412,14 @@ struct {
{ "rcycle", kbfunc_client_rcycle, KBFLAG_NEEDCLIENT, 0 },
{ "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, 0 },
{ "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, 0 },
{ "ptru", kbfunc_ptrmove, 0, (void *)CWM_UP },
{ "ptrd", kbfunc_ptrmove, 0, (void *)CWM_DOWN },
{ "ptrl", kbfunc_ptrmove, 0, (void *)CWM_LEFT },
{ "ptrr", kbfunc_ptrmove, 0, (void *)CWM_RIGHT },
{ "bigptru", kbfunc_ptrmove, 0, (void *)(CWM_UP|CWM_BIGMOVE) },
{ "bigptrd", kbfunc_ptrmove, 0, (void *)(CWM_DOWN|CWM_BIGMOVE) },
{ "bigptrl", kbfunc_ptrmove, 0, (void *)(CWM_LEFT|CWM_BIGMOVE) },
{ "bigptrr", kbfunc_ptrmove, 0, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
{ "groupselect", kbfunc_client_groupselect, 0, 0 },
{ "group1", kbfunc_client_group, 0, (void *)1 },
{ "group2", kbfunc_client_group, 0, (void *)2 },

8
cwm.1
View File

@ -132,6 +132,14 @@ Set sticky group mode on.
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.
.Pp
.Sh POINTER MOVEMENT
The pointer can be moved with the use of the keyboard through bindings.
C-[UP|DOWN|LEFT|RIGHT] moves the pointer a small amount, while
C-shift-[UP|DOWN|LEFT|RIGHT] moves the current window a larger amount.
For example, to move the pointer to the left by a small amount,
press C-LEFT.
To move the pointer down by a larger amount, press C-shift-DOWN.
.El
.Sh WINDOW MOVEMENT AND RESIZING
.Nm

View File

@ -112,6 +112,44 @@ kbfunc_client_resize(struct client_ctx *cc, void *arg)
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;
break;
case CWM_RIGHT:
mx += amt;
break;
case CWM_LEFT:
mx -= amt;
break;
}
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
kbfunc_client_search(struct client_ctx *scratch, void *arg)
{