wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
18.12k stars 809 forks source link

The first left-click of the mouse after FocusChanged(true) will trigger redundant MouseEvent { kind: Move ...}, causing the contents of the tmux clipboard to be lost. #5309

Open zhu-jiyuan opened 7 months ago

zhu-jiyuan commented 7 months ago

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

wezterm 20240203-110809-5046fc22

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

The first click after returning to WezTerm from other applications will inexplicably trigger a long press to move, which does not appear in PowerShell and Alacritty. This is very obvious in the debug log. I think this is a bug, and many functions similar to tmux mouse copying will not be available.

To Reproduce

Click on other applications and then click on wezterm to reproduce the problem. For intuitive effects, you can try to enable the tmux mouse function, which will trigger the replacement of content copied from outside.

Configuration

local wezterm = require "wezterm"

local config = {} if wezterm.config_builder then config = wezterm.config_builder() end

--- wsl_domains local wsl_domains = wezterm.default_wsldomains() for , domain in ipairs(wsl_domains) do domain.default_prog = { "zsh" } end -- config.default_domain = "WSL:Debian" config.wsl_domains = wsl_domains

-- fps config.animation_fps = 120 config.max_fps = 120

config.window_close_confirmation = 'NeverPrompt'

config.font = wezterm.font("JetBrainsMono Nerd Font Mono", { weight = "Regular" })

-- config.color_scheme = "GruvboxDark" local materia = wezterm.color.get_builtin_schemes()['GruvboxDark'] materia.scrollbar_thumb = '#818020' -- 滚动条颜色 config.colors = materia

-- 透明背景 config.window_background_opacity = 0.9 -- 取消 Windows 原生标题栏 config.window_decorations = "INTEGRATED_BUTTONS|RESIZE" -- 滚动条尺寸为 15 ,其他方向不需要 pad config.window_padding = { left = 0, right = 20, top = 0, bottom = 0 } -- tab bar config.enable_tab_bar = true config.hide_tab_bar_if_only_one_tab = false config.use_fancy_tab_bar = true -- config.tab_max_width = 25, config.show_tab_index_in_tab_bar = false config.switch_to_last_active_tab_when_closing_tab = true

-- 启用滚动条 config.enable_scroll_bar = true config.scrollback_lines = 100000 config.min_scroll_bar_height = "2cell"

config.window_background_opacity = 0.95 config.text_background_opacity = 0.98 config.adjust_window_size_when_changing_font_size = true

-- config.disable_default_key_bindings = true

