mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-14 17:12:58 +02:00
fix(wm): handle winvd errors gracefully
Of course, the crate built to interact with an undocumented COM API is not the best candidate for unwrap and expect calls... fix #15
This commit is contained in:
@@ -52,16 +52,17 @@ pub fn listen_for_commands(wm: Arc<Mutex<WindowManager>>) {
|
|||||||
impl WindowManager {
|
impl WindowManager {
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn process_command(&mut self, message: SocketMessage) -> Result<()> {
|
pub fn process_command(&mut self, message: SocketMessage) -> Result<()> {
|
||||||
let virtual_desktop_id = winvd::helpers::get_current_desktop_number()
|
let virtual_desktop_id = winvd::helpers::get_current_desktop_number().ok();
|
||||||
.expect("could not determine the current virtual desktop number");
|
if let (Some(id), Some(virtual_desktop_id)) = (virtual_desktop_id, self.virtual_desktop_id)
|
||||||
|
{
|
||||||
|
if id != virtual_desktop_id {
|
||||||
|
tracing::warn!(
|
||||||
|
"ignoring events while not on virtual desktop {:?}",
|
||||||
|
virtual_desktop_id
|
||||||
|
);
|
||||||
|
|
||||||
if virtual_desktop_id != self.virtual_desktop_id {
|
return Ok(());
|
||||||
tracing::warn!(
|
}
|
||||||
"ignoring commands while not on virtual desktop {}",
|
|
||||||
self.virtual_desktop_id
|
|
||||||
);
|
|
||||||
|
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
|
|||||||
@@ -48,16 +48,17 @@ impl WindowManager {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let virtual_desktop_id = winvd::helpers::get_current_desktop_number()
|
let virtual_desktop_id = winvd::helpers::get_current_desktop_number().ok();
|
||||||
.expect("could not determine the current virtual desktop number");
|
if let (Some(id), Some(virtual_desktop_id)) = (virtual_desktop_id, self.virtual_desktop_id)
|
||||||
|
{
|
||||||
|
if id != virtual_desktop_id {
|
||||||
|
tracing::warn!(
|
||||||
|
"ignoring events while not on virtual desktop {:?}",
|
||||||
|
virtual_desktop_id
|
||||||
|
);
|
||||||
|
|
||||||
if virtual_desktop_id != self.virtual_desktop_id {
|
return Ok(());
|
||||||
tracing::warn!(
|
}
|
||||||
"ignoring events while not on virtual desktop {}",
|
|
||||||
self.virtual_desktop_id
|
|
||||||
);
|
|
||||||
|
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we have the most recently focused monitor from any event
|
// Make sure we have the most recently focused monitor from any event
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub struct WindowManager {
|
|||||||
pub command_listener: UnixListener,
|
pub command_listener: UnixListener,
|
||||||
pub is_paused: bool,
|
pub is_paused: bool,
|
||||||
pub hotwatch: Hotwatch,
|
pub hotwatch: Hotwatch,
|
||||||
pub virtual_desktop_id: usize,
|
pub virtual_desktop_id: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
@@ -123,8 +123,7 @@ impl WindowManager {
|
|||||||
|
|
||||||
let listener = UnixListener::bind(&socket)?;
|
let listener = UnixListener::bind(&socket)?;
|
||||||
|
|
||||||
let virtual_desktop_id = winvd::helpers::get_current_desktop_number()
|
let virtual_desktop_id = winvd::helpers::get_current_desktop_number().ok();
|
||||||
.expect("could not determine the current virtual desktop number");
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
monitors: Ring::default(),
|
monitors: Ring::default(),
|
||||||
|
|||||||
Reference in New Issue
Block a user