[ALL] Add tag transfert function, Clients blocking by bar, and fix Max bug

This commit is contained in:
Martin Duquesnoy 2008-08-12 04:10:04 +02:00
parent a0de55bd9a
commit 00133aed50
4 changed files with 72 additions and 26 deletions

View File

@ -22,7 +22,8 @@ func_name_list_t func_list[] = {
{"keymovey", keymovey},
{"keyresize", keyresize},
{"layoutswitch",layoutswitch},
{"tag", tag}
{"tag", tag},
{"tagtransfert", tagtransfert}
};
key_name_list_t key_list[] = {
@ -64,11 +65,12 @@ init_conf(void) {
static cfg_opt_t misc_opts[] = {
CFG_STR("font", "*-fixed-medium-*-12-*", CFGF_NONE),
CFG_BOOL("raisefocus", cfg_false, CFGF_NONE),
CFG_BOOL("raiseswitch", cfg_true, CFGF_NONE),
CFG_INT("border_height", 1, CFGF_NONE),
CFG_INT("titlebar_height", 12, CFGF_NONE),
CFG_STR("font", "*-fixed-medium-*-12-*", CFGF_NONE),
CFG_BOOL("raisefocus", cfg_false, CFGF_NONE),
CFG_BOOL("raiseswitch", cfg_true, CFGF_NONE),
CFG_INT("border_height", 1, CFGF_NONE),
CFG_INT("titlebar_height", 12, CFGF_NONE),
CFG_BOOL("clients_bar_block", cfg_true, CFGF_NONE),
CFG_END()
};
@ -152,11 +154,12 @@ init_conf(void) {
cfg_keys = cfg_getsec(cfg, "keys");
/* misc */
conf.font = strdup(cfg_getstr(cfg_misc, "font"));
conf.raisefocus = cfg_getbool(cfg_misc, "raisefocus");
conf.raiseswitch = cfg_getbool(cfg_misc, "raiseswitch");
conf.borderheight = cfg_getint(cfg_misc, "border_height");
conf.ttbarheight = cfg_getint(cfg_misc, "titlebar_height");
conf.font = strdup(cfg_getstr(cfg_misc, "font"));
conf.raisefocus = cfg_getbool(cfg_misc, "raisefocus");
conf.raiseswitch = cfg_getbool(cfg_misc, "raiseswitch");
conf.borderheight = cfg_getint(cfg_misc, "border_height");
conf.ttbarheight = cfg_getint(cfg_misc, "titlebar_height");
conf.clientbarblock = cfg_getbool(cfg_misc, "clients_bar_block");
/* colors */
conf.colors.bordernormal = cfg_getint(cfg_colors, "border_normal");

View File

@ -72,6 +72,7 @@ typedef struct {
char *font;
bool raisefocus;
bool raiseswitch;
bool clientbarblock;
int borderheight;
int ttbarheight;
struct {
@ -132,6 +133,8 @@ void spawn(char *cmd);
void tag(char *cmd);
void tagn(int tag);
void tagswitch(char *cmd);
void tagtransfert(char *cmd);
void tagtransfertn(int n);
void tile(char *cmd);
void togglemax(char *cmd);
void unhide(Client *c);

55
wmfs.c
View File

@ -190,6 +190,7 @@ getevent(void) {
}
break;
case ConfigureRequest:
/* configure size and window position */
wc.x = event.xconfigurerequest.x;
wc.y = event.xconfigurerequest.y;
wc.width = event.xconfigurerequest.width;
@ -197,8 +198,9 @@ getevent(void) {
wc.border_width = event.xconfigurerequest.border_width;
wc.sibling = event.xconfigurerequest.above;
wc.stack_mode = event.xconfigurerequest.detail;
XConfigureWindow(dpy, event.xconfigurerequest.window,
event.xconfigurerequest.value_mask, &wc);
event.xconfigurerequest.value_mask, &wc);
break;
case UnmapNotify:
@ -245,6 +247,10 @@ getevent(void) {
if(event.xbutton.x > taglen[i-1]
&& event.xbutton.x < taglen[i]) {
if(event.xbutton.button == Button1) {
if(event.xbutton.state & ALT) {
tagtransfertn(i);
updateall();
}
tagn(i);
updateall();
}
@ -527,6 +533,7 @@ manage(Window w, XWindowAttributes *wa) {
XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask |
PropertyChangeMask | StructureNotifyMask);
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
for(t = clients; t && t->win != trans; t = t->next);
@ -549,11 +556,12 @@ manage(Window w, XWindowAttributes *wa) {
conf.colors.button,
conf.colors.button);
XSelectInput(dpy, c->button, ExposureMask | EnterWindowMask);
grabbuttons(c, False);
setsizehints(c);
attach(c);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
moveresize(c, c->x, c->y, c->w, c->h);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
mapclient(c);
updatetitle(c);
setborder(c->tbar, conf.colors.bordernormal);
@ -589,7 +597,6 @@ mouseaction(Client *c, int x, int y, int type) {
return;
} else if(ev.type == MotionNotify) {
if(c->y <= barheight + conf.ttbarheight) updatebar();
XSync(dpy, 0);
if(type) /* Resize */
@ -611,14 +618,6 @@ moveresize(Client *c, int x, int y, int w, int h) {
if(c) {
/* Resize hints {{{ */
if (w < 1) w = 1;
if (h < 1) h = 1;
w -= c->basew;
h -= c->baseh;
if(c->incw) w -= w % c->incw;
if(c->inch) h -= h % c->inch;
w += c->basew;
h += c->baseh;
if(c->minw > 0 && w < c->minw) w = c->minw;
if(c->minh > 0 && h < c->minh) h = c->minh;
if(c->maxw > 0 && w > c->maxw) w = c->maxw;
@ -634,6 +633,11 @@ moveresize(Client *c, int x, int y, int w, int h) {
c->y = y;
c->w = w;
c->h = h;
if(conf.clientbarblock)
if((y-conf.ttbarheight) <= barheight)
y = barheight+conf.ttbarheight;
XMoveResizeWindow(dpy, c->win, x, y, w ,h);
XMoveResizeWindow(dpy, c->tbar, x, y - conf.ttbarheight, w, conf.ttbarheight);
XMoveResizeWindow(dpy, c->button,
@ -783,6 +787,29 @@ tagswitch(char *cmd) {
return;
}
void
tagtransfert(char *cmd) {
int n = atoi(cmd);
if(!sel)
return;
sel->tag = n;
if(n != seltag)
hide(sel);
if(n == seltag)
unhide(sel);
}
void
tagtransfertn(int n) {
if(!sel)
return;
sel->tag = n;
if(n != seltag)
hide(sel);
if(n == seltag)
unhide(sel);
}
void
tile(char *cmd) {
if(sel) {
@ -842,6 +869,7 @@ togglemax(char *cmd) {
sel->max = True;
sel->layout = Max;
} else if(sel->max) {
raiseclient(sel);
moveresize(sel, sel->ox, sel->oy, sel->ow, sel->oh);
sel->max = False;
sel->layout = Free;
@ -894,8 +922,8 @@ updatebar(void) {
char buf[conf.ntag][100];
tm = localtime(&lt);
lt = time(NULL);
XRaiseWindow(dpy, bar);
if(!conf.clientbarblock)
XRaiseWindow(dpy, bar);
XClearWindow(dpy, bar);
XSetForeground(dpy, gc, conf.colors.text);
@ -923,6 +951,7 @@ updatebar(void) {
(sel) ? conf.symlayout[sel->layout] : conf.symlayout[Free],
(sel) ? strlen(conf.symlayout[sel->layout]) :strlen(conf.symlayout[Free]) );
/* Draw date */
sprintf(status, "%02d:%02d WMFS", tm->tm_hour, tm->tm_min);
j = strlen(status);
XSetForeground(dpy, gc, conf.colors.text);

15
wmfsrc
View File

@ -7,6 +7,7 @@ misc
raiseswitch = true
border_height = 1
titlebar_height = 12
clients_bar_block = true
}
colors
@ -35,7 +36,6 @@ keys
#general keybind
key { mod = {"Control"} key = "Return" func = "spawn" cmd = "urxvt" }
key { mod = {"Alt"} key = "t" func = "spawn" cmd = "thunar" }
key { mod = {"Alt"} key = "q" func = "killclient" cmd = NULL }
key { mod = {"Control"} key = "t" func = "togglemax" cmd = NULL }
key { mod = {"Control"} key = "o" func = "tile" cmd = NULL }
@ -58,7 +58,7 @@ keys
key { mod = {"Shift","Alt"} key = "Up" func = "keyresize" cmd = "-h" }
key { mod = {"Shift","Alt"} key = "Left" func = "keyresize" cmd = "-w" }
# tag switching keybind
# tag manipulation keybind
key { mod = {"Alt"} key = "F1" func = "tag" cmd = "1" }
key { mod = {"Alt"} key = "F2" func = "tag" cmd = "2" }
@ -69,4 +69,15 @@ keys
key { mod = {"Alt"} key = "F7" func = "tag" cmd = "7" }
key { mod = {"Alt"} key = "F8" func = "tag" cmd = "8" }
key { mod = {"Alt"} key = "F9" func = "tag" cmd = "9" }
key { mod = {"Control", "Shift"} key = "F1" func = "tagtransfert" cmd ="1" }
key { mod = {"Control", "Shift"} key = "F2" func = "tagtransfert" cmd ="2" }
key { mod = {"Control", "Shift"} key = "F3" func = "tagtransfert" cmd ="3" }
key { mod = {"Control", "Shift"} key = "F4" func = "tagtransfert" cmd ="4" }
key { mod = {"Control", "Shift"} key = "F5" func = "tagtransfert" cmd ="5" }
key { mod = {"Control", "Shift"} key = "F6" func = "tagtransfert" cmd ="6" }
key { mod = {"Control", "Shift"} key = "F7" func = "tagtransfert" cmd ="7" }
key { mod = {"Control", "Shift"} key = "F8" func = "tagtransfert" cmd ="8" }
key { mod = {"Control", "Shift"} key = "F9" func = "tagtransfert" cmd ="9" }
}