From b5f7c132fccfa8bd9909377bb8a0b0d3b930a099 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ingo=20B=C3=BCrk?= Date: Sun, 29 Mar 2015 17:30:14 +0200 Subject: [PATCH] Added config directive 'no_focus ' (#1416) --- include/config_directives.h | 1 + parser-specs/config.spec | 10 ++++++++++ src/config_directives.c | 13 +++++++++++++ testcases/t/201-config-parser.t | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/config_directives.h b/include/config_directives.h index b9189b2c..f5039624 100644 --- a/include/config_directives.h +++ b/include/config_directives.h @@ -55,6 +55,7 @@ CFGFUN(focus_on_window_activation, const char *mode); CFGFUN(show_marks, const char *value); CFGFUN(hide_edge_borders, const char *borders); CFGFUN(assign, const char *workspace); +CFGFUN(no_focus); CFGFUN(ipc_socket, const char *path); CFGFUN(restart_state, const char *path); CFGFUN(popup_during_fullscreen, const char *value); diff --git a/parser-specs/config.spec b/parser-specs/config.spec index 81357206..433e1d11 100644 --- a/parser-specs/config.spec +++ b/parser-specs/config.spec @@ -31,6 +31,7 @@ state INITIAL: 'hide_edge_borders' -> HIDE_EDGE_BORDERS 'for_window' -> FOR_WINDOW 'assign' -> ASSIGN + 'no_focus' -> NO_FOCUS 'focus_follows_mouse' -> FOCUS_FOLLOWS_MOUSE 'mouse_warping' -> MOUSE_WARPING 'force_focus_wrapping' -> FORCE_FOCUS_WRAPPING @@ -150,6 +151,15 @@ state ASSIGN_WORKSPACE: workspace = string -> call cfg_assign($workspace) +# no_focus +state NO_FOCUS: + '[' + -> call cfg_criteria_init(NO_FOCUS_END); CRITERIA + +state NO_FOCUS_END: + end + -> call cfg_no_focus() + # Criteria: Used by for_window and assign. state CRITERIA: ctype = 'class' -> CRITERION diff --git a/src/config_directives.c b/src/config_directives.c index eddfaa3d..398e53bb 100644 --- a/src/config_directives.c +++ b/src/config_directives.c @@ -431,6 +431,19 @@ CFGFUN(assign, const char *workspace) { TAILQ_INSERT_TAIL(&assignments, assignment, assignments); } +CFGFUN(no_focus) { + if (match_is_empty(current_match)) { + ELOG("Match is empty, ignoring this assignment\n"); + return; + } + + DLOG("new assignment, using above criteria, to ignore focus on manage"); + Assignment *assignment = scalloc(sizeof(Assignment)); + match_copy(&(assignment->match), current_match); + assignment->type = A_NO_FOCUS; + TAILQ_INSERT_TAIL(&assignments, assignment, assignments); +} + /******************************************************************************* * Bar configuration (i3bar) ******************************************************************************/ diff --git a/testcases/t/201-config-parser.t b/testcases/t/201-config-parser.t index 3314aaf7..0f22878d 100644 --- a/testcases/t/201-config-parser.t +++ b/testcases/t/201-config-parser.t @@ -433,7 +433,7 @@ client.focused #4c7899 #285577 #ffffff #2e9ef4 EOT my $expected_all_tokens = <<'EOT'; -ERROR: CONFIG: Expected one of these tokens: , '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'mouse_warping', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'focus_on_window_activation', 'show_marks', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder' +ERROR: CONFIG: Expected one of these tokens: , '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'no_focus', 'focus_follows_mouse', 'mouse_warping', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'focus_on_window_activation', 'show_marks', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder' EOT my $expected_end = <<'EOT'; -- 2.39.2