Merge branch 'new-new_float' into next

This commit is contained in:
Michael Stapelberg 2011-08-09 09:30:12 +02:00
commit 639a4baf7b
7 changed files with 161 additions and 1 deletions

View File

@ -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;

View File

@ -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; }

View File

@ -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 <number> layout_mode
%type <number> border_style
%type <number> new_window
%type <number> new_float
%type <number> colorpixel
%type <number> bool
%type <number> 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; }

View File

@ -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;

View File

@ -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 GIMPs color picker window) get mapped
* to (0, 0), so we push them to a reasonable position
* (centered over their leader) */

View File

@ -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

View File

@ -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 = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my $process = launch_with_config($config);
my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $first = open_standard_window($x);
my @content = @{get_ws_content($tmp)};
ok(@content == 1, 'one container opened');
is($content[0]->{border}, 'normal', 'border normal by default');
exit_gracefully($process->pid);
#####################################################################
# 2: check that new tiling windows start with '1pixel' border when
# configured
#####################################################################
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
new_window 1pixel
EOT
$process = launch_with_config($config);
$tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
$first = open_standard_window($x);
@content = @{get_ws_content($tmp)};
ok(@content == 1, 'one container opened');
is($content[0]->{border}, '1pixel', 'border normal by default');
exit_gracefully($process->pid);
#####################################################################
# 3: check that new floating windows start with 'normal' border unless
# configured otherwise
#####################################################################
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
$process = launch_with_config($config);
$tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
# Create a floating window which is smaller than the minimum enforced size of i3
$first = $x->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 = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
new_float 1pixel
EOT
$process = launch_with_config($config);
$tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
# Create a floating window which is smaller than the minimum enforced size of i3
$first = $x->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;