Merge pull request #3261 from orestisf1993/swap-3259

Don't call con_fullscreen_permits_focusing with ignore_focus
This commit is contained in:
Ingo Bürk 2018-04-22 16:35:25 +02:00 committed by GitHub
commit 55dd5b8d84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 16 deletions

View File

@ -1097,7 +1097,7 @@ static bool _con_move_to_con(Con *con, Con *target, bool behind_focused, bool fi
/* Prevent moving if this would violate the fullscreen focus restrictions. */ /* Prevent moving if this would violate the fullscreen focus restrictions. */
Con *target_ws = con_get_workspace(target); Con *target_ws = con_get_workspace(target);
if (!con_fullscreen_permits_focusing(target_ws)) { if (!ignore_focus && !con_fullscreen_permits_focusing(target_ws)) {
LOG("Cannot move out of a fullscreen container.\n"); LOG("Cannot move out of a fullscreen container.\n");
return false; return false;
} }
@ -2373,6 +2373,10 @@ bool con_swap(Con *first, Con *second) {
/* Move first to second. */ /* Move first to second. */
result &= _con_move_to_con(first, second, false, false, false, true, false); result &= _con_move_to_con(first, second, false, false, false, true, false);
/* If swapping the containers didn't work we don't need to mess with the focus. */
if (!result) {
goto swap_end;
}
/* If we moved the container holding the focused window to another /* If we moved the container holding the focused window to another
* workspace we need to ensure the visible workspace has the focused * workspace we need to ensure the visible workspace has the focused
@ -2385,8 +2389,6 @@ bool con_swap(Con *first, Con *second) {
/* Move second to where first has been originally. */ /* Move second to where first has been originally. */
result &= _con_move_to_con(second, fake, false, false, false, true, false); result &= _con_move_to_con(second, fake, false, false, false, true, false);
/* If swapping the containers didn't work we don't need to mess with the focus. */
if (!result) { if (!result) {
goto swap_end; goto swap_end;
} }

View File

@ -372,26 +372,31 @@ for my $fullscreen (@fullscreen_permutations){
# +---+---+ Layout: H2[ B, F ] # +---+---+ Layout: H2[ B, F ]
# | B | F | Focus Stacks: # | B | F | Focus Stacks:
# +---+---+ H2: F, B # +---+---+ H2: F, B
#
# See issue: #3259
############################################################################### ###############################################################################
$ws1 = fresh_workspace; for my $fullscreen (0..1){
$A = open_window(wm_class => 'mark_A'); $ws1 = fresh_workspace;
$A = open_window(wm_class => 'mark_A');
$ws2 = fresh_workspace; $ws2 = fresh_workspace;
$B = open_window(wm_class => 'mark_B'); $B = open_window(wm_class => 'mark_B');
open_window; open_window;
$expected_focus = get_focused($ws2); cmd 'fullscreen enable' if $fullscreen;
$expected_focus = get_focused($ws2);
cmd '[con_mark=B] swap container with mark A'; cmd '[con_mark=B] swap container with mark A';
$nodes = get_ws_content($ws1); $nodes = get_ws_content($ws1);
is($nodes->[0]->{window}, $B->{id}, 'B is on the first workspace'); is($nodes->[0]->{window}, $B->{id}, 'B is on the first workspace');
$nodes = get_ws_content($ws2); $nodes = get_ws_content($ws2);
is($nodes->[0]->{window}, $A->{id}, 'A is on the left of the second workspace'); is($nodes->[0]->{window}, $A->{id}, 'A is on the left of the second workspace');
is(get_focused($ws2), $expected_focus, 'F is still focused'); is(get_focused($ws2), $expected_focus, 'F is still focused');
kill_all_windows; kill_all_windows;
}
############################################################################### ###############################################################################
# 1. A container cannot be swapped with its parent. # 1. A container cannot be swapped with its parent.