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

816 Commits

Author SHA1 Message Date
Wez Furlong
787f6550b8
macos: link to helpful resources from Help menu 2022-12-21 00:31:58 -07:00
Wez Furlong
b5aea795ca
fixup tests
refs: https://github.com/wez/wezterm/issues/162
refs: https://github.com/wez/wezterm/issues/1485
2022-12-20 20:48:44 -07:00
Wez Furlong
b224aa1b56
macOS: add MenuBar
This took a decent amount of effort to thread through with context;
wrappers around NSMenu and NSMenuItem are added to reduce some of
the objc usability warts, and an additional NSObject wrapper is
added to help copy the KeyAssignment from the existing list
of command palette commands and associate it with the menu item.

When a menu item is selected, macOS will walk through the responder
chain and look for a responder that responds to the selector associated
with the menu item.  In practice that means that our window/view class
will be tried first, and then later, our app delegate will be tried.

This commit implements routing from both of these: the window case
routes to the associated TermWindow and drops into the existing
perform_key_assignment method.

In case there is no window (not currently possible, but will be
in the future), the app delegate also has a placeholder for dispatching
key assignments, although it will only be able to perform a subset
of the possible actions.

A couple of things to note:

* Items aren't smart enough to disable themselves or adjust their
  caption based on the context. To make that work, we either need
  to recreate the entire menubar when any possible context changes
  (doable, but feels heavy), or we need to assign a target to each
  menu item and implement a validation handler on that target.
  That seemed to mess with the responder chain when I briefly
  experimented with it.

* There's some disabled code to add a Services menu. It is disabled
  because when it is enabled, accessing either Services or Help
  from the menu bar sends the process into a busy loop somewhere
  in macOS's internals.  It's unclear what it is unhappy with.

* No keyboard accelerators are associated with the menubar yet.
  That needs some thought, as they would essentially become global
  keyboard shortcuts and take precedence over the shortcuts defined
  for other keys in the config.  This feels like it should be something
  that the user has control over, so there needs to be something to
  allow that before we go ahead and wire those up.

refs: https://github.com/wez/wezterm/issues/162
refs: https://github.com/wez/wezterm/issues/1485
2022-12-20 19:46:08 -07:00
Wez Furlong
30238acb1b
x11: potential fix for hanging IME
refs: https://github.com/H-M-H/xcb-imdkit-rs/issues/5
refs: https://github.com/wez/wezterm/issues/2819
2022-12-19 12:23:04 -07:00
Wez Furlong
28c7c0ba19
macos: allow association with .command file type
Implement an app delegate to receive a callback when the system
requests that we open `.command` files, and then ask the mux
layer to spawn a window for it and execute it via the shell.

Also allow handling `.sh`, `.zsh`, `.bash`, `.fish` and `.tool`,
per kitty.

refs: https://github.com/wez/wezterm/issues/2741
refs: https://github.com/wez/wezterm/issues/2871
2022-12-19 11:06:12 -07:00
Wez Furlong
1f7a34f8b2
fix resizing on windows when wgpu is enabled 2022-11-18 10:03:49 -07:00
Wez Furlong
883e2d11d7
make drawRect work on macos when using webgpu 2022-11-18 10:03:49 -07:00
Wez Furlong
09f1ecbf82
erase generic T from Atlas, Sprite, CachedGlyph etc.
This will make it easier to use the same impl for webgpu and opengl
for a bunch of this stuff.
2022-11-18 10:03:49 -07:00
Wez Furlong
8479be7465
Basic useless wgpu based rendering foundation 2022-11-18 10:03:49 -07:00
Wez Furlong
eaa91e9314
deps: update raw-window-handle 2022-11-18 10:03:49 -07:00
Wez Furlong
387d0ad3e3
rustdoc markdown fences-- 2022-11-15 09:40:10 -07:00
Wez Furlong
9569028d98
xcursor: parse and follow theme inheritance
A couple of users ran into an issue where wezterm couldn't find
their mouse cursor icons.

Looking more deeply into this, we weren't looking at `index.theme`
files and following the inheritance chain from them.

This commit addresses that!

refs: https://github.com/wez/wezterm/issues/2687
refs: https://github.com/wez/wezterm/issues/2743
2022-11-15 09:15:43 -07:00
Wez Furlong
cd386804c4 macos: remove UNHANDLED: IME: do_command_by_selector warnings
We handle this the same whether we know the selector or not these days,
so just remove the warning.
2022-10-22 20:03:15 -07:00
Wez Furlong
473316934b add window-focus-changed event 2022-10-08 09:45:57 -07:00
Wez Furlong
7f8d3a31d7 x11: explicitly enable Dri2
On some systems, the X server will send dri2 events when enabling
opengl. Without telling the rust xcb crate that they might arrive, it
may panic.

refs: https://github.com/rust-x-bindings/rust-xcb/issues/204
refs: https://github.com/wez/wezterm/issues/2559
2022-10-08 08:11:57 -07:00
Wez Furlong
ba57f73bd9 deps: pick up updated rust-xcb
Might help with these:

