Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Prevent temporary resize with second tty client in same session group?

25 views
Skip to first unread message

Richard Michael

unread,
May 30, 2024, 10:53:06 PM5/30/24
to tmux-...@googlegroups.com
Hello,

When I create a second alacritty window (client) with a new tmux
session and new window into an existing session group, tmux resizes
the active window in the first alacritty window (client) to correspond
to the size of the second client's [smaller] active new window. Note,
the first alacritty client itself has not changed size.

Is there a configuration that can prevent this quirk?

(So, there are two tmux clients, one session group, two sessions, and
two windows; each client has a different, active window. The scenario
is a lot to describe carefully, so below I've included a "log" with
notes, from a non-tmux terminal window.)

It seems like an unnecessary resize because if I simply change the
window manager focus back to the first alacritty client window, tmux
automatically corrects (reverts) the size; and, changing focus again,
back to the second window, does not cause [another] resize. i.e.,
tmux needn't have resized the window at all, and it doesn't want to on
subsequent focus changes. (I'm wondering if the effect of a SIGWINCH
for the second client is being applied in the first client?)


I have not set any window sizing related options, such as
`window-size` or `aggressive-resize`. I've used tmux for many years,
and it handles resizing great with default settings. I did experiment
with these options now, but didn't achieve what I'd hoped.


Aside, thanks a lot for tmux, it's indispensable and the code really
is a pleasure to read.

regards,
richard
-----

$ tmux -V ; alacritty -V
tmux 3.4
alacritty 0.13.2 (bb8ea18)

$ W_FMT='[s: ${session_name}] w_idx: #{window_index}:
#{window_name}#{window_raw_flags} (#{window_panes} panes)
[#{window_width}x#{window_height}] [layout #{window_layout}]
#{window_id} #{?window_active, (active),}'

$ while true ; do echo -e "====> $( date +%M:%S )s\n" ; tmux
list-clients \; list-sessions \; list-windows -a -F "${W_FMT}" ; sleep
2 ; echo -e '\n\n' ; done

====> 06:49s

/dev/ttys001: main [129x76 alacritty] (attached,focused,UTF-8)
main: 1 windows (created Thu May 30 15:06:46 2024) (attached)
[main] w_idx: 1: bash* (1 panes) [129x75] [layout c97d,129x75,0,0,0]
@0 (active) <== will be resized, next



====> 06:51s

# `alacritty msg create-window -e tmux new-session -t main \;
new-window` via alacritty keybinding
# window manager auto-focuses new second alacritty client
# tmux resizes original window

/dev/ttys001: main [129x76 alacritty] (attached,UTF-8)
/dev/ttys003: main-1 [123x46 alacritty] (attached,focused,UTF-8)
main: 2 windows (created Thu May 30 15:06:46 2024) (group main) (attached)
main-1: 2 windows (created Thu May 30 15:06:51 2024) (group main) (attached)
[main] w_idx: 1: bash* (1 panes) [123x45] [layout c07d,123x45,0,0,0]
@0 (active) <== resized..
[main] w_idx: 2: bash# (1 panes) [123x45] [layout c07f,123x45,0,0,2] @2
[main-1] w_idx: 1: bash#- (1 panes) [123x45] [layout c07d,123x45,0,0,0] @0
[main-1] w_idx: 2: bash* (1 panes) [123x45] [layout c07f,123x45,0,0,2]
@2 (active) <== ..matching this new window



====> 06:56s

# change window manager focus back to original alacritty client
# tmux automatically "corrects" (reverts) to the original window size

/dev/ttys001: main [129x76 alacritty] (attached,focused,UTF-8)
/dev/ttys003: main-1 [123x46 alacritty] (attached,UTF-8)
main: 2 windows (created Thu May 30 15:06:46 2024) (group main) (attached)
main-1: 2 windows (created Thu May 30 15:06:51 2024) (group main) (attached)
[main] w_idx: 1: bash* (1 panes) [129x75] [layout c97d,129x75,0,0,0]
@0 (active) <== auto-reverted, correct size
[main] w_idx: 2: bash# (1 panes) [123x45] [layout c07f,123x45,0,0,2] @2
[main-1] w_idx: 1: bash#- (1 panes) [129x75] [layout c97d,129x75,0,0,0] @0
[main-1] w_idx: 2: bash* (1 panes) [123x45] [layout c07f,123x45,0,0,2]
@2 (active)



====> 06:58s

# change window manager focus back to new alacritty window (client),
and sizes remain correct
# i.e., tmux does not shrink the original window again, as it did when
the second alacritty client was created and auto-focused

/dev/ttys001: main [129x76 alacritty] (attached,UTF-8)
/dev/ttys003: main-1 [123x46 alacritty] (attached,focused,UTF-8)
main: 2 windows (created Thu May 30 15:06:46 2024) (group main) (attached)
main-1: 2 windows (created Thu May 30 15:06:51 2024) (group main) (attached)
[main] w_idx: 1: bash* (1 panes) [129x75] [layout c97d,129x75,0,0,0]
@0 (active)
[main] w_idx: 2: bash# (1 panes) [123x45] [layout c07f,123x45,0,0,2] @2
[main-1] w_idx: 1: bash#- (1 panes) [129x75] [layout c97d,129x75,0,0,0] @0
[main-1] w_idx: 2: bash* (1 panes) [123x45] [layout c07f,123x45,0,0,2]
@2 (active)

Nicholas Marriott

unread,
May 31, 2024, 3:05:32 AM5/31/24
to Richard Michael, tmux-users
You can set window-size to control which session sets the window size but you can only pick largest, smallest or latest, there is no way to have it pick the oldest session (I don't think this would be hard to add if you wanted). It doesn't resize when you switch focus because simple changing focus does not make a session the latest, it should resize when you type.

If aggressive-resize is on it shouldn't resize unless the sessions share a current window so if you are using different current windows you might want to turn that on.



--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/CABR0jESaRmU43AwNij3S_FeVx6nJD-42HRCR%2BtVAbBjs%3DHHQ-g%40mail.gmail.com.

Richard Michael

unread,
Jun 22, 2024, 6:56:27 PM6/22/24
to Nicholas Marriott, tmux-users
Thanks for the quick reply and help.

On Fri, May 31, 2024 at 12:05 AM Nicholas Marriott
<nicholas...@gmail.com> wrote:

> You can set window-size to control which session sets the window size but you
> can only pick largest, smallest or latest, there is no way to have it pick the
> oldest session (I don't think this would be hard to add if you wanted).

Ok, got it. I don't have intuition for the experience `oldest` would provide.
I think it might truncate content when using a smaller client, if the `oldest`
client's window is larger, which I'm not sure I'd want. tmux's default settings
do work perfect for me, this one quirk is more due to my lack of understanding.

> It doesn't resize when you switch focus because simple changing focus
> does not make a session the latest, it should resize when you type.

tmux does resize on focus change, no need to type. In the case where it didn't
resize (when changing back to the second client; in my original post,
thread-top), there were two different windows active, so no resizing ought to
occur.

> If aggressive-resize is on it shouldn't resize unless the sessions share a
> current window so if you are using different current windows you might want to
> turn that on.

Ok, thanks for the tip.

In the end, I may not use a session group and just side-step this altogether. I
used a session group because I wanted the convenience of accessing other windows
in the second client, and I've since realized it's trivial to change sessions.


With more experimentation and adding a few log_debug() calls, I think I can
explain what's happening, so I thought I'd wrap up this thread for anyone
interested..

I noticed `new-session -t [..]` opens on the first window of the first client (I
guess actually the first session in the targeted group). This causes a resize,
if the second client is smaller. I see the resize check happens in the
server-client loop, via flags and other criteria.

At the end of the second client command sequence:

`new-session -t [..] ; new-window`

..there will be no "contention" for the first client's window. However, of
course tmux doesn't "know" that after the new session starts, a new window will
be created and activated, and presumably the same (as above) window resize
checks happen between the commands, thus the first client resize occurs.

Makes sense, because a command sequence can be long (so tmux musn't wait and do
the reconciliation at the end), but also due to the overall design: the
server-loop and async command processing, to allow for multiple clients,
sessions, etc.

Now that I think I understand this better, I may try to cause the first client
to notice there is no longer another client sharing its window, with the hope it
would resize back on its own; e.g., `new-s ; new-w; <something>`. Maybe a hook
or control mode command could work.

Regards,
richard
Reply all
Reply to author
Forward
0 new messages