fix(wm): don't attach to the desktop window thread

Noticed in the logs when looking at issue #2 that an "Access is denied.
(os error 5)" error was being reported when trying to attach to the
thread of the special Desktop Window, which only happens when switching
to a workspace which doesn't contain any windows. Calling
WindowsApi::set_foreground_window on the HWND directly seems to be the
better option here.
This commit is contained in:
LGUG2Z
2021-08-14 06:55:28 -07:00
parent 820432f9d4
commit a550c088dc

View File

@@ -89,7 +89,11 @@ impl WindowManager {
hwnd: WindowsApi::desktop_window()?,
};
desktop_window.focus()?;
// Calling this directly instead of the window.focus() wrapper because trying to
// attach to the thread of the desktop window always seems to result in "Access is
// denied (os error 5)"
WindowsApi::set_foreground_window(desktop_window.hwnd())
.map_err(|error| eyre::anyhow!("{} {}:{}", error, file!(), line!()))?;
}
}