1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00
wezterm/window
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
..
examples support drag and drop files for macos 2022-04-25 09:49:32 -07:00
src Cache xdg-desktop-portal appearance 2022-08-20 06:06:59 -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
LICENSE.md Add missing license files 2022-08-17 07:19:12 -07:00