local act = wezterm.action config.keys = { { key = "v", mods = "CTRL", action = act { PasteFrom = "Clipboard" } }, -- Ctrl+Shift+Tab 遍历 tab { key = 'Tab', mods = 'SHIFT|CTRL', action = act.ActivateTabRelative(1) }, -- F11 切换全屏 { key = 'F11', mods = 'NONE', action = act.ToggleFullScreen }, -- Ctrl+Shift++ 字体增大 { key = '+', mods = 'SHIFT|CTRL', action = act.IncreaseFontSize }, -- Ctrl+Shift+- 字体减小 { key = '_', mods = 'SHIFT|CTRL', action = act.DecreaseFontSize }, -- Ctrl+Shift+C 复制选中区域 { key = 'C', mods = 'SHIFT|CTRL', action = act.CopyTo 'Clipboard' }, -- Ctrl+Shift+N 新窗口 { key = 'N', mods = 'SHIFT|CTRL', action = act.SpawnWindow }, -- Ctrl+Shift+T 新 tab { key = 'T', mods = 'SHIFT|CTRL', action = act.ShowLauncher }, -- Ctrl+Shift+Enter 显示启动菜单 { key = 'Enter', mods = 'SHIFT|CTRL', action = act.ShowLauncherArgs { flags = 'FUZZY|TABS|LAUNCH_MENUITEMS' } }, -- Ctrl+Shift+V 粘贴剪切板的内容 -- Ctrl+Shift+W 关闭 tab 且不进行确认 { key = 'W', mods = 'SHIFT|CTRL', action = act.CloseCurrentTab { confirm = false } }, -- Ctrl+Shift+PageUp 向上滚动一页 { key = 'PageUp', mods = 'SHIFT|CTRL', action = act.ScrollByPage(-1) }, -- Ctrl+Shift+PageDown 向下滚动一页 { key = 'PageDown', mods = 'SHIFT|CTRL', action = act.ScrollByPage(1) }, -- Ctrl+Shift+UpArrow 向上滚动一行 { key = 'UpArrow', mods = 'SHIFT|CTRL', action = act.ScrollByLine(-1) }, -- Ctrl+Shift+DownArrow 向下滚动一行 { key = 'DownArrow', mods = 'SHIFT|CTRL', action = act.ScrollByLine(1) }, { key = "Insert", mods = "SHIFT", action = act { PasteFrom = "Clipboard" } }, { key = "Insert", mods = "CTRL", action = act { PasteFrom = "PrimarySelection" } }, { key = "Insert", mods = "CTRL|SHIFT", action = act { PasteFrom = "PrimarySelection" } }, { key = '+', mods = 'SHIFT|ALT', action = act.SplitVertical { domain = 'CurrentPaneDomain' } }, { key = '', mods = 'SHIFT|ALT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } }, { key = 'N', mods = 'SHIFT|CTRL', action = act.SpawnWindow },

-- search for things that look like git hashes
{
    key = 'F',
    mods = 'SHIFT|CTRL',
    action = act.Search("CurrentSelectionOrEmptyString"),
},

}

-- config.disable_default_mouse_bindings = true config.mouse_bindings = { -- and make CTRL-Click open hyperlinks { event = { Up = { streak = 1, button = "Left" } }, mods = "CTRL", action = act.OpenLinkAtMouseCursor }, -- Scrolling up while holding CTRL increases the font size { event = { Down = { streak = 1, button = { WheelUp = 1 } } }, mods = 'CTRL', action = act.IncreaseFontSize, },

-- Scrolling down while holding CTRL decreases the font size
{
    event = { Down = { streak = 1, button = { WheelDown = 1 } } },
    mods = 'CTRL',
    action = act.DecreaseFontSize,
},

}

return config

Expected Behavior

When I connect ssh to the server's tmux, the content copied from the wezterm external application is always cleared, which makes me uncomfortable.

Logs

17:26:49.612 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Move, coords: (325, 482), screen_coords: (-631, 759), mouse_buttons: NONE, modifiers: NONE }) 17:26:49.621 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Move, coords: (325, 481), screen_coords: (-631, 758), mouse_buttons: NONE, modifiers: NONE }) 17:26:49.628 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Move, coords: (325, 479), screen_coords: (-631, 756), mouse_buttons: NONE, modifiers: NONE }) 17:26:49.637 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Move, coords: (325, 478), screen_coords: (-631, 755), mouse_buttons: NONE, modifiers: NONE }) 17:26:49.653 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Move, coords: (325, 477), screen_coords: (-631, 754), mouse_buttons: NONE, modifiers: NONE }) 17:26:49.676 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Move, coords: (325, 476), screen_coords: (-631, 753), mouse_buttons: NONE, modifiers: NONE }) 17:26:49.805 DEBUG wezterm_gui::termwindow > FocusChanged(true) 17:26:49.808 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Press(Left), coords: (325, 476), screen_coords: (-631, 753), mouse_buttons: LEFT, modifiers: NONE }) 17:26:49.811 DEBUG wezterm_gui::termwindow > Notification(Any { .. }) 17:26:49.813 DEBUG wezterm_gui::termwindow > Notification(Any { .. }) 17:26:49.816 DEBUG wezterm_gui::termwindow > Notification(Any { .. }) 17:26:49.819 DEBUG wezterm_gui::termwindow > Notification(Any { .. }) 17:26:49.823 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Move, coords: (325, 476), screen_coords: (-631, 753), mouse_buttons: LEFT, modifiers: NONE }) 17:26:49.836 DEBUG wezterm_gui::termwindow > NeedRepaint 17:26:49.839 DEBUG wezterm_gui::termwindow::render::paint > paint_impl before call_draw elapsed=360.5µs 17:26:49.842 DEBUG wezterm_gui::termwindow::render::paint > paint_impl elapsed=2.5748ms, fps=0.023080176 17:26:49.856 DEBUG wezterm_term::terminalstate::performer > perform CSI(Mode(ResetDecPrivateMode(Code(ShowCursor)))) 17:26:49.858 DEBUG wezterm_term::terminalstate::performer > perform CSI(Mode(ResetDecPrivateMode(Code(StartBlinkingCursor)))) 17:26:49.859 DEBUG wezterm_term::terminalstate::performer > perform CSI(Mode(ResetDecPrivateMode(Code(BracketedPaste)))) 17:26:49.861 DEBUG wezterm_term::terminalstate::performer > perform CSI(Mode(ResetDecPrivateMode(Code(StartBlinkingCursor)))) 17:26:49.862 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Reset)) 17:26:49.862 DEBUG wezterm_term::terminalstate > Reset 17:26:49.865 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Foreground(PaletteIndex(4)))) 17:26:49.865 DEBUG wezterm_term::terminalstate > Foreground(PaletteIndex(4)) 17:26:49.867 DEBUG wezterm_term::terminalstate::performer > perform CSI(Cursor(Position { line: OneBased { value: 1 }, col: OneBased { value: 1 } })) 17:26:49.868 DEBUG wezterm_term::terminalstate::performer > perform PrintString("~ ") 17:26:49.869 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Foreground(PaletteIndex(2)))) 17:26:49.870 DEBUG wezterm_term::terminalstate > Foreground(PaletteIndex(2)) 17:26:49.872 DEBUG wezterm_term::terminalstate::performer > perform PrintString("❯ source ") 17:26:49.873 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Foreground(PaletteIndex(12)))) 17:26:49.874 DEBUG wezterm_term::terminalstate > Foreground(PaletteIndex(12)) 17:26:49.876 DEBUG wezterm_term::terminalstate::performer > perform PrintString(".zshrc ") 17:26:49.877 DEBUG wezterm_term::terminalstate::performer > perform CSI(Edit(EraseInLine(EraseToEndOfLine))) 17:26:49.878 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Foreground(PaletteIndex(6)))) 17:26:49.879 DEBUG wezterm_term::terminalstate > Foreground(PaletteIndex(6)) 17:26:49.881 DEBUG wezterm_term::terminalstate::performer > perform PrintString("17:2") 17:26:49.882 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Foreground(TrueColor(SrgbaTuple(0.9607843, 0.7607843, 0.90588236, 1.0))))) 17:26:49.882 DEBUG wezterm_term::terminalstate > Foreground(TrueColor(SrgbaTuple(0.9607843, 0.7607843, 0.90588236, 1.0))) 17:26:49.884 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Background(TrueColor(SrgbaTuple(0.34509805, 0.35686275, 0.4392157, 1.0))))) 17:26:49.885 DEBUG wezterm_term::terminalstate > Background(TrueColor(SrgbaTuple(0.34509805, 0.35686275, 0.4392157, 1.0))) 17:26:49.887 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Intensity(Bold))) 17:26:49.888 DEBUG wezterm_term::terminalstate > Intensity(Bold) 17:26:49.890 DEBUG wezterm_term::terminalstate::performer > perform PrintString("[0/1]") 17:26:49.890 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Foreground(PaletteIndex(4)))) 17:26:49.891 DEBUG wezterm_term::terminalstate > Foreground(PaletteIndex(4)) 17:26:49.892 DEBUG wezterm_gui::termwindow > MouseEvent(MouseEvent { kind: Release(Left), coords: (325, 476), screen_coords: (-631, 753), mouse_buttons: NONE, modifiers: NONE }) 17:26:49.893 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Background(Default))) 17:26:49.896 DEBUG wezterm_term::terminalstate > Background(Default) 17:26:49.898 DEBUG wezterm_term::terminalstate::performer > perform CSI(Sgr(Intensity(Normal))) 17:26:49.899 DEBUG wezterm_term::terminalstate > Intensity(Normal) 17:26:49.901 DEBUG wezterm_term::terminalstate::performer > perform PrintString("~ ")

Anything else?

No response

zhu-jiyuan commented 7 months ago

This only happens for the first time, and no redundant move events will be triggered thereafter.