con_is_maximized: Fix case where parent is workspace (#5880)
See added test for simple example.
This commit is contained in:
parent
a56670bca8
commit
5fdfb14530
@ -456,7 +456,7 @@ bool con_is_maximized(Con *con, orientation_t orientation) {
|
||||
Con *current = con;
|
||||
while (true) {
|
||||
Con *parent = current->parent;
|
||||
if (parent == NULL || parent->type == CT_WORKSPACE) {
|
||||
if (parent == NULL || current->type == CT_WORKSPACE) {
|
||||
/* We are done searching. We found no reason that the container
|
||||
* should not be considered maximized. */
|
||||
return true;
|
||||
|
@ -47,6 +47,15 @@ fresh_workspace;
|
||||
$winA = open_window;
|
||||
ok(maximized_both($winA), 'if there is just one window, it is maximized');
|
||||
|
||||
subtest 'two windows in default layout', sub {
|
||||
$winB = open_window;
|
||||
ok(maximized_vert($winA), 'vertically maximized');
|
||||
ok(maximized_vert($winB), 'vertically maximized');
|
||||
ok(!maximized_horz($winA), 'not horizontally maximized');
|
||||
ok(!maximized_horz($winB), 'not horizontally maximized');
|
||||
cmd 'kill';
|
||||
};
|
||||
|
||||
cmd 'fullscreen enable';
|
||||
ok(maximized_neither($winA), 'fullscreen windows are not maximized');
|
||||
|
||||
@ -63,61 +72,57 @@ ok(maximized_both($winA), 'disabling floating sets maximized to true again');
|
||||
$winB = open_window;
|
||||
|
||||
# Windows in stacked or tabbed containers are considered maximized.
|
||||
cmd 'layout stacking';
|
||||
ok(maximized_both($winA), 'stacking layout maximizes all windows');
|
||||
ok(maximized_both($winB), 'stacking layout maximizes all windows');
|
||||
subtest 'stacking layout', sub {
|
||||
cmd 'layout stacking';
|
||||
ok(maximized_both($winA), 'A maximized');
|
||||
ok(maximized_both($winB), 'B maximized');
|
||||
};
|
||||
|
||||
cmd 'layout tabbed';
|
||||
ok(maximized_both($winA), 'tabbed layout maximizes all windows');
|
||||
ok(maximized_both($winB), 'tabbed layout maximizes all windows');
|
||||
subtest 'tabbed layout', sub {
|
||||
cmd 'layout tabbed';
|
||||
ok(maximized_both($winA), 'A maximized');
|
||||
ok(maximized_both($winB), 'B maximized');
|
||||
};
|
||||
|
||||
# Arrange the two windows with a vertical split.
|
||||
cmd 'layout splitv';
|
||||
ok(!maximized_vert($winA),
|
||||
'vertical split means children are not maximized vertically');
|
||||
ok(!maximized_vert($winB),
|
||||
'vertical split means children are not maximized vertically');
|
||||
ok(maximized_horz($winA),
|
||||
'children may still be maximized horizontally in a vertical split');
|
||||
ok(maximized_horz($winB),
|
||||
'children may still be maximized horizontally in a vertical split');
|
||||
subtest 'vertical split', sub {
|
||||
cmd 'layout splitv';
|
||||
ok(!maximized_vert($winA), 'A not maximized vertically');
|
||||
ok(!maximized_vert($winB), 'B not maximized vertically');
|
||||
ok(maximized_horz($winA), 'A maximized horizontally');
|
||||
ok(maximized_horz($winB), 'B maximized horizontally');
|
||||
};
|
||||
|
||||
# Arrange the two windows with a horizontal split.
|
||||
cmd 'layout splith';
|
||||
ok(maximized_vert($winA),
|
||||
'children may still be maximized vertically in a horizontal split');
|
||||
ok(maximized_vert($winB),
|
||||
'children may still be maximized vertically in a horizontal split');
|
||||
ok(!maximized_horz($winA),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
ok(!maximized_horz($winB),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
subtest 'horizontal split', sub {
|
||||
cmd 'layout splith';
|
||||
ok(maximized_vert($winA), 'A maximized vertically');
|
||||
ok(maximized_vert($winB), 'B maximized vertically');
|
||||
ok(!maximized_horz($winA), 'A not maximized horizontally');
|
||||
ok(!maximized_horz($winB), 'B not maximized horizontally');
|
||||
};
|
||||
|
||||
# Add a vertical split within the horizontal split, and open a third window.
|
||||
cmd 'split vertical';
|
||||
$winC = open_window;
|
||||
ok(maximized_vert($winA), 'winA still reaches from top to bottom');
|
||||
ok(!maximized_vert($winB),
|
||||
'winB and winC are split vertically, so they are not maximized vertically');
|
||||
ok(!maximized_vert($winC),
|
||||
'winB and winC are split vertically, so they are not maximized vertically');
|
||||
ok(!maximized_horz($winA),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
ok(!maximized_horz($winB),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
ok(!maximized_horz($winC),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
subtest 'vertical split within the horizontal split', sub {
|
||||
cmd 'split vertical';
|
||||
$winC = open_window;
|
||||
ok(maximized_vert($winA), 'maximized vertically');
|
||||
ok(!maximized_vert($winB), 'B not maximized vertically');
|
||||
ok(!maximized_vert($winC), 'C not maximized vertically');
|
||||
ok(!maximized_horz($winA), 'A not maximized horizontally');
|
||||
ok(!maximized_horz($winB), 'B not maximized horizontally');
|
||||
ok(!maximized_horz($winC), 'C not maximized horizontally');
|
||||
};
|
||||
|
||||
# Change the vertical split container to a tabbed container.
|
||||
cmd 'layout tabbed';
|
||||
ok(maximized_vert($winA), 'all windows now reach from top to bottom');
|
||||
ok(maximized_vert($winB), 'all windows now reach from top to bottom');
|
||||
ok(maximized_vert($winC), 'all windows now reach from top to bottom');
|
||||
ok(!maximized_horz($winA),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
ok(!maximized_horz($winB),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
ok(!maximized_horz($winC),
|
||||
'horizontal split means children are not maximized horizontally');
|
||||
subtest 'tabbed container within horizontal split', sub {
|
||||
cmd 'layout tabbed';
|
||||
ok(maximized_vert($winA), 'A maximized vertically');
|
||||
ok(maximized_vert($winB), 'B maximized vertically');
|
||||
ok(maximized_vert($winC), 'C maximized vertically');
|
||||
ok(!maximized_horz($winA), 'A not maximized horizontally');
|
||||
ok(!maximized_horz($winB), 'B not maximized horizontally');
|
||||
ok(!maximized_horz($winC), 'C not maximized horizontally');
|
||||
};
|
||||
|
||||
done_testing;
|
||||
|
Loading…
Reference in New Issue
Block a user