diff --git a/Cargo.lock b/Cargo.lock index 1a7bd1e5..57512d9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.0.7" +version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e8611f9ae4e068fa3e56931fded356ff745e70987ff76924a6e0ab1c8ef2e3" +checksum = "31b34190c12bd1d613deba77e1cc13e68eaf4a0d51e389dbd485b7bfe15a47c0" dependencies = [ "atty", "bitflags", @@ -483,7 +483,7 @@ dependencies = [ "sysinfo", "tracing", "tracing-appender", - "tracing-subscriber 0.3.5", + "tracing-subscriber 0.3.6", "uds_windows", "which", "windows", @@ -1064,9 +1064,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.74" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" +checksum = "c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79" dependencies = [ "itoa 1.0.1", "ryu", @@ -1102,9 +1102,9 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "strsim" @@ -1147,9 +1147,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb37aa4af23791c584202d286ed9420e023e9d27e49d5a76215623f4bcc2502" +checksum = "7f1bfab07306a27332451a662ca9c8156e3a9986f82660ba9c8e744fe8455d43" dependencies = [ "cfg-if 1.0.0", "core-foundation-sys", @@ -1248,7 +1248,7 @@ checksum = "94571df2eae3ed4353815ea5a90974a594a1792d8782ff2cbcc9392d1101f366" dependencies = [ "crossbeam-channel", "time", - "tracing-subscriber 0.3.5", + "tracing-subscriber 0.3.6", ] [[package]] @@ -1305,9 +1305,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d81bfa81424cc98cb034b837c985b7a290f592e5b4322f353f94a0ab0f9f594" +checksum = "77be66445c4eeebb934a7340f227bfe7b338173d3f8c00a60a5a58005c9faecf" dependencies = [ "ansi_term", "lazy_static", diff --git a/README.md b/README.md index 51b30017..8c711428 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ repository. Articles, blog posts, demos, and videos about _komorebi_ can be added to this list by PR: - [Moving to Windows from Linux Pt 1](https://kvwu.io/posts/moving-to-windows/) -- [Windows下的现代化平铺窗口管理器 komorebi](https://zhuanlan.zhihu.com/p/455064481) +- [Windows 下的现代化平铺窗口管理器 komorebi](https://zhuanlan.zhihu.com/p/455064481) ## Description diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 04033dca..ba93e945 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -15,6 +15,7 @@ use miow::pipe::connect; use parking_lot::Mutex; use uds_windows::UnixStream; +use komorebi_core::ApplicationIdentifier; use komorebi_core::Axis; use komorebi_core::FocusFollowsMouseImplementation; use komorebi_core::Layout; @@ -123,10 +124,57 @@ impl WindowManager { manage_identifiers.push(id); } } - SocketMessage::FloatRule(_, id) => { + SocketMessage::FloatRule(identifier, id) => { let mut float_identifiers = FLOAT_IDENTIFIERS.lock(); if !float_identifiers.contains(&id) { - float_identifiers.push(id); + float_identifiers.push(id.clone()); + } + + let invisible_borders = self.invisible_borders; + let offset = self.work_area_offset; + + let mut hwnds_to_purge = vec![]; + for (i, monitor) in self.monitors().iter().enumerate() { + for container in monitor + .focused_workspace() + .ok_or_else(|| anyhow!("there is no workspace"))? + .containers() + .iter() + { + for window in container.windows().iter() { + match identifier { + ApplicationIdentifier::Exe => { + if window.exe()? == id { + hwnds_to_purge.push((i, window.hwnd)); + } + } + ApplicationIdentifier::Class => { + if window.class()? == id { + hwnds_to_purge.push((i, window.hwnd)); + } + } + ApplicationIdentifier::Title => { + if window.title()? == id { + hwnds_to_purge.push((i, window.hwnd)); + } + } + } + } + } + } + + for (monitor_idx, hwnd) in hwnds_to_purge { + let monitor = self + .monitors_mut() + .get_mut(monitor_idx) + .ok_or_else(|| anyhow!("there is no monitor"))?; + + monitor + .focused_workspace_mut() + .ok_or_else(|| anyhow!("there is no focused workspace"))? + .remove_window(hwnd)?; + + monitor.update_focused_workspace(offset, &invisible_borders)?; } } SocketMessage::AdjustContainerPadding(sizing, adjustment) => { diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index c7bd20a1..759b15e8 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -466,9 +466,11 @@ impl WindowsApi { let mut path: Vec = vec![0; len as usize]; let text_ptr = path.as_mut_ptr(); - unsafe { QueryFullProcessImageNameW(handle, 0, PWSTR(text_ptr), &mut len as *mut u32) } - .ok() - .process()?; + unsafe { + QueryFullProcessImageNameW(handle, 0, PWSTR(text_ptr), std::ptr::addr_of_mut!(len)) + } + .ok() + .process()?; Ok(String::from_utf16(&path[..len as usize])?) } @@ -543,7 +545,7 @@ impl WindowsApi { let mut monitor_info: MONITORINFO = unsafe { std::mem::zeroed() }; monitor_info.cbSize = u32::try_from(std::mem::size_of::())?; - unsafe { GetMonitorInfoW(hmonitor, (&mut monitor_info as *mut MONITORINFO).cast()) } + unsafe { GetMonitorInfoW(hmonitor, std::ptr::addr_of_mut!(monitor_info).cast()) } .ok() .process()?; @@ -579,7 +581,7 @@ impl WindowsApi { Self::system_parameters_info_w( SPI_GETACTIVEWINDOWTRACKING, 0, - (&mut is_enabled as *mut BOOL).cast(), + std::ptr::addr_of_mut!(is_enabled).cast(), SPIF_SENDCHANGE, )?;