1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 07:46:59 +03:00
Commit Graph

264 Commits

Author SHA1 Message Date
Wez Furlong
349a24ccd9 allow dragging by tab bar on linux
This works with X11 on fedora, but the window movement is ignored
by the xwayland machinery on chromeos.
2019-11-23 11:46:03 -08:00
Wez Furlong
01eaa7db08 window: adopt Point for mouse coordinates
and allow them to be signed again
2019-11-23 08:48:09 -08:00
Wez Furlong
14fbf43485 promise: more properly implement Future::poll
The future won't ever complete if you don't connect the waker
from the context!

Prove this out by making the windowops functions async and
verifying them in the async example
2019-11-23 08:16:12 -08:00
Wez Furlong
152874dd23 window: fixup the async example for stable async 2019-11-23 08:16:12 -08:00
Wez Furlong
4e1cfe01a8 linux: fix potentially busy loop
I introduced this issue with the recent rate limiting changes.  If we
generated sufficient events to fill the pipe buffer and trigger an
EAGAIN on the write side of the pipe, we'd end up in a state where epoll
would continually wake us up to deal with it, but because we gated
reading from the pipe on having entries in the queue we could decide
that there was nothing to do and leave the pipe unread.

This commit adjusts things so that we always try to read some data from
it.

This is OK because we're using the pipe to knock the main thread out of
a sleep rather than as the definitive count of events.
2019-11-22 14:06:17 -08:00
Wez Furlong
95900dc0a5 add some debug to SpawnQueue::has_any_queued
I'm seeing occasional 100% cpu usage on my linux system and I'm
not sure if its just because I'm running a stale binary.
I added this (commented out in this commit, but live on my local
system) debug print to help understand it.
2019-11-22 07:08:22 -08:00
Wez Furlong
a5ece82d69 fix compilation on macos
refs: https://github.com/wez/wezterm/issues/65
2019-11-21 18:31:02 -08:00
Wez Furlong
6787512d62 avoid busy looping over the spawn queue
Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 18:20:59 -08:00
Wez Furlong
06da330087 add low pri spawn queue
Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 18:20:17 -08:00
Wez Furlong
b3032f8a5a window: macos: yes starvation fix
Similar to b83a63126c, this helps
to avoid starving the gui events.

Refs: Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 17:34:01 -08:00
Wez Furlong
b83a63126c fix a starvation issue on linux/x11 systems
The `SpawnQueue::run_impl` would loop until it had exhausted
all queued items.  This prevents returning to the main loop
and resulted in the UI hanging while eg: `yes` was running,
and could also block accepting keyboard input, which is
pretty bad.

In addition, the queue implementation could fill up a pipe
and block the write side while it held a lock, which in
turn would prevent the read side from making room for the
write to succeed!

This commit changes the behavior on linux to change the wakeup
behavior of the queue from having a 1:1 relationship between
enqueue:wakeup to n:m where n and m are both >= 1.  This is
sufficient to wake a sleeping gui thread.  The gui thread
can then pop and process a single item at a time, interleaved
with dispatching the gui events.

The result is a bit more responsive, however, there is no
backpressure from the gui to the read side, so if the read
side is eating 2MB/s of data and the GUI side is processing
less than this, then an interrupt signal may still take a
few seconds to take effect.

I have mixed feelings about adding backpressure, because
I'm not sure that it is worth actually rendering all of
the parsed output text when there is a lot of it.

I need to follow up and verify these changes on macOS
and Windows too.

Refs: https://github.com/wez/wezterm/issues/65
2019-11-21 16:53:01 -08:00
Wez Furlong
6289c08a4e Adopt CSI u modifier encoding for keypresses
See http://www.leonerd.org.uk/hacks/fixterms/ for the specification.

Refs: https://github.com/wez/wezterm/issues/63
2019-11-16 13:38:03 -08:00
Wez Furlong
58d4a0a020 remove local workaround for core-foundation UB issue
My fixes landed upstream in 0a3ac83c1b
and are released already to crates.io
2019-11-13 00:05:55 -08:00
Wez Furlong
3ec3caf8f4 fix type in callback definition 2019-11-11 20:23:38 -08:00
Wez Furlong
398f333c32 macos: workaround UB and undefined instruction issue
The compiler emitted `ud2` right around this code, effectively
breaking wezterm on startup.

