From 1913bf0e5c9ee58497b1c058e4498ed72b03d85e Mon Sep 17 00:00:00 2001 From: Mateusz Poszwa Date: Thu, 4 Aug 2011 17:12:54 +0200 Subject: [PATCH 1/2] Add "instance" to matching criteria --- src/cfgparse.l | 1 + src/cfgparse.y | 6 ++++++ src/cmdparse.l | 1 + src/cmdparse.y | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/src/cfgparse.l b/src/cfgparse.l index 2e1d240a..4cf1a1c3 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -167,6 +167,7 @@ ctrl { return TOKCONTROL; } shift { return TOKSHIFT; } class { yy_push_state(WANT_QSTRING); return TOK_CLASS; } +instance { yy_push_state(WANT_QSTRING); return TOK_INSTANCE; } id { yy_push_state(WANT_QSTRING); return TOK_ID; } con_id { yy_push_state(WANT_QSTRING); return TOK_CON_ID; } con_mark { yy_push_state(WANT_QSTRING); return TOK_MARK; } diff --git a/src/cfgparse.y b/src/cfgparse.y index 38f306e9..59b22c6c 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -547,6 +547,7 @@ void parse_file(const char *f) { %token TOK_MARK "mark" %token TOK_CLASS "class" +%token TOK_INSTANCE "instance" %token TOK_ID "id" %token TOK_CON_ID "con_id" %token TOK_TITLE "title" @@ -694,6 +695,11 @@ criterion: printf("criteria: class = %s\n", $3); current_match.class = $3; } + | TOK_INSTANCE '=' STR + { + printf("criteria: instance = %s\n", $3); + current_match.instance = $3; + } | TOK_CON_ID '=' STR { printf("criteria: id = %s\n", $3); diff --git a/src/cmdparse.l b/src/cmdparse.l index 898416c2..6c756b0d 100644 --- a/src/cmdparse.l +++ b/src/cmdparse.l @@ -153,6 +153,7 @@ false { return TOK_DISABLE; } no { return TOK_DISABLE; } class { BEGIN(WANT_QSTRING); return TOK_CLASS; } +instance { BEGIN(WANT_QSTRING); return TOK_INSTANCE; } id { BEGIN(WANT_QSTRING); return TOK_ID; } con_id { BEGIN(WANT_QSTRING); return TOK_CON_ID; } con_mark { BEGIN(WANT_QSTRING); return TOK_MARK; } diff --git a/src/cmdparse.y b/src/cmdparse.y index e115f3e5..32558f2e 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -175,6 +175,7 @@ bool definitelyGreaterThan(float a, float b, float epsilon) { %token TOK_NOP "nop" %token TOK_CLASS "class" +%token TOK_INSTANCE "instance" %token TOK_ID "id" %token TOK_CON_ID "con_id" %token TOK_TITLE "title" @@ -300,6 +301,11 @@ criterion: printf("criteria: class = %s\n", $3); current_match.class = $3; } + | TOK_INSTANCE '=' STR + { + printf("criteria: instance = %s\n", $3); + current_match.instance = $3; + } | TOK_CON_ID '=' STR { printf("criteria: id = %s\n", $3); From 51119c75c16f86d06b0dde079c8fadd5a7f521ae Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 4 Aug 2011 20:11:01 +0200 Subject: [PATCH 2/2] extend t/65-for_window to check for the 'instance' criterion --- testcases/t/65-for_window.t | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/testcases/t/65-for_window.t b/testcases/t/65-for_window.t index f156f11b..2fb85dfa 100644 --- a/testcases/t/65-for_window.t +++ b/testcases/t/65-for_window.t @@ -244,6 +244,73 @@ cmp_ok(@content, '==', 1, 'one node on this workspace now'); is($content[0]->{border}, 'normal', 'no border'); +exit_gracefully($process->pid); + +############################################################## +# 5: check that a class criterion does not match the instance +############################################################## + +$config = <root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30 ], + background_color => '#00ff00', +); + +$window->_create; + +set_wm_class($window->id, 'bar', 'foo'); +$window->name('usethis'); +$window->map; +sleep 0.25; + +@content = @{get_ws_content($tmp)}; +cmp_ok(@content, '==', 1, 'one node on this workspace now'); +is($content[0]->{border}, 'normal', 'normal border, not matched'); + +exit_gracefully($process->pid); + +############################################################## +# 6: check that the 'instance' criterion works +############################################################## + +$config = <root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30 ], + background_color => '#00ff00', +); + +$window->_create; + +set_wm_class($window->id, 'bar', 'foo'); +$window->name('usethis'); +$window->map; +sleep 0.25; + +@content = @{get_ws_content($tmp)}; +cmp_ok(@content, '==', 1, 'one node on this workspace now'); +is($content[0]->{border}, 'none', 'no border'); + exit_gracefully($process->pid); done_testing;