summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2024-01-15 16:01:20 +0000
committerSean Whitton <spwhitton@spwhitton.name>2024-01-16 17:17:31 +0000
commit15733a679b7884e8253dc5dfbff1ef89f8879b4f (patch)
treefc8df124d71c2e1dff9b16bf63a8954ab96e8f27 /scripts
parent43c43062b601a9f8a0aad7b4ea13b257e06d43e1 (diff)
downloaddotfiles-15733a679b7884e8253dc5dfbff1ef89f8879b4f.tar.gz
i3status-wrapper: attempt to fix some incorrect focus issues
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/desktop/i3status-wrapper19
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper
index ffc910c2..68b10e01 100755
--- a/scripts/desktop/i3status-wrapper
+++ b/scripts/desktop/i3status-wrapper
@@ -389,6 +389,9 @@ sub sync_cols {
sub normalise_ws_cols {
my $ws = $info{paper_ws}{$info{focused_ws}};
my $floating_focus;
+ my $old_cols = $ws->{cols};
+ my $old_i = first { $old_cols->[$_] == $ws->{focused_col} }
+ 0..$#$old_cols;
my @trees = $wmipc->get_tree;
while (@trees) {
for ((shift @trees)->{nodes}->@*) {
@@ -410,22 +413,26 @@ sub normalise_ws_cols {
# Pull column in if there are too few columns but some available.
if ($ws->{ncols} > @$cols
&& ($ws->{off_left}->@* || $ws->{off_right}->@*)) {
- if ($ws->{off_left}->@*
+
+ if ($ws->{off_left}->@* # pull from left
&& ($i < $mid_i || !$ws->{off_right}->@*)) {
my $pulled = pop $ws->{off_left}->@*;
+ my $k = $old_i == $#$old_cols ? $i+1 : $i;
$wmipc->cmd(("focus left")x$i,
show_con($pulled), "move left",
- ("focus right")x$i);
+ ("focus right")x$k);
unshift @$cols, $pulled;
- $ws->{focused_col} = $cols->[$i];
- } elsif ($ws->{off_right}->@*
+ $ws->{focused_col} = $cols->[$k];
+
+ } elsif ($ws->{off_right}->@* # pull from right
&& ($i >= $mid_i || !$ws->{off_left}->@*)) {
my $j = $#$cols - $i;
my $pulled = pop $ws->{off_right}->@*;
$wmipc->cmd(("focus right")x$j,
- show_con($pulled), ("focus left")x$j);
+ show_con($pulled),
+ ("focus left")x($old_i == 0 ? $j+1 : $j));
push @$cols, $pulled;
- $ws->{focused_col} = $cols->[$i+1];
+ $ws->{focused_col} = $cols->[$old_i == 0 ? $i : $i+1];
}
}
# Push a column off if there are too many columns.