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

566 Commits

Author SHA1 Message Date
Wez Furlong
cac02b3bbb Windows: fix enabling dark mode
This got broken by a recentish windows update.
2020-10-17 19:48:43 -07:00
Wez Furlong
b7e303f39c Windows: prefer to use Direct3D11 via ANGLE
This is similar in spirit to the work in 4d71a7913a
but for Windows.

This commit adds ANGLE binaries built from
07ea804e62
to the repo.  The build and packaging will copy those into the same
directory as wezterm.exe so that they can be resolved at runtime.

By default, `prefer_egl = true`, which will cause the window
crate to first try to load an EGL implementation.  If that fails,
or if `prefer_egl = false`, then the window crate will perform
the usual WGL initialization.

The practical effect of this change is that Direct3D11 is used for the
underlying render, which avoids problematic OpenGL drivers and means
that the process can survive graphics drivers being updated.

It may also increase the chances that the GPU will really be used
in an RDP session rather than the pessimised use of the software
renderer.

The one downside that I've noticed is that the resize behavior feels a
little janky in comparison to WGL (frames can render with mismatched
surface/window sizes which makes the window contents feel like they're
zooming/rippling slightly as the window is live resized). I think this
is specific to the ANGLE D3D implementation as EGL on other platforms
feels more solid.

I'm a little on the fence about making this the default; I think
it makes sense to prefer something that won't quit unexpectedly
while a software update is in progress, so that's a strong plus
in favor of EGL as the default, but I'm not sure how much the
resize wobble is going to set people off.

If you prefer WGL and are fine with the risk of a drive update
killing wezterm, then you can set this in your config:

```lua
return {
  prefer_egl = false,
}
```

refs: https://github.com/wez/wezterm/issues/265
closes: https://github.com/wez/wezterm/issues/156
2020-10-17 19:08:16 -07:00
Wez Furlong
f6afec27f5 windows: lowercase the raw key
6c5a996423 was almost great...
the problem is that CTRL-W for example was generating a raw
uppercase W instead of a lowercase W which meant that CTRL-W
for split navigation in vim would trigger the close pane
key assignment.
2020-10-17 14:02:06 -07:00
Wez Furlong
6c5a996423 windows: set KeyEvent::raw_key in key processing
I noticed that the built-in CTRL-SHIFT-1 assignment had
stopped working because that key press was being recognized
as CTRL-SHIFT-! with the recent changes in handling keyboard
input.

This commit sets the raw key to the position-based fallback
that we'd use if ToUnicode didn't return the correct mapping.

This is sufficient for this sort of un-modified key assignment
because the key is based on the virtual key code and is ignorant
of how the keyboard layout might compose those keys with SHIFT;
that is exactly what we want in this situation.
2020-10-17 10:25:55 -07:00
Wez Furlong
4d71a7913a macOS: bundle and use MetalANGLE to enable Metal rendering
This commit adjusts the window layer to have it try to load EGL
implementations on macOS.  This is important as the system
provided OpenGL implementation is deprecated and I wanted to
have a path forward for when it is finally removed.

If EGL fails to initialize, we fall back to the CGL/OpenGL
implementation that we used previously.

I've included binaries built for 64-bit intel from the MetalANGLE
project; here's how I built them:

```
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --depth 1
git clone https://github.com/kakashidinho/metalangle --depth 1
cd metalangle
PATH=$PWD/../depot_tools:$PATH python scripts/bootstrap.py
PATH=$PWD/../depot_tools:$PATH gclient sync
PATH=$PWD/../depot_tools:$PATH gn --args="is_debug=false angle_enable_metal=true angle_enable_vulkan=false angle_enable_gl=false angle_build_all=false" gen out/Release
PATH=$PWD/../depot_tools:$PATH autoninja -C out/Release
```

Those steps are a little too long to want to put them directly
into the wezterm CI.

It is important for metalangle to be >= 8230df39a5
in order for scaling to be handled correctly when dragging windows
between monitors.

refs: https://github.com/kakashidinho/metalangle/issues/34
2020-10-17 09:34:01 -07:00
Wez Furlong
13cd24d9b5 Windows: improve ALT + dead key handling, part 2
This changes the ALT/dead key behavior a little bit more,
and in a way that is likely more useful to terminal users.

The default behavior is that system dead key processing is enabled.
For example, with DEU keyboard layout activated:

* `^` `<SPACE>` results in a single `^`
* `^` `e` result in those two characters combining into an e with a
  diacritic.

If the config sets `use_dead_keys = false` then the behavior changes;
wezterm probes the active keymap to determine which keys are marked
as dead keys and computes their single character expansion.  When
the dead key is pressed then that expansion is substituted instead.
So `^` is simply `^`.

In order to pull this off, the window layer needs to selectively
call `TranslateMessage` for the system dead key expansion case
instead of unconditionally in the global message loop.

As a result of *that*, it means that we don't perform the default ALT
key translation for every key press any more.  I looked to see how old
friend putty handles this and found that it only allows default system
processing for ALT-space and ALT-F4.  I was resistent to selectively
processing system shortcuts because the full set are effectively
unknowable to an application and I didn't want to try to replicate
a wide selection of varying keypresses.  I'm fine to only allow
these two, so this commit does that, and reverts the portion of
the prior commit that prevented passing general ALT key combinations
through.

refs: #275
refs: #296
2020-10-15 17:06:09 -07:00
Wez Furlong
5088c62954 Windows: improve ALT and dead key handling
For some definition of improve, at least.