In talking this through with @dtolnay, the definition of the
structs in the core_foundation crate makes it undefined behavior
to pass a null pointer to its fields, despite that being a valid
and documented way to use the struct.

This commit works around this by defining our own local versions
of the types and functions with the safe signature.

I'll follow up with the owners of the core_foundation crate
to submit an equivalent patch upstream.
2019-11-11 19:10:20 -08:00
Wez Furlong
86ec66bb6c macos: transmute -> MaybeUninit 2019-11-08 20:35:23 -08:00
Wez Furlong
ea75474650 macos: place windows in the center of the screen
previously we'd place relative to the top left of the screen,
but that looks ridiculous on a 49" ultrawide monitor.
2019-11-08 20:24:26 -08:00
Wez Furlong
fda9671197 rustfmt 1.39 2019-11-08 18:51:37 -08:00
Wez Furlong
7afd77976a macos: when scheduling timer, schedule first call for later
we were running it immediately which is too soon: the empty
mux check would fire before some of the scheduled jobs would
have run and registered tabs/windows.
2019-11-08 18:50:12 -08:00
Wez Furlong
3af9a6e626 macos: allow reporting Alt-Backspace
The IME was mapping this to Delete (equivalent to Fn-Delete).
Special casing this allows Alt-Backspace to delete a word in
the shell.
2019-11-06 00:51:12 -08:00
Wez Furlong
b651d8bd61 macos: add missing deleteForward: action
on mac the `Delete` key is really `Backspace` and should generate the
`BS` sequence.

`Fn-Delete` is equivalent to the `Delete` key on other keyboards and
should generate the `DEL` sequence.

BS maps to deleteBackward
DEL maps to deleteForward

heads up to @fanzeyi: this partially reverses 8c26b77057
2019-11-06 00:34:31 -08:00
Wez Furlong
fea35978c4 macos: add un-shifted keycode for raw_key
The NSEvent::charactersIgnoringModifiers method ignores modifiers
except for shift, which is unfortunate because it produces eg: `!`
instead of `1`.

This commit adds a mapping from the underlying `keyCode` to the
corresponding letter position.
2019-11-06 00:18:55 -08:00
Wez Furlong
eb1bc7f736 allow binding opt + key based on pre-composed key presses
This diff adds some plumbing to track the `raw_key` in the KeyEvent;
this is the key prior to composing or eg: mapping dead keys.

With that field in place, we can teach the termwindow layer to attempt
looking up that key mapping from the user defined key bindings.

If we get a match then we can stop further key processing.
2019-11-05 21:32:23 -08:00
Wez Furlong
8c26b77057 macos: fixup IME generated enter and backspace sequences
Rather than \n and bs these need to be \r and del respectively otherwise
we can end up triggering the wrong ctrl based key mappings in a remote
tmux session.
2019-11-04 18:54:41 -08:00
Wez Furlong
44d1b031e2 windows: fix ambiguous module import for tests 2019-11-04 09:40:27 -08:00
Wez Furlong
c8f34aa81b windows: use application icon in window title bar 2019-11-04 08:09:52 -08:00
Wez Furlong
fdacb4b7bc windows: set the ime position to the cursor position
leveraging the plumbing from the prior commit, this sets the
IME window to the current terminal cursor position.
2019-11-04 00:19:53 -08:00
Wez Furlong
cb5e351187 macos: try to set the IME cursor position a bit better
Use the current terminal cursor position as the basis for the position
of the IME.
2019-11-04 00:11:27 -08:00
Wez Furlong
e3f6375551 fix brightness/color of emoji in the opengl renderer 2019-11-03 22:01:35 -08:00
Wez Furlong
405cd3be36 fix key repeat with IME 2019-11-03 22:01:35 -08:00
Wez Furlong
40386b964c only print unhandled IME commands 2019-11-03 22:01:35 -08:00
Wez Furlong
ea25055d42 add a couple of missing IME operations -> KeyCode 2019-11-03 22:01:35 -08:00
Wez Furlong
8d32bbf49e remove some key debug prints on macos 2019-11-03 22:01:35 -08:00
Wez Furlong
c99e2989ef Fix ctrl-J processing
The front-end was treating both \r and \n as Enter and passing
that through to the terminal.

