Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
linux: Implement `should_auto_hide_scrollbars` (#12366)
Raunak Rajda70741ece40
diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rsindex 71c069a9f42..6974eb7fbd8 100644--- a/crates/gpui/src/platform/linux/platform.rs+++ b/crates/gpui/src/platform/linux/platform.rs@@ -34,7 +34,7 @@ use wayland_protocols::wp::cursor_shape::v1::client::wp_cursor_shape_device_v1::use xkbcommon::xkb::{self, Keycode, Keysym, State};use crate::platform::linux::wayland::WaylandClient;-use crate::platform::linux::xdg_desktop_portal::window_appearance;+use crate::platform::linux::xdg_desktop_portal::{should_auto_hide_scrollbars, window_appearance};use crate::{px, Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CosmicTextSystem, CursorStyle,DisplayId, ForegroundExecutor, Keymap, Keystroke, LinuxDispatcher, Menu, MenuItem, Modifiers,@@ -90,6 +90,7 @@ pub(crate) struct LinuxCommon {pub(crate) foreground_executor: ForegroundExecutor,pub(crate) text_system: Arc<CosmicTextSystem>,pub(crate) appearance: WindowAppearance,+ pub(crate) auto_hide_scrollbars: bool,pub(crate) callbacks: PlatformHandlers,pub(crate) signal: LoopSignal,}@@ -106,12 +107,15 @@ impl LinuxCommon {let appearance = window_appearance(&background_executor).log_err().unwrap_or(WindowAppearance::Light);+ let auto_hide_scrollbars =+ should_auto_hide_scrollbars(&background_executor).unwrap_or(false);let common = LinuxCommon {background_executor,foreground_executor: ForegroundExecutor::new(dispatcher.clone()),text_system,appearance,+ auto_hide_scrollbars,callbacks,signal,};@@ -402,9 +406,8 @@ impl<P: LinuxClient + 'static> Platform for P {self.set_cursor_style(style)}- // todo(linux)fn should_auto_hide_scrollbars(&self) -> bool {- false+ self.with_common(|common| common.auto_hide_scrollbars)}fn write_credentials(&self, url: &str, username: &str, password: &[u8]) -> Task<Result<()>> {diff --git a/crates/gpui/src/platform/linux/xdg_desktop_portal.rs b/crates/gpui/src/platform/linux/xdg_desktop_portal.rsindex e23af679b51..67115727935 100644--- a/crates/gpui/src/platform/linux/xdg_desktop_portal.rs+++ b/crates/gpui/src/platform/linux/xdg_desktop_portal.rs@@ -131,3 +131,14 @@ pub fn window_appearance(executor: &BackgroundExecutor) -> Result<WindowAppearanOk(appearance)})}++pub fn should_auto_hide_scrollbars(executor: &BackgroundExecutor) -> Result<bool, anyhow::Error> {+ executor.block(async {+ let settings = Settings::new().await?;+ let auto_hide = settings+ .read::<bool>("org.gnome.desktop.interface", "overlay-scrolling")+ .await?;++ Ok(auto_hide)+ })+}