On Windows, ALT is basically reserved by the Window management
layer for functions such as ALT-space, ALT-F4 and so on.
Windows doesn't provide a method by which an application can
test whether a given key would be processed by the default
window procedure so we're in a bit of a bind in terms of
allowing ALT+a keypress to do something meaningful in the
terminal.

What I've settled on for now is:

On Windows only, if ALT is pressed, allow matching key assignments that
include ALT to be matched.  If there are no key assignments, then DON'T
pass the key press to the active pane, and instead allow it to be passed
to DefWindowProc.  This allows ALT-space to be handled correctly,
provided the user hasn't defined an ALT-space key assignment of their
own.

This may have some unforeseen consequences.  For example, ALT-<number>
is a readline binding that repeats an argument a number of times.
This change "breaks" that, but the user can provide a key assignment
to `SendString` the equivalent sequence to restore that behavior.
I'm kindof hoping that no one notices, but I'm prepared to explicitly
add default key assignments for that.

The other aspect of this commit is that I now understand a bit better
what a dead key is and how they should be handled.  I've tested the
behavior of wezterm with these changes and the behavior is consistent
with a regular CMD window when I have the DEU keymap active.
Specifically, using the on-screen keyboard, if I click `^` then click
`e` wezterm will emit `ê`.  If I click `^` then `^` then wezterm emits
`^^`.

refs: #275
refs: #296
2020-10-14 20:02:23 -07:00
Wez Furlong
5f0c859caa windows: fix an issue processing ctrl+shift for non-alpha keys
This appears to be an unexpected consequence of 6708ea4b36
but thankfully that change allows de-coupling shift processing
from the ctrl processing in this block of code.

refs: #275
2020-10-14 18:12:03 -07:00
Wez Furlong
9e46ac83be Windows: force Mesa/Software mode when started in an RDP session
refs: #265
2020-10-14 09:21:30 -07:00
Wez Furlong
05b02e178b window: fix Hide action on Windows
This was hiding the window completely with no way to show it again(!).
Change it instead to minimize, which was the intent.

refs: #296
2020-10-14 08:42:55 -07:00
Wez Furlong
8fcad1c1ee egl: improve trace logging of successful choice
refs: #272
2020-10-13 19:45:43 -07:00
Wez Furlong
baebc81432 egl: try all configs one by one in case first choice fails
It's not clear why the first choice isn't always the right choice
for some users.

This commit changes the logic to try all potential configs,
one after the other, until we find one that sticks.

I don't know if this will work in practice: I suspect that
trying to configure one of them may prevent later configs from
being used.

But maybe it will, and it may reveal more information about
what the real cause of the problem is.

refs: #272
2020-10-13 19:22:37 -07:00
Wez Furlong
0a39328e9d macos: adjust trackpad scroll sensitivity
This is imperfect in that it may feel slightly off for very large
or very small font sizes, but it feels more similar to the scroll
speed in eg: iTerm2 with these changes.

refs: #206
2020-10-12 19:24:23 -07:00
Wez Furlong
ce44ec2e70 macos: improve positioning for new windows
We used to always create them in the center of the screen,
but now subsequently created windows are offset slightly.
2020-10-12 17:54:44 -07:00
Wez Furlong
c8d59dffb6 macos: fix an issue where new windows created cocoa tabs
To reproduce the problem, maximize wezterm, then press CMD-N.

This commit tells the window not to use cocoa native tabs and
instead really create a new window when we ask it to create
a new window.

closes: #254
2020-10-12 17:20:12 -07:00
Wez Furlong
da2bba866d window: macos: trigger resize event when screen resolution changes
The easiest repro for this is dragging a window between monitors.

refs: #161
2020-10-12 11:29:17 -07:00
Wez Furlong
5257e34e2c window: update to latest glium version 2020-10-11 17:07:47 -07:00
Wez Furlong
dedfc4513b wayland: clear modifiers when keyboard focus changes
refs: #222
2020-10-11 10:02:37 -07:00
Wez Furlong
807ed3ba1e wayland: fixup timing issue on startup
025732d00f introduced deferred
window creation; the creation would get scheduled into the
spawn queue and then get run again a few milliseconds later
on the main thread.

For reasons that I don't understand, returning to the scheduler
loop to flush or otherwise process messages causes a wayland
protocol error.

Adjusting the notify routine to dispatch immediately if we're
already on the mux thread seems to resolve this.

While looking at this, I cleaned up a destruction order issue
with the opengl state that was then causing a segfault on shutdown.

I also removed a bit of dead paint related code that doesn't
appear to be needed any more.

refs: #293
2020-10-10 16:09:04 -07:00
Wez Furlong
5fb1414b69 fix clipboard on x11
This was broken by the changes in
aad493ab2a.  The issue was that the
channel send didn't wakeup the receiver.  I'm not sure why, and I tried
a couple of different async channel implementation.

Doing the simplistic solution here works reliably.
2020-10-09 11:07:18 -07:00
Wez Furlong
f497391958 gah, cargo fmt 2020-10-05 11:57:27 -07:00
Wez Furlong
bf266a326d maybe fixup build for windows 2020-10-05 11:57:08 -07:00
Wez Furlong
5eb4d32004 upgrade misc deps, notably, async-task 2020-10-05 00:06:01 -07:00
Wez Furlong
f3bccc7d08 window: X/Wayland: Software frontend is now llvmpipe
refs: https://github.com/wez/wezterm/issues/265#issuecomment-701882933
2020-10-01 20:03:45 -07:00
Wez Furlong
e6a858664f windows: Software frontend is now mesa llvmpipe
This is a bit of a switch-up, see this comment for more background:
refs: https://github.com/wez/wezterm/issues/265#issuecomment-701882933

