1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00
Commit Graph

625 Commits

Author SHA1 Message Date
Wez Furlong
60ea06e188 revise default xcursor path
refs: https://github.com/wez/wezterm/issues/524#issuecomment-1015984205
2022-01-18 19:26:44 -07:00
Wez Furlong
e4ed2c93e2 encoding my preferred import grouping in the rustfmt config
This uses an unstable option in rustfmt, you `cargo +nightly fmt`
needs to be used to format the code correctly.
2022-01-17 13:50:51 -07:00
Wez Furlong
e575bc9ff9 simplify window reconciliation logic
refs: https://github.com/wez/wezterm/issues/1531
2022-01-16 09:50:16 -07:00
Wez Furlong
6d288696c8 Add SwitchToWorkspace keyassignment action
This action causes the active workspace for the gui to change.

If the name is omitted a random name will be generated.
If the workspace doesn't exist, it will be be created.
The optional spawn parameter can be used to launch a specific
program into the new workspace; if omitted, the default prog
will be used.

The gui only supports a single active workspace. Switching workspaces
will repurpose existing gui windows and re-assign them to windows
in the new workspace, adjusting their size to fit those windows,
spawning new windows or closing unused windows as required.

The gui now exits when there are no panes in the active workspace,
rather than no panes at all.

refs: #1531
2022-01-15 13:53:34 -07:00
Wez Furlong
35e921b9e6 input: fix alt-h on macos
We'd lost support for send_composed_key_when_X_alt_is_pressed;
this commit restores it.

refs: https://github.com/wez/wezterm/issues/1541
2022-01-12 16:47:08 -07:00
Wez Furlong
ca69515e3b window: x11/wayland keyboard: try harder to populate Composing info
When a dead key is composing, we gave no information about what was
composing.  Contrast with Windows and macOS where we show the first
key in the composition as part of that state.

This commit makes an attempt to populate equivalent information.
It's a bit more complex with the xkeyboard stuff as there can be
multiple combining sequences and there's no guarantee that we can
show a meaningful label.

We try our best for the common case of a single dead key, and have
a probably reasonable fall back for other cases where we don't
other get that information.

This allows removing DeadKeyStatus::Holding.
2022-01-09 08:25:25 -07:00
Wez Furlong
6afc35507c window: macos: fix lalt-` in default config w/ US layout
lalt-` is technically a dead key combo, so we entered dead key
processing, then realized that
`send_composed_key_when_left_alt_is_pressed == false` and that
we should ignore the dead-key-ness of the combo, but returned
a composed result, which had the modifiers discarded.

The correct way to handle this is to signal that it wasn't
dead after all and to allow the main flow to build the KeyEvent
as normal.
2022-01-07 23:53:23 -07:00
Wez Furlong
67b8c453ca windows: adjust wait mask to include posted messages
This improves latency in situations where other applications
are using eg: SetWindowPos on wezterm's window handle.

refs: https://github.com/wez/wezterm/issues/1013
refs: https://github.com/wez/wezterm/issues/1398
refs: https://github.com/wez/wezterm/issues/1484 (maybe; cannot
reproduce, but I don't want to install a window manager)
2022-01-07 16:39:11 -07:00
Wez Furlong
4524abcdba gui: revise win32-input-mode flow
We need 100% of the info for it to work correctly, so this commit:

* Exposes the keyboard encoding mode via the Pane trait
* Adds the scan code to the RawKeyEvent
* Has the GUI perform the encoding if the keyboard is set that way
* Removes the basic encoder from termwiz in favor of the gui level one

The net result is that we bypass the Pane::key_up/Pane::key_down methods
in almost all cases when the encoding mode is set to win32-input-mode.

There is now a config option: allow_win32_input_mode that can be
used to prevent using this mode.

refs: #1509
2022-01-07 13:02:09 -07:00
Wez Furlong
bd952bcc2b input: fix key_is_down in RawKeyEvent on windows 2022-01-06 20:11:55 -07:00
Wez Furlong
ce23ee9eb8 input: generate win32-input-mode for a subset of keys
This commit causes the terminal to emit win32-input-mode encoded key up
and down events for a limited subset of keys When win32-input-mode is
enabled.

We limit them to keys where we know the VK key code equivalent,
and where those keys are either not representable (eg: modifier
only key events), or may generate ambiguous output (eg: CTRL-SPACE
in different keyboard layouts).

However, in my experiments, modifier only key presses confuse powershell
and cause it to emit `@`, so I've disabled that in the code for now.

