1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00
wezterm/window
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
..
examples support drag and drop files for macos 2022-04-25 09:49:32 -07:00
src x11/wayland: always try the portal for appearance 2022-07-15 15:23:47 -07:00
build.rs macos: handle dead keys without IME 2021-01-31 17:06:30 -08:00
Cargo.toml x11/wayland: use xdg desktop portal settings interface to get dark mode 2022-07-13 08:55:43 -07:00