To verify behavior, pay attention to your termios configuration:

```
$ stty -icrnl
$ od -c
<CTRL-J><CTRL-D>
0000000   \n
0000001
$ od -c
<CTRL-M><CTRL-D><Enter>
0000000   \r  \n
0000002
```

Closes https://github.com/wez/wezterm/issues/56
2019-11-03 22:01:35 -08:00
Wez Furlong
bb637e9884 improve coverage of macos function key -> KeyCode 2019-11-03 22:01:35 -08:00
Wez Furlong
61f4a8d32a Add basic support for IME on macOS
Similar to the windows IME support, the placement needs refinement, but
this is sufficient for pinyin input and insertion of emoji via the emoji
palette.
2019-11-03 22:01:35 -08:00
Wez Furlong
81ec2a8a26 find a better way to decide that the IME is active on windows
wparam is set to VK_PROCESSKEY so gate on that; this helps to prevent
emitting the initial character of a composition sequence to the
terminal.
2019-11-02 18:08:18 -07:00
Wez Furlong
f88fed9dfb don't swallow things like ctrl+ 2019-11-02 13:42:10 -07:00
Wez Furlong
da58b36881 Improve? IME on Windows
This isn't perfect, but is sufficient to allow using the IME to enter
eg: the heart emoji with cmd.exe.

We have some issues locating and rendering chinese characters that
make it difficult to prove/disprove that the IME is working 100%
because we just can't see the glyphs.

In addition, there appears to be something a bit wonky with conpty and
emoji.  If we use eg: `wezterm ssh HOST` to log in to a remote system,
and use the IME to pick eg: the pig face emoji, this renders correctly.
In that scenario we don't use conpty at all.

The IME window is always placed in the top left corner of the window
at the moment, which isn't great, but is better than the system default
which is outside of the window.  I need to introduce a way to set the
IME position in the window layer so that the front end gui can set it
to the current cursor position.
2019-11-02 12:39:05 -07:00
Wez Furlong
30c6ac7831 fix formatting 2019-10-28 07:37:10 -07:00
Wez Furlong
e8dbf18bb6 avoid ambiguous resolution in cargo test --all 2019-10-28 00:18:46 -07:00
Wez Furlong
d80169ceff Avoid accidental application mode delete output in key processing
I thought that I'd broken something with the DEL processing in vim with
the new frontend but it turned out that the other frontend was emitting
BS always and that I'd actuall unbroken passing DEL through and that
other layers were translating DEL into an application cursor mode output
for DEL that emits a totally different sequence.

This diff preserves DEL and disables that other sequence.

Will follow up with some explicit configuration to control this
behavior, but in the short term, the default behavior should be much
closer to what people actually want and expect!

refs: https://github.com/wez/wezterm/issues/52
2019-10-27 23:59:15 -07:00
Wez Furlong
66f5f6842d implement window size changing when the font scaling is changed on windows 2019-10-27 18:13:02 -07:00
Wez Furlong
c5d9766d50 x11: implement window resizing when font scaling changes 2019-10-27 17:58:37 -07:00
Wez Furlong
4e01dec636 font scaling now also resizes the window for opengl+software frontend 2019-10-27 17:48:02 -07:00
Wez Furlong
fd8738ea0e window: macos: rewrite Del to Backspace
this is more appropriate for vim
2019-10-27 16:33:48 -07:00
Wez Furlong
4116d7d523 remove byte-swapping workaround for opengl
We handle this with a temporary buffer for the upload, which is
a little gross but avoids leaking that implementation aspect
out to the rest of the code.
2019-10-27 10:07:14 -07:00
Wez Furlong
3a7f4cdff2 explicitly select a 24-bit visual on x11 2019-10-27 09:07:52 -07:00
Wez Furlong
04d6fed848 fixup tests for recent api changes 2019-10-27 09:04:42 -07:00
Wez Furlong
d97a84f984 render iterm2 image protocol in the software renderer
This is still a bit rough because the terminal parser doesn't
understand the pixel sizes, so it relies on the hard coded
cell dimensions being accurate.
2019-10-26 23:30:39 -07:00
Wez Furlong
71b4f52e5e clippy 2019-10-26 13:22:16 -07:00
Wez Furlong
f2fce18586 window: use wgl for opengl on windows 2019-10-24 19:12:18 -07:00
Wez Furlong
5135c724e6 window: fixup windows build for egl changes 2019-10-24 17:48:49 -07:00
Wez Furlong
7c2afce851 implement EGL based render for termwindow/opengl mode on linux 2019-10-24 17:43:37 -07:00
Wez Furlong
0e95f00a52 window: remove debug print on x11 2019-10-24 16:03:32 -07:00
Wez Furlong
6a96b7ddea window: take a stabe at EGL for linux/windows
This doesn't initialize it at all properly yet, but is groundwork
for completing that work in a later commit
2019-10-24 15:54:41 -07:00
Wez Furlong
f57b5deb80 allow compiling on win and linux 2019-10-24 10:37:40 -07:00
Wez Furlong
c6ce005b2a make new opengl frontend basically work on macos
It doesn't yet handle underlines or strikethrough.
Notably, live resizing now works, which is nice!
2019-10-24 08:27:11 -07:00
Wez Furlong
41e392fc79 we can now init opengl but not render it 2019-10-10 08:15:00 -07:00
Wez Furlong
999e651b17 window: impl Texture2d for SrgbTexture2d 2019-10-07 08:34:54 -07:00
Wez Furlong
2a19850350 add opengl frontend that sits on top of the window code
This uses the same plumbing as the software frontend, but tries
to enable opengl.

