This commit is contained in:
Piotr Osiewicz 2025-08-18 19:45:48 +02:00
parent b4ef6ec60b
commit bf577383a5
2 changed files with 44 additions and 47 deletions

View file

@ -701,29 +701,28 @@ impl WindowsWindowInner {
// Fix auto hide taskbar not showing. This solution is based on the approach
// used by Chrome. However, it may result in one row of pixels being obscured
// in our client area. But as Chrome says, "there seems to be no better solution."
if is_maximized {
if let Some(ref taskbar_position) = self
if is_maximized
&& let Some(ref taskbar_position) = self
.state
.borrow()
.system_settings
.auto_hide_taskbar_position
{
// Fot the auto-hide taskbar, adjust in by 1 pixel on taskbar edge,
// so the window isn't treated as a "fullscreen app", which would cause
// the taskbar to disappear.
match taskbar_position {
AutoHideTaskbarPosition::Left => {
requested_client_rect[0].left += AUTO_HIDE_TASKBAR_THICKNESS_PX
}
AutoHideTaskbarPosition::Top => {
requested_client_rect[0].top += AUTO_HIDE_TASKBAR_THICKNESS_PX
}
AutoHideTaskbarPosition::Right => {
requested_client_rect[0].right -= AUTO_HIDE_TASKBAR_THICKNESS_PX
}
AutoHideTaskbarPosition::Bottom => {
requested_client_rect[0].bottom -= AUTO_HIDE_TASKBAR_THICKNESS_PX
}
{
// Fot the auto-hide taskbar, adjust in by 1 pixel on taskbar edge,
// so the window isn't treated as a "fullscreen app", which would cause
// the taskbar to disappear.
match taskbar_position {
AutoHideTaskbarPosition::Left => {
requested_client_rect[0].left += AUTO_HIDE_TASKBAR_THICKNESS_PX
}
AutoHideTaskbarPosition::Top => {
requested_client_rect[0].top += AUTO_HIDE_TASKBAR_THICKNESS_PX
}
AutoHideTaskbarPosition::Right => {
requested_client_rect[0].right -= AUTO_HIDE_TASKBAR_THICKNESS_PX
}
AutoHideTaskbarPosition::Bottom => {
requested_client_rect[0].bottom -= AUTO_HIDE_TASKBAR_THICKNESS_PX
}
}
}
@ -1125,28 +1124,26 @@ impl WindowsWindowInner {
// lParam is a pointer to a string that indicates the area containing the system parameter
// that was changed.
let parameter = PCWSTR::from_raw(lparam.0 as _);
if unsafe { !parameter.is_null() && !parameter.is_empty() } {
if let Some(parameter_string) = unsafe { parameter.to_string() }.log_err() {
log::info!("System settings changed: {}", parameter_string);
match parameter_string.as_str() {
"ImmersiveColorSet" => {
let new_appearance = system_appearance()
.context(
"unable to get system appearance when handling ImmersiveColorSet",
)
.log_err()?;
let mut lock = self.state.borrow_mut();
if new_appearance != lock.appearance {
lock.appearance = new_appearance;
let mut callback = lock.callbacks.appearance_changed.take()?;
drop(lock);
callback();
self.state.borrow_mut().callbacks.appearance_changed = Some(callback);
configure_dwm_dark_mode(handle, new_appearance);
}
if unsafe { !parameter.is_null() && !parameter.is_empty() }
&& let Some(parameter_string) = unsafe { parameter.to_string() }.log_err()
{
log::info!("System settings changed: {}", parameter_string);
match parameter_string.as_str() {
"ImmersiveColorSet" => {
let new_appearance = system_appearance()
.context("unable to get system appearance when handling ImmersiveColorSet")
.log_err()?;
let mut lock = self.state.borrow_mut();
if new_appearance != lock.appearance {
lock.appearance = new_appearance;
let mut callback = lock.callbacks.appearance_changed.take()?;
drop(lock);
callback();
self.state.borrow_mut().callbacks.appearance_changed = Some(callback);
configure_dwm_dark_mode(handle, new_appearance);
}
_ => {}
}
_ => {}
}
}
Some(0)

View file

@ -821,14 +821,14 @@ fn file_save_dialog(
window: Option<HWND>,
) -> Result<Option<PathBuf>> {
let dialog: IFileSaveDialog = unsafe { CoCreateInstance(&FileSaveDialog, None, CLSCTX_ALL)? };
if !directory.to_string_lossy().is_empty() {
if let Some(full_path) = directory.canonicalize().log_err() {
let full_path = SanitizedPath::from(full_path);
let full_path_string = full_path.to_string();
let path_item: IShellItem =
unsafe { SHCreateItemFromParsingName(&HSTRING::from(full_path_string), None)? };
unsafe { dialog.SetFolder(&path_item).log_err() };
}
if !directory.to_string_lossy().is_empty()
&& let Some(full_path) = directory.canonicalize().log_err()
{
let full_path = SanitizedPath::from(full_path);
let full_path_string = full_path.to_string();
let path_item: IShellItem =
unsafe { SHCreateItemFromParsingName(&HSTRING::from(full_path_string), None)? };
unsafe { dialog.SetFolder(&path_item).log_err() };
}
if let Some(suggested_name) = suggested_name {