1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-28 17:23:26 +03:00
Commit Graph

795 Commits

Author SHA1 Message Date
Wez Furlong
924b63eb42 macos: fixup Backspace key
refs: https://github.com/wez/wezterm/issues/1891#issuecomment-1103501418
2022-04-19 23:24:36 -07:00
Wez Furlong
b92f31e7a6 macos: fix CTRL-Backslash on German layouts
refs: https://github.com/wez/wezterm/issues/1891
2022-04-19 14:17:04 -07:00
Wez Furlong
d64bc7248e pty: pre-fill base env from registry env settings on Windows
I think I'd like to make a config option for this, but for the moment,
this first pass unconditionally updates the base environment with
data from the registry.

refs: https://github.com/wez/wezterm/issues/1848
2022-04-19 09:56:23 -07:00
Wez Furlong
77ecbe29b1 x11: set _NET_WM_NAME for clients like polywins/polybar 2022-04-18 08:05:20 -07:00
Wez Furlong
47addfa53c Ctrl-[ and Ctrl-Esc didn't send key_down until key_up
Looking closer, I think I'd misread the key event generated by
perform_key_equivalent for the ctrl-escape case as a key down.

Fixing this is fairly straightforward: when we return YES from
perform_key_equivalent we synthesize a key_down event.
macos will follow up with the key up.

We can fold two cases together in there and remove the horrible
hack style fix I just added in a4b68247bb

refs: https://github.com/wez/wezterm/issues/1877
2022-04-15 21:28:26 -07:00
Wez Furlong
325c1a9e91 window: macos: suppress UNHANDLED logging for Shift-Tab 2022-04-15 21:23:24 -07:00
Wez Furlong
3688055ced macos: remove .normalize_ctrl from key processing
We don't want/need this any longer.

refs: https://github.com/wez/wezterm/issues/1851#issuecomment-1099501144
2022-04-15 21:04:12 -07:00
Wez Furlong
a4b68247bb window: fix CTRL-[ on macos
This is another key combination that doesn't generate a key-down
event.

refs: https://github.com/wez/wezterm/issues/1877
2022-04-15 20:51:01 -07:00
Wez Furlong
fdb3471017 xkeyboard: resolve ambiguous CTRL-i / CTRL-Tab
We want to avoid normalizing control key presses; there were
two places where it was happening; one in our own code and
the other was in the xkeyboard mapping stuff itself.

refs: https://github.com/wez/wezterm/issues/1851
2022-04-15 07:27:01 -07:00
Wez Furlong
e680cc848a macos: workaround weird CMD-. behavior
There are certain key combinations that macOS prefers to handle
without giving the application much opportunity to process them.

CTRL-ESC and CMD-. both cause doCommandBySelector(cancel:) to be
called.  The former we had already special cased but since we
can't disambiguate the two things, we need a better way.

performKeyEquivalent: is a method we can implement to have an
opportunity to "do something" and prevent the default macOS behavior.

So we implement that. What's interesting is that saying that we handled
CMD-. results in no further processing at all by macOS, whereas saying
that we handled CTRL-ESC results in macOS doing the normal key event
dispatch.  So we need to route that event for ourselves in that one
case.

Doesn't feel great!

refs: https://github.com/wez/wezterm/issues/1867
2022-04-12 17:41:37 -07:00
Wez Furlong
bbb842c3e9 macos: suppress IME UNHANDLED warning for shift up/down 2022-04-09 22:19:22 -07:00
Wez Furlong
738e180295 x11/wayland: add tracing to xcursor loading code
Makes it easier to understand what is happening when debugging xcursor
issues:

```
WEZTERM_LOG=window::os::x11::cursor=trace,info wezterm
```
2022-04-09 06:48:29 -07:00
David Rios
44a26c78f2 wayland: improve touchpad scroll precision
- Save the remainder of the scroll delta to be used on the next event
when it doesn't meet the activation threshold

refs: https://github.com/wez/wezterm/issues/1827
2022-04-08 07:50:47 -07:00
Wez Furlong
b35e3b2aad deps: remove pretty_env_loggger
Go directly to the underlying env_logger crate, as pretty_env_logger
hasn't been updated in some time, and I'd like to be able to redirect
the log output to a file more directly, and that feature is in a newer
version of the env logger than pretty_env_logger was pulling in.
2022-04-07 08:24:07 -07:00
Wez Furlong
0cfdf0999c macos: send_composed_key_when_X_alt_is_pressed now ignores other mods
For reasons that I cannot remember, I made
`send_composed_key_when_left_alt_is_pressed` and
`send_composed_key_when_right_alt_is_pressed` only take effect if only
the ALT modifiers were pressed.  If SHIFT or CTRL were pressed, then
the purpose of `send_composed_key_when_left_alt_is_pressed` was
bypassed.

This commit scopes this back to the alt mods - other kinds of mods
don't affect this functionality any more.

refs: https://github.com/wez/wezterm/issues/1826
2022-04-06 18:26:16 -07:00
Wez Furlong
6c5e54c47e deps: unpin glium from git, use latest release
We were pinned on the revision where I had added dual source blending,
because I wanted that feature ahead of the crate being published.

Since then a couple of releases have been made so we can unpin.

On Windows 11, we had a report of glium complaining about the opengl
version. I can't find that error message string in the current version
of the code so it's possible that that situation has been resolved.

refs: https://github.com/wez/wezterm/issues/1813
2022-04-04 06:54:49 -07:00
Wez Furlong
0284bcdd3d x11: set position only if explicitly requested
refs: #1794
2022-04-03 18:00:27 -07:00
Wez Furlong
603f6d69ce try harder to set the x,y position on x11
refs: #1794
2022-04-03 17:01:03 -07:00
Wez Furlong
7526b0567c x11: add KP_End keysym mapping
refs: #1804
2022-04-03 07:36:48 -07:00
Wez Furlong
02d5d9425d x11: improve trace logging for keyboard handling
refs: #1804
2022-04-03 06:32:42 -07:00
Wez Furlong
e95707fe70 flesh out % based and named display for positioning on X11
refs: #1794
2022-04-02 22:45:13 -07:00
Wez Furlong
13bfa27d2e flesh out % based and named display for positioning on macOS
refs: #1794
2022-04-02 15:40:09 -07:00
Wez Furlong
9a324385eb flesh out % based and named display for positioning on Windows
refs: #1794
2022-04-02 11:11:28 -07:00
Wez Furlong
02aae83794 fix windows build
refs: #1794
2022-04-02 09:46:36 -07:00
Wez Furlong
52edc8bb11 window: speculative code to enable initial position on windows
need to move this to my windows machine to try it

refs: #1794
2022-04-02 09:40:41 -07:00
Wez Furlong
8ac793a619 add --position CLI option for requesting initial window position
refs: #1794
2022-04-02 09:32:21 -07:00
Wez Furlong
2faa6822f9 fix mac, windows builds
refs: https://github.com/wez/wezterm/issues/1794
2022-04-02 07:58:27 -07:00
Wez Furlong
89b653acb8 x11: respect requested x/y geometry if provided
refs: https://github.com/wez/wezterm/issues/1794
2022-04-02 07:47:03 -07:00
Wez Furlong
69288aee4c window: Add RequestedWindowGeometry type
This is mostly a refactoring: pulling out the discrete width/height from
the `new_window` method and preparing to pass down x/y coords as well.

The types are expressed as Dimension so that screen relative sizes could
be expressed in the future... once we know how to obtain that
information on each platform.

refs: https://github.com/wez/wezterm/issues/1794
2022-04-02 07:25:59 -07:00
Wez Furlong
67218d3a85 fix formatting 2022-04-01 08:15:32 -07:00
Wez Furlong
8ba0ef2375 macos: notch avoidance tweak
https://github.com/wez/wezterm/issues/1737#issuecomment-1085923867
2022-04-01 08:14:11 -07:00
David Rios
821b6f67bb Improve touchpad precision on Wayland 2022-03-31 07:15:45 -07:00
Wez Furlong
ff88fec880 window: add Debug trait to os parameters types 2022-03-30 07:02:47 -07:00
David Rios
45072fa475 Overhaul scroll thumb calculation
- Simplify scroll thumb calculations
- Correct thumb position when dragging with mouse
- Support border OS parameters
- Use usize for OS borders, to explicitly only accept positive integers
- Get correct tab height when using fancy tab bar
- Correctly draw depending on tab bar position
- Adjust minimum thumb size to be 1/2 of a cell height, so it has consistent size across platforms and screen densities

Fixes #1525
2022-03-29 08:55:25 -07:00
Wez Furlong
045698e6ca x11: query focus prior to painting if we don't know focus state
We don't assume that we start up focused, and some WM don't tell
us our focus state, so prior to painting, if we don't know the
focus state, explicitly query it and synthesize a focus change event.

refs: https://github.com/wez/wezterm/issues/1757
2022-03-27 07:10:47 -07:00
Wez Furlong
4cd893335b fix build for intel mac 2022-03-26 23:14:15 -07:00
Wez Furlong
4e343eb1e5 macos: try to avoid the notch
Flesh out the get_os_parameters impl for macOS.  When running on a
system that provides `NSScreen::safeAreaInsets`, use that to determine
the border required to avoid the "notch" on certain models of mac.

In the GUI layer: when the os parameters include a border, adjust
the render position to account for it.

This is a bit of a speculative change, as I don't have a mac with
a notch.

refs: https://github.com/wez/wezterm/issues/1737
2022-03-26 22:47:42 -07:00
Wez Furlong
a61d3a1b99 macos: clear scroll remainder when changing scroll direction 2022-03-26 20:46:28 -07:00
David Rios
491fe14ca9 Fix touchpad on windows 2022-03-26 17:45:40 -07:00
David Rios
fca3559a0f
Implement native window dragging on Windows (#1771)
Implement native window dragging on Windows
2022-03-26 17:28:43 -07:00
Wez Furlong
91a0903246 windows: simplify logfont assignment/fetch 2022-03-26 07:52:25 -07:00
David Rios
109330fefa Get window state on resize, fixes #1502 2022-03-26 07:27:54 -07:00
David Rios
5c5f2dbca5 Cache title_font 2022-03-26 07:27:54 -07:00
David Rios
eaaf98ad2f Uncomment title font 2022-03-26 07:27:54 -07:00
David Rios
c55d44aa72 Use anyhow ensure
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2022-03-26 07:27:54 -07:00
David Rios
da74100d5e Use equality to check focus
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2022-03-26 07:27:54 -07:00
David Rios
b3f1ef7577 Remove unused function 2022-03-26 07:27:54 -07:00
David Rios
a95b081620 Improve the responsiveness of the drawn border 2022-03-26 07:27:54 -07:00
David Rios
b036bb3b05 Improve RESIZE window_decoration on Windows 2022-03-26 07:27:54 -07:00
Wez Furlong
623f617951 x11: window icon had red/blue channels swapped
closes: #1754
closes: #1755
2022-03-23 07:01:26 -07:00
Wez Furlong
5c8ff787c6 x11: query geometry if we're painting and never had CONFIGURE_NOTIFY
If the WM has never confirmed our size and we're about to paint,
explicitly query it and generate a resize event so that we stand
a better chance of showing the right stuff.

refs: https://github.com/wez/wezterm/issues/1710
2022-03-22 09:50:52 -07:00
Wez Furlong
57c66053d2 x11: more logging around configure notify events
refs: #1710
2022-03-22 09:30:50 -07:00
Wez Furlong
9936b8a5ab add xcursor_theme and xcursor_size config options
refs: #1742
2022-03-22 08:23:17 -07:00
Wez Furlong
bd9088372a wayland: speculative handling of pointer when seat changes
It compiles and launches under weston, so that's promising.
I can't test the suspend/resume case on the hardware I have available.

refs: #1497
2022-03-19 05:47:04 -07:00
Adam Harvey
0c7e735a86 window: correctly handle keyboard input after seat updates
When the user switches to another virtual console and then back into a
Wayland session, a number of seat updates are received by the listener
installed by `Environment::listen_for_seats()`. These updates
essentially flip the keyboard and pointer flags off and then back on in
the seat data, which indicates that new handlers need to be assigned to
the keyboard and pointer objects.

However, because one update is received for _each_ flag being toggled,
this means that the listener is fired twice with `has_keyboard` set to
true, which means that two keyboard handlers end up being installed.
Users then experience each keypress being delivered twice to the
terminal.

This commit adds a map to track the keyboard object that has been
assigned on each seat, thereby preventing duplicate assignments and (by
extension) duplicate keypresses being registered. This logic is
essentially the same as what's used in the `kbd_input` example in SCTK,
which doesn't have this issue.

Something similar is required for pointer handling, which also breaks
after switching to another virtual console and back into Wayland, but I
was scared off by the TODO in the `listen_for_seats` callback and didn't
investigate this further.
2022-03-19 05:11:04 -07:00
Wez Furlong
0b7cb6550b macos: more urgh with alt+shift key combinations
refs: https://github.com/wez/wezterm/issues/760
refs: https://github.com/wez/wezterm/issues/1706
2022-03-18 13:32:43 -07:00
Wez Furlong
8c3d2f6eb6 windows: make repeated dead key handling consistent with other apps
On Windows in FRA layout, `^^SPACE` results in `^^SPACE`, whereas
on Linux it results in `^SPACE`.  We were doing the latter instead
of the former.

Let's just be consistent with other windows apps.

closes: #1729
closes: #1730
2022-03-18 10:42:14 -07:00
Wez Furlong
edd997d0f7 macos: fix CTRL-Tab
refs: https://github.com/wez/wezterm/issues/1684
2022-03-12 13:25:42 -07:00
Wez Furlong
c1fb73409d macos: improve handling of keys when both ALT+SHIFT are pressed
refs: https://github.com/wez/wezterm/issues/1706
2022-03-12 12:01:16 -07:00
Sebastian Wiesner
277d30ef2e Support primary selection on Wayland
Closes #1423
2022-03-12 05:42:01 -08:00
David Rios
aaad2be606
Detect mouse leaving the window (#1679)
* Detect mouse leaving the window

* Implement leave

* Use new API

* Fix mouse leave

* Fix mouse leave on Wayland

* Mouse leave on X11

* Detect mouse leaving window on macOS

* Fix example

refs:  #1434
2022-03-11 08:26:09 -08:00
David Rios
3b05dac0c6 Use newer windows crate 2022-03-11 07:40:39 -08:00
Greg V
9879005f87 add support for XF86Copy/XF86Paste keys 2022-03-11 06:43:18 -08:00
Wez Furlong
3234ef0ec9 x11: add fallbacks when loading xcursor themes
refs: #1655
2022-02-23 08:53:11 -07:00
Wez Furlong
c9f1f0e12c window: x11: avoid potential crash when pasting non-utf8 text
This might "break" eg: pasting from apps that just use ATOM_STRING
and that happen to have utf-8 compatible text.

Ideally the get_text_property interface would expose the actual
text encoding in the returned data and allow the application to
"do stuff" with it.

refs: https://github.com/meh/rust-xcb-util/issues/21
2022-02-13 07:34:47 -07:00
Wez Furlong
240026de48 refactor: move color parsing into wezerm-color-types crate
Resolves a little bit of the awkward duplication of color types
between some of the crates by factoring them a little bit better.

This is prep for allowing specifying alpha for some colors
in the config.
2022-02-05 13:59:54 -07:00
Wez Furlong
bd47979292 revise ligature render / cursor intersection
This puts to final rest #478, wherein ligatured glyphs that span
cells would render portions of the glyph with the wrong fg color,
where wrong was usually the bg color and cause the glyph to turn
invisible when cursoring through the ligature.

The approach used here is to divide the glyph into 7 discrete strips
where each strip either intersects with the cursor, the selection, or
neither. That allows us to render each strip with the appropriate
foreground color.

This change simplifies some of the logic and allows some other code
to be removed, so that feels good!

As is tradition with these renderer changes, there's a good chance that
I overlooked something in testing and that the metrics or alignment
might be slightly off for some font/text combo.  Let's see how this
goes!

refs: #784
refs: #478
refs: #1617
2022-02-05 10:49:49 -07:00
Wez Furlong
5f2c905db8 shaping: feed presentation width from the terminal through to glyph info
This allows unicode_version to be respected again when rendering.

The updated emoji-presentation.sh script now highlights this slightly
better by putting `.` characters after the emoji; unicode version 14
emoji presentation will show the `.` in the 3rd column, while earlier
versions will show it in the 2nd column for glyphs that are sensitive
to the version.

refs: #1607
refs: #1563
2022-02-01 09:23:57 -07:00
Wez Furlong
4ca1378f1f fonts: allow shaping with additional paragraph context
we don't really use this yet, except internally when we do fallback
2022-01-28 17:19:36 -07:00
Wez Furlong
8cfad0455c fix build on linux
refs: https://github.com/wez/wezterm/issues/784
2022-01-25 09:27:01 -07:00
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
Wez Furlong
d714c5d5b6 window: track phys_code on macos
We don't do anything useful with it yet

refs: https://github.com/wez/wezterm/issues/1483
2022-01-01 22:04:59 -07:00
Wez Furlong
52c198ab8c x11: default use_ime=true, add xim_im_name option 2021-12-31 09:55:17 -07:00
Wez Furlong
d031342b72 macos: avoid unrecognized selector error
I saw this when the IME was active:

```
2021-12-31 00:46:26.941 wezterm-gui[46160:16665949] -[NSConcreteMutableAttributedString UTF8String]: unrecognized selector sent to instance 0x600002b24180
```

the issue is that some of the window callbacks can receive either
NSString or NSAttributedString.  The latter doesn't have a UTF8String
method, but does have a string property that returns an NSString
that can be used instead.
2021-12-31 00:54:52 -07:00
Wez Furlong
143f7c9acc macos: detect when IME swallows a key press (eg: F8, F9)
Certain keys are "handled" by the IME through it generating a "noop"
command.

That's not super useful for us, so this commit detects the noop case
and then treats it as though the IME didn't handle the input event.

While implementing the above fix, I realized that the same technique
could be used more generally to return processing to our main input
handling for the various selectors that we do recognize: we were
essentially inferring the original key combinations based on the
selector which is not scalable and potentially lossy.

We can't capture CTRL-ESC this same way, as that key combination
is magical and is routed to the callback without generating any
key events.

refs: https://github.com/wez/wezterm/issues/615
refs: https://github.com/wez/wezterm/issues/975
refs: https://github.com/wez/wezterm/pull/1410
2021-12-30 22:50:26 -07:00
Wez Furlong
e3afdd7b8f macos: normalize Composed("p") -> Char('p') when use_ime=true
When the IME is enabled, pressing `CTRL-A P` would generate
`Composed("P")` for the second key press, which we couldn't
then match in the keymapping layer.

This commit checks for that and normalizes it to `Char('P')`
instead.

refs: https://github.com/wez/wezterm/issues/1409
refs: https://github.com/wez/wezterm/issues/1410
2021-12-30 21:36:25 -07:00
Wez Furlong
96dd41c5c5 window: update smithay-client deps 2021-12-28 07:28:07 -07:00
Wez Furlong
f4fab10e69 gui: box model style layout/render for fancy tab bar
This commit adds a CSS box model inspired element / layout
facility, and replaces the hand implemented fancy tab bar
element render.

This makes the code for fancy tab bar much easier to read
and update.

The right status area now expands to the full height of the
tab bar area, and uses a line height of 2.0, which makes
it line up nicely in the tab bar.
2021-12-28 00:14:54 -07:00
Wez Furlong
a78ff883a9 windows: query the system caption font
Use this for the tab bar font by default
2021-12-25 09:54:31 -07:00
Wez Furlong
9e146beb02 gui: more fun with gamma correction
On Windows, both EGL and MESA render modes were too dark.
After a bit of hunting around what I found made EGL and MESA
consistent with my default nVidia GPL rendering was:

* Tell glium that our shader outputs srgb
* Add explicit gamma conversion from linear to srgb in the shader

AFAICT, that shouldn't be required, but it seems as though something
deep in glium really wants to apply some kind of gamma conversion,
and it seems to select the wrong kind unless we set things explicitly
to SRGB.

There are some people complaining about this in
https://github.com/glium/glium/issues/1615.

I actually tried to move entirely aware from the glium srgbtexture2d
type in the hope of having explicit control over the gamma, but the
issue is in what happens to the outputs rather than the inputs.

It appears to me as though the text now looks slightly less
intense, so I think this may be what we need for the gamma issue
in https://github.com/wez/wezterm/issues/544 and potentially
also https://github.com/wez/wezterm/issues/1025

refs: https://github.com/wez/wezterm/issues/1373
2021-12-22 18:14:52 -07:00
Wez Furlong
136b4a9bf1 window: fix unused field warning 2021-12-12 07:57:59 -07:00
Wez Furlong
7b402678e4 gui: fix initial pixel geometry on hidpi displays
refs: #1387
2021-12-10 09:20:41 -07:00
Wez Furlong
f905ec8100 fix some unused/unread field warnings 2021-12-10 08:18:36 -07:00
Wez Furlong
4dd014b14e macos: enable rounded corners when title is disabled
refs: https://github.com/wez/wezterm/issues/1034
2021-12-08 21:44:21 -07:00
Wez Furlong
f9ce727281 remove wgpu from window test deps
We don't use this and all it really does it make `cargo test`
take longer
2021-11-23 05:39:07 -07:00
Wez Furlong
ae18996c23 wayland: fix warning 2021-11-03 06:40:28 -07:00
Greg V
cf1c4240c2 wayland: Support disabled key repeat
Noticed by running in bare KWin (windowed mode, no other plasma stuff installed)
and getting the "attempt to divide by zero" panic.
2021-10-26 08:23:43 -07:00
Greg V
c6062d9d22 wayland: Actually properly fix HiDPI initialization
The issue was that surface vs pixel conversions used dpi which wasn't updated yet.
2021-10-23 22:06:04 -07:00
Greg V
a1209096f6 wayland: do not skip reshaping the title on DPI scale change
Otherwise HiDPI screens start out with a too-small title text until the text changes once
2021-10-23 22:06:04 -07:00
Greg V
57a2c660bc wayland: do not reshape_title if it won't be rendered
It's a waste of CPU time
2021-10-23 22:06:04 -07:00
Greg V
a90e6dde75 wayland: frame: fix window title being too high on HiDPI screens 2021-10-23 22:06:04 -07:00
Greg V
6fbb8802c0 wayland: do not spam the compositor with title "changes" that don't change
In the worst case this can cause badly implemented desktop components like panels
to constantly rerender and waste 100% CPU (that's how I found a bug in mine :D)
when anything is constantly updating in the terminal (like viewing a log stream).
2021-10-23 22:06:04 -07:00
Wez Furlong
8c613d8588 wayland: partially respect window_decorations
When using client-side decorations, we can now skip rendering
the header/title bar.

If you've set NONE decorations, then wezterm will configure
the window that way, but that is only respected when the window
is created, as weston crashed when I tried to change this in
a window config reload event.

The wayland frame now also observes config change events,
so frame color adjustments should now take effect without
restarting.

refs: #1077
2021-10-09 17:34:26 -07:00
Wez Furlong
70ab5e7712 implement beeps for Windows
refs: #3
2021-09-26 13:50:57 -07:00
Wez Furlong
aefbab5a9d enable audible bell for X11
refs: #3
2021-09-26 13:36:43 -07:00
Wez Furlong
72cb110b65 add audible_bell config option
This allows using the system beep sound, currently only on macos.

refs: #3
2021-09-26 12:55:19 -07:00
Greg V
275dee4aa3 window: implement increment step resize on Wayland 2021-09-21 08:19:56 -07:00
Greg V
c5da219847 window: do not lose maximized/fullscreen -> default transitions on Wayland
Changing surface configuration flags *to* default would never be applied.
This was uncovered when implementing increment step resize: it would stop
working after *one* maximization.
2021-09-21 08:19:46 -07:00
Wez Furlong
8f0ab02b09 wayland: keymap File no longer needs to be mut 2021-09-19 18:27:57 -07:00
Wez Furlong
5657141dae wayland: Expand use clause 2021-09-19 15:59:29 -07:00
Greg V
b94e78c8ec window: read the xdg keymap fd from 0 on Wayland (fixes #1144)
The wl_keyboard definition does not define that the incoming fd is always at seek position 0.
In fact, the spec says the fd "can be memory-mapped" and that's it.
And e.g. smithay client-toolkit uses mmap, but we don't :/

Use pread() to read from zero.
2021-09-19 15:59:29 -07:00