refs: https://github.com/rust-x-bindings/rust-xcb/issues/195
refs: https://github.com/wez/wezterm/issues/2559
refs: https://github.com/rust-x-bindings/rust-xcb/issues/204
2022-10-04 07:53:46 -07:00
Wez Furlong
694ffdbed2 macos: revise how we prevent routing to the IME
https://github.com/wez/wezterm/pull/2435 proposed including
CTRL-modified keys, but I think that the state of the code now means
that we can simplify that area and adjust it so that we will default to
routing keys to the IME, but excluding them based on the
`send_composed_key_when_(left|right)_alt_is_pressed` configuration.

I've only very lightly tested this, but it seems ok with roman text and
me punching in random pinyin and then using CTRL-H or CTRL-M to delete
or enter.

refs: https://github.com/wez/wezterm/pull/2435
2022-09-21 21:22:38 -07:00
Wez Furlong
006e19813f x11: use _NET_WM_MOVERESIZE to drag by tab bar
refs: https://github.com/wez/wezterm/issues/2530
2022-09-18 17:20:41 -07:00
Wez Furlong
1355a5f83b macos: add logging around querying appearance 2022-09-17 05:57:54 -07:00
Wez Furlong
72c83e0599 ls-fonts: fix ascii rasterization of emoji/bitmap fonts
Need to scale them using the same rules we do when the window
renders them for real.

wezterm  ls-fonts --text "$(printf hi\\U1faf0💩)" --rasterize-ascii
2022-09-06 18:49:20 -07:00
unrelentingtech
682e83433d wayland: only cancel key repeat when the *held* key was released, fixes #2452 2022-09-06 07:31:08 -07:00
Wez Furlong
804fc04630 deps: xkbcommon-rs released 0.5
can stop using my git repo for this
2022-09-02 09:25:20 -07:00
Wez Furlong
b9d0843b71 deps: tiny-skia 0.7 -> 0.8 2022-08-28 20:50:27 -07:00
Wez Furlong
4edc9c5d9f macos: make us run again on Mojave
refs: https://github.com/wez/wezterm/issues/2451
2022-08-23 11:48:59 -07:00
Wez Furlong
7be824db62 deps: update zbus 2022-08-21 09:18:32 -07:00
Wez Furlong
f4b8028e5e macos: fixup CI build
weirdly, BOOL is considered bool when I compile locally,
but in the CI:

```
error[E0308]: mismatched types
   --> window/src/os/macos/connection.rs:170:22
    |
170 |     let max_fps = if has_max_fps {
    |                      ^^^^^^^^^^^ expected `bool`, found `i8`
```

I can't explain the difference in behavior (feels like a compiler
bug?) but let's try comparing explicitly against YES
2022-08-21 08:29:17 -07:00
Wez Furlong
99391e39d2 macos: NSScreen::maximumFramesPerSecond is newish
Gate calling it to avoid a runtime failure on eg: Big Sur.

refs: https://github.com/wez/wezterm/issues/2440
2022-08-21 07:21:12 -07:00
Wez Furlong
b181935303 win32: implement max_fps option 2022-08-20 19:20:41 -07:00
Wez Furlong
dc62aa5198 win32: set ScreenInfo::max_fps 2022-08-20 17:39:51 -07:00
Wez Furlong
cb09e71214 x11: populate ScreenInfo::max_fps from xrandr 2022-08-20 07:07:58 -07:00
Magnus Groß
ba309931a3 Cache xdg-desktop-portal appearance
This slightly improves the startup time of wezterm.

Right now we query the portal appearance value again over dbus every
time that we access it, for example every time that the user calls
wezterm.gui.get_appearance() from the Lua interface.

Queries over dbus are slow, they usually take a few milliseconds to
complete, for example on my system a portal query over dbus takes around
2 milliseconds to complete.

Wezterm also automatically calls the portal during its own internal
x11/wayland connection initialization, thus right now wezterm queries
the appearance portal setting n+1 times on startup, where n is the
number of times that the user calls get_appearance() from the config.

To fix this problem, we simply cache the portal appearance.

Thus this patch decreases the startup time by 2ms for users that
configure wezterm to follow the global system theme and potentially by
more for users that call get_appearance() in inflational amounts.

With the naive implementation wezterm would be subject to the following
race condition:

1. wezterm calls get_appearance() and caches the value
2. System-wide dark mode changes
3. wezterm subscribes to portal notifications

In that scenario wezterm would miss the dark mode switch entirely and
would cache the wrong value until the dark mode switches again after
wezterm subscribed.

To fix this race condition we call read_setting() again **after** we
have subscribed just to be on the safe side.

Note that while this still introduces a second "redundant" dbus query
for the same value, this time it does not actually block start up since
it happens in another thread.

