Re: FVWM: fvwm focus change causes vim to leave insert mode
On Tue, Jul 27, 2021 at 12:28:42PM -0400, John Sellens wrote: > Why did I think this was fvwm related? I think xterm only gets these events > with a suitably modern window manager. The windowmanager cannot intercept these events, but the exact sequence of events depends on how windows are managed internally. Ciao Dominik ^_^ ^_^ -- Dominik Vogt
Re: FVWM: fvwm focus change causes vim to leave insert mode
Thank you Thomas, Dominik, and Chris for your replies. tl;dr is that there was a vim bug between version 8.2.2345 Jan 14 2021 and 8.2.2564 Mar 3 2021, and the ubuntu 21.04 vim 8.2.2434 has the bug. Chris's mention of xterm FocusIn/FocusOut led me down the right path. vim 8.2.2345 added support for enabling FocusIn/FocusOut features, but missed not enabling it if vim's "noesckeys" option is set. If "noesckeys" is set, the FocusOut escape sequence from xterm is handled as ESC, then [ then O - which ends insert, then beeps at the O. Otherwise it could run an autocmd is one is set. Why did I think this was fvwm related? I think xterm only gets these events with a suitably modern window manager. I tried it with old window managers (ctwm, vtwm) and with no window manager, and I only saw it with fvwm. I should have tried with some other modern window manager, but didn't really have one handy. (Sorry.) This vim bug only showed up if "noesckeys" was set - I set "compatible" (I'm old school vi-wise), which sets "noesckeys". So you need a particular vim patch level, and esckeys turned off to replicate it. And just in case you're interested, or anyone else stumbles on this, setting these X resources seems to be a suitable workaround for me, until ubuntu updates vim: XTerm*allowMouseOps: false XTerm*disallowedMouseOps: FocusEvent Thanks again for your help, and apologies for my unintended digression! John | When I have the vim editor open in an xterm window, in insert mode, | and move my mouse (and focus) into another window, the vim in the | original window receives some sort of escape sequence that causes | it to leave insert mode and beep.
Re: FVWM: fvwm focus change causes vim to leave insert mode
> I've googled and FAQd and experimented without success. > > When I have the vim editor open in an xterm window, in insert mode, > and move my mouse (and focus) into another window, the vim in the > original window receives some sort of escape sequence that causes > it to leave insert mode and beep. xterm (and presumably things that immitate it closely enough) can be set to send escape sequences when it gains or loses window keyboard focus: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-FocusIn_FocusOut Apparently vim can be set to automatically do things when this happens, which probably makes it have xterm turn on generating the escape sequences. People use this for things like auto-saving when you move focus away from vim, through what vim apparently calls 'autocmds': https://vim.fandom.com/wiki/Auto_save_files_when_focus_is_lost http://vimdoc.sourceforge.net/htmldoc/autocmd.html I suspect that somewhere in either your vim settings or system-wide vim settings there is something that turns on a FocusLost autocmd. If I'm reading the vim help correctly, I think using ':au FocusLost' in vim should tell you something about the situation. This behavior is unlikely to be visible outside vim (or a specifically crafted environment), because as far as I know xterm must be specifically told to send these escape sequences. Vim (or anything else wanting to do this) normally turns on this sort of escape sequence when it starts and turns them off when it exits (or starts a shell). Unfortunately I don't think there's any way to have xterm tell you (in one of its menus) whether these are enabled or not. It's possible that using ctrl+button-3 to bring up xterm's menu (well, one of them) would let you turn this off to experiment by turning off some combination of 'Allow Mouse Ops' and 'Allow Window Ops' (probably mostly or entirely the former). (To be clear here, this behavior almost certainly has nothing to do with fvwm, unless the Ubuntu 21.04 vim environment you're using does something different depending on the window manager. I would expect this to happen on any window manager or desktop when an xterm with vim inside it loses focus.) - cks
Re: FVWM: fvwm focus change causes vim to leave insert mode
On Thu, Jul 22, 2021 at 03:34:56PM -0400, John Sellens wrote: > When I have the vim editor open in an xterm window, in insert mode, > and move my mouse (and focus) into another window, the vim in the > original window receives some sort of escape sequence that causes > it to leave insert mode and beep. > I can't figure out what's happening or why, or how to prevent it. > > Anyone have any hints? Try to attach the "xev" program to the xterm. It creates an awful lot of output, but that should contain some indication of what's happening. You can also post the relevant part of the output to the list. Ciao Dominik ^_^ ^_^ -- Dominik Vogt
Re: FVWM: fvwm focus change causes vim to leave insert mode
On Thu, Jul 22, 2021 at 03:34:56PM -0400, John Sellens wrote: > When I have the vim editor open in an xterm window, in insert mode, > and move my mouse (and focus) into another window, the vim in the > original window receives some sort of escape sequence that causes > it to leave insert mode and beep. You presumably have some sort of vim plugin installed causing this. There's nothing that fvwm is going to be doing to make vim in xterm (or any other terminal emulator) come out of insert mode. The only way it could is if fvwm was using FakeKeyPress, but this hasn't worked in years due to most applications not allowing synthetic key events due to security considerations. > I tried starting vim without customization, and fvwm 2.6.8 and fvwm 3 with > stock configuration. It seems to happen in xterm, x-terminal-emumator, > terminator, uxterm, but not in rxvt. I'm on ubuntu 21.04. Can you share your fvwm configuration? I know you've said it happend with "stock configuration", but I can't reproduce the problem doing just that with vim8. Kindly, Thomas