refs: https://github.com/wez/wezterm/issues/318
refs: https://github.com/wez/wezterm/issues/1509
refs: https://github.com/wez/wezterm/issues/1510
2022-01-06 10:19:58 -07:00
Wez Furlong
27d452a20f input: route key up events to pane on win32
refs: https://github.com/wez/wezterm/issues/1509
2022-01-06 09:45:51 -07:00
Wez Furlong
e39b0b1b4a input: add VK_MENU -> LeftAlt mapping for windows
refs: https://github.com/wez/wezterm/issues/1509
refs: https://github.com/wez/wezterm/issues/1483
2022-01-06 08:10:14 -07:00
Wez Furlong
1dc5af5e69 x11: ime: enable pre-edit callbacks to show compose status
This also adjusts the IME position so that it doesn't obscure
the composition status.

refs: https://github.com/fcitx/xcb-imdkit/issues/9
2022-01-05 15:36:20 -07:00
Wez Furlong
e66b788759 windows: feed dead key composition state to gui layer 2022-01-05 10:34:18 -07:00
Wez Furlong
27d84e08de windows: route IME composition to render layer
This shows the pending composition in the same font as the terminal display,
rather than the anemic looking system default font!
2022-01-05 10:29:27 -07:00
Wez Furlong
612afca961 windows: restore recognizing the Insert key
refs: #1483
2022-01-05 09:49:33 -07:00
Wez Furlong
2456eefaa6 cargo fmt 2022-01-05 08:49:50 -07:00
Wez Furlong
f11281a4fa window: downgrade fallback error to warning level
refs: #1505
2022-01-05 08:33:03 -07:00
Wez Furlong
cc9ceeef22 macos: feed dead key composition to IME composing status
Now we can show the in-progress dead key composition on macos
2022-01-05 08:29:54 -07:00
Wez Furlong
0d6fbc1aa2 macos: improve ime vs dead key composing
When we translate a dead key, send the composed event immediately
and don't try to route the current key press via the IME.

Improve rendering when in the composing state: overlay the composing
text at the cursor position to show what the composing text would
look like, even though it hasn't been committed to the input stream
yet.

refs: https://github.com/wez/wezterm/issues/1504
2022-01-05 07:50:12 -07:00
Wez Furlong
71dae34b75 macos: improve IME handling
For Korean text input, pressing SHIFT and then typing in certain
keys begins a composition sequence.  Our logic for when to route
via the IME got so distracted by ALT that it didn't consider SHIFT
and didn't send this sequence to the IME, so we'd fail to compose
those sequences.

While poking at this, I realized that we should treat this composition
similarly to dead keys, in that we can signal the term window to
highlight the cursor color and report that status.

There's some further work to do: the composing text should be rendered
by us.  So far our IME integration assumes that the IME itself will
render over the top of our window, but for this particular input
it doesn't do that.

refs: https://github.com/wez/wezterm/issues/1504
2022-01-04 22:51:49 -07:00
Wez Furlong
3ab78f7fac window: remove stray debug 2022-01-03 21:48:50 -07:00
Wez Furlong
e2e7d60200 fix build on linux
refs: #1495
2022-01-03 11:11:36 -07:00
Wez Furlong
2890e4e723 keyboard: use more consistent backspace/delete names for physkeycodes
refs: #1495
2022-01-03 11:05:38 -07:00
Wez Furlong
34dd0b6688 add mapping from phys to keycode, tidy up windows event processing
refs: #1483
2022-01-03 10:56:32 -07:00
Wez Furlong
640ffbe1e8 window: remove unused local variable on macos 2022-01-03 09:24:30 -07:00
Wez Furlong
5f26746286 window/gui: remove raw/phys fallback fields from KeyEvent
Since we now have RawKeyEvent and a sane way to indicate handling,
we don't need these any more, and it simplifies key dispatch to
remove them.

refs: #1483
2022-01-03 09:13:55 -07:00
Wez Furlong
2616efa72e window: fix test build 2022-01-03 09:13:38 -07:00
Wez Furlong
83052530d9 window: populate live_resizing for Windows
refs: https://github.com/wez/wezterm/issues/1491
2022-01-03 08:41:55 -07:00
Wez Furlong
49904eac9c window: populate live_resizing for x11/wayland
We don't really know for sure, but we can make a reasonable deduction on
X11.

refs: https://github.com/wez/wezterm/issues/1491
2022-01-03 08:38:03 -07:00
Wez Furlong
0224f65fed gui: avoid glitchy live resize
Pass down whether we are in a live resize to the gui layer, so that
we don't incorrectly assume that the scale has changed, and fight
with the window manager.

Built this on my mac: will need to fixup for windows and linux.

