1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00
Commit Graph

594 Commits

Author SHA1 Message Date
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
Wez Furlong
8282faf31f window: allow specifying window resize increments on macos and x11
This commit introduces a mechanism for specifying resize increments
for a window, and then arranges for the termwindow to set those
to match the current font cell metrics.

This should help to avoid cases where there is excess padding pixels
resulting from the window being slightly larger than computed number
of cells and the font metrics.
2021-09-08 22:57:42 -07:00