mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-17 22:33:12 +01:00
refactor(windows): window_manager.rs and process_command.rs take KDE's text where the behaviour is the same
BEHAVIOUR (log text only, nothing else expected): the Windows copy of these functions is changed to the text KDE and macOS have where the two do the same: - eyre::bail! is written in full (the bail import goes), as in KDE; - toggle_lock flips the flag through Lockable (set_locked/locked), as in KDE, instead of assigning the field; - the log line of maximize_window says 'maximizing window' (it said 'maximizing windowj') and the one of clear_workspace_layout_rules says 'clearing workspace layout rules' (it said 'setting workspace layout'); - the SessionFloatRules arm uses unwrap_or_else and the State arm names State, which is the text of the KDE arms. Nothing else of the 61 functions that differ by at most four lines is the same behaviour: the rest are real differences (core-model.md section 18). Windows e2e scenarios needed: toggle-lock, maximize, clear layout rules, session-float-rules, state (all cheap). Verified: Windows clippy --locked --all-targets -D warnings: PASS (after touching the sources: the shared target dir had stale metadata). Not run: Windows tests, e2e.
This commit is contained in:
1 parent
c1f9aab49e
commit
63f1d36b79
2 files changed
+20
-23
No files matched your search
@@ -85,7 +85,6 @@ use crate::notify_subscribers;
|
||||
use crate::stackbar_manager;
|
||||
use crate::stackbar_manager::STACKBAR_FONT_FAMILY;
|
||||
use crate::stackbar_manager::STACKBAR_FONT_SIZE;
|
||||
use crate::state;
|
||||
use crate::state::GlobalState;
|
||||
use crate::state::State;
|
||||
use crate::static_config::StaticConfig;
|
||||
@@ -515,10 +514,8 @@ impl WindowManager {
|
||||
}
|
||||
SocketMessage::SessionFloatRules => {
|
||||
let session_floating_applications = SESSION_FLOATING_APPLICATIONS.lock();
|
||||
let rules = match serde_json::to_string_pretty(&*session_floating_applications) {
|
||||
Ok(rules) => rules,
|
||||
Err(error) => error.to_string(),
|
||||
};
|
||||
let rules = serde_json::to_string_pretty(&*session_floating_applications)
|
||||
.unwrap_or_else(|error| error.to_string());
|
||||
|
||||
reply.write_all(rules.as_bytes())?;
|
||||
}
|
||||
@@ -953,7 +950,7 @@ impl WindowManager {
|
||||
self.set_workspace_name(monitor_idx, workspace_idx, name.to_string())?;
|
||||
}
|
||||
SocketMessage::State => {
|
||||
let state = match serde_json::to_string_pretty(&state::State::from(&*self)) {
|
||||
let state = match serde_json::to_string_pretty(&State::from(&*self)) {
|
||||
Ok(state) => state,
|
||||
Err(error) => error.to_string(),
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@ use std::sync::atomic::Ordering;
|
||||
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::OptionExt;
|
||||
use color_eyre::eyre::bail;
|
||||
use crossbeam_channel::Receiver;
|
||||
use hotwatch::EventKind;
|
||||
use hotwatch::Hotwatch;
|
||||
@@ -58,6 +57,7 @@ use komorebi_core::ContainerWindow;
|
||||
use crate::CrossBoundaryBehaviour;
|
||||
use crate::DATA_DIR;
|
||||
use crate::HOME_DIR;
|
||||
use crate::Lockable;
|
||||
use crate::NO_TITLEBAR;
|
||||
use crate::REGEX_IDENTIFIERS;
|
||||
use crate::SUBSCRIPTION_SOCKETS;
|
||||
@@ -1560,7 +1560,7 @@ impl WindowManager {
|
||||
let workspace = self.focused_workspace()?;
|
||||
let focused_hwnd = WindowsApi::foreground_window()?;
|
||||
if !workspace.contains_managed_window(focused_hwnd) {
|
||||
bail!("ignoring commands while active window is not managed by komorebi");
|
||||
eyre::bail!("ignoring commands while active window is not managed by komorebi");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1693,7 +1693,7 @@ impl WindowManager {
|
||||
) -> eyre::Result<()> {
|
||||
// check the target before anything is taken out of the workspace it is in
|
||||
if monitor_idx >= self.monitors().len() {
|
||||
bail!("there is no monitor at index {monitor_idx}");
|
||||
eyre::bail!("there is no monitor at index {monitor_idx}");
|
||||
}
|
||||
|
||||
self.handle_unmanaged_window_behaviour()?;
|
||||
@@ -1722,7 +1722,7 @@ impl WindowManager {
|
||||
.ok_or_eyre("there is no workspace")?;
|
||||
|
||||
if workspace.maximized_window.is_some() {
|
||||
bail!("cannot move native maximized window to another monitor or workspace");
|
||||
eyre::bail!("cannot move native maximized window to another monitor or workspace");
|
||||
}
|
||||
|
||||
let foreground_hwnd = WindowsApi::foreground_window()?;
|
||||
@@ -1801,7 +1801,7 @@ impl WindowManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bail!("failed to find a window to move");
|
||||
eyre::bail!("failed to find a window to move");
|
||||
}
|
||||
|
||||
if should_load_workspace {
|
||||
@@ -1867,7 +1867,7 @@ impl WindowManager {
|
||||
|
||||
// check the target before the workspace is taken out of its monitor
|
||||
if idx >= self.monitors().len() {
|
||||
bail!("there is no monitor at index {idx}");
|
||||
eyre::bail!("there is no monitor at index {idx}");
|
||||
}
|
||||
|
||||
let mouse_follows_focus = self.mouse_follows_focus;
|
||||
@@ -2449,7 +2449,7 @@ impl WindowManager {
|
||||
// removing this messes up the monitor / container / window index somewhere
|
||||
// and results in the wrong window getting moved across the monitor boundary
|
||||
if workspace.is_focused_window_monocle_or_maximized()? {
|
||||
bail!("ignoring command while active window is in monocle mode or maximized");
|
||||
eyre::bail!("ignoring command while active window is in monocle mode or maximized");
|
||||
}
|
||||
|
||||
tracing::info!("moving container");
|
||||
@@ -2718,7 +2718,7 @@ impl WindowManager {
|
||||
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
if workspace.is_focused_window_monocle_or_maximized()? {
|
||||
bail!("ignoring command while active window is in monocle mode or maximized");
|
||||
eyre::bail!("ignoring command while active window is in monocle mode or maximized");
|
||||
}
|
||||
|
||||
tracing::info!("moving container");
|
||||
@@ -2753,7 +2753,7 @@ impl WindowManager {
|
||||
.ok_or_eyre("there must be at least one window in a container")?;
|
||||
|
||||
if len.get() == 1 {
|
||||
bail!("there is only one window in this container");
|
||||
eyre::bail!("there is only one window in this container");
|
||||
}
|
||||
|
||||
let current_idx = container.focused_window_idx();
|
||||
@@ -2789,7 +2789,7 @@ impl WindowManager {
|
||||
.ok_or_eyre("there must be at least one window in a container")?;
|
||||
|
||||
if len.get() == 1 {
|
||||
bail!("there is only one window in this container");
|
||||
eyre::bail!("there is only one window in this container");
|
||||
}
|
||||
|
||||
let current_idx = container.focused_window_idx();
|
||||
@@ -2822,11 +2822,11 @@ impl WindowManager {
|
||||
.ok_or_eyre("there must be at least one window in a container")?;
|
||||
|
||||
if len.get() == 1 && idx != 0 {
|
||||
bail!("there is only one window in this container");
|
||||
eyre::bail!("there is only one window in this container");
|
||||
}
|
||||
|
||||
if container.windows().get(idx).is_none() {
|
||||
bail!("there is no window in this container at index {idx}");
|
||||
eyre::bail!("there is no window in this container at index {idx}");
|
||||
}
|
||||
|
||||
container.focus_window(idx);
|
||||
@@ -3066,7 +3066,7 @@ impl WindowManager {
|
||||
tracing::info!("removing window");
|
||||
|
||||
if self.focused_container()?.windows().len() == 1 {
|
||||
bail!("a container must have at least one window");
|
||||
eyre::bail!("a container must have at least one window");
|
||||
}
|
||||
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
@@ -3115,7 +3115,7 @@ impl WindowManager {
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
if let Some(container) = workspace.focused_container_mut() {
|
||||
// Toggle the locked flag
|
||||
container.locked = !container.locked;
|
||||
container.set_locked(!container.locked());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -3239,7 +3239,7 @@ impl WindowManager {
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn maximize_window(&mut self) -> eyre::Result<()> {
|
||||
tracing::info!("maximizing windowj");
|
||||
tracing::info!("maximizing window");
|
||||
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
workspace.new_maximized_window()
|
||||
@@ -3523,7 +3523,7 @@ impl WindowManager {
|
||||
monitor_idx: usize,
|
||||
workspace_idx: usize,
|
||||
) -> eyre::Result<()> {
|
||||
tracing::info!("setting workspace layout");
|
||||
tracing::info!("clearing workspace layout rules");
|
||||
|
||||
let focused_monitor_idx = self.focused_monitor_idx();
|
||||
|
||||
@@ -3759,7 +3759,7 @@ impl WindowManager {
|
||||
if self.monitors().get(idx).is_some() {
|
||||
self.monitors.focus(idx);
|
||||
} else {
|
||||
bail!("this is not a valid monitor index");
|
||||
eyre::bail!("this is not a valid monitor index");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user