mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 14:48:34 +01:00
refactor(core,kde,mac): the unmanaged-window gate of the router is the CommandHost::gate_message hook
Section 22.1 of core-model.md: KDE and macOS refuse every message before the router's match while the focused window is not managed (handle_unmanaged_window_behaviour); Windows gates inside 18 functions. CommandHost gets a defaulted gate_message(&mut self, &SocketMessage) that lets everything through (the Windows form, its impl is untouched); the KDE and macOS impls call handle_unmanaged_window_behaviour and their routers call the hook where they called the method, so behaviour is identical per daemon. komorebi-core now depends on komorebi-protocol (for SocketMessage; Cargo.lock gains that one edge). This is the groundwork only: the router itself is still per daemon, because a shared router needs WindowManager<P> in core (see the struct-move analysis in core-model.md). No BEHAVIOUR change. Verified: KDE cargo test -p komorebi-linux 670 passed, 0 failed; fake-CC clippy -D warnings for the four macOS packages passes; cargo clippy -p komorebi-windows -p komorebi-core --all-targets -D warnings passes; tools/format-all --check clean. Not verified: KDE VM, macOS hand check (no behaviour change expected).
This commit is contained in:
1 parent
2ba338347c
commit
fab53bd1f8
5 files changed
+28
-2
No files matched your search
Generated
+1
@@ -3583,6 +3583,7 @@ dependencies = [
|
||||
"komorebi-collections",
|
||||
"komorebi-config",
|
||||
"komorebi-layouts",
|
||||
"komorebi-protocol",
|
||||
"komorebi-scrolling",
|
||||
"nanoid 0.5.0",
|
||||
"schemars 1.2.3",
|
||||
|
||||
@@ -8,6 +8,7 @@ edition = "2024"
|
||||
komorebi-collections = { path = "../komorebi-collections" }
|
||||
komorebi-config = { path = "../komorebi-config", default-features = false }
|
||||
komorebi-layouts = { path = "../../komorebi-layouts" }
|
||||
komorebi-protocol = { path = "../komorebi-protocol" }
|
||||
komorebi-scrolling = { path = "../../komorebi-scrolling" }
|
||||
color-eyre = { workspace = true }
|
||||
nanoid = "0.5"
|
||||
|
||||
@@ -14,6 +14,7 @@ use color_eyre::eyre;
|
||||
use color_eyre::eyre::OptionExt;
|
||||
use komorebi_layouts::CycleDirection;
|
||||
use komorebi_layouts::OperationDirection;
|
||||
use komorebi_protocol::message::SocketMessage;
|
||||
use std::collections::VecDeque;
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
@@ -43,6 +44,15 @@ pub trait CommandHost {
|
||||
/// Shows workspace `idx` on the focused monitor and focuses it.
|
||||
fn focus_workspace(&mut self, idx: usize) -> eyre::Result<()>;
|
||||
|
||||
/// Whether the router may run `message` at all: an error refuses it before any arm runs. The
|
||||
/// default lets everything through (Windows, which gates inside 18 window manager functions
|
||||
/// instead, section 22.1 of docs/dev/core-model.md); KDE and macOS refuse every message while the
|
||||
/// focused window is not managed and `unmanaged_window_operation_behaviour` is `NoOp`.
|
||||
fn gate_message(&mut self, message: &SocketMessage) -> eyre::Result<()> {
|
||||
let _ = message;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Shows workspace `workspace_idx` on the monitor at `monitor_idx` (creating it if it is not
|
||||
/// there) without focusing that monitor.
|
||||
fn show_workspace_on(&mut self, monitor_idx: usize, workspace_idx: usize) -> eyre::Result<()>;
|
||||
|
||||
@@ -999,7 +999,7 @@ impl WindowManager {
|
||||
// We don't have From implemented for &mut WindowManager
|
||||
let initial_state = State::from(self.as_ref());
|
||||
|
||||
self.handle_unmanaged_window_behaviour()?;
|
||||
komorebi_core::CommandHost::gate_message(self, &message)?;
|
||||
|
||||
match message {
|
||||
SocketMessage::Promote => self.promote_container_to_front()?,
|
||||
@@ -2013,6 +2013,13 @@ fn push_simple_rule(rules: &mut Vec<MatchingRule>, kind: ApplicationIdentifier,
|
||||
impl komorebi_core::CommandHost for WindowManager {
|
||||
type P = crate::workspace::KdePlatform;
|
||||
|
||||
fn gate_message(
|
||||
&mut self,
|
||||
_message: &komorebi_protocol::message::SocketMessage,
|
||||
) -> eyre::Result<()> {
|
||||
self.handle_unmanaged_window_behaviour()
|
||||
}
|
||||
|
||||
fn monitors(&self) -> &std::collections::VecDeque<crate::monitor::Monitor> {
|
||||
WindowManager::monitors(self)
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ impl WindowManager {
|
||||
// We don't have From implemented for &mut WindowManager
|
||||
let initial_state = State::from(self.as_ref());
|
||||
|
||||
self.handle_unmanaged_window_behaviour()?;
|
||||
komorebi_core::CommandHost::gate_message(self, &message)?;
|
||||
|
||||
match message {
|
||||
SocketMessage::Promote => self.promote_container_to_front()?,
|
||||
@@ -1696,6 +1696,13 @@ impl WindowManager {
|
||||
impl komorebi_core::CommandHost for WindowManager {
|
||||
type P = crate::workspace::MacosPlatform;
|
||||
|
||||
fn gate_message(
|
||||
&mut self,
|
||||
_message: &komorebi_protocol::message::SocketMessage,
|
||||
) -> eyre::Result<()> {
|
||||
self.handle_unmanaged_window_behaviour()
|
||||
}
|
||||
|
||||
fn monitors(&self) -> &std::collections::VecDeque<crate::monitor::Monitor> {
|
||||
WindowManager::monitors(self)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user