mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
merge kbfunc_{ptrmove,client_{move,resize}} into one function that takes a flag,
this code was almost identical... ok okan.
This commit is contained in:
parent
cd5c340e01
commit
898bfff36a
16
calmwm.h
16
calmwm.h
@ -205,10 +205,14 @@ struct xevent {
|
|||||||
|
|
||||||
TAILQ_HEAD(xevent_q, xevent);
|
TAILQ_HEAD(xevent_q, xevent);
|
||||||
|
|
||||||
#define CWM_BIGMOVE 0x1000
|
#define CWM_MOVE 0x01
|
||||||
enum directions {
|
#define CWM_RESIZE 0x02
|
||||||
CWM_UP = 0, CWM_DOWN, CWM_LEFT, CWM_RIGHT,
|
#define CWM_PTRMOVE 0x04
|
||||||
};
|
#define CWM_BIGMOVE 0x08
|
||||||
|
#define CWM_UP 0x10
|
||||||
|
#define CWM_DOWN 0x20
|
||||||
|
#define CWM_LEFT 0x40
|
||||||
|
#define CWM_RIGHT 0x80
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Match a window.
|
* Match a window.
|
||||||
@ -447,11 +451,9 @@ void kbfunc_client_nogroup(struct client_ctx *, void *);
|
|||||||
void kbfunc_client_maximize(struct client_ctx *, void *);
|
void kbfunc_client_maximize(struct client_ctx *, void *);
|
||||||
void kbfunc_client_vmaximize(struct client_ctx *, void *);
|
void kbfunc_client_vmaximize(struct client_ctx *, void *);
|
||||||
void kbfunc_quit_wm(struct client_ctx *, void *);
|
void kbfunc_quit_wm(struct client_ctx *, void *);
|
||||||
void kbfunc_client_move(struct client_ctx *, void *);
|
void kbfunc_moveresize(struct client_ctx *, void *);
|
||||||
void kbfunc_client_resize(struct client_ctx *, void *);
|
|
||||||
void kbfunc_menu_search(struct client_ctx *, void *);
|
void kbfunc_menu_search(struct client_ctx *, void *);
|
||||||
void kbfunc_exec(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_ssh(struct client_ctx *, void *);
|
||||||
void kbfunc_term(struct client_ctx *, void *);
|
void kbfunc_term(struct client_ctx *, void *);
|
||||||
void kbfunc_lock(struct client_ctx *, void *);
|
void kbfunc_lock(struct client_ctx *, void *);
|
||||||
|
69
conf.c
69
conf.c
@ -238,14 +238,6 @@ struct {
|
|||||||
{ "rcycle", kbfunc_client_rcycle, 0, 0 },
|
{ "rcycle", kbfunc_client_rcycle, 0, 0 },
|
||||||
{ "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, 0 },
|
{ "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, 0 },
|
||||||
{ "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, 0 },
|
{ "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, 0 },
|
||||||
{ "ptrmoveup", kbfunc_ptrmove, 0, (void *)CWM_UP },
|
|
||||||
{ "ptrmovedown", kbfunc_ptrmove, 0, (void *)CWM_DOWN },
|
|
||||||
{ "ptrmoveleft", kbfunc_ptrmove, 0, (void *)CWM_LEFT },
|
|
||||||
{ "ptrmoveright", kbfunc_ptrmove, 0, (void *)CWM_RIGHT },
|
|
||||||
{ "bigptrmoveup", kbfunc_ptrmove, 0, (void *)(CWM_UP|CWM_BIGMOVE) },
|
|
||||||
{ "bigptrmovedown", kbfunc_ptrmove, 0, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
|
||||||
{ "bigptrmoveleft", kbfunc_ptrmove, 0, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
|
||||||
{ "bigptrmoveright", kbfunc_ptrmove, 0, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
|
||||||
{ "group1", kbfunc_client_group, 0, (void *)1 },
|
{ "group1", kbfunc_client_group, 0, (void *)1 },
|
||||||
{ "group2", kbfunc_client_group, 0, (void *)2 },
|
{ "group2", kbfunc_client_group, 0, (void *)2 },
|
||||||
{ "group3", kbfunc_client_group, 0, (void *)3 },
|
{ "group3", kbfunc_client_group, 0, (void *)3 },
|
||||||
@ -266,22 +258,51 @@ struct {
|
|||||||
{ "ssh", kbfunc_ssh, 0, 0 },
|
{ "ssh", kbfunc_ssh, 0, 0 },
|
||||||
{ "terminal", kbfunc_term, 0, 0 },
|
{ "terminal", kbfunc_term, 0, 0 },
|
||||||
{ "lock", kbfunc_lock, 0, 0 },
|
{ "lock", kbfunc_lock, 0, 0 },
|
||||||
{ "moveup", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_UP },
|
{ "moveup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "movedown", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN },
|
(void *)(CWM_UP|CWM_MOVE) },
|
||||||
{ "moveright", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT },
|
{ "movedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "moveleft", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT },
|
(void *)(CWM_DOWN|CWM_MOVE) },
|
||||||
{ "bigmoveup", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_UP|CWM_BIGMOVE) },
|
{ "moveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "bigmovedown", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
(void *)(CWM_RIGHT|CWM_MOVE) },
|
||||||
{ "bigmoveright", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
{ "moveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "bigmoveleft", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
(void *)(CWM_LEFT|CWM_MOVE) },
|
||||||
{ "resizeup", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_UP) },
|
{ "bigmoveup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "resizedown", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN },
|
(void *)(CWM_UP|CWM_MOVE|CWM_BIGMOVE) },
|
||||||
{ "resizeright", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT },
|
{ "bigmovedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "resizeleft", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT },
|
(void *)(CWM_DOWN|CWM_MOVE|CWM_BIGMOVE) },
|
||||||
{ "bigresizeup", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_UP|CWM_BIGMOVE) },
|
{ "bigmoveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "bigresizedown", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
(void *)(CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE) },
|
||||||
{ "bigresizeright", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
{ "bigmoveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
{ "bigresizeleft", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
(void *)(CWM_LEFT|CWM_MOVE|CWM_BIGMOVE) },
|
||||||
|
{ "resizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_UP|CWM_RESIZE) },
|
||||||
|
{ "resizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_DOWN|CWM_RESIZE) },
|
||||||
|
{ "resizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_RIGHT|CWM_RESIZE) },
|
||||||
|
{ "resizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_LEFT|CWM_RESIZE) },
|
||||||
|
{ "bigresizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_UP|CWM_RESIZE|CWM_BIGMOVE) },
|
||||||
|
{ "bigresizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE) },
|
||||||
|
{ "bigresizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE) },
|
||||||
|
{ "bigresizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT,
|
||||||
|
(void *)(CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE) },
|
||||||
|
{ "ptrmoveup", kbfunc_moveresize, 0, (void *)(CWM_UP|CWM_PTRMOVE) },
|
||||||
|
{ "ptrmovedown", kbfunc_moveresize, 0, (void *)(CWM_DOWN|CWM_PTRMOVE) },
|
||||||
|
{ "ptrmoveleft", kbfunc_moveresize, 0, (void *)(CWM_LEFT|CWM_PTRMOVE) },
|
||||||
|
{ "ptrmoveright", kbfunc_moveresize, 0,
|
||||||
|
(void *)(CWM_RIGHT|CWM_PTRMOVE) },
|
||||||
|
{ "bigptrmoveup", kbfunc_moveresize, 0,
|
||||||
|
(void *)(CWM_UP|CWM_PTRMOVE|CWM_BIGMOVE) },
|
||||||
|
{ "bigptrmovedown", kbfunc_moveresize, 0,
|
||||||
|
(void *)(CWM_DOWN|CWM_PTRMOVE|CWM_BIGMOVE) },
|
||||||
|
{ "bigptrmoveleft", kbfunc_moveresize, 0,
|
||||||
|
(void *)(CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE) },
|
||||||
|
{ "bigptrmoveright", kbfunc_moveresize, 0,
|
||||||
|
(void *)(CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE) },
|
||||||
{ NULL, NULL, 0, 0},
|
{ NULL, NULL, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
87
kbfunc.c
87
kbfunc.c
@ -41,9 +41,12 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg)
|
|||||||
client_raise(cc);
|
client_raise(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define typemask (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE)
|
||||||
|
#define movemask (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
||||||
void
|
void
|
||||||
kbfunc_client_move(struct client_ctx *cc, void *arg)
|
kbfunc_moveresize(struct client_ctx *cc, void *arg)
|
||||||
{
|
{
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
int x,y,flags,amt;
|
int x,y,flags,amt;
|
||||||
u_int mx,my;
|
u_int mx,my;
|
||||||
|
|
||||||
@ -57,7 +60,7 @@ kbfunc_client_move(struct client_ctx *cc, void *arg)
|
|||||||
amt = amt*10;
|
amt = amt*10;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (flags) {
|
switch (flags & movemask) {
|
||||||
case CWM_UP:
|
case CWM_UP:
|
||||||
my -= amt;
|
my -= amt;
|
||||||
break;
|
break;
|
||||||
@ -71,7 +74,8 @@ kbfunc_client_move(struct client_ctx *cc, void *arg)
|
|||||||
mx -= amt;
|
mx -= amt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
switch (flags & typemask) {
|
||||||
|
case CWM_MOVE:
|
||||||
cc->geom.y += my;
|
cc->geom.y += my;
|
||||||
cc->geom.x += mx;
|
cc->geom.x += mx;
|
||||||
client_move(cc);
|
client_move(cc);
|
||||||
@ -79,39 +83,8 @@ kbfunc_client_move(struct client_ctx *cc, void *arg)
|
|||||||
cc->ptr.y = y + my;
|
cc->ptr.y = y + my;
|
||||||
cc->ptr.x = x + mx;
|
cc->ptr.x = x + mx;
|
||||||
client_ptrwarp(cc);
|
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;
|
break;
|
||||||
case CWM_DOWN:
|
case CWM_RESIZE:
|
||||||
my += amt;
|
|
||||||
break;
|
|
||||||
case CWM_RIGHT:
|
|
||||||
mx += amt;
|
|
||||||
break;
|
|
||||||
case CWM_LEFT:
|
|
||||||
mx -= amt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc->geom.height += my;
|
cc->geom.height += my;
|
||||||
cc->geom.width += mx;
|
cc->geom.width += mx;
|
||||||
client_resize(cc);
|
client_resize(cc);
|
||||||
@ -123,44 +96,20 @@ kbfunc_client_resize(struct client_ctx *cc, void *arg)
|
|||||||
cc->ptr.x = -1;
|
cc->ptr.x = -1;
|
||||||
cc->ptr.y = -1;
|
cc->ptr.y = -1;
|
||||||
client_ptrwarp(cc);
|
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;
|
break;
|
||||||
case CWM_DOWN:
|
case CWM_PTRMOVE:
|
||||||
my += amt;
|
|
||||||
break;
|
|
||||||
case CWM_RIGHT:
|
|
||||||
mx += amt;
|
|
||||||
break;
|
|
||||||
case CWM_LEFT:
|
|
||||||
mx -= amt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cc) {
|
if (cc) {
|
||||||
xu_ptr_getpos(cc->pwin, &px, &py);
|
xu_ptr_getpos(cc->pwin, &x, &y);
|
||||||
xu_ptr_setpos(cc->pwin, px + mx, py + my);
|
xu_ptr_setpos(cc->pwin, x + mx, y + my);
|
||||||
} else {
|
} else {
|
||||||
xu_ptr_getpos(sc->rootwin, &px, &py);
|
xu_ptr_getpos(sc->rootwin, &x, &y);
|
||||||
xu_ptr_setpos(sc->rootwin, px + mx, py + my);
|
xu_ptr_setpos(sc->rootwin, x + mx, y + my);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
warnx("invalid flags passed to kbfunc_client_moveresize");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user