diff --git a/include/config.h b/include/config.h index b81c3492..fe5405bc 100644 --- a/include/config.h +++ b/include/config.h @@ -77,7 +77,11 @@ struct Config { int container_stack_limit; int container_stack_limit_value; - bool focus_follows_mouse; + /** By default, focus follows mouse. If the user explicitly wants to + * turn this off (and instead rely only on the keyboard for changing + * focus), we allow him to do this with this relatively special option. + * It is not planned to add any different focus models. */ + bool disable_focus_follows_mouse; const char *default_border; diff --git a/src/cfgparse.y b/src/cfgparse.y index cc1b2d16..6b458e2c 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -381,10 +381,27 @@ new_window: } ; -focus_follows_mouse: - TOKFOCUSFOLLOWSMOUSE WHITESPACE NUMBER +bool: + NUMBER { - config.focus_follows_mouse = ($3 == 0 ? 0 : 1); + $$ = ($1 == 1); + } + | WORD + { + DLOG("checking word \"%s\"\n", $1); + $$ = (strcasecmp($1, "yes") == 0 || + strcasecmp($1, "true") == 0 || + strcasecmp($1, "on") == 0 || + strcasecmp($1, "enable") == 0 || + strcasecmp($1, "active") == 0); + } + ; + +focus_follows_mouse: + TOKFOCUSFOLLOWSMOUSE WHITESPACE bool + { + DLOG("focus follows mouse = %d\n", $3); + config.disable_focus_follows_mouse = !($3); } ; diff --git a/src/handlers.c b/src/handlers.c index a0097bcd..6e54b04b 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -236,7 +236,7 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_ return 1; } - if (config.focus_follows_mouse) + if (!config.disable_focus_follows_mouse) set_focus(conn, client, false); return 1;