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

797 Commits

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

refs: https://github.com/wez/wezterm/issues/1483
2022-01-01 22:43:12 -07:00
Wez Furlong
d714c5d5b6 window: track phys_code on macos
We don't do anything useful with it yet

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Use pread() to read from zero.
2021-09-19 15:59:29 -07:00
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
Greg V
94ede1e8f1 window: implement window movement by dragging on Wayland 2021-09-08 17:45:48 -07:00
Greg V
455ea89fa8 window: unbreak bypass_mouse_reporting_modifiers on Wayland (fixes #1122)
Modifier state was not saved to the `modifiers` field that's read when converting mouse events,
so these events always had no modifiers.
2021-09-08 09:27:23 -07:00
Greg V
5b85e80b75 window: fix synthesized configure event for Wayland DPI scale (fixes #1111) 2021-09-06 19:26:24 -07:00
Wez Furlong
91209af8da window: fix default dpi on X11 and Wayland systems
Similar to da455cafa1, the extra
connection layer wasn't forwarding the call to the actual impl.

closes #947
2021-09-06 10:01:16 -07:00
Wez Furlong
da455cafa1 window: plumb get_appearance on x11/wayland systems
Not sure what happened here: presumably a borked merge or something
similar, but this commit allows `window:get_appearance` to return
the actual appearance value on X11.

Even though this plumbs the call through to Wayland, Wayland doesn't
provide an equivalent concept so still always return Light, as is
mentioned on our docs.

closes: #1098
2021-09-02 09:08:21 -07:00
Wez Furlong
b53a6059de increase max fps to 60 by default, improve coalesce
* Trigger a paint immediately from invalidate if not throttled
* Otherwise defer the other events until we're about to sleep for xcb
  events, which should maximize the coalesce around resize/expose events

refs: #1051
2021-09-02 08:53:03 -07:00
Wez Furlong
367797c1ae x11: coalesce resize and repaint events
The thesis is that some WM's might send a whole bunch of events
that cause us to over draw/over resize.

I'm not convinced that this is a righteous change, but it can't
hurt to try.

refs: #1051
2021-09-02 08:53:03 -07:00
Ziyang Lin
df68147af5 (macOS) respect alt key configs for ime 2021-09-01 22:54:44 +08:00
Shizeeg Unadequatov
61c5063654 X11: Composite isn't required anymore
on X11 bits_per_value() reports 11 when Composite is disabled and 8 otherwize.
2021-08-27 07:49:17 -07:00
Wez Furlong
f09d747f14 window: use released xcb-imdkit crate
refs: #250
2021-08-23 09:09:45 -07:00
Wez Furlong
5629e0c1ca deps: tiny-skia -> 0.6 2021-08-23 07:48:13 -07:00
Wez Furlong
fc5ca5a297 don't vsync on x11, do our own throttling
Some users mentioned that there's a lag after selecting text
on X11.  Tracing through, I saw that the we invalidate the window
quite a lot when dragging the selection, and the buffer swap could
delay for several ms each time while waiting for the vsync.

Rather than blocking the GUI thread and making it bog down, this
commit adopts a technique similar to the recent Wayland frame sync
changes, except that we enforce a minimum of 33ms between frames
in our own scheduler to avoid blocking for several ms at a time.

This seems to do a decent job of balancing responsiveness during
selection with updating the display, and keeps the buffer swap
delay down to microseconds.

We may want to make this delay configurable.
2021-08-19 20:53:21 -07:00
HMH
6404099d25
IME support on X11 (#1043)
* WIP: IME support for X11

* Handle text generated by IME.

* Set IME position according to the cursor position.

* Improve IME position handling.

Geometry as well as window focus changes are now handled.

* Dispatch IME strings like it's done on windows.

* Make sure not to silently drop IME errors.

* Respect `use_ime` configuration.

* Add xcb-util as dependency.

* Only update IME position if necessary.

* Formatting.

* Update xcb-imdkit-rs.

* Set IME position under the start of the cursor.

This seems to be the way it is commonly done among gui frameworks.
(Tested with Firefox for GTK and Konsole for QT).

* Update xcb-imdkit-rs.

* Handle systems only providing libxcb-util0-dev.

* Add libxcb to freebsd dependencies.

Required by xcb-imdkit-rs.

* Update xcb-imdkit-rs.

* Try to use more recent gcc on centos7.

* More recent C++ compiler on centos7 as well.

* Also setup correct env on centos7 for tests.
2021-08-19 20:51:56 -07:00
Wez Furlong
571c137955 gui: gamma fixup
This makes the comparison in https://github.com/wez/wezterm/issues/544
work for me on mac, linux (x11, wayland) and also on Windows but
only using WGL.

It looks like we can use the proper colorspace on all targets
except for ANGLE EGL.  For whatever reason, the combination of
glium and ANGLE EGL on windows over-gamma corrects.

AFAICT, the framebuffer and perhaps the surfaces it creates
don't indicate srgb support, and whatever combination of status
they return tickles glium's srgb stuff the wrong way.

I think the "solution" is just to directly use WGL by default.

EGL was on by default because it tended to be more survivable
when graphics card drivers were updated, but the last couple
of times I updated mine it still killed wezterm anyway.

refs: #544
2021-08-19 09:17:09 -07:00
Wez Furlong
ab21910d80 deps: update bitflags -> 1.3 2021-08-15 18:21:17 -07:00
Wez Furlong
0866e5d213 fonts/shaping: respect the Presentation selection for a cluster
This commit annotates fonts with a boolean that indicates whether
we think it contains glyphs with emoji presentation, and then
passes the cluster.presentation field down to the shaper.

If the presentation doesn't match the current font in the fallback,
then it will be skipped until we exhaust its options.

`wezterm ls-fonts` also shows whether we think a font has emoji
presentation.

refs: #997
2021-08-11 09:11:59 -07:00
Wez Furlong
8d93222000 window: x11: assume default theme if no cursor theme specified
refs: #1007
2021-08-11 08:22:53 -07:00
Wez Furlong
ee71d478c4 window+gui: enable dual source blending
This replaces the slightly gnarly subpixel enabled blending in the
shader with Dual Source Blending, which is a technique where the
fragment shader can specify both the primary color (RGBA) as well
as an additional per-channel mask that can be used to alpha blend
with the destination.

This enables artifact-free alpha blending when used together
with a transparent window background.

refs: https://github.com/wez/wezterm/issues/932
2021-08-10 18:23:18 -07:00
Wez Furlong
2e158f58f3 x11: avoid make_current assertion for wezterm connect unix
The connection UI show/close could cause an assertion/bad alloc
error when it closes.
2021-08-08 12:27:16 -07:00
Wez Furlong
45576eeeab wayland: make use of the frame callback
This commit ties our invalidation requests together with the surface
frame callback request so that we can throttle our frame rate if
we're busy, but still remain largely idle if we're not changing
any content.

refs: https://github.com/wez/wezterm/issues/884
2021-08-07 09:30:36 -07:00
Wez Furlong
609f9358eb wayland: use non-blocking eglSwapInterval
https://emersion.fr/blog/2018/wayland-rendering-loop/ suggests that
it is best practice to do this so that the compositor doesn't
cause an application to block forever if the window is moved to
an off-screen state.

That article also suggests using the frame callback to schedule
paints; this commit has that code included, but I've left it
disabled because it causes us to repaint at the monitor refresh
rate which is often more frequently than we would anyway;
in our problem scenario we're painting once per second and we
just want to make sure that that doesn't block.

So hopefully this makes the sway/scratchpad experience better!

refs: https://github.com/wez/wezterm/issues/884
2021-08-07 08:31:15 -07:00
Wez Furlong
e9ad43765c fix build on macos 2021-08-06 21:44:45 -07:00
Wez Furlong
79165617b1 window: add WindowState concept
WindowState is a bitfield that can represent maximized, full screen
and hidden window states.

WindowState is passed along with resize events, improving on the
prior basic is_full_screen boolean by representing the other states.

Notably, WindowState::MAXIMIZED is used to represent a state where
the window's size is constrained by some window environment function;
it could be due to the window being maximized in either or both the
vertical or horizontal directions, or by the window being in a tiled
state on any edge.

When the window is MAXIMIZED, wezterm will behave as though
`adjust_window_size_when_changing_font_size = false` because it knows
that it cannot adjust the window size in that state.

This potentially helps with #695, depending on whether the window
manager propagates this state information to wezterm.  Gnome/mutter
does a good job at this with both X11 and Wayland, but I couldn't get
sway to report these states and I don't know of any other tiling wm
that I can easily install and use on fedora, so there's a question
mark around that.
2021-08-06 18:56:37 -07:00
Wez Furlong
86bf251f3f add some more metrics around get_lines_with_hyperlinks_applied + others 2021-08-01 14:50:50 -07:00
Wez Furlong
ecc63e2e5d wayland: improve mouse cursor resolution and diagnostics
Switch to using `xterm` rather than `text` for the name of the
xterm style I-beam mouse cursor, as that appears to be more
compatible across themes; the gnome theme aliases text -> xterm
via a symlink.

Improve error diagnostics in the case that no cursor is found.

refs: https://github.com/wez/wezterm/issues/532
2021-08-01 13:47:24 -07:00
Wez Furlong
267885ce0b workaround a guillotiere issue
We don't need to free any allocations, so we can use the simple
allocator instead and avoid the issue.

refs: https://github.com/nical/guillotiere/issues/25
2021-08-01 00:12:19 -07:00
Wez Furlong
c867b4e079 window: fix warning when buildings tests on !macos 2021-07-29 19:44:34 -07:00
Wez Furlong
b13ca6fac4 window: x11: no need to complain loudly if no xsettings 2021-07-24 08:34:36 -07:00
Wez Furlong
07dfccaddd window: x11: avoid extraneous title updates
Avoid setting the title again if it matches the last thing we set;
this in turn avoids receiving a property update from the window
manager to tell us that we set the title.

refs: #964 (but isn't the root cause)
2021-07-21 08:58:35 -07:00
Wez Furlong
5904140abf improve error handling around xsettings reading 2021-07-18 22:13:18 -07:00
Wez Furlong
a2e882a7cb deps: cargo update, and a couple of dependabot suggestions 2021-07-18 19:10:46 -07:00
Wez Furlong
f050659543 window: implement get_appearance and AppearanceChanged on Windows
refs: #806
2021-07-18 14:17:05 -07:00
Wez Furlong
a697b30223 window: add xsettings support on X11 systems
This allows reading xsettings which contain information about
both the active theme as well as the DPI.

refs: #947
2021-07-18 12:54:52 -07:00
Wez Furlong
1f5b900f3d plumb appearance change event -> reload on macos
This commit causes a window-config-reloaded event to trigger
when the appearance (dark/light mode) is changed on macos.

It also arranges to propagate the window level config to newly
spawned panes and tabs, created both via the gui and via the
CLI/mux interface.

refs: https://github.com/wez/wezterm/issues/894
refs: https://github.com/wez/wezterm/issues/806
2021-07-18 00:01:53 -07:00
Wez Furlong
daaa3299d6 window: introduce interface for determining if dark mode is active
This is a baby step: it introduces the Appearance concept
and provides an accessor at the Connection level.

Only macos implements this at this time, and nothing else
makes use of it.

refs: https://github.com/wez/wezterm/issues/894
refs: https://github.com/wez/wezterm/issues/806
2021-07-17 23:08:08 -07:00
Rashil Gandhi
1d800c956b Listen for settings change event 2021-07-17 11:26:16 -07:00
Rashil Gandhi
4ad9f10f9f Remove hardcoded logic for titlebar color 2021-07-17 11:26:16 -07:00
Wez Furlong
ce1a05d9bd window: add some trace logging
refs: #949
2021-07-17 08:37:04 -07:00
Wez Furlong
5c4fb92b87 fixup wgpu example 2021-07-11 12:46:23 -07:00
Wez Furlong
77c5acaaf5 fixup tests on macos 2021-07-10 19:01:20 -07:00
Wez Furlong
37ec16329e fixup tests + wayland bits 2021-07-10 18:07:16 -07:00
Wez Furlong
cc2b9507f8 fixup build on windows 2021-07-10 17:52:14 -07:00
Wez Furlong
6aa575d838 fixup build on macos 2021-07-10 17:42:05 -07:00
Wez Furlong
db6da81272 window: move away from async event queue
I added this originally thinking that it would make it easier to resolve
https://github.com/wez/wezterm/issues/695 and to integrate wgpu support,
but it's the cause of https://github.com/wez/wezterm/issues/922 so let's
take it out and more directly connect the window events to those in the
terminal.

This commit likely breaks mac and windows; pushing it so that I can
check it out and verify on those systems.
2021-07-10 17:30:19 -07:00
Wez Furlong
ad19b4f57b window: de-Future most of the WindowOps methods 2021-07-10 17:30:19 -07:00
Wez Furlong
cd1f7b1784 x/wayland: remove Mod3 -> SUPER mapping
I'm not sure where this came from in its originating commit
(05a60e6e8b), but it is inconsistent with
the reverse mapping function added in that same commit:
05a60e6e8b/window/src/os/x11/xkeysyms.rs (L3)

It is causing problems in https://github.com/wez/wezterm/issues/933
and is rarely used by default, so it seems safe to just remove
this mapping.
2021-07-10 08:04:28 -07:00
Wez Furlong
fc4c165ca3 window: update wgpu -> 0.9
This is still used only in an example
2021-07-09 20:37:34 -07:00
Wez Furlong
8ecfdb618f wayland: disambiguate Event type 2021-06-27 16:23:03 -07:00
Wez Furlong
46476f2eec wayland: remove unused code
This stuff was added because the underlying types lacked Debug
and Send. They've since added those impls and we don't need this
layer.
2021-06-27 16:01:26 -07:00
Wez Furlong
37a57e8a41 wayland: refine event loop 2021-06-27 15:13:41 -07:00
Wez Furlong
0a00ffe98b wayland: fix key repeat
The main culprit was the calloop feature that is used by default
in the underlying SCTK crate.

This commit:

* Routes keyboard processing via the same keyboard mapping code
  that we use for X11
* Implements key repeats directly, and with awareness of elapsed
  time in case the repeat rate is quicker than the event dispatching
  quantum
* Disables the calloop feature of SCTK and let us do our own polling
  of the wayland connection.

Critically, key repeat is sticky and unpredictable while calloop is
enabled.

closes: #669
2021-06-27 14:29:03 -07:00
Wez Furlong
c514254138 wayland: use proportional font for title bar
allow specifying the font in the config file
2021-06-27 13:04:20 -07:00
Wez Furlong
ca8209b230 wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color

```lua
return {
  window_frame = {
    inactive_titlebar_bg = "",
    active_titlebar_bg = "",
    inactive_titlebar_fg = "",
    active_titlebar_fg = "",
    inactive_titlebar_border_bottom = "",
    active_titlebar_border_bottom = "",
    button_fg = "",
    button_bg = "",
    button_hover_fg = "",
    button_hover_bg = "",
  }
}
```

refs: https://github.com/wez/wezterm/issues/761
2021-06-27 12:33:56 -07:00
Wez Furlong
7f04c4601a window: fixup tests for font config changes 2021-06-26 22:58:42 -07:00
Wez Furlong
282c148bf6 wayland: render title with our font layer when doing CSD
This isn't perfect by any means:

* Should allow configuring a sans-serif font
* Emoji need to be scaled

but it allows us to upgrade SCTK without loosing the titlebar
or any control over client side decorations.
2021-06-26 22:58:42 -07:00
Wez Furlong
4f9532f9d8 window: plumb font config to underlying window impl 2021-06-26 22:58:42 -07:00
Wez Furlong
e69869efa7 refactor deps so that window can depend on wezterm-font
I want to use this to render the font in the title bar
2021-06-26 22:58:42 -07:00
Wez Furlong
d04486f30a wayland: replace andrew with tiny_skia
This has the consequence of removing the title bar text when
client side decorations are in use.
2021-06-26 22:58:42 -07:00
Wez Furlong
d1177a29c2 wayland: update to SCTK 0.14 2021-06-26 22:58:42 -07:00
Wez Furlong
355b2f5b5a wayland: import ConceptFrame impl from SCTK
This has been removed in a later version, so pull it in ahead
of updating that dependency to verify that it builds.
2021-06-26 22:58:42 -07:00
Wez Furlong
8ab025b7fc Allow building without wayland support
You can run `cargo build --release --no-default-features` to build
without wayland support.

This is useful for systems that do not have wayland (eg: the `slint`
distro).
2021-06-26 22:58:42 -07:00
Wez Furlong
2fc143e6dd click to focus window now focuses the pane under the mouse cursor
refs: https://github.com/wez/wezterm/issues/881
2021-06-26 15:24:17 -07:00
Wez Furlong
4c0d789ac3 zeno -> tiny_skia
Mostly so that we can turn off anti-aliasing for smaller sizes,
but it also happens to be more complete anyway.
2021-06-25 22:55:42 -07:00
Wez Furlong
a514adfec0 windows: avoid ctrl normalization in the common case
in https://github.com/wez/wezterm/issues/767 CTRL-Tab was getting
incorrectly normalized to CTRL-i; that normalization is valid (Tab is
actually equivalent to CTRL-i as far as unix terminals are concerned)
but unwanted at this layer.

I suspect that this change will come back to haunt me in the future,
as keyboard input is a bit of a zoo.
2021-05-29 10:23:41 -07:00
Wez Furlong
030e517b43 deps: metrics 0.15 -> 0.16, cargo update 2021-05-24 07:57:03 -07:00
Wez Furlong
18ae2ccc8e window: log/retry self-pipe-writes
At the bottom of https://github.com/wez/wezterm/issues/815 is some
discussion about an apparent hang.

Let's make the self pipe writing a bit more robust and log to see
if that might be related.
2021-05-23 19:07:48 -07:00
Wez Furlong
f78190ec9c filedescriptor: remove anyhow from public interface
Use thiserror instead
2021-05-23 14:24:01 -07:00
Wez Furlong
a59e9b1706 update metrics 0.14 -> 0.15
closes: https://github.com/wez/wezterm/pull/778
2021-05-11 19:20:24 -07:00
Wez Furlong
5f5a48c830 tidy up log levels for wgpu 2021-05-09 10:59:48 -07:00
Wez Furlong
7cfbd133ac fixup warning in wgpu example 2021-05-09 08:20:03 -07:00
Wez Furlong
4e6f341f10 window: wayland support is no longer optional at build time 2021-05-08 17:48:58 -07:00
Wez Furlong
35351a97b4 x11: don't need to ref gl context in window any more
This is now managed by the client application
2021-05-08 15:05:07 -07:00
Wez Furlong
5f59bf25be window: tidy up infinite sleeps
refs: #770
2021-05-08 14:58:07 -07:00
Wez Furlong
4c847ff4ff window: remove now-dead bits on macos
refs: #770
2021-05-08 14:12:30 -07:00
Wez Furlong
5f612c17f5 windows: remove some now-dead code
refs: #770
2021-05-08 13:04:59 -07:00
Wez Furlong
7d301b91a7 x11/wayland: reduce frequency of core event loop
In an earlier incarnation we needed to wake up more often to paint,
but we now should have reliable event sources for all of the
invalidation cases and we can thus sleep for much longer in
the main event loop.

refs: #770
2021-05-08 12:59:33 -07:00
Wez Furlong
a884021074 window: remove Connection::schedule_timer
smol's Timer is used to replace this concept

refs: #770
2021-05-08 12:38:34 -07:00
Wez Furlong
325e755216 window: don't propagate errors from close notif channel
When a window is being destroyed we expect the receiver end
to be disconnected, so we don't want to break out of the
message loop if a couple of residual windows fail to notify.
2021-05-08 10:20:26 -07:00
Wez Furlong
453cfc1813 avoid a panic during shutdown 2021-05-08 09:36:20 -07:00
Wez Furlong
e81fb6e721 make alpha work on macos 2021-05-08 09:36:20 -07:00
Wez Furlong
0503abc63a fixup build on windows, make transparent 2021-05-08 09:36:20 -07:00
Wez Furlong
655eef271f fixup build on macos 2021-05-08 09:36:20 -07:00
Wez Furlong
058c3f612f add wgpu example 2021-05-08 09:36:19 -07:00
Wez Furlong
f4939c510b impl raw window handle on Window 2021-05-08 09:36:19 -07:00
Wez Furlong
c4e1f2434a add raw-window-handle impls 2021-05-08 09:36:19 -07:00
Wez Furlong
3d760653b4 window: macos: disable window restoration 2021-05-08 09:36:19 -07:00
Wez Furlong
a44607fb3f with_window inner from FnMut -> FnOnce
Not sure why it was FnMut, but this tidies up an awkward
option/take/unwrap thing in notify().
2021-05-08 09:36:19 -07:00
Wez Furlong
fb72338689 window: macos set gl layer placement to top-left 2021-05-08 09:36:19 -07:00
Wez Furlong
89dfeb69d6 tweak message pumping around paint on win32
It's not perfect; the revised code won't repaint immediate during
resize which can make the window a little "wobbly" during resize.
2021-05-08 09:36:19 -07:00
Wez Furlong
630d9d215b fixup build on windows
and correct the notify same thread optimization on unix
2021-05-08 09:36:19 -07:00
Wez Furlong
0f384b5c06 make window.notify more efficient on unix
avoid going through an extra queue if we already are in the right place
2021-05-08 09:36:19 -07:00
Wez Furlong
9fd04f6024 fixup linux build 2021-05-08 09:36:19 -07:00
Wez Furlong
5d037eae52 adjust gui layer for window changes 2021-05-08 09:36:19 -07:00
Wez Furlong
4d73448387 window: fixup build for macos 2021-05-08 09:36:19 -07:00
Wez Furlong
fe836da980 window: fixup build on windows 2021-05-08 09:36:19 -07:00
Wez Furlong
d56bfd0b7f window: separate gui window state from app state
Removes the callbacks type and replaces event dispatch with
an async capable channel.

This makes it a bit simpler to model some of the window internals,
and to prepare for a wgpu enabled future.

This changes have been tested only on linux so far.
2021-05-08 09:36:19 -07:00
Chris
2add312c5c
Allow VoidSymbol keycode to be seen by wezterm (#759)
* allow voidsymbol for key code

* update docs, cleanup

* cleanup and fmt of files

* remove unnecessary inputs
2021-05-07 07:54:24 -07:00
Wez Furlong
e400f2f524 fixup build on windows
refs: https://github.com/wez/wezterm/issues/695
2021-05-03 21:40:20 -07:00
Wez Furlong
b2b0b8b011 fixup build on linux
refs: https://github.com/wez/wezterm/issues/695
2021-05-03 21:09:08 -07:00
Wez Furlong
0df755b8f0 window: set_inner_size now returns Future<Dimensions>
This should help us reason about whether a resize respected
our request.

This may break linux and windows builds, will fixup once
this is pushed.

refs: https://github.com/wez/wezterm/issues/695
2021-05-03 20:49:22 -07:00
Wez Furlong
772991a1f0 window: remove WindowOpsMut trait
It doesn't serve any purpose and makes it awkward to make
a change in a later commit.

refs: https://github.com/wez/wezterm/issues/695
2021-05-03 20:26:33 -07:00
Wez Furlong
e4d45de9ec cargo fmt 2021-05-02 12:59:31 -07:00
Wez Furlong
6a5582f45a fixup tests for new_window async change 2021-05-02 12:43:00 -07:00
Wez Furlong
6919630810 refactor: new_window is now async
This doesn't really change anything, but it makes it a little
simpler to integrate wgpu in a later commit.
2021-05-02 12:05:28 -07:00
Wez Furlong
45262c3091 macos: fix numpad enter key reporting
refs: https://github.com/wez/wezterm/issues/739
2021-04-27 07:39:10 -07:00
Wez Furlong
ff7f097fb9 macos: fix "reflected" mouse x coordinate values
We were getting abs() of the backing-rect-adjusted value, so we need to
restore the sign to avoid what should be logically cell position "-1"
being treated as cell position "1" and so on.

With this change, the logic in the gui layer successfully clamps the x
coordinate to zero when trying to drag left off the window.
2021-04-23 18:31:44 -07:00
Wez Furlong
aea4fd5020 macos: ensure window is always miniaturizable
We need to keep the miniaturizable flag in even when there is no
titlebar, otherwise the miniaturize action has no effect.
2021-04-15 18:12:14 -07:00
Wez Furlong
2bb0e4e797 macos: use alternative cursor hiding technique
NSCursor hide/unhide must be perfectly balanced otherwise
the cursor can vanish unexpectedly when the mouse leaves
the window, and not come back.

So, let's use NSCursor:setHiddenUntilMouseMoves instead; it's
not 100% fulfilling the promise of the API, but it's close enough
and should avoid the permanent invisibility issue.

refs: https://github.com/wez/wezterm/issues/618
2021-04-10 14:30:06 -07:00
Wez Furlong
1415d16c9f window: x11: explicitly set titles in utf8
closes: https://github.com/wez/wezterm/issues/673
2021-04-10 07:44:51 -07:00
Wez Furlong
16e7457049 x11: notice dynamic changes to Xft.dpi
This commit allows the x11 window implementation to detect changes
in the DPI that occur after a window is created.

These can occur when changing desktop resolution or when changing
the accessibility option for "Large Text" in gnome.

In order to avoid continually polling for the value on every resize,
we look for the `_GTK_EDGE_CONSTRAINTS` atom in our property change
notifications.  This seems to be sent at least as often as the
dpi/scaling changes.

It's also worth noting that some dpi changes don't generate resize
events, so we can't just read the dpi value on every resize, because
we'd miss some of those changes.

Part of this commit changes the font scaling logic: previously
we'd keep a notion of "dpi scale" to apply.  That dates from an
earlier time in wezterm where we didn't think that we knew an
actual dpi value.

The way that worked was that we'd compare our current guestimate
of the DPI against what we though the baseline OS dpi should be to
produce a scaling factor.

On X11 that dpi value is global and we'd effectively always produce
a revised scaling factor of 1 after we'd set up the initial window.

This commit changes that logic to just pass down the actual DPI value
to the font code.  That DPI value already accounts for HiDPI scaling
so this is hopefully a NOP change for the other systems.

refs: https://github.com/wez/wezterm/issues/667
2021-04-09 09:23:25 -07:00
Wez Furlong
7a17ae833f macos: add logging around NSOpenGLPixelFormat
This just makes it easier to see when this is slowing things down.

refs: https://github.com/wez/wezterm/issues/452
2021-04-03 20:08:57 -07:00
Wez Furlong
1658627e2c macos: the event loop would keep running until mouse moved after quit
On macos, once all panes were closed, the GUI would request that the app
stop, but it wouldn't actually exit until a UI event occurred.

This was mostly noticeable when running debug builds from another
terminal.

Calling NSApp::abortModal is sufficient to knock us out of that state.
2021-04-03 14:57:20 -07:00
Wez Furlong
7deb215303 macos: recognize CTRL-Tab
macOS only sends key up events for this, so we remap them to
key down events.

closes: https://github.com/wez/wezterm/issues/630
2021-04-03 11:29:03 -07:00
Wez Furlong
fe48951e7a macos: fixup SUPER+SHIFT+[ key decoding
One of the default key assignments was registered as `SUPER+SHIFT+{`
which worked on macOS, but on Linux, would never match because the
keypress over there was (correctly) reporting as `SUPER+{`.

I originally thought that the user reported issue was a linux
normalization problem, but in looking deeper, the issue is really
that macos is doing something funky!

On macos we collect the interpreted key event as a string, and also
the interpretation of that event without any modifiers applied.

For letters this means that eg: `ALT-l` reports as `¬` for the
processed string and `l` for the unmodified string.  That's good!

However, for punctuation we get a backwards result: SUPER+SHIFT+[
produces `[` for the processed text and `{` for the unmodified
text!

This commit tries to detect this, using a heuristic that is
potentially bad on non-US layouts: if both the processed and
unmodified strings are punctuation then we bias to the unmodified
version.

With that change, that key press is correctly reported as `SUPER+{`,
and we can fix the key assignment registration to reflect that.

I quickly checked the behavior of pressing that same physical key
combination with a DEU layout active, and it appears that the unmodified
stuff is also flipped there; we get a lower-case version of something
that I think should be uppercase.  This commit doesn't change that
behavior:

```
key_event KeyEvent { key: Char('ü'), modifiers: NONE,
        raw_key: Some(Char('Ü')),
        raw_modifiers: SHIFT | SUPER,
        raw_code: Some(33),
        repeat_count: 1, key_is_down: true }
```

refs: https://github.com/wez/wezterm/issues/601
2021-04-03 06:32:13 -07:00
Wez Furlong
d7b78b4163 x11: handle setting cursor to None (= hide)
refs: https://github.com/wez/wezterm/issues/618
2021-04-03 05:43:01 -07:00
Wez Furlong
298e0b8d76 hide mouse cursor each time we send key input to a pane
Mouse movement will show the cursor again.

macOS: fix hiding the cursor

refs: https://github.com/wez/wezterm/issues/618
2021-04-02 22:34:58 -07:00
Gus Wynn
b057e1f671 switch to just button 2 2021-04-01 08:38:50 -07:00
Gus Wynn
76041265d6 other_mouse_down as well 2021-04-01 08:38:50 -07:00
Gus Wynn
e84811085e filter mouse buttons 2021-04-01 08:38:50 -07:00
Gus Wynn
0bae61d580 Capture middle mouse events on macos 2021-04-01 08:38:50 -07:00
Wez Furlong
b4876da2aa fix windows build 2021-03-23 22:41:04 -07:00
Wez Furlong
51e22d4c90 remove ConfigBridge, Windows edition 2021-03-23 22:17:44 -07:00
Wez Furlong
e294123215 window: remove ConfigBridge on x11/wayland 2021-03-23 22:11:41 -07:00
Wez Furlong
b876fbabd6 remove the config bridge and have window -> config directly 2021-03-23 21:56:57 -07:00
Wez Furlong
a7c9d9123b window: fix compilation warning when wayland feature disabled 2021-03-21 20:20:24 -07:00
Wez Furlong
a0d39989df simplify Color data type
There's something fishy with colorspaces and blending.
This commit removes the `window::Color` type and replaces
it and the confusing array of color types exposed by the
`palette` crate with a pair of much simpler types:

`LinearRgb` - a tuple of f32 linear color components
`SrgbaPixel` - the u32 sRGBA pixel representation

This doesn't change anything about rendering, it just
makes it a bit simpler and makes the SrgbaPixel -> LinearRgb
conversion happen slightly earlier which shaves off some
ad-hoc conversions.

Refs: https://github.com/wez/wezterm/issues/544
2021-03-21 16:54:22 -07:00
Wez Furlong
4767fcc28c windows: some minor performance improvements
* Make window invalidation more efficient by avoiding spawning a call
  that spawns a call to invalidate the window.  Just directly mark as
  invalidated.

* Suppress default background erase

* hoist the bg_color calc for quads that don't have Cells outside of
  its loop.

refs: https://github.com/wez/wezterm/issues/546
2021-03-21 10:06:43 -07:00
Wez Furlong
f3d01c4d19 windows: fix window_background_opacity
I'm not sure what exactly changed (perhaps it was a Windows updated?)
but window_background_opacity was only taking effect for windows
with no title bar.

I found that explicitly configuring a region makes transparency
work again.

refs: #553
2021-03-21 00:57:09 -07:00
Wez Furlong
86a0f0939c x11: preserve SHIFT modifier for control characters
Basically the same thing as #516, but preserve the SHIFT
modifier for backspace and delete.

refs: #516
refs: #545
2021-03-16 18:32:49 -07:00
Wez Furlong
09081d2189 improve texture upload performance, part 2
Continuing along the same lines as the prior commit, the goal
of this commit is to remove the buffer transformation that was
part of uploading the texture to the GPU provided surface.

In order to do so:

* The sense of our local textures needs to change from bgra32 to rgba32.
  bgra32 was a hangover from earlier versions of our window crate that
  allowed direct-to-fb writes in software mode.  We had to pick bgra32
  for that for the broadest OS compatibility.  I believe that that
  constraint has been totally removed, although there is a chance that
  this will flip the colors on macos.
* There was an additional linear-to-srgb conversion inlined in that
  buffer transformation.  I have no idea where that is needed because
  the source data is carefully constructed as SRGB.  I don't yet know
  how to signal that, but for now I've moved that gamma correction
  into the shader when we sample the texture.

With this change, timg playback now has vtparse as the hottest
region of code.

refs: #537
2021-03-14 09:14:30 -07:00
Wez Furlong
b8dcfba9a4 improve texture upload performance
Two issues highlighted by profiling:

* Clearing the texture takes a non-trivial percentage of the profile.
  The docs suggest that it is better to create a new texture than
  to update large portions of a texture, so add some plumbing so
  that we can do that in the first texture-full case.

* Next on the list is the code that translates from linear BGRA to
  SRGBA.  This is present for reasons that I believe are now legacy,
  but for the moment: those two primitives now have faster and
  easier implementations, so simplify to those.

This improves the timg video playback performance by ~10% for me.

refs: #537
2021-03-13 23:18:15 -08:00
Wez Furlong
333f5f9750 fix a rounding issue when computing block glyphs
The leftmost pixel was being set to at least 1 by the scale
function.

Fix that up by computing the x coordinate without calling
the scale function.

refs: https://github.com/wez/wezterm/issues/536
2021-03-13 11:29:57 -08:00
Wez Furlong
1c1a4ebe05 windows: track per-window config
I hadn't hooked this up fully... and so now I have.
2021-03-10 20:06:02 -08:00
Wez Furlong
21f3f90e34 x11: remove some dead code 2021-03-09 08:21:23 -08:00
Wez Furlong
18cb179227 x11: query Xft.dpi from the root window
We should now be using the root window specified default dpi
if the dpi is left unspecified in the wezterm configuration.

refs: #515
2021-03-08 22:19:44 -08:00
Wez Furlong
aceb4933a9 x11: load XCursor.theme based cursors when available
This requires `xcb-util-image-devel` on fedora, not sure about debian
or other systems so far.

refs: #524
2021-03-08 22:00:42 -08:00
Wez Furlong
387579cfb4 use xcb-util's cursor constants 2021-03-08 08:36:31 -08:00
Wez Furlong
3f3de0f544 refactor: move x11 cursor code to its own file 2021-03-08 08:30:29 -08:00
Wez Furlong
41a0148c50 x11: fix reporting shift modifiers for SHIFT-Enter, Space, Tab
refs: https://github.com/wez/wezterm/issues/516
2021-03-07 22:13:53 -08:00
Benoit de Chezelles
683d8e96e8 windows: Add option to treat left ctrl-alt as altgr
The previous behavior was to always treat ctrl-alt as altgr on Windows,
this has been done to better support altgr through a VNC session,
but this is very unintuitive when you don't need this behavior.

ref: #472
2021-03-07 12:52:03 -08:00
Wez Furlong
fae9b35368 fixup macos build
refs: https://github.com/wez/wezterm/issues/291
2021-03-07 12:49:31 -08:00
Wez Furlong
ba5d50ba9e add window-resized event
This is to support <https://github.com/wez/wezterm/issues/291>.

The window resized event happens asynchronously wrt. processing
a window resize, triggering at the end of the normal window
resize handling.

This commit introduces the notion of whether we are in full screen
mode or not in the underlying event callback, which is useful to
gate the desired feature, which is: when in full screen mode,
increase the padding for the window to center its content.

While poking around at this, I noticed that we weren't passing
the per-window config down to the code that computes the quad
locations for the window.

This commit also changes the font size increase/decrease behavior
so that in full screen mode it doesn't try to resize the window.

```lua
local wezterm = require 'wezterm';

wezterm.on("window-resized", function(window, pane)
  local window_dims = window:get_dimensions();
  local pane_dims = pane:get_dimensions();
  local overrides = window:get_config_overrides() or {}

  if not window_dims.is_full_screen then
    if not overrides.window_padding then
      -- not changing anything
      return;
    end
    overrides.window_padding = nil;
  else
    -- Use only the middle 33%
    local third = math.floor(window_dims.pixel_width / 3)
    local new_padding = {
      left = third,
      right = third,
      top = 0,
      bottom = 0
    };
    if overrides.window_padding and new_padding.left == overrides.window_padding.left then
      -- padding is same, avoid triggering further changes
      return
    end
    overrides.window_padding = new_padding

  end
  window:set_config_overrides(overrides)
end);

return {
}
```
2021-03-07 11:54:15 -08:00
Wez Furlong
a3429d189b fixup build on windows 2021-03-04 23:23:09 -08:00
Wez Furlong
a736492497 fixup build on x11/wayland 2021-03-04 23:16:18 -08:00
Wez Furlong
cfed798e79 window: allow window layer to hold per-window config
This is to allow for eg: hotkey to change window decorations
(https://wezfurlong.org/wezterm/config/lua/window/set_config_overrides.html)

So far only macos actually keeps a per-window config.
Hopefully this still compiles for windows and x11.
2021-03-04 23:05:44 -08:00
Wez Furlong
1178639a22 windows: implement decoration setting, change to bitfield
Can now set `window_decorations = "TITLE|RESIZE"` or variations
on those flags.  `NONE` is a shortcut for no flags.
2021-03-04 09:40:38 -08:00
Wez Furlong
945b6b726f windows: allow disabling titlebar, fixup dragging 2021-03-04 08:37:29 -08:00
Wez Furlong
1ca9fb3555 x11: allow disabling the titlebar
I've kept resizing in there because it doesn't appear to render
a border in mutter and seems useful.

I think I'll probably change WindowDecorations to bitflags so
that the user can control this, but first need to verify what
windows supports for this.
2021-03-04 08:02:13 -08:00
Wez Furlong
4834a29791 macos: support disabling the titlebar
This isn't fully baked yet, so I'm not documenting it yet.
2021-03-03 22:47:31 -08:00
Wez Furlong
f7c26d1866 egl: log error if make_current fails
I see this trigger in debug builds only.  Not sure why yet.
2021-02-28 12:32:58 -08:00
Wez Furlong
d4c6f52771 window: fix build on windows 2021-02-28 00:38:14 -08:00
Wez Furlong
04ecd16493 remove --front-end CLI option
Can use `--config front_end="Software"` instead.
2021-02-27 23:59:04 -08:00
Wez Furlong
38e6a1bc4c window: fix ToggleFullScreen on Windows
closes: https://github.com/wez/wezterm/issues/177
2021-02-26 19:39:35 -08:00
Wez Furlong
3e44abcca8 Adopt new shaper logic in gui
Connect the gui to the new shaping logic; this means that we
can now correctly render fg/bg color when the cursor moves
through the cells that comprise a ligature.

refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong
ee17e4e174 Add shaper post-processing function
This function is intended to deal with certain kinds of ligatures
and certain combining sequences that don't have corresponding glyphs.

It isn't hooked up to the gui yet, but does have unit tests that
are probably mostly correct.

refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong
4e2b2eddba split shaders, adjust srgb opengl render settings
https://learnopengl.com/Advanced-Lighting/Gamma-Correction suggests
some good practices:

* Only enable SRGB output on the final draw call, so that all prior
  stages can operate on linear values and avoid converting to/from
  linear multiple times.
* The SRGBA textures automatically linearize when sampled, but:
  * The RGB data must be SRGB (non-linear)
  * The A channel is assumed to be linear!

This commit nudges us closer to that by:

* Converting the freetype coverage map from its linear value to
  non-linear when rasterizing.
* Splitting the shader files into one per stage (background, lines,
  glyphs) and only setting outputs_srgb for the glyph stage

refs: #491
2021-02-20 17:12:36 -08:00
Wez Furlong
41cb9d3f38 wayland: attempt to handle seat changes that impact the keyboard
A couple of times today while debugging things on wayland, I lost
keyboard input to wezterm.

I don't know if that is strictly a wezterm bug, or just a general
wayland bug (not long after, the whole mutter session hung, and
somehow wedged all processes with my uid).

So, this is a quick stab in that direction.
2021-02-13 21:07:22 -08:00
Wez Furlong
b4ded64e14 wayland: fix an issue with key repeat potentially hanging/spinning 2021-02-13 19:47:06 -08:00
Wez Furlong
f697de82fc wayland: fix initial window decoration, toggle full screen
This fixes a longstanding issue under mutter where client side
decorations are in use.  The decorations were being drawn too
early in the initialization of the window which could leave them
off-screen and weird.  This was masked by a couple of mutter
related bugs with client side decorations.

With these changes I now get sane decorations under mutter,
and the toggle fullscreen action is now enabled as well!

closes: #224
2021-02-13 11:02:04 -08:00
Wez Furlong
894d056947 wayland: allow matching raw modifiers for raw:123 key bindings 2021-02-13 09:11:55 -08:00
Greg V
58e2a181f2 wayland: do not create OpenGL context before the configure event
The existing code seems to use "configure" for just resizes,
so introduce a "start" flag in pending events to handle the
initial configure.
2021-02-12 16:56:24 -08:00
Wez Furlong
a14e3669f2 window: update smithay-client-toolkit
However, I'm not able to create wayland windows any more on my nvidia
system (either with or without this change).

I don't know if this is specific to my nvidia drivers or something else
:-/

refs: https://github.com/wez/wezterm/issues/476
2021-02-12 08:19:51 -08:00
Wez Furlong
d9275e110c deps: update metrics from 0.12 -> 0.14 2021-02-03 23:50:29 -08:00
Wez Furlong
0c6f0cac1b x11: track primary selection and clipboard requests separately
otherwise we get confused about the state of these and paste
the wrong thing
2021-02-01 07:50:48 -08:00
Wez Furlong
f541e923de macos: also respect use_dead_keys = false
refs: #410
2021-01-31 17:32:11 -08:00
Wez Furlong
6bfadfac0a macos: handle dead keys without IME
Dead key processing respects the
`send_composed_key_when_left_alt_is_pressed` and
`send_composed_key_when_right_alt_is_pressed` options.

See doc changes included in this commit for more info.

refs: https://github.com/wez/wezterm/issues/410
2021-01-31 17:06:30 -08:00
Wez Furlong
b201e43b94 window: doc comment for opacity config
refs: #445
2021-01-30 08:08:11 -08:00
Wez Furlong
baf168e458 window: slightly condense opaque/shadow setting logic
refs: #445
2021-01-30 08:02:48 -08:00
Zeyi (Rice) Fan
6b9401365c
Only disable drop shadow on macOS when window background opacity is transparent (#445)
* only set shadow when background is transparent

* set opaque correctly
2021-01-30 07:58:53 -08:00
Wez Furlong
8dad34fa61 more configuration options for Copy/Paste
* Adds `CopyTo` and `PasteFrom` assignments that specify the
  destination/source.
* Adds `default_clipboard_copy_destination` and `default_paste_source`
  config options that specify the default destination/source for
  existing `Copy` and `Paste` operations (for @bew)
* Deprecating `PastePrimarySelection` in favor of `PasteFrom`.
* Added `CTRL-Insert` -> `Copy` (for @Babar)

Aside from the new key assignment, these changes shouldn't change
the default behavior, but do make it easier to consider changing
that in a later commit.

They should allow for example:

* Set `default_clipboard_copy_destination = "PrimarySelection"` to
  prevent populating the clipboard by default when using the mouse.
* Overriding the CTRL-Insert, CTRL-SHIFT-C to explicitly populate
  the clipboard
* Set `default_paste_source = "PrimarySelection"` for middle click
  to paste the selection.
* Overriding SHIFT-Insert, CTRL-SHIFT-V to explicitly paste from
  the clipboard.

refs: #417
2021-01-27 10:20:17 -08:00
Wez Furlong
aee37784e5 Windows: fix initial window size when display scaling != 100%
The heart of this issue was that the resize callbacks have two
layers of state; one in the low level window and one in the application
level window.

On Windows, the system triggers the low level callback prior to
opengl being initialized.  Since the application level depends on
the opengl state, there are some code paths where it NOPs and
returns early if opengl isn't yet initialized.

When the system-wide display scaling is set to say 200%, the application
layer can't know the effective DPI of the window it is creating because
it doesn't know which monitor will be used or what its DPI will be.

New windows are created at the default DPI of 96, and we rely on the
resize events to detect the actual DPI and adjust the scaling in
the window.

The early call of the resize callback meant that the low level and
application level size/dpi state was out of sync and the result was
that the window had half as many pixels as it should, but that the
terminal model was still sized as though it had the correct amount
(twice as many as visible).  This resulted in the window being too
small for the viewport.

The resolution is simple: we now suppress emitting the resize processing
until opengl has been initialized.

The test scenario for this is:

* Set system scaling to 100%
* Launch wezterm
* Set system scaling to 200%
* Observe that wezterm scales to match
* Press CTRL-SHIFT-N to spawn a new window
* Observe that the new window size matches the other window (previously
  this one would be half the size)

While I was looking at this, I noticed that the manifest didn't
match the DPI awareness that we have in the code, so update that.

refs: https://github.com/wez/wezterm/issues/427
2021-01-18 09:27:04 -08:00
Wez Furlong
0ef89f3de0 window: remove some dead code on Windows
Since removing non-GL usage, this code is dead.
2021-01-17 10:29:49 -08:00
Wez Furlong
697d41aeb1 Render the various underline styles
```
$ printf "\x1b[58;2;255;0;0m\x1b[4msingle\x1b[21mdouble\x1b[60mcurly\x1b[61mdotted\x1b[62mdashed\x1b[0m"
```

refs: https://github.com/wez/wezterm/issues/415
2021-01-05 23:46:15 -08:00
Wez Furlong
b5e5f2a764 window: fix painting on x11
Need to clear paint_all otherwise we don't settle and flush buffers.
2020-12-30 09:42:16 -08:00
Wez Furlong
cc4cdd81b3 window: remove avx code in bitmaps/mod.rs
I don't think it is worth the complexity of keeping this around;
we rarely do direct bitmap stuff any more.
2020-12-29 14:26:57 -08:00
Wez Furlong
c73e1d3924 window: remove PaintContext 2020-12-29 13:53:20 -08:00
Wez Furlong
38a0137660 window: remove now-dead code on Windows 2020-12-29 13:42:18 -08:00
Wez Furlong
1ca2aeaeb4 window: remove now-dead code for x11/wayland 2020-12-29 13:40:50 -08:00
Wez Furlong
1af1c85818 window: fixup build for x11/wayland 2020-12-29 13:35:59 -08:00
Wez Furlong
4f80fd9bcd window: macos: remove dead code 2020-12-29 13:29:59 -08:00
Wez Furlong
cf6914c5d8 window: remove non-opengl paint, rename paint_opengl -> paint 2020-12-29 13:25:35 -08:00
Wez Furlong
972c07a692 window: update examples for opengl-only-ness 2020-12-29 13:15:16 -08:00
Wez Furlong
5a3c6a6b15 window: macos: remove non-opengl back buffer 2020-12-29 12:52:44 -08:00
Wez Furlong
709682079e window: macos: refactor now opengl is always enabled
Hoist opengl out of a submodule.
2020-12-29 12:47:25 -08:00
Wez Furlong
cf418c34e3 window: consolidate opengl_initialize with created callback
Since we now always init opengl and fail to create a window if that
fails, may as well combine these two callbacks.
2020-12-29 12:44:39 -08:00
Wez Furlong
ec7d511750 window: implicitly enable_opengl at new_window creation 2020-12-29 12:31:25 -08:00
Wez Furlong
4c22de9f6d window: make opengl always required 2020-12-29 12:13:23 -08:00
Wez Furlong
7cf68365a5 deps: misc updates 2020-12-29 09:24:34 -08:00
Wez Furlong
c68bf92bcd window: implement FullScreen for x11
refs: https://github.com/wez/wezterm/issues/177
2020-12-28 10:59:53 -08:00
Wez Furlong
f8f8dc7240 remove now-dead code 2020-12-27 22:37:52 -08:00
Wez Furlong
d302f82335 window+gui: macOS: add native_macos_fullscreen_mode option
Defaults to false.  If set to true, the ToggleFullScreen action
prefers native macOS fullscreen mode.

refs: https://github.com/wez/wezterm/issues/177
2020-12-27 22:34:31 -08:00
Wez Furlong
cd997cbe48 window+gui: migrate prefer_egl to WindowConfiguration 2020-12-27 22:06:04 -08:00
Wez Furlong
228356105e window+gui: migrate enable_wayland to WindowConfiguration 2020-12-27 22:00:51 -08:00
Wez Furlong
fb53f98295 window+gui: migrate windows dead keys config to WindowConfiguration
untested as I'm on a mac, but seems like it might compile...
2020-12-27 21:56:16 -08:00
Wez Furlong
44ca61da66 window+gui: introduce WindowConfiguration trait
This adopts a similar technique to that used to pass the wezterm
config to the term crate, but this time it is for passing it to
the window crate.

The use_ime option has been ported over to this new mechanism.
2020-12-27 21:51:56 -08:00
Wez Furlong
7ae52cd2b5 wezterm: plumbing for FullScreen action
Hooks up toggling fullscreen mode on macos, with plumbing for
other systems.

I prefer not to use the "modern fullscreen" mode because I find
the transition animations in macOS are horrendously slow.

I'll make an option to allow selecting whether that is used or not
in a follow-on diff.

refs: https://github.com/wez/wezterm/issues/177
2020-12-27 19:15:47 -08:00
Wez Furlong
cbf29c2e53 window: x11: remove SHIFT state from KeyCode::Char(_)
When we decode a key event from X11 into a `KeyCode::Char(_)` variant,
that result has already factored in the result of the SHIFT modifier
state.

That makes SHIFT largely useless for unicode keys; we do want to
preserve the SHIFT modifier for keys such as the arrow keys.

This commit removes SHIFT from the `KeyEvent::modifiers` for
`KeyCode::Char(_)` variants so that those modifiers don't get
in the way of keymap lookups.

refs: https://github.com/wez/wezterm/issues/394
2020-12-25 10:29:30 -08:00