wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

CTRL+\ sending wrong character on X11

Open FuZzledd opened this issue 3 years ago • 2 comments

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

Linux X11

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

KDE

WezTerm version

wezterm 20230527-141007-05a2d633

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

Pressing CTRL+\ on X11 sends a < instead of a CTRL+\ code

To Reproduce

Set X11 layout, model, and variant to gb,pc105,extd, type CTRL+\

Configuration

local keys = {}

if string.find(wezterm.target_triple, "darwin") then
	table.insert(keys, { key = "\\", mods = "CTRL", action = wezterm.action.SendString("\x1c") })
	table.insert({ key = "phys:Help", action = wezterm.action.SendKey({ key = "Insert" }) })
end

return {
	enable_kitty_keyboard = true,
	enable_csi_u_key_encoding = true,
	allow_win32_input_mode = false,
	debug_key_events = true,
	launch_menu = launch_menu,
	window_decorations = "RESIZE",
	color_scheme = "Catppuccin Frappe",
	default_domain = wezterm.target_triple == "x86_64-pc-windows-msvc" and "WSL:Arch" or nil,
	use_fancy_tab_bar = false,
	font = wezterm.font_with_fallback({
		{
			family = "Fira Code",
			harfbuzz_features = { "zero", "onum", "ss07", "ss02", "ss10" },
			weight = "Medium",
		},
		"OpenMoji",
		"Symbols Nerd Font Mono",
	}),
	font_rules = {
		{
			italic = true,
			font = wezterm.font_with_fallback({
				{
					family = "Fira Code",
					harfbuzz_features = { "zero", "onum", "ss07", "ss02", "ss10" },
					weight = "DemiBold",
					style = "Oblique",
				},
				"OpenMoji",
				"Symbols Nerd Font Mono",
			}),
		},
	},
	window_background_opacity = 0.95,
	font_size = 10.0,
	keys = keys,
	ssh_domains = {
		{ name = "fuzzle.uk", remote_address = "fuzzle.uk", username = "zuzi" },
	},
}

Expected Behavior

A CTRL+\ code (I think "\x1c"?) should be sent to the terminal

Logs

 WEZTERM_LOG=window::os::x11::keyboard=trace,info wezterm start --always-new-process
00:42:51.956  WARN   window::os::x11::connection > Unable to resolve appearance using xdg-desktop-portal: invalid value: string "()", expected at least one field signature between `(` and `)`: invalid value: string "()", expected at least one field signature between `(` and `)`
00:42:53.344  INFO   wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: (empty), phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }
00:42:53.344  TRACE  window::os::x11::keyboard         > process_key_event: RawKeyEvent FeedResult::Nothing: "", 65507. kc -> None def_sym=65507
00:42:53.344  INFO   wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: LeftControl, modifiers: NONE, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: (empty), phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
00:42:53.344  INFO   wezterm_gui::termwindow::keyevent > send to pane DOWN key=LeftControl mods=NONE
00:42:54.427  INFO   wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: RawCode(94), modifiers: CTRL, leds: (empty), phys_code: None, raw_code: 94, repeat_count: 1, key_is_down: true, handled: Handled(false) }
00:42:54.427  TRACE  window::os::x11::keyboard         > process_key_event: RawKeyEvent FeedResult::Nothing: "\u{1c}", 92. kc -> None def_sym=60
00:42:54.427  INFO   wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Char('<'), modifiers: CTRL, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: RawCode(94), modifiers: CTRL, leds: (empty), phys_code: None, raw_code: 94, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
00:42:54.427  INFO   wezterm_gui::termwindow::keyevent > send to pane DOWN key=Char('<') mods=CTRL
00:42:54.427  INFO   wezterm_term::terminalstate::keyboard > key_down: sending "\u{1b}[60;5u", Char('<') CTRL
00:42:54.564  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('\\'), modifiers: CTRL, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: RawCode(94), modifiers: CTRL, leds: (empty), phys_code: None, raw_code: 94, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
00:42:54.564  INFO   wezterm_gui::termwindow::keyevent     > send to pane UP key=Char('\\') mods=CTRL
00:42:54.877  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: LeftControl, modifiers: CTRL, leds: (empty), repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: CTRL, leds: (empty), phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
00:42:54.877  INFO   wezterm_gui::termwindow::keyevent     > send to pane UP key=LeftControl mods=CTRL

Anything else?

I believe this is happening because the code to get the default_keymap doesn't quite make sense. The system default layout and such I assume is a regular ANSI keyboard, but you want to be getting the default configured layout, so on X11 you should query the server for the configured string (see https://github.com/xkbcommon/libxkbcommon/blob/master/doc/quick-guide.md I think?)

FuZzledd avatar Jun 06 '23 00:06 FuZzledd

Likely a duplicate of:

  • https://github.com/wez/wezterm/issues/3610

wez avatar Jun 06 '23 15:06 wez

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Aug 12 '23 03:08 github-actions[bot]