Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcuts with the 3-key modifiers Ctrl +Shift + Alt are not working if KDE's Alt + Shift shortcut is set for changing layout #3010

Closed
Ernest0x opened this issue Jan 25, 2023 · 8 comments

Comments

@Ernest0x
Copy link

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

Linux X11

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

KWin

WezTerm version

20221119-145034-49b9839f

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

No, and I'll explain why below

Describe the bug

Using the mentioned version of WezTerm from the latest archlinux package, I cannot trigger an action via a shortcut that involves the pressing of Ctrl + Shift + Alt modifiers.

For example, Ctrl + Shift + Alt + ", which is the default combination to trigger the SplitVertical action in order to split the active pane vertically, does not work. As you can see in the debug output I am posting below, it seems that the Alt key has not been added to the modifiers combination when the KeyEvent event for the " key press is generated. An interesting observation I can make in the debug log is the fact that the key press of Alt only produces a RawKeyEvent event, in contrast with the other two key presses of Ctrl and Shift before, which have produced each both a RawKeyEvent and a KeyEvent event.

However, If I press some other combination (not mapped to an action), e.g. Ctrl + Alt + Super + m, I can see in the "KeyEvent" event of the m key press that all the modifiers include all pressed modifier keys (Ctrl + Alt + Super). In that case, the key press of Super has triggered both a RawKeyEvent and a KeyEvent event.

To Reproduce

No response

Configuration

return {
scrollback_lines = 20000,
ssh_domains = {
{
name = 'somehost',
remote_address = 'someaddress',
username = 'someusername',
},
},
}

Expected Behavior

No response

Logs

13:10:06.983  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) })
13:10:06.984  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Control, modifiers: NONE, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
13:10:07.001  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:07.001  DEBUG  wezterm_gui::termwindow                > NeedRepaint
13:10:07.001  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=440.82µs
13:10:07.002  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=696.388µs, fps=3.4380107
13:10:08.003  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:08.003  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:08.003  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:08.521  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(LeftShift), modifiers: CTRL, phys_code: Some(LeftShift), raw_code: 50, repeat_count: 1, key_is_down: true, handled: Handled(false) })
13:10:08.522  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Shift, modifiers: CTRL, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftShift), modifiers: CTRL, phys_code: Some(LeftShift), raw_code: 50, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
13:10:08.539  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:08.539  DEBUG  wezterm_gui::termwindow                > NeedRepaint
13:10:08.540  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=391.539µs
13:10:08.540  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=546.69µs, fps=0.65009546
13:10:09.541  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:09.541  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:09.541  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:10:10.477  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(LeftAlt), modifiers: SHIFT | CTRL, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: true, handled: Handled(false) })
13:10:12.520  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(Quote), modifiers: SHIFT | CTRL, phys_code: Some(Quote), raw_code: 48, repeat_count: 1, key_is_down: true, handled: Handled(false) })
13:10:12.520  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Char('"'), modifiers: SHIFT | CTRL, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(Quote), modifiers: SHIFT | CTRL, phys_code: Some(Quote), raw_code: 48, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
16:43:08.651  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) })
16:43:08.651  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Control, modifiers: NONE, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
16:43:08.669  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:08.669  DEBUG  wezterm_gui::termwindow                > NeedRepaint
16:43:08.670  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=424.483µs
16:43:08.670  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=623.514µs, fps=2.4152017
16:43:09.671  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:09.671  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:09.672  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:10.676  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(LeftAlt), modifiers: CTRL, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: true, handled: Handled(false) })
16:43:10.676  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Alt, modifiers: CTRL, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: CTRL, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
16:43:10.693  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:10.694  DEBUG  wezterm_gui::termwindow                > NeedRepaint
16:43:10.694  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=343.655µs
16:43:10.694  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=469.625µs, fps=0.49398178
16:43:11.695  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:11.695  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:11.696  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:13.378  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(LeftWindows), modifiers: ALT | CTRL, phys_code: Some(LeftWindows), raw_code: 133, repeat_count: 1, key_is_down: true, handled: Handled(false) })
16:43:13.378  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Super, modifiers: ALT | CTRL, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftWindows), modifiers: ALT | CTRL, phys_code: Some(LeftWindows), raw_code: 133, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
16:43:13.396  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:13.396  DEBUG  wezterm_gui::termwindow                > NeedRepaint
16:43:13.396  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=342.623µs
16:43:13.397  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=482.25µs, fps=0.37004006
16:43:14.397  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:14.398  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:14.398  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:15.711  DEBUG  wezterm_gui::termwindow                > RawKeyEvent(RawKeyEvent { key: Physical(M), modifiers: ALT | CTRL | SUPER, phys_code: Some(M), raw_code: 58, repeat_count: 1, key_is_down: true, handled: Handled(false) })
16:43:15.711  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Char('m'), modifiers: ALT | CTRL | SUPER, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(M), modifiers: ALT | CTRL | SUPER, phys_code: Some(M), raw_code: 58, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
16:43:15.711  DEBUG  wezterm_gui::termwindow                > NeedRepaint
16:43:15.713  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=1.175585ms
16:43:15.713  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=1.625524ms, fps=0.4318828
16:43:15.729  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:15.731  DEBUG  wezterm_gui::termwindow                > NeedRepaint
16:43:15.732  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=353.967µs
16:43:15.732  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=522.091µs, fps=0.4318828
16:43:15.738  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:15.738  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
16:43:15.748  DEBUG  wezterm_gui::termwindow                > NeedRepaint
16:43:15.749  DEBUG  wezterm_gui::termwindow::render        > paint_impl before call_draw elapsed=519.76µs
16:43:15.749  DEBUG  wezterm_gui::termwindow::render        > paint_impl elapsed=700.941µs, fps=0.4318828
16:43:15.796  DEBUG  wezterm_gui::termwindow                > KeyEvent(KeyEvent { key: Char('m'), modifiers: ALT | CTRL | SUPER, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(M), modifiers: ALT | CTRL | SUPER, phys_code: Some(M), raw_code: 58, repeat_count: 1, key_is_down: false, handled: Handled(false) }) })

Anything else?

No response

@Ernest0x Ernest0x added the bug Something isn't working label Jan 25, 2023
@wez
Copy link
Member

wez commented Jan 25, 2023

Can you run through the Debugging Keyboard Related Issues section of the docs?

That should give us some slightly more focused debug diagnostics, but it also has a suggestion about the IME that you should try.

Also, this issue may be relevant:

@wez wez added the waiting-on-op Waiting for more information from the original poster label Jan 25, 2023
@Ernest0x
Copy link
Author

@wez I have already included debug log taken by running wezterm with WEZTERM_LOG=debug env var set, so it should include messages that would be in the output with the debug_key_events option enabled. That said, I think I have found what is causing the issue. I am using a dual keyboard layout, "US" and "GR" (greek). The combination for changing the layout is configured as Alt + Shift. If I disable that combination for changing the layout, the Ctrl+Shift+Alt+ ... combinations work in WezTerm. So, the question is if WezTerm can somehow workaround the possibility of some keyboard shortcuts configured in the desktop environment system (KDE in my case) interfering with the shortcuts in the WezTerm configuration.

@github-actions github-actions bot removed the waiting-on-op Waiting for more information from the original poster label Jan 25, 2023
@wez
Copy link
Member

wez commented Jan 25, 2023

Glad that you found the cause. Sadly, no, wezterm cannot change or intercept system-wide shortcuts like that, or even know if they exist.

@Ernest0x
Copy link
Author

Glad that you found the cause. Sadly, no, wezterm cannot change or intercept system-wide shortcuts like that, or even know if they exist.

I am thinking of a different approach, not intercepting the shortcuts of the system. As you can see from the debug output, with the keyboard layout changing shortcut being active, WezTerm is still seeing the correct order of key press events. So, I am not sure why WezTerm cannot fire its own action, regardless of what action has been triggered in the mean time by the system (the keyboard layout change in that case). As far as any action triggered by a system-wide key combination that is completed first is not taking the focus from WezTerm's window, WezTerm can still continue receiving the key press events needed to complete the combination that triggers its own action.

@wez
Copy link
Member

wez commented Jan 25, 2023

keyboard processing is complicated; just because a key may be physically marked as LeftAlt, it doesn't mean that it will be regarded as the Alt modifier being active. That can vary based on the keyboard layout, IME and other system configuration. Importantly, there are no APIs available to help reason about the effect of a key like this.

While it may be possible for wezterm to assume a use, it would be counter to the behavior of the system and be a source of more bug reports.

I'm not going to add logic to wezterm to treat the keys in that way.

However, if you feel strongly that you want it to work that way, and don't want to configure your system to remove the conflicting key assignment, you may wish to look at using Key Tables to try to define that mapping for yourself.

@Ernest0x Ernest0x changed the title Shortcuts with the 3-key modifiers Ctrl +Shift + Alt are not working Shortcuts with the 3-key modifiers Ctrl +Shift + Alt are not working if KDE's Alt + Shift shortcut is set for changing layout Feb 2, 2023
@Ernest0x
Copy link
Author

Ernest0x commented Feb 3, 2023

I have changed the title of this issue to represent the actual problem I was facing. I am not sure if the keyboard layout is relevant and I will explain why. I have tested this by setting just two layout options, English and English (aka the same layout twice), so that the system shortcut does not actually change the layout, and the problem still exists. The problem exists even with just one layout option (English) configured, but with the Alt + Shift shortcut still active (and having no apparent effect). The only way to make Wezterm's shortcuts with CTRL + SHIFT + ALT modifiers work is to set KDE's shortcut for changing the keyboard layout to something different than Alt + Shift. So, what I have come to, and I am satisfied with that, is to set the KDE's keyboard layout changing shortcut to LeftAlt + LeftShift. That way I can use the RightCtrl + RightShift + RightAlt combination for WezTerm's actions (split pane, etc.) to work. This combination will not work though if the keyboard layout has been changed to Greek layout! Surely, I can live with it, but it is quite strange... I set the keyboard layout changing shortcut to Alt + Shift, WezTerm's shortcuts become dead, but the keyboard layout is not relevant. I set the shortcut to LeftAlt + LeftShift, WezTerm's shortcuts work with English layout but not with Greek layout, making in that case the keyboard layout relevant! Go figure!

Another question I have, and this has nothing to do with WezTerm, is why my system (KDE) is triggering the keyboard layout changing action even if I start pressing and keeping down the Ctrl key first, then Shift, then Alt. I mean, if the configured shortcut is just Alt+Shift (or LeftAlt + LeftShift), without Ctrl, why does KDE trigger the action while I am pressing Ctrl first? Does it make sense?

@wez
Copy link
Member

wez commented Feb 3, 2023

All of the things you've described are happening at a layer above wezterm, in your windowing environment.
wezterm has no ability to see or alter those things.
If you have questions about how KDE works, then I'm afraid you'll need to find someone else to help answer that question, as I don't use it and don't know about it.

I'm going to close this out as it is out of the scope of this project.

@wez wez closed this as completed Feb 3, 2023
@wez wez removed the bug Something isn't working label Feb 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

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 github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants