mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-01-11 22:12:53 +01:00
fix(wm): limit to a single virtual desktop
An issue was reported in which switching between Windows Virtual Desktops was causing issues with the layout generation. This was due to WinEvents being emitted from other Virtual Desktops ending up in the WM state when they shouldn't. This commit introduces a check to ensure that the WM will only listen to events and commands emitted from the Windows Virtual Desktop that it was started on. fix #15
This commit is contained in:
43
Cargo.lock
generated
43
Cargo.lock
generated
@@ -160,6 +160,37 @@ dependencies = [
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "com"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a30a2b2a013da986dc5cc3eda3d19c0d59d53f835be1b2356eb8d00f000c793"
|
||||
dependencies = [
|
||||
"com_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "com_macros"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7606b05842fea68ddcc89e8053b8860ebcb2a0ba8d6abfe3a148e5d5a8d3f0c1"
|
||||
dependencies = [
|
||||
"com_macros_support",
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "com_macros_support"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97e9a6d20f4ac8830e309a455d7e9416e65c6af5a97c88c55fbb4c2012e107da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const-sha1"
|
||||
version = "0.2.0"
|
||||
@@ -491,6 +522,7 @@ dependencies = [
|
||||
"tracing-subscriber",
|
||||
"uds_windows",
|
||||
"which",
|
||||
"winvd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1439,6 +1471,17 @@ dependencies = [
|
||||
"windows_gen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winvd"
|
||||
version = "0.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bab2d5c745381b9c72797230150ec62244e693064fa0d654b5c4e6c75132a56"
|
||||
dependencies = [
|
||||
"com",
|
||||
"crossbeam-channel",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ws2_32-sys"
|
||||
version = "0.2.1"
|
||||
|
||||
@@ -266,7 +266,7 @@ If `komorebi` ever stops responding, it is most likely either due to either a pa
|
||||
panic, this will be reported in the log. In the case of a deadlock, there will not be any errors in the log, but the
|
||||
process and the log will appear frozen.
|
||||
|
||||
If you believe you have encountered a deadlock, you can compile `komorebi` with `--feature deadlock_detection` and try
|
||||
If you believe you have encountered a deadlock, you can compile `komorebi` with `--features deadlock_detection` and try
|
||||
reproducing the deadlock again. This will check for deadlocks every 5 seconds in the background, and if a deadlock is
|
||||
found, information about it will appear in the log which can be shared when opening an issu which can be shared when
|
||||
opening an issue.
|
||||
|
||||
@@ -30,6 +30,7 @@ tracing = "0.1"
|
||||
tracing-appender = "0.1"
|
||||
tracing-subscriber = "0.2"
|
||||
uds_windows = "1"
|
||||
winvd = "0.0.20"
|
||||
which = "4"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -50,6 +50,18 @@ pub fn listen_for_commands(wm: Arc<Mutex<WindowManager>>) {
|
||||
impl WindowManager {
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn process_command(&mut self, message: SocketMessage) -> Result<()> {
|
||||
let virtual_desktop_id = winvd::helpers::get_current_desktop_number()
|
||||
.expect("could not determine the current virtual desktop number");
|
||||
|
||||
if virtual_desktop_id != self.virtual_desktop_id {
|
||||
tracing::warn!(
|
||||
"ignoring commands while not on virtual desktop {}",
|
||||
self.virtual_desktop_id
|
||||
);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
match message {
|
||||
SocketMessage::Promote => self.promote_container_to_front()?,
|
||||
SocketMessage::FocusWindow(direction) => {
|
||||
|
||||
@@ -48,6 +48,18 @@ impl WindowManager {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let virtual_desktop_id = winvd::helpers::get_current_desktop_number()
|
||||
.expect("could not determine the current virtual desktop number");
|
||||
|
||||
if virtual_desktop_id != self.virtual_desktop_id {
|
||||
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
|
||||
match event {
|
||||
WindowManagerEvent::FocusChange(_, window)
|
||||
|
||||
@@ -43,6 +43,7 @@ pub struct WindowManager {
|
||||
pub command_listener: UnixListener,
|
||||
pub is_paused: bool,
|
||||
pub hotwatch: Hotwatch,
|
||||
pub virtual_desktop_id: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@@ -95,12 +96,16 @@ pub fn new(incoming: Arc<Mutex<Receiver<WindowManagerEvent>>>) -> Result<WindowM
|
||||
|
||||
let listener = UnixListener::bind(&socket)?;
|
||||
|
||||
let virtual_desktop_id = winvd::helpers::get_current_desktop_number()
|
||||
.expect("could not determine the current virtual desktop number");
|
||||
|
||||
Ok(WindowManager {
|
||||
monitors: Ring::default(),
|
||||
incoming_events: incoming,
|
||||
command_listener: listener,
|
||||
is_paused: false,
|
||||
hotwatch: Hotwatch::new()?,
|
||||
virtual_desktop_id,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user