This commit:

* Adds a pre-compiled mesa3d opengl32.dll replacement
* The mesa dll is deployed to `<appdir>/mesa/opengl32.dll` which by
  default is ignored.
* When the frontend is set to `Software` then the `mesa` directory
  is added to the dll search path, causing the llvmpipe renderer
  to be enabled.
* The old software renderer implementation is available using the
  `OldSoftware` frontend name

I'm not a huge fan of the subdirectory for the opengl32.dll, but
I couldn't get it to work under a different dll name; the code
thought that everything was initialized, but the window just rendered
a white rectangle.
2020-10-01 18:31:57 -07:00
Wez Furlong
6069eabc9b window: speculatively try enabling mesa llvmpipe as egl fallback
If we've failed to initialize EGL, try setting `LIBGL_ALWAYS_SOFTWARE=true`
in the environment and make another pass at initialization in the hope
that it brings up something usable.

This commit only impacts linux systems at the time of writing.

I've made the line that logs the GL implementation information
have `error` level again, because it is more convenient for me
even if it isn't technically an error.

refs: https://github.com/wez/wezterm/issues/272
(but isn't the true fix; this is just trying to make the consequences
of that problem less.  I would like to get that fixed correctly)

refs: https://github.com/wez/wezterm/issues/265#issuecomment-701882933
(which discusses what I think the end state should be)
2020-09-30 22:41:02 -07:00
Wez Furlong
6708ea4b36 window: normalize SHIFT modifier state
When a keypress is ASCII uppercase and SHIFT is held, remove SHIFT
from the set of active modifiers.

refs: https://github.com/wez/wezterm/issues/157#issuecomment-699516096
2020-09-26 09:17:51 -07:00
Wez Furlong
70fc76a040 window: fix segv when using multiple egl windows with linux/X11
This could be reproduced via `wezterm connect localhost`.
This bug was surfaced after the last release added a Drop impl
to cleanup the display.

This commit tracks the display in the connection.

closes: https://github.com/wez/wezterm/issues/252
2020-08-16 10:43:14 -07:00
Wez Furlong
11b298d3ed window: add some more application keypad mappings
@petermblair: I didn't test this beyond it compiling because I don't
have any keyboards that have a keypad :-p
2020-08-12 22:53:53 -07:00
Wez Furlong
ea7d28e2f3 Add error reason to X11 connection error
refs: https://github.com/wez/wezterm/issues/249
2020-08-12 22:03:57 -07:00
Wez Furlong
96cdadca48 Terrible workaround for an opengl crash
This isn't a fix by any stretch of the imagination, but it stops
a crash.  Should be good enough until I get a chance to fix this
properly.

refs: https://github.com/wez/wezterm/issues/252
2020-08-12 21:49:01 -07:00
Wez Furlong
4605244af7 egl: prefer some amount of alpha when selecting a config
This fixes a sort of hilarious accidental window transparency for
me when running under XWayland.
2020-08-02 22:45:18 -07:00
Wez Furlong
dddf67e07a egl: add explicit drop impl for GlState
This tidies up the valgrind output some more, but seems to highlight
some leaks in the egl implementation around init/shutdown.

I still don't see a smoking gun for a memory leak that grows over time.

refs: https://github.com/wez/wezterm/issues/238
2020-07-13 09:36:37 -07:00
Wez Furlong
888cded0e3 x11: remove Rc cycle between XConnection, Window, bitmaps
refs: https://github.com/wez/wezterm/issues/238

It's not a smoking gun, but helps clean up the valgrind output
2020-07-13 09:00:00 -07:00
Wez Furlong
4cd4ee2eb5 egl: revise how we report egl init errors 2020-07-13 08:02:19 -07:00
Wez Furlong
30f0e5b2c1 egl: look for exactly 8bpc configurations
When running on a 30bpp display with 2 bit alpha, eglChooseConfig
will match and list the 10bpc configuration first, which don't match
the desired pixel format.

Filter the config list so that it only includes 8bpc configurations.

refs: https://github.com/wez/wezterm/issues/240
2020-07-11 13:29:05 -07:00
Wez Furlong
68a91835ee window: egl: speculatively relax min alpha size
In refs: https://github.com/wez/wezterm/issues/240 there are a number
of configurations that report 0 for the alpha size and where we are
unable to otherwise find a working config.

This is a speculative commit to releax the alpha channel size to
basically anything available and see if that helps.
2020-07-09 17:47:38 -07:00
Wez Furlong
1e50493b84 window: x11: fix minor leak of a display connection
These were two separate one-time losses.

refs: https://github.com/wez/wezterm/issues/238
2020-07-08 09:16:43 -07:00
Wez Furlong
95a52fb661 window: egl: log available, matching configurations
Hopefully this can shed some light on why we're not matching any configs
in refs: https://github.com/wez/wezterm/issues/240
2020-07-07 08:59:44 -07:00
Wez Furlong
793af71592 egl: relax context creation requirements
This commit refactors the wayland EGL init code to call into the
non-wayland init code which is more in the spirit of DRY.

It also highlights that we were requesting PBUFFER and PIXMAP capable
contexts in the non-wayland case.  Since we appear to survive without
those in the wayland renderer, presumably we can survive without them
in all cases.

