From cd5ebc2dcac207665dd2f4ca6b388d3be63cb5ad Mon Sep 17 00:00:00 2001 From: Mateusz Poszwa Date: Mon, 8 Aug 2011 20:49:49 +0200 Subject: [PATCH 1/3] src/manage.c: properly set automatic flag when calling floating_enable() --- src/manage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manage.c b/src/manage.c index 68c91e72..18e94dd2 100644 --- a/src/manage.c +++ b/src/manage.c @@ -321,7 +321,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki if (want_floating) { DLOG("geometry = %d x %d\n", nc->geometry.width, nc->geometry.height); - floating_enable(nc, false); + floating_enable(nc, true); } /* to avoid getting an UnmapNotify event due to reparenting, we temporarily From 42db9de7ec1c0b82ced3fa08abd238c5ba12d844 Mon Sep 17 00:00:00 2001 From: Mateusz Poszwa Date: Mon, 8 Aug 2011 21:51:21 +0200 Subject: [PATCH 2/3] Add new_float config option. This option sets the default border style for containers automatically put into floating mode. Fixes #264 --- include/config.h | 3 +++ src/cfgparse.l | 1 + src/cfgparse.y | 11 +++++++++++ src/config.c | 1 + src/floating.c | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/include/config.h b/include/config.h index 1021a612..3234b91e 100644 --- a/include/config.h +++ b/include/config.h @@ -126,6 +126,9 @@ struct Config { /** The default border style for new windows. */ border_style_t default_border; + /** The default border style for new floating windows. */ + border_style_t default_floating_border; + /** The modifier which needs to be pressed in combination with your mouse * buttons to do things with floating windows (move, resize) */ uint32_t floating_modifier; diff --git a/src/cfgparse.l b/src/cfgparse.l index 4cf1a1c3..e29f6efc 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -118,6 +118,7 @@ vertical { return TOK_VERT; } auto { return TOK_AUTO; } workspace_layout { return TOK_WORKSPACE_LAYOUT; } new_window { return TOKNEWWINDOW; } +new_float { return TOKNEWFLOAT; } normal { return TOK_NORMAL; } none { return TOK_NONE; } 1pixel { return TOK_1PIXEL; } diff --git a/src/cfgparse.y b/src/cfgparse.y index 68173757..4a4c26ca 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -579,6 +579,7 @@ void parse_file(const char *f) { %token TOK_AUTO "auto" %token TOK_WORKSPACE_LAYOUT "workspace_layout" %token TOKNEWWINDOW "new_window" +%token TOKNEWFLOAT "new_float" %token TOK_NORMAL "normal" %token TOK_NONE "none" %token TOK_1PIXEL "1pixel" @@ -610,6 +611,7 @@ void parse_file(const char *f) { %type layout_mode %type border_style %type new_window +%type new_float %type colorpixel %type bool %type popup_setting @@ -634,6 +636,7 @@ line: | orientation | workspace_layout | new_window + | new_float | focus_follows_mouse | force_focus_wrapping | workspace_bar @@ -924,6 +927,14 @@ new_window: } ; +new_float: + TOKNEWFLOAT border_style + { + DLOG("new floating windows should start with border style %d\n", $2); + config.default_floating_border = $2; + } + ; + border_style: TOK_NORMAL { $$ = BS_NORMAL; } | TOK_NONE { $$ = BS_NONE; } diff --git a/src/config.c b/src/config.c index 14fc6e02..b3a20442 100644 --- a/src/config.c +++ b/src/config.c @@ -333,6 +333,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, INIT_COLOR(config.bar.urgent, "#2f343a", "#900000", "#ffffff"); config.default_border = BS_NORMAL; + config.default_floating_border = BS_NORMAL; /* Set default_orientation to NO_ORIENTATION for auto orientation. */ config.default_orientation = NO_ORIENTATION; diff --git a/src/floating.c b/src/floating.c index b394f315..2ba08330 100644 --- a/src/floating.c +++ b/src/floating.c @@ -129,6 +129,10 @@ void floating_enable(Con *con, bool automatic) { con->percent = 1.0; con->floating = FLOATING_USER_ON; + /* 4: set the border style as specified with new_float */ + if (automatic) + con->border_style = config.default_floating_border; + /* Some clients (like GIMP’s color picker window) get mapped * to (0, 0), so we push them to a reasonable position * (centered over their leader) */ From 74687fa97c04cb1205bbc88cbd066bbe5fff8c0a Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 9 Aug 2011 09:12:44 +0200 Subject: [PATCH 3/3] tests: add t/74-border-config which checks new_window and new_float --- testcases/t/74-border-config.t | 140 +++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 testcases/t/74-border-config.t diff --git a/testcases/t/74-border-config.t b/testcases/t/74-border-config.t new file mode 100644 index 00000000..c8a4d73d --- /dev/null +++ b/testcases/t/74-border-config.t @@ -0,0 +1,140 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3 +# +# Tests the new_window and new_float config option. +# + +use i3test; +use X11::XCB qw(:all); +use X11::XCB::Connection; + +my $x = X11::XCB::Connection->new; + +##################################################################### +# 1: check that new windows start with 'normal' border unless configured +# otherwise +##################################################################### + +my $config = <{border}, 'normal', 'border normal by default'); + +exit_gracefully($process->pid); + +##################################################################### +# 2: check that new tiling windows start with '1pixel' border when +# configured +##################################################################### + +$config = <{border}, '1pixel', 'border normal by default'); + +exit_gracefully($process->pid); + +##################################################################### +# 3: check that new floating windows start with 'normal' border unless +# configured otherwise +##################################################################### + +$config = <root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30], + background_color => '#C0C0C0', + # replace the type with 'utility' as soon as the coercion works again in X11::XCB + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), +); + +$first->map; + +sleep 0.25; + +my $wscontent = get_ws($tmp); +my @floating = @{$wscontent->{floating_nodes}}; +ok(@floating == 1, 'one floating container opened'); +my $floatingcon = $floating[0]; +is($floatingcon->{nodes}->[0]->{border}, 'normal', 'border normal by default'); + +exit_gracefully($process->pid); + +##################################################################### +# 4: check that new floating windows start with '1pixel' border when +# configured +##################################################################### + +$config = <root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30], + background_color => '#C0C0C0', + # replace the type with 'utility' as soon as the coercion works again in X11::XCB + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), +); + +$first->map; + +sleep 0.25; + +$wscontent = get_ws($tmp); +@floating = @{$wscontent->{floating_nodes}}; +ok(@floating == 1, 'one floating container opened'); +$floatingcon = $floating[0]; +is($floatingcon->{nodes}->[0]->{border}, '1pixel', 'border normal by default'); + +exit_gracefully($process->pid); + +done_testing;