None of the opengl rendering is plumbed through here yet, so this
is currently functionally identical to the software renderer.
2019-10-07 07:51:49 -07:00
Wez Furlong
378e7b326f only use simd if the region is wide enough
Refs: https://github.com/wez/wezterm/issues/40
2019-10-07 07:41:11 -07:00
Wez Furlong
89a0046f5a window: A basic opengl capability 2019-10-07 07:17:57 -07:00
Wez Furlong
85311373a5 clippy 2019-10-01 22:20:52 -07:00
Wez Furlong
29095f8560 software: remove a little bit of overhead from draw_image 2019-09-30 08:36:23 -07:00
Wez Furlong
b2212c3105 software: improve alpha blending for draw_line 2019-09-30 08:17:47 -07:00
Wez Furlong
b5e07005b7 software: fix aligment check 2019-09-30 07:52:31 -07:00
Wez Furlong
b0efba9300 improve linear f32 -> srgb8 conversion
This uses a combination of lookup tables and simd to reduce the
cpu utilization by about ~15% compared to the prior brute force
implementation.
2019-09-30 00:45:35 -07:00
Wez Furlong
07fcc96f5a window: disable alignment based optimization for fill_pixel 2019-09-29 20:59:20 -07:00
Wez Furlong
1e25003cb6 speed up rgb conversion from u8 -> linear f32 2019-09-29 20:52:47 -07:00
Wez Furlong
c6fd88d8c5 add basic simd support for clearing rectangles 2019-09-29 20:24:26 -07:00
Wez Furlong
569408de66 software: handle OutOfTextureSpace condition 2019-09-29 12:42:51 -07:00
Wez Furlong
91e6bb4a5a rustfmt 2019-09-29 12:29:34 -07:00
Wez Furlong
99579bfca2 make it possible to build async example on stable rust
This should make the CI a bit happier
2019-09-28 22:00:07 -07:00
Wez Furlong
1c5f20f5e5 window: impl close for Windows 2019-09-28 21:16:08 -07:00
Wez Furlong
d44f380a82 window: impl close method on x11 2019-09-28 21:01:18 -07:00
Wez Furlong
950a7d2b22 cargo fix dyn 2019-09-28 20:29:48 -07:00
Wez Furlong
7e09492606 Add close operation on macos 2019-09-28 17:46:43 -07:00
Wez Furlong
dd1621e693 window: fixup mouse coords on macos hidpi display 2019-09-28 10:29:47 -07:00
Wez Furlong
389c477b16 software: ligatures now render, but scaled emoji need work 2019-09-28 10:06:47 -07:00
Wez Furlong
a9621170f7 window: on macos, query the dpi and improve resize/scaling handling 2019-09-28 09:01:14 -07:00
Wez Furlong
3a49b79ec6 basic timer list for x11 in software front end 2019-09-24 09:29:28 -07:00
Wez Furlong
67d6e7fd1a window: cache window bitmap between paint calls
Without this, apps that only render invalidated portions of the screen
will render blank areas for the rest of the screen!
2019-09-23 08:03:23 -07:00
Wez Furlong
b0dd3a3803 fixup basic example for Point changes 2019-09-23 08:01:27 -07:00
Wez Furlong
c1c61974f8 implement timers for windows 2019-09-23 07:36:59 -07:00
Wez Furlong
4a742ea56b (almost) fixup compilation for windows 2019-09-23 06:48:47 -07:00
Wez Furlong
8e38f34b6d fix a couple of warnings 2019-09-22 21:02:02 -07:00
Wez Furlong
ed90a1487d scroll wheel events on macos 2019-09-22 15:51:33 -07:00
Wez Furlong
ec280a54f8 incomplete but functional key input for software frontend 2019-09-22 10:25:31 -07:00
Wez Furlong
68f81e23f7 software render can now render basic glyphs 2019-09-22 08:12:52 -07:00
Wez Furlong
f17824994f window: add basic timer functionality
We need this to poll the model and invalidate the gui so that it
can repaint as the child process emits output
2019-09-21 22:16:27 -07:00
Wez Furlong
0d7d438270 separate Sprite and SpriteSlice impls 2019-09-21 14:25:12 -07:00
Wez Furlong
fb5cbb5827 fixup x11 build for euclid point/rect changes 2019-09-21 13:33:21 -07:00
Wez Furlong
709990b9e7 use euclid crate for point/rect 2019-09-21 13:05:50 -07:00
Wez Furlong
c7c25025ed upgrade euclid dep 2019-09-21 12:32:21 -07:00
Wez Furlong
3dce78bd9c copy and adapt our opengl texture atlas code for the window crate 2019-09-21 09:00:08 -07:00
Wez Furlong
1950843de4 these rect methods should have been public 2019-09-21 08:03:14 -07:00
Wez Furlong
4e62b59628 rediscover the Rect type for x11 and consolidate 2019-09-21 08:01:31 -07:00
Wez Furlong
050dde6b4f clean up draw_image api 2019-09-21 07:44:28 -07:00
Wez Furlong
896586809f add Rect::bottom_right 2019-09-21 07:31:44 -07:00
Wez Furlong
6d902d8a39 introduce a Rect type 2019-09-21 00:19:31 -07:00
Wez Furlong
1c8ba615f3 fix build on macos 2019-09-15 19:09:08 -07:00
Wez Furlong
ce102d36b3 improve conditional use statements 2019-09-15 19:09:08 -07:00
Wez Furlong
fa54f02b27 fixup macos compilation 2019-09-15 19:09:08 -07:00
Wez Furlong
96c9633539 on windows, the windows map Mutex -> RefCell 2019-09-15 19:09:08 -07:00
Wez Furlong
f793b36ff0 spawning async tasks now impl on all platforms 2019-09-15 19:09:08 -07:00
Wez Furlong
3d379791c8 refactor SpawnQueue on macos 2019-09-15 19:09:08 -07:00
Wez Furlong
6e8424a92d refactor SpawnQueue on windows and x11 2019-09-15 19:09:08 -07:00
Wez Furlong
7128e3e7cc compile on windows again 2019-09-15 19:09:08 -07:00
Wez Furlong
d4cafefb87 make the basic example build again on x11 2019-09-15 19:09:08 -07:00
Wez Furlong
cabb9d155c see if we can DRY around some cross platform stuff, baby step 2019-09-15 19:09:08 -07:00
Wez Furlong
9a2037e846 fix some warnings 2019-09-15 19:09:08 -07:00
Wez Furlong
bdc634276d plumbing for polling std::future::futures on macos 2019-09-15 19:09:08 -07:00
Wez Furlong
6d23be0164 use Image to generate underline glyphs 2019-09-15 19:09:08 -07:00
Wez Furlong
e98b29aec6 add apply function to safely access inner data 2019-09-15 19:09:08 -07:00
Wez Furlong
d69938701c macos: cache the bitmap buffer across draw_rect calls 2019-09-15 19:09:08 -07:00
Wez Furlong
a4405ba60d macos: plumb changing the cursor 2019-09-15 19:09:08 -07:00
Wez Furlong
5f547b6972 macos: allow changing window title 2019-09-15 19:09:08 -07:00
Wez Furlong
d8b143776d plumb WindowOps for macos 2019-09-15 19:09:08 -07:00
Wez Furlong
0f25545014 decode key inputs 2019-09-15 19:09:08 -07:00
Wez Furlong
5f7d2f5ccc basic plumbing for mouse input on macos 2019-09-15 19:09:08 -07:00
Wez Furlong
57992c0570 add resize handler for macos 2019-09-15 19:09:08 -07:00
Wez Furlong
8ae35f5b01 Arc -> Rc for macos 2019-09-15 19:09:08 -07:00
Wez Furlong
da90ad7ec6 fix byteorder for bitmaps on macos 2019-09-15 19:09:08 -07:00
Wez Furlong
0b7556893d bunch of plumbing to allow using new window layer as software rendered frontend 2019-09-15 19:09:08 -07:00
Wez Furlong
9e63038391 propagate errors from set_cursor 2019-09-15 19:09:08 -07:00
Wez Furlong
c54d3b55be prove that spawning additional windows works 2019-09-15 19:09:08 -07:00
Wez Furlong
dff8e1e652 introduce WindowContext for manipulating the window in a callback 2019-09-15 19:09:08 -07:00
Wez Furlong
e6265c93a4 add arbitrary line drawing with anti-aliasing 2019-09-15 19:09:08 -07:00
Wez Furlong
5d40733d8c implement basic rendering for macos 2019-09-15 19:09:08 -07:00
Wez Furlong
e371e0385d x11: mouse cursors 2019-09-15 19:09:08 -07:00
Wez Furlong
cc4a089c41 remove some debug prints 2019-09-15 19:09:08 -07:00
Wez Furlong
6902de9da4 mouse events for x11 2019-09-15 19:09:08 -07:00
Wez Furlong
f8f470ab1d add mouse event processing for windows 2019-09-15 19:09:08 -07:00
Wez Furlong
05a60e6e8b plumb keyboard events for x11 2019-09-15 19:09:08 -07:00
Wez Furlong
93f4008719 add keyboard support for windows 2019-09-15 19:09:08 -07:00
Wez Furlong
bed8664617 borrow input types from termwiz 2019-09-15 19:09:08 -07:00
Wez Furlong
7cd92a92c8 introduce Connection::executor() -> impl BasicExecutor
This can be called from any thread
2019-09-15 19:09:08 -07:00
Wez Furlong
cab062118b promise: split execute out to BasicExecutor
This makes it easier to implement just the scheduling portion
without imposing other restrictions on the executor type.
2019-09-15 19:09:08 -07:00
Wez Furlong
7761b76d3c almost impl Executor for x11 Connection 2019-09-15 19:09:08 -07:00
Wez Furlong
0ce4a0fb0d impl Executor for win32 Connection 2019-09-15 19:09:08 -07:00
Wez Furlong
37541eef96 fixup probing for SHM support 2019-09-15 19:09:08 -07:00
Wez Furlong
95cc66e9c0 x11: maintain the image buffer across paint calls 2019-09-15 19:09:08 -07:00
Wez Furlong
ff0d079737 use shm when available 2019-09-15 19:09:08 -07:00
Wez Furlong
3a2493dc9e fixup build on linux 2019-09-15 19:09:08 -07:00
Wez Furlong
b9b94aa516 add resize callback 2019-09-15 19:09:08 -07:00
Wez Furlong
56dc24a1ee hook up paint method for x11 2019-09-15 19:09:08 -07:00
Wez Furlong
1de4165152 x11: plumb destroy notification more correctly 2019-09-15 19:09:08 -07:00
Wez Furlong
ee203b0b76 improve lifecycle management on macos
I'm not totally convinced that the refcounting is right
because I've not seen `dealloc` get triggered, but the
important thing is that closing the window does cause the
rust level objects to be dropped.
2019-09-15 19:09:08 -07:00
Wez Furlong
645f4f6315 really basic macos window 2019-09-15 19:09:08 -07:00