This may help with activating opengl for this issue:
refs: https://github.com/wez/wezterm/issues/240
2020-07-06 07:49:02 -07:00
Wez Furlong
627a1c6c1b x11: improve support for non-24bpp displays
While looking into what it might take to support 10bpc (30bpp) displays
(https://github.com/wez/wezterm/issues/240) I was experimenting with
Xephyr at a reduced 16bpp depth and noticed that the server still
offered a 32bpp TrueColor depth option.

This commit adjusts the window/bitmap code to allow it to select depths
24bpp or 32bpp, preferring the largest depth.  we restrict ourselves to
24 and 32 bit selections for this, as those appear to be bit for bit
compatible for the r/g/b channels.  I suspect that 10bpc will require
some scaling somewhere.

This change allows running wezterm against the reduced depth Xephyr, but
since Xephyr doesn't support GL it runs with the software renderer; I
don't know quite how opengl is going to play with this.  I can confirm
that running wezterm on my native 24bpp display when it picks a 32bpp
visual does run with opengl enabled, so maybe this is good enough?
2020-07-05 11:10:18 -07:00
Wez Furlong
ab1e83c7eb window: fallback to basic opengl context if extensions fail
8f1f1a65ea added support for probing
for opengl extensions, and I thought that I had the fallback covered
but it turned out that we were only falling back if one of the major
extensions wasn't present.

This commit adds a fallback for the case where things look ok at
first glance, but where they fail at runtime for whatever reason.

refs: https://github.com/wez/wezterm/issues/235
2020-06-29 18:05:43 -07:00
Wez Furlong
8f1f1a65ea window: handle opengl context loss on windows.
With this commit, we now survive a reinstall or upgrade of the nvidia
drivers on my Windows sytem without crashing.

This commit allows notifying the application of the context loss
so the application can either try to reinit opengl or open a new
window as a replacement and init opengl there.

I've not had success at reinitializing opengl after a driver upgrade;
it seems to be persistently stuck in a state where it fails to allocate
a vertex buffer.

SO, the state we have now is that we try to reinit opengl on a new
window, and if that fails, leave it set to the software renderer.

This isn't a perfect UX, but it is better than terminating!

refs: https://github.com/wez/wezterm/issues/156
2020-06-16 21:17:48 -07:00
Wez Furlong
ff32dc727f window: allow opengl reinit on context loss on macos
Again, I haven't seen a case where this triggers, but this compiles
and works in the normal case.
2020-06-15 12:33:52 -07:00
Wez Furlong
6744a0235d window: fixup tests for opengl init changes 2020-06-15 12:33:30 -07:00
Wez Furlong
aa93008935 window: allow re-initializing opengl for X11 and Wayland
I don't have a great way to test this on those platforms,
so other than compiling and running and verifying that things
work normally, I'm not sure if this is sufficient!
2020-06-15 09:03:16 -07:00
Wez Furlong
500e404db4 window: move opengl post-init to a callback on the trait
This allows potentially automatically re-initializing the
state if the context is lost.
2020-06-14 21:47:40 -07:00
Wez Furlong
90fa968a34 window: glium and gl_generator version bump 2020-06-14 21:24:54 -07:00
Wez Furlong
2803e8fc58 wezterm: improve left vs right alt behavior on macos
This commit allows distinguishing between left and right alt
modifiers at the window layer.  So far only macos provides
this additional information.

Expand the logic that decides whether Alt should emit the
composed key or act as the raw key with the Alt modifier flag
set so that we can set that behavior separately for the left
and right modifiers on systems that support it, and use the
existing config for systems that don't support it.

The default settings for these flags is that Left Alt will
send the uncomposed key + Alt modifier while the Right Alt
will behave more like AltGr (which is typically on the RHS
of the keyboard) and send the composed key.

This gives more flexibility by default and hopefully matches
expectations a bit better.

refs: https://github.com/wez/wezterm/issues/216
2020-06-13 22:45:13 -07:00
Wez Furlong
e70a58e7f3 cargo update 2020-06-13 10:21:49 -07:00
Wez Furlong
9395fd3465 window: remove unused feature from cargo.toml 2020-06-12 18:14:15 -07:00
Wez Furlong
542fede5a5 window: update smithay-client-toolkit 2020-06-06 11:58:38 -07:00
Wez Furlong
9ff9bf15fd window: allow for stronger separation between raw and composed keys
The goal at the window layer is to preserve enough useful information
for other layers.  In this specific circumstance on macos we'd like
to be able know both that eg: ALT-1 was pressed and that ALT-1 composes
to a different unmodified sequence and then allow the user's key
binding assignment to potentially match on both.

We sort of allowed for this, but didn't separate out the modifier keys.
This commit adds a `raw_modifiers` concept to the underlying event
struct so that we can carry both the raw key and modifier information
as well as the composed key and modifier information.

In the scenario above, we want the raw key/modifier tuple to be ALT-1
but the composed key/modifier to be eg: unmodified `¡` in my english
keymap.

refs: https://github.com/wez/wezterm/issues/158
2020-05-28 19:35:50 -07:00
Wez Furlong
ed1450326d window: Windows: dos->unix line endings when fetching clipboard 2020-05-22 18:22:33 -07:00
Wez Furlong
a9d1429888 window: allow specifying the clipboard context when getting clipboard
refs: https://github.com/wez/wezterm/issues/183
2020-05-21 08:46:16 -07:00
Wez Furlong
7ddff705a4 window: Windows: improve AltGr handling
Adds some detection to see if the active keyboard layout has
AltGr, and if so, adjust our key mapping logic to accomodate it.

With this change, when using an ENG layout, I can use either left
or right alt-b/alt-f to move through words in wsl.  When I switch
to DEU my left alt is still alt and my right alt causes the
Windows On-Screen keyboard to act as though AltGr is pressed.

I can then use the On-Screen keyboard to press the `<` key which
is to the left of the `Z` key on a German layout and have it produce
the `|` character.

refs: https://github.com/wez/wezterm/issues/185
2020-05-20 20:35:04 -07:00
Wez Furlong
a92b33c727 Revert "window: default to reading the PRIMARY selection under X11"
This reverts commit 5ebdcc3642.

It turns out not to be desirable, so lets back it out and think up
a different way to satisfy this.
2020-05-16 15:55:20 -07:00
Wez Furlong
5ebdcc3642 window: default to reading the PRIMARY selection under X11
We switched to using clipboard because of problems under XWayland.
These days we have much better native Wayland support and folks
should use that.

Test plan:

In one window:

```
echo "clipboard" | xclip -i -selection clipboard; echo "primary" | xclip -i -selection primary;
```

then start `wezterm` and press shfit-insert.

Prior to this change we'd always print `clipboard`.
After this change we'll print `primary`.

However, if you run:

```
WEZTERM_X11_PREFER_CLIPBOARD_OVER_PRIMARY=1 wezterm
```

then we'll use the old `clipboard` behavior.
2020-05-16 11:53:42 -07:00
Wez Furlong
538ce5e110 window: fix shift-tab processing on X11
This was being silently swallowed.  For some reason shift-tab generates
ISO Left Tab rather than regular Tab and we weren't mapping that.
2020-05-16 08:35:25 -07:00
Wez Furlong
d3cb27129c upgrade to latest smithay client toolkit
This version greatly improves the client side decoration handling
under Wayland and allows rendering the window title in the titlebar
(shocker!).
2020-05-03 10:31:30 -07:00
Wez Furlong
14c73f7122 window: linux: set window icon
Teach the window layer about window icons and implement the
plumbing for this on X11.

For Wayland there is no direct way to specify the icon; instead
the application ID is used to locate an appropriate .desktop filename.
We set the app id from the classname but that didn't match the installed
name for our desktop file which is namespaced under my domain, so change
the window class to match that and enable the window icon on Wayland.

refs: https://github.com/wez/wezterm/issues/172#issuecomment-619938047
2020-05-02 12:07:34 -07:00
Wez Furlong
8511bda6cf window: Adjust some debug logging
https://github.com/wez/wezterm/issues/172#issuecomment-619935565
interpreted these as errors but they're really just informational
messages.
2020-05-02 09:32:08 -07:00
Wez Furlong
73c0c02ffb window: x11: adjust log level for a debug print 2020-03-08 08:40:46 -07:00
Wez Furlong
8cd029ae63 wayland: remove a debug print 2020-02-26 23:21:59 -08:00
Wez Furlong
7e714a5ca1 x11: avoid changing the mouse cursor glyph on each move
@kalgynirae showed me weirdly laggy behavior when moving the mouse
in front of his x11 window.  My suspicion was that this is somehow
related to updating the mouse cursor glyph, and looking at this code
there were two things that might influence this:

* We weren't saving the newly applied cursor value, so we'd create
  a new cursor every time the mouse moved (doh!)
* We'd create a new cursor id each time it changed, and then destroy it
  (which isn't that bad, but if it contributes to lag, maybe it is?)

This commit addresses both of these by making a little cache map
from cursor type to cursor id.

I can't observe a difference on my system, so I wonder if this might
also be partially related to graphics drivers and hardware/software
cursors?
2020-02-21 09:10:13 -08:00
Wez Furlong
bc6cf6eed6 fix typo in some debug 2020-02-16 09:32:22 -08:00
Wez Furlong
754f8166b5 Add HideApplication and QuitApplication key assignments
```
[[keys]]
key = "q"
mods = "CMD"
action = "QuitApplication"
```

refs: https://github.com/wez/wezterm/issues/150
2020-02-14 08:49:15 -08:00
Wez Furlong
da6783bbd0 macos: implement Hide function
Hiding a window is implemented as miniaturizing the window, which
is typically shown with an animation of the window moving into the
dock.

This is not the same as the application-wide hide function in macOS;
that function hides the entire app with no animation.  We don't use
that here because our Hide function is defined as a window operation
and not an application operation.

refs: https://github.com/wez/wezterm/issues/150
2020-02-12 22:04:10 -08:00
Wez Furlong
02ace26e0a macos: Fix an issue with chorded keys in norwegian keymap
fixes: https://github.com/wez/wezterm/issues/151
2020-02-12 18:36:05 -08:00
Wez Furlong
c778307b0e macos: fix light background/border
The opengl based render first clears the window to the background
color and then renders the cells over the top.

on macOS I noticed a weird lighter strip to the bottom and right of
the window and ran it down to the initial clear: our colors are SRGB
rather than plain RGB and the discrepancy from rendering SRGB as RGB
results in the color being made a brighter shade.  This was less
noticeable for black backgrounds.
2020-01-26 19:04:34 -08:00
Wez Furlong
85c70aebb7 macos: improve support for dvorak
Remove a normalizing function that made assumptions based on the
keycaps that did not hold up when selecting Dvorak as an input
source.  For example "CTRL-C" where `C` is the key with the C keycap
would send `CTRL-C` even when Dvorak was selected; it should send CTRL-J
in that layout.

I think with the other normalization that happens in the termwindow
layer we don't need this function any more.
2020-01-26 18:13:16 -08:00
Wez Furlong
f3e42c3d2a point to local filedescriptor crate 2020-01-26 09:15:24 -08:00
Wez Furlong
e67022344f remove a debug print 2020-01-25 23:20:01 -08:00
Jun Wu
511fc55b10 Respect wheel scrolling speed settings on Windows
The default values are 3 lines. With this change, scrolling speed now seems
similar to other programs like cmd.exe. Before this change it feels too slow.
2020-01-20 15:18:33 -08:00
Jun Wu
ff6ff649af Make mouse wheel scroll smooth on Windows
I noticed my trackpoint or touchpad reports a lot of < 120 (WHEEL_DELTA) events.
They shouldn't be ignored.

Also https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel says:

> The wheel rotation will be a multiple of WHEEL_DELTA, which is set at 120.
> This is the threshold for action to be taken, and one such action (for
> example, scrolling one increment) should occur for each delta.
>
> The delta was set to 120 to allow Microsoft or other vendors to build
> finer-resolution wheels (a freely-rotating wheel with no notches) to send
> more messages per rotation, but with a smaller value in each message. To use
> this feature, you can either add the incoming delta values until WHEEL_DELTA
> is reached (so for a delta-rotation you get the same response), or scroll
> partial lines in response to the more frequent messages. You can also choose
> your scroll granularity and accumulate deltas until it is reached.
2020-01-20 15:17:44 -08:00
Wez Furlong
dc0573457c windows: fix compilation for 32-bit target
The CI shouldn't be trying to build this, but this is what was blocking
its builds on windows.
2020-01-17 10:12:25 -08:00
Wez Furlong
2eed9d67f4 fixup windows build 2020-01-17 09:23:30 -08:00
Wez Furlong
55e1cceb87 remove more Executors 2020-01-16 23:27:54 -08:00
Wez Furlong
75eb16bec4 move spawn_task into a new promise::spawn module 2020-01-16 03:50:48 -08:00
Wez Furlong
ac3ccab1c5 window: adopt async_task for spawn_task 2020-01-16 01:31:28 -08:00
Wez Furlong
256b4e6da8 fix pollable_channel to be non-blocking on Windows
Upgrade filedescriptor to 0.7 to use the portable helper for
setting non-blocking mode, and enable non-blocking mode on Windows.
2020-01-15 21:30:14 -08:00
Wez Furlong
ad2f724416 bump some versions 2020-01-09 22:39:34 -08:00
Wez Furlong
9670fc3fdf macos: fix minimum scroll wheel tick
macos generates fractional distance values for the mouse wheel,
with one tick starting at 0.1.  We were truncating this to a 0 row
move, which meant that you'd need to build up some acceleration to
move the rows when all you really wanted was a single tick.

This commit changes things so that we round up to at least 1.0 in this
situation.
2020-01-06 10:44:43 -08:00
Wez Furlong
180a991760 macos: add use_ime option to disable the IME
The IME stuff on macos tends to swallow repeats for some keys.
Ugh.  So this commit adds an option to disable the use of the IME.

Switching away from it effectively inverts the meanging of backspace
and delete (because our method is no longer called by the IME), so
we need to check for that and remap it.  Ugh.

Ugh.
2020-01-05 22:54:59 -08:00
Wez Furlong
59de97034a belt and suspenders to clip the copy region
a debug assertion triggers for me on macos because we were trying
to copy out of bounds.  This makes the copy routine safe again.
2020-01-05 17:58:14 -08:00
Wez Furlong
bda0a3b5fe windows: remove DoubleClick from input enums
double clicks weren't registering correctly with the new selection
logic.  Tell windows that we're doing all our own click counting
and simplify the logic.
2020-01-05 16:16:06 -08:00
Wez Furlong
048495b651 Fix x11 compilation due to bad semver bump in xcb-util
Force using xcb-util 0.2.1 precisely because 0.2.2 pulls in a
conflicting major version of xcb (0.8 -> 0.9).

It's a non-trivial upgrade: the types around xkb are different
and features need to be specified in the manifest to enable compilation
of the things that we depend upon.

In addition, xkbdcommon, on which we depend, requires xcb 0.8 and
results in pulling in two conflicting versions of the crates.

It's a bit of a painful situation and will require some effort to
figure out how to upgrade the xcb dependency, when we're ready for that.

refs: https://github.com/meh/rust-xcb-util/issues/12
2020-01-05 15:51:48 -08:00
Wez Furlong
400c8aa66d remove explicit dirty manipulation from Renderable
This commit leaves mux domains broken for the moment,
but also simplifes the implementation of the renderable interface.
2020-01-05 14:37:17 -08:00
Wez Furlong
d8701dc771 instrument executor spawn delay 2020-01-05 14:37:17 -08:00
Wez Furlong
e424a4ce6c x11: improve default wheel distance per tick
On x11 we'd get just a single line per scroll wheel tick.
Contrast with Wayland where we get multiple.

This config change makes us feel more snappy by default on X11.

I'd like to make this configurable using the live configuration
infra, but we don't currently have a way for this crate to see
that config, so this just changes the default to be "better".

refs: https://github.com/wez/wezterm/issues/92
2020-01-02 11:32:26 -08:00
Wez Furlong
b5e410e843 wayland: normalize clipboard to unix line endings on copy 2020-01-02 11:08:16 -08:00
Wez Furlong
0db15ecaf4 wayland: fix spurious resize event on focus change
The resize event would be fine except that it happens to trigger
the scroll position to reset to the bottom.
2020-01-02 11:03:12 -08:00
Wez Furlong
4b4683b1af fix focus messages on Windows
Use SETFOCUS/KILLFOCUS rather than ENABLE.

Closes: https://github.com/wez/wezterm/issues/93
2019-12-31 17:28:51 -08:00
Wez Furlong
b4b24aacca suppress warning 2019-12-30 11:11:41 -08:00
Wez Furlong
3f2e29b024 macos: fix keyboard repeat issue with backspace
wtf?  Not sure why this only impacted backspace
2019-12-30 11:09:19 -08:00
Wez Furlong
d58f1ff5dc Implement focus_change for macos
Refs: https://github.com/wez/wezterm/issues/93
2019-12-30 10:32:12 -08:00
Wez Furlong
a396a64550 Revert "wayland: implement focus_change callback"
This reverts commit bfa8d0c207,
which proved not to be needed because it was already covered
by the `KeyboardEvent::Enter` and `KeyboardEvent::Leave` handling.
2019-12-30 08:35:52 -08:00
Wez Furlong
bfa8d0c207 wayland: implement focus_change callback
Refs: https://github.com/wez/wezterm/issues/93
2019-12-29 17:17:46 -08:00
Jeremy Fitzhardinge
fce215f10f Enable focus for Windows.
Untested; passes a `cargo check`, but I'm not sure whether I've got the right
event for focus.
2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
71acd7d2a9 Add focus tracking for Wayland 2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
6558230c9f Implment focus_change for X11 2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
69ed1e7aed Add focus_change to WindowCallbacks 2019-12-29 16:58:15 -08:00
Wez Furlong
bd0859bef6 Make it possible to more easily tweak atlas padding 2019-12-28 11:55:42 -08:00
Wez Furlong
0e568ea161 wayland: reduce CPU utilization by correctly handling Refresh
On a Fedora 31 system running Wayland I noticed that wezterm and
the compositor were running pretty hot on their respective CPU
cores.

It turned out that we had a lot of
[Refresh](https://docs.rs/smithay-client-toolkit/0.6.4/smithay_client_toolkit/window/enum.Event.html#variant.Refresh)
events being generated and consumed. We were treating this as needing
a full paint so we'd be effectively continually running the opengl
paint cycle over and over.

The docs for that event say that it is intended to refresh the client
decorations so let's focus it towards that instead.  This does bring
the CPU usage back down to intended levels.

I believe this hot CPU usage to be compositor-dependent: this is the
first I've seen of it out of 4 different Wayland environments!
2019-12-27 08:48:00 -08:00
Wez Furlong
f493139305 clippy 2019-12-21 23:13:26 -08:00
Wez Furlong
3750337b30 window: wayland: improve handling of initial scale notification
1f81a064ed added support for noticing
that the dpi scale was not 1 on startup, but the timing of this
signal was different between the opengl and software renderers.

When using the software renderer, we'd end up computing a scaling
change with a pre-change pixel size but adjusted by a post-post
scaling factor, and that effectively caused the window to halve
its size on startup.

This commit improves things by also tracking the dpi in our locally
stored dimensions.
2019-12-21 22:35:23 -08:00
Wez Furlong
1f81a064ed wayland: avoid appearing blurry on startup on scaled displays
@sunshowers mentioned to me that the window appeared blurry on a hidpi
display on startup, and was fixed by changing focus in a tiling window
manager.

I could replicate this using weston with scaling set to 2; the issue was
that the initial scale factor change event wasn't fully propagated and
bubbled up as a resize event to the terminal layer.

This commit taps into the dpi change event and forces it to be
interpreted as a window configuration change, resulting in more crisp
text.
2019-12-19 23:05:17 -08:00
Wez Furlong
ff4f0add98 clippy 2019-12-15 08:50:12 -08:00
Wez Furlong
52dfce6c4e more mac + windows build tweaks 2019-12-14 22:38:24 -08:00
Wez Furlong
c6e4d31e47 maybe fix mac build for real 2019-12-14 22:20:50 -08:00
Wez Furlong
c87a1c3b03 maybe fixup compilation on macos and windows 2019-12-14 22:10:08 -08:00
Wez Furlong
9a2c7a1485 failure -> anyhow + thiserror 2019-12-14 21:43:05 -08:00
Wez Furlong
51c2646eee fonts: remove some unused code and fixup some warnings 2019-12-14 12:29:38 -08:00
Wez Furlong
a9b0197075 fonts: add an Allsorts shaper
Adds the ability to specify `--font-shaper Allsorts` and use that
for metrics and shaping.

It is sufficient to expand things like ligatures, but there's something
slightly off about how the metrics are computed and they differ slightly
from the freetype renderer, which leads to some artifacts when rendering
with opengl.

One of my tests is to `grep message src/main.rs` to pull out the line
that has a selection of emoji.  The heart emoji is missing from that
line currently.

Refs: https://github.com/wez/wezterm/issues/66
2019-12-14 08:46:06 -08:00
Jeremy Fitzhardinge
0558662813 Convert chit-chat into info
I assume it was being printed as error from a mass conversion to the logging framework.
2019-12-06 15:11:42 -08:00
Wez Furlong
d4ab211190 PendingMouse and CopyAndPaste now impl Debug 2019-12-04 19:45:13 -08:00
Wez Furlong
fc53b3969a rustfmt 2019-12-01 15:24:03 -08:00
Wez Furlong
b3f23bbf4a fixup some build and test warnings 2019-12-01 13:35:34 -08:00
Wez Furlong
0edceea972 fix compilation on macos 2019-12-01 10:16:14 -08:00
Wez Furlong
3059488753 window: wayland: round up for pixel->surface conversion 2019-12-01 09:32:35 -08:00
Wez Furlong
d53553491a window: wayland: tidy up some scaling code 2019-12-01 09:26:46 -08:00
Wez Furlong
f15f556054 wayland: add config option to avoid using it
Just in case!
2019-12-01 07:56:41 -08:00
Wez Furlong
70f09ef1b4 fix window size calculation when scaling changes
I noticed that we were relatively undersized for newly created
windows; there were two problems:

1. We weren't propagating the old rows and cols counts through
   to the speculative resize.
2. The speculative resize wasn't implemented on wayland, and
   needs a surprising amout of work to actually make the resize
   take effect.
2019-11-30 21:27:03 -08:00
Wez Furlong
1960655915 window: wayland: fix segfault on shutdown 2019-11-30 17:35:58 -08:00
Wez Furlong
c1fc335115 window: wayland: implement mouse cursor changing 2019-11-30 17:08:53 -08:00
Wez Furlong
fb54329f6b window: wayland: tidy up some debugging 2019-11-30 13:32:45 -08:00
Wez Furlong
18d9fabe9f window: wayland: don't lose keystrokes after clicking titlebar 2019-11-30 13:30:37 -08:00
Wez Furlong
317d3105bc window: wayland: fix routing of point and data events
Like the keyboard, the point and data related events are seat
centric and we need to manage our own routing to windows.
2019-11-30 13:05:19 -08:00
Wez Furlong
29a6c62b6c window: wayland: fix routing of keyboard events
The seat is a global thing, so we need to track the active
surface and route events to the appropriate window.
2019-11-30 10:00:34 -08:00
Wez Furlong
2d6d54bfab window: wayland: scale scroll values by dpi factor
Otherwise it feels eg: twice as hard to scroll when the factor is
set to 2x.
2019-11-30 07:52:00 -08:00
Wez Furlong
718b1fb535 window: wayland: make dpi values for sw and gl the same
Make the numbers consistent with each other
2019-11-30 07:29:24 -08:00
Wez Furlong
9d1b253379 window: wayland: more clearly distinguish inactive titlebar 2019-11-29 22:18:16 -08:00
Wez Furlong
1f11c82751 window: wayland: improve mouse event processing latency
Use a similar queueing technique as with the window size events
2019-11-29 22:03:36 -08:00
Wez Furlong
9085f118d5 window: tidy up some debug prints around selection 2019-11-29 19:16:37 -08:00
Wez Furlong
c3447930b7 window: wayland: queue Configure/Resize/Close events
This makes eg: window resizing a bit more smooth and responsive
2019-11-29 18:51:47 -08:00
Wez Furlong
2475969eca window: enable egl support for wayland 2019-11-29 18:05:09 -08:00
Wez Furlong
c03eda1279 window: fixup clipboard on macos 2019-11-29 12:47:56 -08:00
Wez Furlong
2b795aa08d window: fix build and clipboard on Windows 2019-11-29 12:32:30 -08:00
Wez Furlong
478d1f53bc window: bring back our own x11 clipboard handling
revives the guts of the x11 clipboard code from back in
d69c718a73
2019-11-29 12:18:52 -08:00
Wez Furlong
4ef20480c5 wayland: implement clipboard
This was honestly a PITA because of its complexity.  The `clipboard`
crate (now dropped as a dep) didn't support wayland, so I looked at
the `smithay-clipboard` crate, which caused all of my input to become
laggy just by enabling it--even without actually copying or pasting!

Both of those crates try to hide a number of details of working with
the clipboard from the embedding application, but that works against
our window crate implementation, so I decided to integrate it into
the window crate using Futures so that the underlying IPC timing and
potential for the peer to flake out are not completely hidden.

This first commit removes the SystemClipboard type from wezterm
and instead bridges the window crate clipboard to the term crate
Clipboard concept.

The clipboard must be associated with a window in order to function
at all on Wayland, to we place the get/set operations in WindowOps.

This commit effectively breaks the keyboard on the other window
environments; will fix those up in follow on commits.
2019-11-29 12:17:52 -08:00
Wez Furlong
c84a3f6c4c window: wayland: refresh decorations more proactively 2019-11-28 09:56:25 -08:00
Wez Furlong
00b9f188f3 window: improve avx bounds check 2019-11-28 09:00:13 -08:00
Wez Furlong
21284ce6d5 window: allow wayland and x11 to co-exist
This is a pretty gross and coarse "smash them together" commit.
There is some redundancy between the two connection and window
impls that I'd like to unify later, but this lets us build with
support for both systems for now.
2019-11-28 08:55:14 -08:00
Wez Furlong
edbdda697a window: wayland: clean up window lifecycle and shutdown 2019-11-28 00:46:42 -08:00
Wez Furlong
eb953a511c window: wayland: improve keyboard mapping 2019-11-28 00:22:56 -08:00
Wez Furlong
c63766ffe2 window: wayland: input mostly working, and hidpi output
Some key mappings are not done yet (arrows!) and need to make
opengl work, but this can run a basic wezterm with the software
renderer under wayland.
2019-11-27 22:00:44 -08:00
Wez Furlong
51ada155df window: initial wayland render support 2019-11-27 16:39:00 -08:00
Wez Furlong
517084ff2f clippy 2019-11-24 07:20:41 -08:00
Wez Furlong
10a0006eaf window: fix build for examples post mouse coords changes 2019-11-23 16:46:46 -08:00
Wez Furlong
bbe9c6e14b window: Windows: allow dragging by the tab bar 2019-11-23 16:43:25 -08:00
Wez Furlong
ef0f53ab7b window: Windows: fix mouse screen coordinates 2019-11-23 16:00:27 -08:00
Wez Furlong
a28e4c0e1e allow dragging by the tab bar on macOS 2019-11-23 14:05:39 -08:00
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