From 88b9700cdbf6029f90dd86d4d441a7e9c186e4bb Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 29 Jan 2010 21:51:38 +0100 Subject: [PATCH] Invert logic for the last commit This makes it more clear that the option is meant to be a special case (it *disables* part of the focus handling). Also, when initializing the config data structure with zeros, it will get initialized with the right value. Furthermore, the config file parser now also accepts various values which represent "true", not only numbers. --- include/config.h | 6 +++++- src/cfgparse.y | 21 +++++++++++++++++++-- src/handlers.c | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) 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: } ; +bool: + NUMBER + { + $$ = ($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 NUMBER + TOKFOCUSFOLLOWSMOUSE WHITESPACE bool { - config.focus_follows_mouse = ($3 == 0 ? 0 : 1); + 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; -- 2.39.5