refs: #2258
2022-08-20 06:06:59 -07:00
Wez Furlong
4fead3171e macos: report max_fps in ScreenInfo
Other platforms can be added later
2022-08-19 21:02:51 -07:00
Wez Furlong
8ca3faa6ee macos: implement max_fps
Use the same technique that we use on x11 systems to schedule/throttle
painting frames.

refs: https://github.com/wez/wezterm/discussions/2419
2022-08-19 20:39:39 -07:00
Davide Cavalca
0048209bcf Add missing license files 2022-08-17 07:19:12 -07:00
Wez Furlong
e2bf468393 wayland: disable use of wlr-output-management protocol
refs: #2297
refs: #2293
refs: #2360
2022-08-07 08:13:38 -07:00
Magnus Groß
60b5be2b34 x11/wayland: always try the portal for appearance
Right now the initial x11 appearance retrieval uses the specific
connection interface, which completely circumvents the already existing
more complete implementation in x_and_wayland.rs.
The latter implementation is strictly better, because it first attempts
getting the appearance from the XDG desktop portal and then falls back
to the X11 interface.

Before this patch there was a very weird issue for folks using the OS
system dark mode with the following config snippet:

```
color_scheme = scheme_for_appearance(wezterm.gui.get_appearance())
```

The color_scheme on startup would be correct, but there would be a very
weird problem where sometimes wezterm ignores the first time that the
portal notifies about an appearance update.

The source of the bug was an inconsistent retrieval of the appearance
setting:
- The Lua API used the XDG desktop portal
- The internal appearance used the X11 specific connection at startup

For example due to this, the internal appearance variable could have
stored "Dark" from the X11 connection, but the actual appearance from
the XDG desktop portal was "Light".
If then the XDG desktop portal changes to "Dark", the
appearance_changed() method would dismiss the update because
self.appearance was already "Dark".

It is only after that, that the internal inconsistency would have been
solved and following appearance changes would succeed and update the
colorscheme correctly.

To fix this problem, we now use the portal directly in both the x11 and
wayland connections,  which is consistent with the Lua
wezterm.gui.get_appearance() API.

refs: #2258
2022-07-15 15:23:47 -07:00
Wez Furlong
a1c8b4a9b3 x11/wayland: subscribe to xdg desktop portal for settings changes
We use this to detect changes in dark mode

refs: https://github.com/wez/wezterm/issues/2258
2022-07-13 18:56:21 -07:00
Wez Furlong
8ef70d1e31 windows: avoid recursing and borrowing inner twice
Querying the window can call into windowproc so we need to avoid
it when we hold `inner`.  Adjust the flow so that we can get
the info about the window state purely from an HWND.

refs: #2257
2022-07-13 11:37:04 -07:00
Wez Furlong
8dcfbc6718 x11/wayland: use xdg desktop portal settings interface to get dark mode
There are some other settings in there that could also help with
things like the cursor theme on Wayland.

Note that we don't currently subscribe to the settings changed
signal: that can be done in a follow up.

refs: https://github.com/wez/wezterm/issues/2258
refs: https://github.com/wez/wezterm/issues/1742
2022-07-13 08:55:43 -07:00
Wez Furlong
d7fa541745 windows: fixup starting maximized
Since applying the maximized state is async, we hadn't fully applied
it before we got to the startup logic that resizes the window to fit
the initial terminal size.

This adds a final check to see if we are resizable before we try
to apply that size, and skips it.

refs: #284
2022-07-10 07:19:08 -07:00
Wez Furlong
f11b240a1c wayland: double-buffer ime events
refs: #1772
2022-07-10 06:52:21 -07:00
Wez Furlong
607287935f wayland: ime: clear compose state after commit
refs: #1772
2022-07-09 23:12:43 -07:00
Wez Furlong
2196279689 wayland: workaround mutter IME issue
refs: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4776
refs: https://github.com/wez/wezterm/issues/1772
2022-07-09 22:29:25 -07:00
Wez Furlong
7f6ae3c82d wayland: fixup IME preedit
The done event shouldn't clear the state.

refs: #1772
2022-07-09 12:35:01 -07:00
Wez Furlong
9c758dd203 wayland: fix ime position when scaling > 1
refs: #1772
2022-07-09 12:20:22 -07:00
Wez Furlong
e2b748a0d4 wayland: initial support for zwp_text_input_v3 / IME
refs: #1772
2022-07-09 09:44:08 -07:00
Wez Furlong
c906179bb9 wayland: use zwlr_output_manager if available
This seems to have better names and also returns fractional
scaling information.
2022-07-08 13:40:28 -07:00
Wez Furlong
fdb5fc2d66 wayland: implement wezterm.gui.screens()
Hook it up for resolving geometry, but note that wayland doesn't
allow positioning and we don't expose a way to set width/height
based on screen right now.
2022-07-08 09:54:42 -07:00
Wez Furlong
2c093b976d windows: implement window:maximize(), window:restore() 2022-07-07 06:25:43 -07:00
Wez Furlong
9779b29c39 wayland: implement window:maximize() window:restore() 2022-07-07 06:19:08 -07:00