mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-07 17:26:56 +00:00
linux: Implement should_auto_hide_scrollbars
(#12366)
Implemented the should_auto_hide_scrollbars method for Linux using `xdg_desktop_portal` approach Release Notes: - N/A
This commit is contained in:
parent
08e3840379
commit
da70741ece
2 changed files with 17 additions and 3 deletions
|
@ -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<()>> {
|
||||
|
|
|
@ -131,3 +131,14 @@ pub fn window_appearance(executor: &BackgroundExecutor) -> Result<WindowAppearan
|
|||
Ok(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)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue