diff --git a/config.c b/config.c index e82a0e7..d1b37f1 100644 --- a/config.c +++ b/config.c @@ -135,7 +135,6 @@ init_conf(void) static cfg_opt_t misc_opts[] = { - CFG_STR("font", "*-fixed-medium-*-12-*", CFGF_NONE), CFG_STR("bar_position", "top", CFGF_NONE), CFG_BOOL("raisefocus", cfg_false, CFGF_NONE), CFG_BOOL("raiseswitch", cfg_true, CFGF_NONE), @@ -144,6 +143,14 @@ init_conf(void) CFG_END() }; + static cfg_opt_t font_opts[] = + { + CFG_STR("face", "fixed", CFGF_NONE), + CFG_STR("style", "medium", CFGF_NONE), + CFG_INT("size", 12, CFGF_NONE), + CFG_END() + }; + static cfg_opt_t colors_opts[] = { CFG_INT("border_normal", 0x354B5C, CFGF_NONE), @@ -227,6 +234,7 @@ init_conf(void) static cfg_opt_t opts[] = { CFG_SEC("misc", misc_opts, CFGF_NONE), + CFG_SEC("font", font_opts, CFGF_NONE), CFG_SEC("colors", colors_opts, CFGF_NONE), CFG_SEC("layouts", layouts_opts, CFGF_NONE), CFG_SEC("tags", tags_opts, CFGF_NONE), @@ -237,6 +245,7 @@ init_conf(void) cfg_t *cfg; cfg_t *cfg_misc; + cfg_t *cfg_font; cfg_t *cfg_colors; cfg_t *cfg_layouts; cfg_t *cfg_tags; @@ -263,6 +272,7 @@ init_conf(void) } cfg_misc = cfg_getsec(cfg, "misc"); + cfg_font = cfg_getsec(cfg, "font"); cfg_colors = cfg_getsec(cfg, "colors"); cfg_layouts = cfg_getsec(cfg, "layouts"); cfg_tags = cfg_getsec(cfg, "tags"); @@ -270,13 +280,17 @@ init_conf(void) cfg_buttons = cfg_getsec(cfg, "buttons"); /* 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.bartop = (strcmp(strdup(cfg_getstr(cfg_misc, "bar_position")), "top") == 0) ? True : False; + /* font */ + conf.font.face = strdup(cfg_getstr(cfg_font, "face")); + conf.font.style = strdup(cfg_getstr(cfg_font, "style")); + conf.font.size = cfg_getint(cfg_font, "size"); + /* colors */ conf.colors.bordernormal = cfg_getint(cfg_colors, "border_normal"); conf.colors.borderfocus = cfg_getint(cfg_colors, "border_focus"); diff --git a/event.c b/event.c index 66f8b35..f950f27 100644 --- a/event.c +++ b/event.c @@ -55,7 +55,7 @@ buttonpress(XEvent ev) /* BUTTON 1 */ { if(ev.xbutton.button == Button1) - mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, Move); + mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, False); } /* BUTTON 2 */ { @@ -70,14 +70,15 @@ buttonpress(XEvent ev) /* BUTTON 3 */ { if(ev.xbutton.button == Button3) - mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, Resize); + mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, True); } } + } - /* ***************** */ - /* TITLEBAR'S BUTTON */ - /* ***************** */ + /* ****** */ + /* BUTTON */ + /* ****** */ { if((c = getbutton(ev.xbutton.window))) { @@ -98,6 +99,7 @@ buttonpress(XEvent ev) } } } + } } @@ -112,7 +114,7 @@ buttonpress(XEvent ev) /* BUTTON 1 */ { if(ev.xbutton.button == Button1) - mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, Move); + mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, False); } /* BUTTON 2 */ { @@ -127,9 +129,10 @@ buttonpress(XEvent ev) /* BUTTON 3 */ { if(ev.xbutton.button == Button3) - mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, Resize); + mouseaction(c, ev.xbutton.x_root, ev.xbutton.y_root, True); } } + } /* *** */ @@ -142,6 +145,7 @@ buttonpress(XEvent ev) /* TAG */ /* *** */ { + /* CLICK */ { for(i = 0; i < conf.ntag + 1; ++i) @@ -162,6 +166,7 @@ buttonpress(XEvent ev) } } } + } /* SCROLL */ @@ -179,13 +184,17 @@ buttonpress(XEvent ev) tag("-1"); } } + } + + } /* ****** */ /* LAYOUT */ /* ****** */ { + if(ev.xbutton.x >= taglen[conf.ntag] - 3 && ev.xbutton.x < taglen[conf.ntag] + TEXTW(tags[seltag].layout.symbol) - 3) @@ -203,12 +212,15 @@ buttonpress(XEvent ev) layoutswitch("-"); } } + } + + } } /* **** */ - /* Root */ + /* ROOT */ /* **** */ { if(ev.xbutton.window == root) @@ -221,14 +233,15 @@ buttonpress(XEvent ev) /* BUTTON 5 */ { if(ev.xbutton.button == Button5) - tag("-1"); + tag("-1"); } } + } - /* ********** */ - /* Bar Button */ - /* ********** */ + /* *********** */ + /* BAR BUTTONS */ + /* *********** */ { for(i=0; inext) if(!ishide(c)) unhide(c); @@ -46,7 +45,6 @@ arrange(void) focus(NULL); tags[seltag].layout.func(); updatebar(); - return; } @@ -212,28 +210,28 @@ grabbuttons(Client *c, Bool focused) 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, 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); if(conf.ttbarheight) { /* Titlebar */ - XGrabButton(dpy, Button1, AnyModifier, c->tbar, False, ButtonMask,GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button2, AnyModifier, c->tbar, False, ButtonMask,GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button3, AnyModifier, c->tbar, False, ButtonMask,GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button1, AnyModifier, c->tbar, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button2, AnyModifier, c->tbar, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button3, AnyModifier, c->tbar, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); /* Titlebar Button */ if(conf.ttbarheight > 5) { - XGrabButton(dpy, Button1, AnyModifier, c->button, False, ButtonMask,GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button3, AnyModifier, c->button, False, ButtonMask,GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button1, AnyModifier, c->button, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button3, AnyModifier, c->button, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); } } /* Bar Button */ for(i=0; i< conf.nbutton; ++i) - XGrabButton(dpy, Button1, AnyModifier, conf.barbutton[i].win, False, ButtonMask,GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button1, AnyModifier, conf.barbutton[i].win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); } else { @@ -245,7 +243,7 @@ grabbuttons(Client *c, Bool focused) XGrabButton(dpy, AnyButton, AnyModifier, c->button, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); } for(i=0; i< conf.nbutton; ++i) - XGrabButton(dpy, Button1, AnyModifier, conf.barbutton[i].win, False, ButtonMask,GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button1, AnyModifier, conf.barbutton[i].win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None); } return; @@ -295,6 +293,7 @@ init(void) XSetWindowAttributes at; XModifierKeymap *modmap; int i, j; + char fontbuf[128]; /* FIRST INIT */ gc = DefaultGC (dpy, screen); @@ -307,14 +306,18 @@ init(void) taglen[0] = 3; seltag = 1; for(i = 0; i < conf.ntag + 1; ++i) - tags[i] = conf.tag[i-1]; + tags[i] = conf.tag[i - 1]; /* INIT FONT */ - font = XLoadQueryFont(dpy, conf.font); + sprintf(fontbuf, "*-%s-%s-*-%d-*", + conf.font.face, + conf.font.style, + conf.font.size); + font = XLoadQueryFont(dpy, fontbuf); if(!font) { - fprintf(stderr, "XLoadQueryFont: failed loading font '%s'\n", conf.font); - exit(0); + fprintf(stderr, "XLoadQueryFont: failed loading font '%s'\n", fontbuf); + exit(EXIT_FAILURE); } XSetFont(dpy, gc, font->fid); fonth = (font->ascent + font->descent) - 1; @@ -1421,11 +1424,10 @@ main(int argc,char **argv) if(!dpy) { printf("WMFS: cannot open X server.\n"); - exit(1); + exit(EXIT_FAILURE); } /* Let's Go ! */ - init_conf(); init(); scan(); diff --git a/wmfs.h b/wmfs.h index a41498a..e359ab1 100644 --- a/wmfs.h +++ b/wmfs.h @@ -60,8 +60,6 @@ #define ALT Mod1Mask #define ITOA(p ,n) sprintf(p, "%i", n) #define debug(p) printf("debug: %i\n", p) -#define Move 0 -#define Resize 1 #define MAXTAG 36 #define NBUTTON 5 #define BUTY(y) y - conf.ttbarheight + 3 @@ -135,13 +133,18 @@ typedef struct /* Configuration structure */ typedef struct { - char *font; bool raisefocus; bool raiseswitch; bool bartop; int borderheight; int ttbarheight; struct + { + char *face; + char *style; + int size; + } font; + struct { int bordernormal; int borderfocus; @@ -269,7 +272,6 @@ Display *dpy; XEvent event; GC gc; Window root; -Window bar; int screen; int mw, mh; Conf conf; @@ -301,7 +303,6 @@ Client *sel; /* Other */ unsigned int numlockmask; -fd_set fd; #endif /* LOCAL_H */ diff --git a/wmfsrc b/wmfsrc index 4122982..fc51a79 100644 --- a/wmfsrc +++ b/wmfsrc @@ -2,7 +2,6 @@ misc { - font = "*-fixed-medium-*-12-*" bar_position = "top" raisefocus = false raiseswitch = true @@ -10,6 +9,13 @@ misc titlebar_height = 12 } +font +{ + face = "fixed" + style = "medium" + size = 12 +} + colors { border_normal = 0x3F485E