diff --git a/src/client.c b/src/client.c index 517e7ec..5bdb3c9 100644 --- a/src/client.c +++ b/src/client.c @@ -131,7 +131,7 @@ client_focus(Client *c) if(sel && sel != c) { grabbuttons(sel, False); - XSetWindowBorder(dpy, sel->win, conf.colors.bordernormal); + XSetWindowBorder(dpy, sel->win, conf.client.bordernormal); } if(c) @@ -142,7 +142,7 @@ client_focus(Client *c) if(c) { - XSetWindowBorder(dpy, c->win, conf.colors.borderfocus); + XSetWindowBorder(dpy, c->win, conf.client.borderfocus); if(conf.raisefocus) client_raise(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); @@ -253,7 +253,7 @@ client_manage(Window w, XWindowAttributes *wa) c->geo.width = wa->width; c->geo.height = wa->height; c->tag = seltag; - c->border = conf.borderheight; + c->border = conf.client.borderheight; /* Create titlebar */ if(conf.titlebar.height) @@ -265,7 +265,7 @@ client_manage(Window w, XWindowAttributes *wa) winc.border_width = c->border; XConfigureWindow(dpy, w, CWBorderWidth, &winc); - XSetWindowBorder(dpy, w, conf.colors.bordernormal); + XSetWindowBorder(dpy, w, conf.client.bordernormal); grabbuttons(c, False); XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask); diff --git a/src/config.c b/src/config.c index 3b571d5..ae02404 100644 --- a/src/config.c +++ b/src/config.c @@ -37,7 +37,7 @@ func_name_list_t func_list[] = { {"spawn", uicb_spawn }, - {"killclient", uicb_client_kill }, + {"client_kill", uicb_client_kill }, {"client_prev", uicb_client_prev }, {"client_next", uicb_client_next }, {"togglemax", uicb_togglemax }, @@ -173,15 +173,12 @@ init_conf(void) CFG_STR("bar_position", "top", 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("tag_border_width", 0, CFGF_NONE), CFG_END() }; static cfg_opt_t colors_opts[] = { - CFG_STR("border_normal", "#354B5C", CFGF_NONE), - CFG_STR("border_focus", "#6286A1", CFGF_NONE), CFG_STR("bar_bg", "#090909", CFGF_NONE), CFG_STR("bar_fg", "#6289A1", CFGF_NONE), CFG_STR("tag_sel_fg", "#FFFFFF", CFGF_NONE), @@ -210,6 +207,15 @@ init_conf(void) CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI) }; + static cfg_opt_t client_opts[]= + { + CFG_INT("border_height", 1, CFGF_NONE), + CFG_STR("border_normal", "#354B5C", CFGF_NONE), + CFG_STR("border_focus", "#6286A1", CFGF_NONE), + CFG_STR("modifier", "Alt", CFGF_NONE), + CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI) + }; + static cfg_opt_t layout_opts[] = { CFG_STR("type", "", CFGF_NONE), @@ -287,6 +293,7 @@ init_conf(void) CFG_SEC("misc", misc_opts, CFGF_NONE), CFG_SEC("variables", variables_opts, CFGF_NONE), CFG_SEC("titlebar", titlebar_opts, CFGF_NONE), + CFG_SEC("client", client_opts, CFGF_NONE), CFG_SEC("colors", colors_opts, CFGF_NONE), CFG_SEC("layouts", layouts_opts, CFGF_NONE), CFG_SEC("tags", tags_opts, CFGF_NONE), @@ -300,6 +307,7 @@ init_conf(void) cfg_t *cfg_colors; cfg_t *cfg_variables; cfg_t *cfg_titlebar; + cfg_t *cfg_client; cfg_t *cfg_layouts; cfg_t *cfg_tags; cfg_t *cfg_keys; @@ -328,6 +336,7 @@ init_conf(void) cfg_misc = cfg_getsec(cfg, "misc"); cfg_variables = cfg_getsec(cfg, "variables"); cfg_titlebar = cfg_getsec(cfg, "titlebar"); + cfg_client = cfg_getsec(cfg, "client"); cfg_colors = cfg_getsec(cfg, "colors"); cfg_layouts = cfg_getsec(cfg, "layouts"); cfg_tags = cfg_getsec(cfg, "tags"); @@ -351,13 +360,10 @@ init_conf(void) conf.font = var_to_str(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.tagbordwidth = cfg_getint(cfg_misc, "tag_border_width"); conf.bartop = (strcmp(strdup(cfg_getstr(cfg_misc, "bar_position")), "top") == 0) ? True : False; /* colors */ - conf.colors.bordernormal = getcolor(var_to_str(cfg_getstr(cfg_colors, "border_normal"))); - conf.colors.borderfocus = getcolor(var_to_str(cfg_getstr(cfg_colors, "border_focus"))); conf.colors.bar = getcolor(var_to_str(cfg_getstr(cfg_colors, "bar_bg"))); conf.colors.text = strdup(var_to_str(cfg_getstr(cfg_colors, "bar_fg"))); conf.colors.tagselfg = strdup(var_to_str(cfg_getstr(cfg_colors, "tag_sel_fg"))); @@ -390,6 +396,24 @@ init_conf(void) conf.titlebar.mouse[i].cmd = strdup(var_to_str(cfg_getstr(cfgtmp, "cmd"))); } + /* client */ + conf.client.borderheight = cfg_getint(cfg_client, "border_height"); + conf.client.bordernormal = getcolor(var_to_str(cfg_getstr(cfg_client, "border_normal"))); + conf.client.borderfocus = getcolor(var_to_str(cfg_getstr(cfg_client, "border_focus"))); + conf.client.mod |= char_to_modkey(cfg_getstr(cfg_client, "modifier")); + + conf.client.nmouse = cfg_size(cfg_titlebar, "mouse"); + conf.client.mouse = emalloc(conf.client.nmouse, sizeof(MouseBinding)); + + for(i = 0; i < conf.client.nmouse; ++i) + { + cfgtmp = cfg_getnsec(cfg_client, "mouse", i); + conf.client.mouse[i].button = char_to_button(cfg_getstr(cfgtmp, "button")); + conf.client.mouse[i].func = name_to_func(cfg_getstr(cfgtmp, "func"), func_list); + conf.client.mouse[i].cmd = strdup(var_to_str(cfg_getstr(cfgtmp, "cmd"))); + } + + /* layout */ if((conf.nlayout = cfg_size(cfg_layouts, "layout")) > MAXLAYOUT || !(conf.nlayout = cfg_size(cfg_layouts, "layout"))) diff --git a/src/event.c b/src/event.c index 232f8cc..cf43cbb 100644 --- a/src/event.c +++ b/src/event.c @@ -48,45 +48,22 @@ buttonpress(XEvent ev) /* ******** */ { if(conf.titlebar.height) - { if((c = client_gettbar(ev.xbutton.window))) for(i = 0; i < conf.titlebar.nmouse; ++i) if(ev.xbutton.button == conf.titlebar.mouse[i].button) if(conf.titlebar.mouse[i].func) conf.titlebar.mouse[i].func(conf.titlebar.mouse[i].cmd); - } } - /* ****** */ /* CLIENT */ /* ****** */ { if((c = client_get(ev.xbutton.window))) - { - client_raise(c); - /* BUTTON 1 */ - { - if(ev.xbutton.button == Button1) - mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, False); - } - /* BUTTON 2 */ - { - if(ev.xbutton.button == Button2) - { - if(tags[seltag].layout.func == tile) - uicb_tile_switch(NULL); - else - uicb_togglemax(NULL); - } - } - /* BUTTON 3 */ - { - if(ev.xbutton.button == Button3) - mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, True); - } - } - + for(i = 0; i < conf.client.nmouse; ++i) + if(ev.xbutton.button == conf.client.mouse[i].button) + if(conf.client.mouse[i].func) + conf.client.mouse[i].func(conf.client.mouse[i].cmd); } /* *** */ @@ -146,7 +123,8 @@ buttonpress(XEvent ev) /* ****** */ { if(ev.xbutton.x >= taglen[conf.ntag] - && ev.xbutton.x <= taglen[conf.ntag] + textw(tags[seltag].layout.symbol) + PAD/2) + && ev.xbutton.x <= taglen[conf.ntag] + + textw(tags[seltag].layout.symbol) + PAD/2) { /* BUTTON 1 / 4 */ { @@ -287,17 +265,19 @@ focusin(XEvent ev) void grabbuttons(Client *c, Bool focused) { + uint mod = conf.client.mod; + XUngrabButton(dpy, AnyButton, AnyModifier, c->win); if(focused) { /* Window */ - XGrabButton(dpy, Button1, ALT, c->win, False, ButtonMask, GrabModeAsync,GrabModeSync, None, None); - XGrabButton(dpy, Button1, ALT|LockMask, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button2, ALT, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button2, ALT|LockMask, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button3, ALT, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button3, ALT|LockMask, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button1, mod, c->win, False, ButtonMask, GrabModeAsync,GrabModeSync, None, None); + XGrabButton(dpy, Button1, mod|LockMask, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button2, mod, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button2, mod|LockMask, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button3, mod, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button3, mod|LockMask, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); } else XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); diff --git a/src/layout.c b/src/layout.c index ebf6d86..8db34e9 100644 --- a/src/layout.c +++ b/src/layout.c @@ -131,8 +131,8 @@ maxlayout(void) c->ogeo.width = c->geo.width; c->ogeo.height = c->geo.height; geo.x = sgeo.x; geo.y = sgeo.y; - geo.width = sgeo.width - (conf.borderheight * 2); - geo.height = sgeo.height - (conf.borderheight * 2); + geo.width = sgeo.width - (c->border * 2); + geo.height = sgeo.height - (c->border * 2); client_moveresize(c, geo, False); } @@ -188,7 +188,7 @@ tile(void) XRectangle cgeo = {sgeo.x, sgeo.y, 0, 0}; uint n, mwfact = tags[seltag].mwfact * sgeo.width; uint nmaster = tags[seltag].nmaster; - uint tileheight, i, border = conf.borderheight*2; + uint tileheight, i, border = conf.client.borderheight * 2; for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), ++n); if(!n) @@ -296,8 +296,8 @@ uicb_togglemax(uicb_t cmd) sel->ogeo.width = sel->geo.width; sel->ogeo.height = sel->geo.height; geo.x = sgeo.x; geo.y = sgeo.y; - geo.width = sgeo.width - (conf.borderheight * 2); - geo.height = sgeo.height - (conf.borderheight * 2); + geo.width = sgeo.width - (sel->border * 2); + geo.height = sgeo.height - (sel->border * 2); client_moveresize(sel, geo, False); client_raise(sel); diff --git a/src/structs.h b/src/structs.h index ea1b625..6709b5c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -148,14 +148,11 @@ typedef struct bool raisefocus; bool raiseswitch; bool bartop; - int borderheight; int tagbordwidth; struct { /* Only the colors will be use for text * are 'char*' (for xprint -> XftColorAllocName) */ - uint bordernormal; - uint borderfocus; uint bar; char *text; char *tagselfg; @@ -165,6 +162,15 @@ typedef struct uint layout_bg; } colors; struct + { + int borderheight; + uint bordernormal; + uint borderfocus; + uint mod; + MouseBinding *mouse; + int nmouse; + } client; + struct { int height; uint bg; diff --git a/src/wmfs.c b/src/wmfs.c index e077826..4ebeb62 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -101,6 +101,8 @@ quit(void) free(conf.barbutton); free(keys); free(clients); + free(conf.titlebar.mouse); + free(conf.client.mouse); XSync(dpy, False); return; diff --git a/src/wmfs.h b/src/wmfs.h index a41fcb5..8ca6b51 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -57,7 +57,6 @@ #define ButtonMask (ButtonPressMask | ButtonReleaseMask) #define MouseMask (ButtonMask | PointerMotionMask) #define KeyMask (KeyPressMask | KeyReleaseMask) -#define ALT Mod1Mask #define ITOA(p ,n) sprintf(p, "%i", n) #define debug(p) fprintf(stderr, "debug: %i\n", p) #define PAD 8 diff --git a/wmfsrc b/wmfsrc index 081ed92..cedc646 100644 --- a/wmfsrc +++ b/wmfsrc @@ -11,16 +11,11 @@ misc bar_position = "top" raisefocus = false raiseswitch = true - border_height = 1 tag_border_width = 1 } colors { - #Border - border_normal = "#3F485E" - border_focus = "#7E89A2" - #Bar bar_bg = "#191919" bar_fg = "#D4D4D4" @@ -35,6 +30,40 @@ colors layout_bg = "#7E89A2" } +layouts +{ + layout { type = "tile" symbol = "TILE" } + layout { type = "max" symbol = "MAX" } + layout { type = "free" symbol = "FREE" } +} + +tags +{ + tag { name = "one" mwfact = 0.65 nmaster = 1 layout = "tile" resizehint = false } + tag { name = "two" } + tag { name = "three" } + tag { name = "four" } + tag { name = "five" } + tag { name = "six" } + tag { name = "seven" } + tag { name = "eight" } + tag { name = "nine" } +} + +client +{ + border_height = 1 + border_normal = "#3F485E" + border_focus = "#7E89A2" + modifier = "Alt" + + mouse { button = "1" func = "client_raise" } + mouse { button = "1" func = "mouse_move" } + mouse { button = "2" func = "tile_switch" } + mouse { button = "3" func = "client_raise" } + mouse { button = "3" func = "mouse_resize" } +} + titlebar { height = 12 @@ -45,31 +74,11 @@ titlebar mouse { button = "1" func = "client_raise" } mouse { button = "1" func = "mouse_move" } - mouse { button = "2" func = "tile_switch" } + mouse { button = "2" func = "client_kill" } mouse { button = "3" func = "client_raise" } mouse { button = "3" func = "mouse_resize" } } -layouts -{ - layout { type = "tile" symbol = "TILE" } - layout { type = "max" symbol = "MAX" } - layout { type = "free" symbol = "FREE" } -} - -tags -{ - tag { name = "one" mwfact = 0.65 nmaster = 2 layout = "tile" resizehint = false } - tag { name = "two" } - tag { name = "three" } - tag { name = "four" } - tag { name = "five" } - tag { name = "six" } - tag { name = "seven" } - tag { name = "eight" } - tag { name = "nine" } -} - buttons { # MWFACT BUTTON {{{ @@ -118,7 +127,7 @@ keys { # general keybind key { mod = {"Control"} key = "Return" func = "spawn" cmd = term } - key { mod = {"Alt"} key = "q" func = "killclient" } + key { mod = {"Alt"} key = "q" func = "client_kill" } key { mod = {"Control", "Alt", "Shift"} key = "q" func = "quit" } key { mod = {"Control"} key = "m" func = "togglemax" } key { mod = {"Control"} key = "b" func = "togglebarpos" }