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 xkbcommon::xkb::{self, Keycode, Keysym, State};
|
||||||
|
|
||||||
use crate::platform::linux::wayland::WaylandClient;
|
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::{
|
use crate::{
|
||||||
px, Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CosmicTextSystem, CursorStyle,
|
px, Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CosmicTextSystem, CursorStyle,
|
||||||
DisplayId, ForegroundExecutor, Keymap, Keystroke, LinuxDispatcher, Menu, MenuItem, Modifiers,
|
DisplayId, ForegroundExecutor, Keymap, Keystroke, LinuxDispatcher, Menu, MenuItem, Modifiers,
|
||||||
|
@ -90,6 +90,7 @@ pub(crate) struct LinuxCommon {
|
||||||
pub(crate) foreground_executor: ForegroundExecutor,
|
pub(crate) foreground_executor: ForegroundExecutor,
|
||||||
pub(crate) text_system: Arc<CosmicTextSystem>,
|
pub(crate) text_system: Arc<CosmicTextSystem>,
|
||||||
pub(crate) appearance: WindowAppearance,
|
pub(crate) appearance: WindowAppearance,
|
||||||
|
pub(crate) auto_hide_scrollbars: bool,
|
||||||
pub(crate) callbacks: PlatformHandlers,
|
pub(crate) callbacks: PlatformHandlers,
|
||||||
pub(crate) signal: LoopSignal,
|
pub(crate) signal: LoopSignal,
|
||||||
}
|
}
|
||||||
|
@ -106,12 +107,15 @@ impl LinuxCommon {
|
||||||
let appearance = window_appearance(&background_executor)
|
let appearance = window_appearance(&background_executor)
|
||||||
.log_err()
|
.log_err()
|
||||||
.unwrap_or(WindowAppearance::Light);
|
.unwrap_or(WindowAppearance::Light);
|
||||||
|
let auto_hide_scrollbars =
|
||||||
|
should_auto_hide_scrollbars(&background_executor).unwrap_or(false);
|
||||||
|
|
||||||
let common = LinuxCommon {
|
let common = LinuxCommon {
|
||||||
background_executor,
|
background_executor,
|
||||||
foreground_executor: ForegroundExecutor::new(dispatcher.clone()),
|
foreground_executor: ForegroundExecutor::new(dispatcher.clone()),
|
||||||
text_system,
|
text_system,
|
||||||
appearance,
|
appearance,
|
||||||
|
auto_hide_scrollbars,
|
||||||
callbacks,
|
callbacks,
|
||||||
signal,
|
signal,
|
||||||
};
|
};
|
||||||
|
@ -402,9 +406,8 @@ impl<P: LinuxClient + 'static> Platform for P {
|
||||||
self.set_cursor_style(style)
|
self.set_cursor_style(style)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(linux)
|
|
||||||
fn should_auto_hide_scrollbars(&self) -> bool {
|
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<()>> {
|
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)
|
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…
Add table
Add a link
Reference in a new issue