refs: https://github.com/wez/wezterm/issues/1491
2022-01-03 08:29:05 -07:00
Wez Furlong
c0502012d5 redefine key assignments in terms of physical key location
and then remove horrible mac hacks.

This resolves the root cause for some horrible mac key mapping stuff
that is responsible for at least 3 different user issues by making the
default key assignments work from the physical key location.  That makes
them unambiguous.

refs: https://github.com/wez/wezterm/issues/601
refs: https://github.com/wez/wezterm/issues/760
refs: https://github.com/wez/wezterm/issues/1080
refs: https://github.com/wez/wezterm/issues/1483
2022-01-03 00:22:51 -07:00
Wez Furlong
369f388f90 window: macOS: workaround key repeat issue when use_ime=true
The logic is explained in comments in this commit.

While we're at it, tweak the IME window position so that it
sits below the text.

refs: #1131
2022-01-02 23:36:57 -07:00
Wez Furlong
05073fbaf9 window: macos: fix double pressing of dead key
We want it to emit the original key; it wasn't changing
any state.
2022-01-02 21:27:17 -07:00
Wez Furlong
8a476b70ab window: macos: generate dead key events
refs: #688
2022-01-02 21:14:59 -07:00
Wez Furlong
306133af7a window: implement dead key status events for x11/wayland
refs: #688
2022-01-02 17:20:29 -07:00
Wez Furlong
8d9ae31ff0 window: fix example build 2022-01-02 17:17:47 -07:00
Wez Furlong
79ab6e8103 window: add deadkeystatus event
Plumbs it for Windows.
Doesn't do anything useful with it yet.

refs: #688
2022-01-02 17:00:18 -07:00
Wez Furlong
2d62bffe41 window: fix CTRL+C with Russian keyboard on windows
Turns out that we had the same issue on Windows

refs: #678
2022-01-02 16:50:26 -07:00
Wez Furlong
ea964e74e3 window: generate RawKeyEvent on Windows
refs: refs: https://github.com/wez/wezterm/issues/877
2022-01-02 16:35:50 -07:00
Wez Furlong
d9851e5c2a window: generate RawKeyEvents on X11/Wayland
Similar to d5726ba91a but for X11/Wayland.

Handling a RawKey event cancels any composition or further processing
on the same key.

refs: https://github.com/wez/wezterm/issues/877
2022-01-02 16:14:40 -07:00
Wez Furlong
1a342adfc1 window: fix test build. remove dead code 2022-01-02 15:37:34 -07:00
Wez Furlong
6feabb8178 window: adjust xkb handling for future RawKeyEvent support
This moves the event dispatching into the keyboard processor,
which will allow for the processor to skip feeding an event
into the dead key/composition stuff if a key assignment is
handled.

It doesn't actually do that bit yet though, as the wayland
key repeat processing was a bit more involved and I wanted
to constrain the scope of this commit.

refs: #877
2022-01-02 15:33:42 -07:00
Wez Furlong
d5726ba91a window: add RawKeyEvent concept
on macos only (for now), we generate a RawKeyEvent prior to
dead key or IME composition and route it to the window to give it
a chance to handle the event.

RawKeyEvent handling is scoped only to key assignments, not generating
input for the terminal.

A raw key event can be marked as handled to prevent moving on to
performing composition and generating cooked key input.

refs: https://github.com/wez/wezterm/issues/877
2022-01-02 15:04:27 -07:00
Wez Furlong
43d9392c52 window: x11/wayland: extract utf8 version of key from key state
Previously, we'd take a couple of guesses at how to map the key
to a utf8 value, but! the keyboard state has a method that can tell
us what to use.

This is important in non-latin keymaps where, for example, the `c`
key generates cyrillic small letter es and we'd end up sending
CTRL + that through to the terminal when CTRL is held down.

If we get the utf8 string from the keyboard layer then we get
CTRL+c instead, and that is what we want.

refs: https://github.com/wez/wezterm/issues/678
2022-01-02 11:16:52 -07:00
Wez Furlong
822202b7be window: add some comments about xkd lookups 2022-01-02 00:52:46 -07:00
Wez Furlong
e8967d9c17 window: remove stray debug logging 2022-01-02 00:50:19 -07:00
Wez Furlong
30a390053a window: track phys_code on X11/Wayland
We don't do anything useful with it yet

refs: https://github.com/wez/wezterm/issues/1483
2022-01-02 00:47:04 -07:00
Wez Furlong
45631389c3 window: track phys_code on Windows
We don't do anything useful with it yet

refs: https://github.com/wez/wezterm/issues/1483
2022-01-01 22:43:12 -07:00