From 42fa59a524b235f11f51608e9df88d3b098ac02d Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 3 Jul 2009 19:04:09 +0200 Subject: [PATCH] Conf/Event: Add option "focus_follow_mouse" in misc section request by gyo. --- src/config.c | 7 ++++--- src/config_struct.h | 1 + src/event.c | 17 ++++++++++------- src/structs.h | 1 + src/util.c | 6 ++++++ wmfsrc.in | 7 ++++--- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/config.c b/src/config.c index f62634f..e1d5cad 100644 --- a/src/config.c +++ b/src/config.c @@ -125,9 +125,10 @@ conf_alias_section(cfg_t *cfg_a) void conf_misc_section(cfg_t *cfg_m) { - conf.font = alias_to_str(_strdup(cfg_getstr(cfg_m, "font"))); - conf.raisefocus = cfg_getbool(cfg_m, "raisefocus"); - conf.raiseswitch = cfg_getbool(cfg_m, "raiseswitch"); + conf.font = alias_to_str(_strdup(cfg_getstr(cfg_m, "font"))); + conf.raisefocus = cfg_getbool(cfg_m, "raisefocus"); + conf.raiseswitch = cfg_getbool(cfg_m, "raiseswitch"); + conf.focus_fmouse = cfg_getbool(cfg_m, "focus_follow_mouse"); if(cfg_getint(cfg_m, "pad") > 24 || cfg_getint(cfg_m, "pad") < 1) { diff --git a/src/config_struct.h b/src/config_struct.h index 6f66486..65dce4f 100644 --- a/src/config_struct.h +++ b/src/config_struct.h @@ -43,6 +43,7 @@ cfg_opt_t misc_opts[] = CFG_INT("pad", 12, CFGF_NONE), CFG_BOOL("raisefocus", cfg_false, CFGF_NONE), CFG_BOOL("raiseswitch", cfg_true, CFGF_NONE), + CFG_BOOL("focus_follow_mouse", cfg_true, CFGF_NONE), CFG_END() }; diff --git a/src/event.c b/src/event.c index 823cca1..0a95e00 100644 --- a/src/event.c +++ b/src/event.c @@ -316,13 +316,16 @@ enternotify(XCrossingEvent *ev) && ev->window != ROOT) return; - if((c = client_gb_win(ev->window)) - || (c = client_gb_frame(ev->window)) - || (c = client_gb_titlebar(ev->window)) - || (c = client_gb_button(ev->window, &n))) - client_focus(c); - else - client_focus(NULL); + if(conf.focus_fmouse) + { + if((c = client_gb_win(ev->window)) + || (c = client_gb_frame(ev->window)) + || (c = client_gb_titlebar(ev->window)) + || (c = client_gb_button(ev->window, &n))) + client_focus(c); + else + client_focus(NULL); + } return; } diff --git a/src/structs.h b/src/structs.h index b9b5456..38c16c3 100644 --- a/src/structs.h +++ b/src/structs.h @@ -282,6 +282,7 @@ typedef struct char *font; Bool raisefocus; Bool raiseswitch; + Bool focus_fmouse; uint pad; struct { diff --git a/src/util.c b/src/util.c index 81cb723..95bbcc3 100644 --- a/src/util.c +++ b/src/util.c @@ -224,6 +224,12 @@ spawn(const char *format, ...) char cmd[512]; va_list ap; + if(strlen(format) > 511) + { + fprintf(stderr, "WMFS spawn(): Error, command too long.\n"); + return; + } + va_start(ap, format); vsprintf(cmd, format, ap); va_end(ap); diff --git a/wmfsrc.in b/wmfsrc.in index 42ff7de..71da2fa 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -10,9 +10,10 @@ alias misc { - font = "dejavu-10" - raisefocus = false - raiseswitch = true + font = "dejavu-10" + raisefocus = false + raiseswitch = true + focus_follow_mouse = true pad = 12 }