summary refs log tree commit diff
diff options
context:
space:
mode:
authortodd <todd>2007-11-13 23:08:49 +0000
committertodd <todd>2007-11-13 23:08:49 +0000
commit576d299095ac1a0aec7fef700d94f6c1a53c2bcb (patch)
tree87db35baa2c14d5c49a3f73125b18b49bbcc518e
parentdc39e11ff9da56fe22f9c29eb90be8508e50d0be (diff)
downloadcwm-576d299095ac1a0aec7fef700d94f6c1a53c2bcb.tar.gz
cwm-576d299095ac1a0aec7fef700d94f6c1a53c2bcb.tar.xz
cwm-576d299095ac1a0aec7fef700d94f6c1a53c2bcb.zip
enable pointer movement in cwm via C-<arrowkeys>
looked over by oga@
-rw-r--r--calmwm.h1
-rw-r--r--conf.c28
-rw-r--r--cwm.18
-rw-r--r--kbfunc.c38
4 files changed, 75 insertions, 0 deletions
diff --git a/calmwm.h b/calmwm.h
index 75b968b..1f2ce6f 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -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);
diff --git a/conf.c b/conf.c
index 0bec9aa..381ded8 100644
--- a/conf.c
+++ b/conf.c
@@ -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 },
diff --git a/cwm.1 b/cwm.1
index 533a9c0..e231ca5 100644
--- a/cwm.1
+++ b/cwm.1
@@ -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
diff --git a/kbfunc.c b/kbfunc.c
index 05e8d93..1275a83 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -113,6 +113,44 @@ kbfunc_client_resize(struct client_ctx *cc, void *arg)
 }
 
 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)
 {
 	struct menu_q menuq;