mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 14:48:34 +01:00
refactor(core): hiding takes a HideSpot and says whether it worked (D-coord-7)
BEHAVIOUR for the shared signature; none intended on KDE or Windows. Needs the Windows and KDE gates below. ContainerWindow gets 'type HideSpot: Copy + Default' (() on KDE and Windows; on macOS the monitor's corner and, when known, the display bounds) and its four operations return eyre::Result: hide_window(spot), restore_window(), hide_stacked(spot), restore_stacked(). Container::hide(omit, spot), restore(), load_focused_window(spot) and add_window(window, spot) return Result (hide logs a window that cannot be hidden and goes on, as macOS does; the others propagate). WorkspacePlatform gets two hooks with a default of Default::default(): hide_spot(&globals) (the spot of a window) and hide_spot_on_display(&globals) (the containers of a workspace that is being hidden; macOS passes the display there and not for its floating windows). The eight shared workspace functions that hide (focus_container_by_window, new_container_for_window, move_window_to_container, new_container_for_focused_window, new_monocle_container, reintegrate_monocle_container, new_container_for_floating_window, new_floating_window) and hide take the spot from the hook; new_container_for_window and hide now return Result. KDE and Windows: their Window impls return Ok(()) and take (); about 90 call sites pass () and drop the Ok (let _ = ...) or use ?; nothing is hidden or restored with a different argument than before: the same backend().hide / restore, hide_with_border(false) and restore_with_border(false) calls run in the same order, the Result is always Ok. macOS: the Window impl hides with hide_on(spot.position, spot.screen) and restores, skipping both under cfg!(test) as the old container code did; its ContainerExt is unchanged until the Workspace layer. No silent bind: every shared function whose behaviour depends on the spot changed its signature (an added argument, or a Result where there was none), so any caller written for the old form is a compile error in all three trees (the six unused-Result warnings it produced on each of KDE and Windows were each fixed by hand-checked 'let _ ='). The four macOS-only extension methods (add_window_at, load_focused_window_at, hide_on, restore_focused_window) share no name with a core inherent method (checked: the intersection of the two name lists is empty), so no inherent method can shadow one. Core tests: a stub window records the spot it is given; new tests pin that a floating window is hidden at hide_spot, the containers of a hidden workspace at hide_spot_on_display, and that stacking passes hide_spot through add_window and load_focused_window; the container tests assert the spot. Verified: native cargo test -p komorebi-core 26 passed; fast-check: Windows clippy --all-targets -D warnings PASS, KDE check + lib tests PASS, macOS fake-CC type-check PASS; KDE cargo test -p komorebi-linux --no-fail-fast 672 passed, 0 failed. Not verified: Windows and macOS tests, any run. Verified on the Mini: not yet. Gates for the coordinator: Windows e2e: workspaces, stacking, monocle (the commands scenario), floating (toggle-float), lifecycle, resize, scrolling, borders; KDE VM fast tier plus the stack, workspace, monocle and float scenarios. These exercise exactly the hide/restore/stack paths touched.
This commit is contained in:
1 parent
22e6011333
commit
3baf1c1b39
19 files changed
+339
-198
No files matched your search
@@ -13,6 +13,7 @@
|
||||
use komorebi_collections::Lockable;
|
||||
use komorebi_collections::ring::Ring;
|
||||
use nanoid::nanoid;
|
||||
use color_eyre::eyre;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::collections::VecDeque;
|
||||
@@ -22,11 +23,18 @@ use std::collections::VecDeque;
|
||||
/// The window is a handle that is cheap to clone (Windows: an `HWND`; KDE: the compositor's id; macOS: an
|
||||
/// Accessibility element). Showing and
|
||||
/// hiding it is the platform's business, so the container calls these four operations and nothing
|
||||
/// else; none of them reports a failure, because a window that cannot be hidden is left where it is.
|
||||
/// else. They say whether they worked (`Ok` always, on KDE and Windows, where a window that cannot
|
||||
/// be hidden is left where it is), and hiding takes the [`ContainerWindow::HideSpot`].
|
||||
pub trait ContainerWindow: Clone + PartialEq + std::fmt::Debug {
|
||||
/// What names a window to the rest of the daemon: `isize` on Windows, `u32` on KDE.
|
||||
/// What names a window to the rest of the daemon: `isize` on Windows, `u32` on KDE and macOS.
|
||||
type Id: Copy + PartialEq;
|
||||
|
||||
/// Where a window is put when it is hidden, for a platform that hides by moving the window
|
||||
/// somewhere: on macOS the corner of the monitor and the bounds of its display. `()` where
|
||||
/// hiding takes no argument (KDE and Windows). The workspace asks the platform for it with
|
||||
/// [`WorkspacePlatform::hide_spot`](crate::WorkspacePlatform::hide_spot).
|
||||
type HideSpot: Copy + Default;
|
||||
|
||||
/// The window's id.
|
||||
fn id(&self) -> Self::Id;
|
||||
|
||||
@@ -34,18 +42,18 @@ pub trait ContainerWindow: Clone + PartialEq + std::fmt::Debug {
|
||||
fn exe_name(&self) -> Option<String>;
|
||||
|
||||
/// Takes the window out of sight, as a window that is not in front of its stack is.
|
||||
fn hide_window(&self);
|
||||
fn hide_window(&self, spot: Self::HideSpot) -> eyre::Result<()>;
|
||||
|
||||
/// Brings the window back into sight.
|
||||
fn restore_window(&self);
|
||||
fn restore_window(&self) -> eyre::Result<()>;
|
||||
|
||||
/// Hides the window as [`Container::load_focused_window`] does, which on Windows leaves the
|
||||
/// window's border alone; elsewhere it is [`ContainerWindow::hide_window`].
|
||||
fn hide_stacked(&self);
|
||||
fn hide_stacked(&self, spot: Self::HideSpot) -> eyre::Result<()>;
|
||||
|
||||
/// Restores the window as [`Container::load_focused_window`] does, which on Windows leaves the
|
||||
/// window's border alone; elsewhere it is [`ContainerWindow::restore_window`].
|
||||
fn restore_stacked(&self);
|
||||
fn restore_stacked(&self) -> eyre::Result<()>;
|
||||
}
|
||||
|
||||
/// What a workspace asks of a platform window, besides what a container asks.
|
||||
@@ -147,8 +155,10 @@ impl<W: ContainerWindow> Container<W> {
|
||||
self.id == "PRESELECT"
|
||||
}
|
||||
|
||||
/// Hides every window of the container but `omit`, or every window when it is `None`
|
||||
pub fn hide(&self, omit: Option<W::Id>) {
|
||||
/// Hides every window of the container but `omit`, or every window when it is `None`, at `spot`.
|
||||
/// A window that cannot be hidden is logged and the others are still hidden: a window that has
|
||||
/// gone away must not leave the ones after it in view.
|
||||
pub fn hide(&self, omit: Option<W::Id>, spot: W::HideSpot) -> eyre::Result<()> {
|
||||
for window in self.windows().iter().rev() {
|
||||
let mut should_hide = omit.is_none();
|
||||
|
||||
@@ -159,33 +169,39 @@ impl<W: ContainerWindow> Container<W> {
|
||||
should_hide = true
|
||||
}
|
||||
|
||||
if should_hide {
|
||||
window.hide_window();
|
||||
if should_hide && let Err(error) = window.hide_window(spot) {
|
||||
tracing::warn!("failed to hide window {:?}: {error}", window);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Restores the focused window of the container, which is the one that is in front when the
|
||||
/// container is a stack
|
||||
pub fn restore(&self) {
|
||||
pub fn restore(&self) -> eyre::Result<()> {
|
||||
if let Some(window) = self.focused_window() {
|
||||
window.restore_window();
|
||||
window.restore_window()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Hides the unfocused windows of the container and restores the focused one. This function
|
||||
/// is used to make sure we update the window that should be shown on a stack. If the container
|
||||
/// isn't a stack this function won't change anything.
|
||||
pub fn load_focused_window(&mut self) {
|
||||
pub fn load_focused_window(&mut self, spot: W::HideSpot) -> eyre::Result<()> {
|
||||
let focused_idx = self.focused_window_idx();
|
||||
|
||||
for (i, window) in self.windows_mut().iter_mut().enumerate() {
|
||||
if i == focused_idx {
|
||||
window.restore_stacked();
|
||||
window.restore_stacked()?;
|
||||
} else {
|
||||
window.hide_stacked();
|
||||
window.hide_stacked(spot)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The index of the first window of the executable `exe` in this container
|
||||
@@ -238,7 +254,7 @@ impl<W: ContainerWindow> Container<W> {
|
||||
|
||||
/// Puts a window at the back of the container and gives it the front, hiding every other
|
||||
/// window of the container ([`ContainerWindow::hide_window`])
|
||||
pub fn add_window(&mut self, window: W) {
|
||||
pub fn add_window(&mut self, window: W, spot: W::HideSpot) -> eyre::Result<()> {
|
||||
self.windows_mut().push_back(window);
|
||||
self.focus_window(self.windows().len().saturating_sub(1));
|
||||
|
||||
@@ -246,9 +262,11 @@ impl<W: ContainerWindow> Container<W> {
|
||||
|
||||
for (i, window) in self.windows().iter().enumerate() {
|
||||
if i != focused_window_idx {
|
||||
window.hide_window();
|
||||
window.hide_window(spot)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Gives the front to the window at `idx`
|
||||
@@ -275,8 +293,12 @@ mod tests {
|
||||
LOG.with(|log| std::mem::take(&mut *log.borrow_mut()))
|
||||
}
|
||||
|
||||
/// the spot that the tests ask windows to be hidden at
|
||||
const SPOT: u8 = 7;
|
||||
|
||||
impl ContainerWindow for Stub {
|
||||
type Id = u32;
|
||||
type HideSpot = u8;
|
||||
|
||||
fn id(&self) -> u32 {
|
||||
self.0
|
||||
@@ -286,20 +308,24 @@ mod tests {
|
||||
Some(format!("exe{}", self.0))
|
||||
}
|
||||
|
||||
fn hide_window(&self) {
|
||||
LOG.with(|log| log.borrow_mut().push(format!("hide {}", self.0)));
|
||||
fn hide_window(&self, spot: u8) -> eyre::Result<()> {
|
||||
LOG.with(|log| log.borrow_mut().push(format!("hide {} at {spot}", self.0)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_window(&self) {
|
||||
fn restore_window(&self) -> eyre::Result<()> {
|
||||
LOG.with(|log| log.borrow_mut().push(format!("restore {}", self.0)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn hide_stacked(&self) {
|
||||
LOG.with(|log| log.borrow_mut().push(format!("hide-stacked {}", self.0)));
|
||||
fn hide_stacked(&self, spot: u8) -> eyre::Result<()> {
|
||||
LOG.with(|log| log.borrow_mut().push(format!("hide-stacked {} at {spot}", self.0)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_stacked(&self) {
|
||||
fn restore_stacked(&self) -> eyre::Result<()> {
|
||||
LOG.with(|log| log.borrow_mut().push(format!("restore-stacked {}", self.0)));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,7 +360,7 @@ mod tests {
|
||||
fn container_of(ids: &[u32]) -> Container<Stub> {
|
||||
let mut container = Container::default();
|
||||
for id in ids {
|
||||
container.add_window(Stub(*id));
|
||||
container.add_window(Stub(*id), SPOT).unwrap();
|
||||
}
|
||||
log();
|
||||
container
|
||||
@@ -393,11 +419,11 @@ mod tests {
|
||||
#[test]
|
||||
fn a_window_added_is_in_front_and_the_others_are_hidden() {
|
||||
let mut container = Container::default();
|
||||
container.add_window(Stub(1));
|
||||
container.add_window(Stub(2));
|
||||
container.add_window(Stub(1), SPOT).unwrap();
|
||||
container.add_window(Stub(2), SPOT).unwrap();
|
||||
|
||||
assert_eq!(container.focused_window(), Some(&Stub(2)));
|
||||
assert_eq!(log(), ["hide 1"]);
|
||||
assert_eq!(log(), ["hide 1 at 7"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -405,11 +431,11 @@ mod tests {
|
||||
let mut container = container_of(&[1, 2, 3]);
|
||||
container.focus_window(0);
|
||||
|
||||
container.load_focused_window();
|
||||
container.load_focused_window(SPOT).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
log(),
|
||||
["restore-stacked 1", "hide-stacked 2", "hide-stacked 3"]
|
||||
["restore-stacked 1", "hide-stacked 2 at 7", "hide-stacked 3 at 7"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -418,13 +444,13 @@ mod tests {
|
||||
let mut container = container_of(&[7, 8, 9]);
|
||||
container.focus_window(1);
|
||||
|
||||
container.hide(Some(9));
|
||||
assert_eq!(log(), ["hide 8", "hide 7"]);
|
||||
container.hide(Some(9), SPOT).unwrap();
|
||||
assert_eq!(log(), ["hide 8 at 7", "hide 7 at 7"]);
|
||||
|
||||
container.hide(None);
|
||||
assert_eq!(log(), ["hide 9", "hide 8", "hide 7"]);
|
||||
container.hide(None, SPOT).unwrap();
|
||||
assert_eq!(log(), ["hide 9 at 7", "hide 8 at 7", "hide 7 at 7"]);
|
||||
|
||||
container.restore();
|
||||
container.restore().unwrap();
|
||||
assert_eq!(log(), ["restore 8"]);
|
||||
}
|
||||
|
||||
@@ -449,8 +475,8 @@ mod tests {
|
||||
r#"{"id":"c1","locked":true,"windows":{"elements":[],"focused":0}}"#
|
||||
);
|
||||
|
||||
container.add_window(Stub(5));
|
||||
container.add_window(Stub(9));
|
||||
container.add_window(Stub(5), SPOT).unwrap();
|
||||
container.add_window(Stub(9), SPOT).unwrap();
|
||||
container.focus_window(0);
|
||||
|
||||
assert_eq!(
|
||||
|
||||
@@ -248,6 +248,7 @@ mod tests {
|
||||
|
||||
impl ContainerWindow for W {
|
||||
type Id = u32;
|
||||
type HideSpot = ();
|
||||
|
||||
fn id(&self) -> u32 {
|
||||
self.0
|
||||
@@ -257,13 +258,21 @@ mod tests {
|
||||
None
|
||||
}
|
||||
|
||||
fn hide_window(&self) {}
|
||||
fn hide_window(&self, _spot: ()) -> color_eyre::eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_window(&self) {}
|
||||
fn restore_window(&self) -> color_eyre::eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn hide_stacked(&self) {}
|
||||
fn hide_stacked(&self, _spot: ()) -> color_eyre::eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_stacked(&self) {}
|
||||
fn restore_stacked(&self) -> color_eyre::eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl WorkspaceWindow for W {
|
||||
|
||||
@@ -43,6 +43,9 @@ use std::num::NonZeroUsize;
|
||||
/// What names a window of the platform `P`: the id the shared code compares.
|
||||
pub type PlatformWindowId<P> = <<P as WorkspacePlatform>::Window as ContainerWindow>::Id;
|
||||
|
||||
/// What a window of the platform `P` is hidden at.
|
||||
pub type PlatformHideSpot<P> = <<P as WorkspacePlatform>::Window as ContainerWindow>::HideSpot;
|
||||
|
||||
/// What the shared [`Workspace`] needs of a platform.
|
||||
pub trait WorkspacePlatform: Sized + Clone + std::fmt::Debug + PartialEq + 'static {
|
||||
/// The platform's window handle.
|
||||
@@ -56,6 +59,21 @@ pub trait WorkspacePlatform: Sized + Clone + std::fmt::Debug + PartialEq + 'stat
|
||||
(None, None)
|
||||
}
|
||||
|
||||
/// Where a window of a workspace with these globals is hidden (macOS: the monitor's corner).
|
||||
/// Every shared function that hides or stacks a window asks for it, so the platform needs no
|
||||
/// other way to know the monitor.
|
||||
fn hide_spot(_globals: &WorkspaceGlobals) -> PlatformHideSpot<Self> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
/// Where the containers of a workspace that is being hidden ([`Workspace::hide`]) are hidden,
|
||||
/// when the platform knows the display of the monitor (macOS passes its bounds, so that a window
|
||||
/// that hangs over the edge of a display is parked on the display of its monitor). The floating
|
||||
/// windows of the workspace are hidden at [`WorkspacePlatform::hide_spot`].
|
||||
fn hide_spot_on_display(globals: &WorkspaceGlobals) -> PlatformHideSpot<Self> {
|
||||
Self::hide_spot(globals)
|
||||
}
|
||||
|
||||
/// The id of the window that has the focus, if any window does.
|
||||
fn foreground_window_id() -> Option<PlatformWindowId<Self>>;
|
||||
|
||||
@@ -454,6 +472,8 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
&mut self,
|
||||
window_id: PlatformWindowId<P>,
|
||||
) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
|
||||
let container_idx = self
|
||||
.container_idx_for_window(window_id)
|
||||
.ok_or_eyre("there is no container/window")?;
|
||||
@@ -476,7 +496,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
container.focus_window(window_idx);
|
||||
|
||||
if should_load {
|
||||
container.load_focused_window();
|
||||
container.load_focused_window(spot)?;
|
||||
}
|
||||
|
||||
self.focus_container(container_idx);
|
||||
@@ -488,7 +508,8 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
/// preselection reserved, if there is one, and otherwise at the index the workspace's initial
|
||||
/// window placement rules give it ([`Workspace::initial_window_placement_rules`]), which is
|
||||
/// after the focused container unless they say otherwise (at the start of an empty workspace)
|
||||
pub fn new_container_for_window(&mut self, window: P::Window) {
|
||||
pub fn new_container_for_window(&mut self, window: P::Window) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let next_idx = if let Some(idx) = self.preselected_container_idx {
|
||||
let next = idx;
|
||||
self.preselected_container_idx = None;
|
||||
@@ -503,9 +524,11 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
};
|
||||
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
container.add_window(window, spot)?;
|
||||
|
||||
self.insert_container_at_idx(next_idx, container);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Resolves the container index at which a new window should be placed,
|
||||
@@ -775,6 +798,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
/// There is no focused container or window, or no container at the target's index (counted
|
||||
/// after the container the window left has been removed, if it goes).
|
||||
pub fn move_window_to_container(&mut self, target_container_idx: usize) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let focused_idx = self.focused_container_idx();
|
||||
|
||||
let container = self
|
||||
@@ -795,7 +819,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
target_container_idx
|
||||
}
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
container.load_focused_window(spot)?;
|
||||
target_container_idx
|
||||
};
|
||||
|
||||
@@ -804,12 +828,12 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
.get_mut(adjusted_target_container_index)
|
||||
.ok_or_eyre("there is no container")?;
|
||||
|
||||
target_container.add_window(window);
|
||||
target_container.add_window(window, spot)?;
|
||||
|
||||
self.focus_container(adjusted_target_container_index);
|
||||
self.focused_container_mut()
|
||||
.ok_or_eyre("there is no container")?
|
||||
.load_focused_window();
|
||||
.load_focused_window(spot)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -823,6 +847,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
///
|
||||
/// There is no focused container or window.
|
||||
pub fn new_container_for_focused_window(&mut self) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let focused_container_idx = self.focused_container_idx();
|
||||
|
||||
let container = self
|
||||
@@ -836,13 +861,13 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
if container.windows().is_empty() {
|
||||
self.remove_container_by_idx(focused_container_idx);
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
container.load_focused_window(spot)?;
|
||||
}
|
||||
|
||||
self.new_container_for_window(window.clone());
|
||||
self.new_container_for_window(window.clone())?;
|
||||
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
container.add_window(window, spot)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -890,6 +915,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
///
|
||||
/// The workspace has no containers.
|
||||
pub fn new_monocle_container(&mut self) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let focused_idx = self.focused_container_idx();
|
||||
|
||||
// we shouldn't use remove_container_by_idx here because it doesn't make sense for
|
||||
@@ -911,7 +937,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
self.monocle_container
|
||||
.as_mut()
|
||||
.ok_or_eyre("there is no monocle container")?
|
||||
.load_focused_window();
|
||||
.load_focused_window(spot)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -948,6 +974,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
///
|
||||
/// The workspace has no monocle container.
|
||||
pub fn reintegrate_monocle_container(&mut self) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let restore_idx = self
|
||||
.monocle_container_restore_idx
|
||||
.ok_or_eyre("there is no monocle restore index")?;
|
||||
@@ -971,7 +998,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
|
||||
self.focused_container_mut()
|
||||
.ok_or_eyre("there is no container")?
|
||||
.load_focused_window();
|
||||
.load_focused_window(spot)?;
|
||||
|
||||
self.monocle_container = None;
|
||||
self.monocle_container_restore_idx = None;
|
||||
@@ -986,13 +1013,14 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
///
|
||||
/// The window the compositor has focused is not a floating window of the workspace.
|
||||
pub fn new_container_for_floating_window(&mut self) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let focused_idx = self.focused_container_idx();
|
||||
let window = self
|
||||
.remove_focused_floating_window()
|
||||
.ok_or_eyre("there is no floating window")?;
|
||||
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
container.add_window(window, spot)?;
|
||||
|
||||
self.insert_container_at_idx(focused_idx, container);
|
||||
|
||||
@@ -1392,6 +1420,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
/// Takes the focused window of the workspace (the maximized one, the monocle's or the focused
|
||||
/// container's) out of its place and makes it a floating window.
|
||||
pub fn new_floating_window(&mut self) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let window = if let Some(maximized_window) = self.maximized_window.clone() {
|
||||
P::unmaximize_window(&maximized_window)?;
|
||||
self.maximized_window = None;
|
||||
@@ -1406,7 +1435,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
self.monocle_container = None;
|
||||
self.monocle_container_restore_idx = None;
|
||||
} else {
|
||||
monocle_container.load_focused_window();
|
||||
monocle_container.load_focused_window(spot)?;
|
||||
}
|
||||
|
||||
window
|
||||
@@ -1428,7 +1457,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
self.focus_container(focused_idx.saturating_sub(1));
|
||||
}
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
container.load_focused_window(spot)?;
|
||||
}
|
||||
|
||||
window
|
||||
@@ -1441,7 +1470,10 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
|
||||
/// Hides every window of the workspace, or every one but `omit`: the floating windows and the
|
||||
/// windows of every container, the maximized window and the monocle container.
|
||||
pub fn hide(&mut self, omit: Option<PlatformWindowId<P>>) {
|
||||
pub fn hide(&mut self, omit: Option<PlatformWindowId<P>>) -> eyre::Result<()> {
|
||||
let spot = P::hide_spot(&self.globals);
|
||||
let display_spot = P::hide_spot_on_display(&self.globals);
|
||||
|
||||
for window in self.floating_windows_mut().iter_mut().rev() {
|
||||
let mut should_hide = omit.is_none();
|
||||
|
||||
@@ -1452,15 +1484,17 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
should_hide = true
|
||||
}
|
||||
|
||||
if should_hide {
|
||||
window.hide_window();
|
||||
if should_hide && let Err(error) = window.hide_window(spot) {
|
||||
tracing::warn!(
|
||||
"failed to hide floating window, but this might be because it is already hidden: {error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let resize_dimensions = P::before_hide_containers(self);
|
||||
|
||||
for container in self.containers_mut() {
|
||||
container.hide(omit);
|
||||
container.hide(omit, display_spot)?;
|
||||
}
|
||||
|
||||
if let Some(resize_dimensions) = resize_dimensions {
|
||||
@@ -1468,12 +1502,14 @@ impl<P: WorkspacePlatform> Workspace<P> {
|
||||
}
|
||||
|
||||
if let Some(window) = &self.maximized_window {
|
||||
window.hide_window();
|
||||
window.hide_window(spot)?;
|
||||
}
|
||||
|
||||
if let Some(container) = &mut self.monocle_container {
|
||||
container.hide(omit);
|
||||
container.hide(omit, display_spot)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1485,15 +1521,21 @@ mod tests {
|
||||
struct W(u32);
|
||||
|
||||
thread_local! {
|
||||
static HIDDEN: std::cell::RefCell<Vec<u32>> = const { std::cell::RefCell::new(Vec::new()) };
|
||||
static HIDDEN: std::cell::RefCell<Vec<(u32, u8)>> = const { std::cell::RefCell::new(Vec::new()) };
|
||||
}
|
||||
|
||||
fn hidden() -> Vec<u32> {
|
||||
/// the spot that `Plat` asks windows to be hidden at, and the one for the containers of a
|
||||
/// workspace that is being hidden
|
||||
const SPOT: u8 = 7;
|
||||
const DISPLAY_SPOT: u8 = 9;
|
||||
|
||||
fn hidden() -> Vec<(u32, u8)> {
|
||||
HIDDEN.with(|hidden| std::mem::take(&mut *hidden.borrow_mut()))
|
||||
}
|
||||
|
||||
impl ContainerWindow for W {
|
||||
type Id = u32;
|
||||
type HideSpot = u8;
|
||||
|
||||
fn id(&self) -> u32 {
|
||||
self.0
|
||||
@@ -1503,15 +1545,23 @@ mod tests {
|
||||
Some(format!("exe{}", self.0))
|
||||
}
|
||||
|
||||
fn hide_window(&self) {
|
||||
HIDDEN.with(|hidden| hidden.borrow_mut().push(self.0));
|
||||
fn hide_window(&self, spot: u8) -> eyre::Result<()> {
|
||||
HIDDEN.with(|hidden| hidden.borrow_mut().push((self.0, spot)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_window(&self) {}
|
||||
fn restore_window(&self) -> eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn hide_stacked(&self) {}
|
||||
fn hide_stacked(&self, spot: u8) -> eyre::Result<()> {
|
||||
HIDDEN.with(|hidden| hidden.borrow_mut().push((self.0, spot)));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_stacked(&self) {}
|
||||
fn restore_stacked(&self) -> eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl WorkspaceWindow for W {
|
||||
@@ -1539,6 +1589,14 @@ mod tests {
|
||||
type Window = W;
|
||||
type State = ();
|
||||
|
||||
fn hide_spot(_globals: &WorkspaceGlobals) -> u8 {
|
||||
SPOT
|
||||
}
|
||||
|
||||
fn hide_spot_on_display(_globals: &WorkspaceGlobals) -> u8 {
|
||||
DISPLAY_SPOT
|
||||
}
|
||||
|
||||
fn foreground_window_id() -> Option<u32> {
|
||||
Some(2)
|
||||
}
|
||||
@@ -1584,7 +1642,7 @@ mod tests {
|
||||
fn workspace_of(ids: &[u32]) -> Workspace<Plat> {
|
||||
let mut workspace = Workspace::<Plat>::default();
|
||||
for id in ids {
|
||||
workspace.new_container_for_window(W(*id));
|
||||
workspace.new_container_for_window(W(*id)).unwrap();
|
||||
}
|
||||
workspace
|
||||
}
|
||||
@@ -1653,11 +1711,25 @@ mod tests {
|
||||
workspace.floating_windows_mut().push_back(W(9));
|
||||
hidden();
|
||||
|
||||
workspace.hide(Some(2));
|
||||
workspace.hide(Some(2)).unwrap();
|
||||
|
||||
let mut hidden = hidden();
|
||||
hidden.sort();
|
||||
assert_eq!(hidden, [1, 3, 9]);
|
||||
// the floating window at the spot of a window, the containers at the one for a display
|
||||
assert_eq!(hidden, [(1, DISPLAY_SPOT), (3, DISPLAY_SPOT), (9, SPOT)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_functions_that_stack_and_unstack_hide_at_the_spot_of_the_platform() {
|
||||
let mut workspace = workspace_of(&[1, 2]);
|
||||
hidden();
|
||||
|
||||
// stacking window 2 on container 0 hides window 1, which was in front, at the spot
|
||||
workspace.focus_container(1);
|
||||
workspace.move_window_to_container(0).unwrap();
|
||||
|
||||
// once by add_window, once by load_focused_window, both at the platform's spot
|
||||
assert_eq!(hidden(), [(1, SPOT), (1, SPOT)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//! ([`Container::load_focused_window`](komorebi_core::Container::load_focused_window)).
|
||||
|
||||
use crate::window::Window;
|
||||
use color_eyre::eyre;
|
||||
use komorebi_core::ContainerWindow;
|
||||
use komorebi_core::WorkspaceWindow;
|
||||
|
||||
@@ -16,6 +17,7 @@ pub type Container = komorebi_core::Container<Window>;
|
||||
|
||||
impl ContainerWindow for Window {
|
||||
type Id = u32;
|
||||
type HideSpot = ();
|
||||
|
||||
fn id(&self) -> u32 {
|
||||
self.id
|
||||
@@ -25,20 +27,24 @@ impl ContainerWindow for Window {
|
||||
self.exe()
|
||||
}
|
||||
|
||||
fn hide_window(&self) {
|
||||
fn hide_window(&self, _spot: ()) -> eyre::Result<()> {
|
||||
self.hide();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_window(&self) {
|
||||
fn restore_window(&self) -> eyre::Result<()> {
|
||||
self.restore();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn hide_stacked(&self) {
|
||||
fn hide_stacked(&self, _spot: ()) -> eyre::Result<()> {
|
||||
self.hide();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_stacked(&self) {
|
||||
fn restore_stacked(&self) -> eyre::Result<()> {
|
||||
self.restore();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +88,8 @@ mod tests {
|
||||
r#"{"id":"c1","locked":true,"windows":{"elements":[],"focused":0}}"#
|
||||
);
|
||||
|
||||
container.add_window(Window::from(5));
|
||||
container.add_window(Window::from(9));
|
||||
let _ = container.add_window(Window::from(5), ());
|
||||
let _ = container.add_window(Window::from(9), ());
|
||||
container.focus_window(0);
|
||||
|
||||
let json = serde_json::to_string(&container).unwrap();
|
||||
@@ -114,7 +120,7 @@ mod tests {
|
||||
let mut container = Container::default();
|
||||
for id in ids {
|
||||
fake.open_window(id, "foot", "foot", &format!("window {id}"));
|
||||
container.add_window(Window::from(id));
|
||||
let _ = container.add_window(Window::from(id), ());
|
||||
}
|
||||
container.focus_window(focus);
|
||||
container
|
||||
@@ -140,7 +146,7 @@ mod tests {
|
||||
with_backend(fake.clone(), || {
|
||||
let mut container = stack_of(&fake, 704..=706, 0);
|
||||
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
|
||||
assert!(!fake.is_hidden(704));
|
||||
assert!(fake.is_hidden(705) && fake.is_hidden(706));
|
||||
@@ -155,13 +161,13 @@ mod tests {
|
||||
with_backend(fake.clone(), || {
|
||||
let container = stack_of(&fake, 707..=709, 1);
|
||||
|
||||
container.hide(Some(709));
|
||||
let _ = container.hide(Some(709), ());
|
||||
assert!(fake.is_hidden(707) && fake.is_hidden(708) && !fake.is_hidden(709));
|
||||
|
||||
container.hide(None);
|
||||
let _ = container.hide(None, ());
|
||||
assert!(fake.is_hidden(709));
|
||||
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
assert!(fake.is_hidden(707) && !fake.is_hidden(708) && fake.is_hidden(709));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ impl MonitorExt for Monitor {
|
||||
|
||||
if target_workspace.monocle_container.is_some() {
|
||||
for container in target_workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
for window in target_workspace.floating_windows_mut() {
|
||||
@@ -830,7 +830,7 @@ mod tests {
|
||||
"Virtual-0",
|
||||
"Virtual-0",
|
||||
);
|
||||
m.focused_workspace_mut()
|
||||
let _ = m.focused_workspace_mut()
|
||||
.unwrap()
|
||||
.new_container_for_window(Window::from(id));
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
if let Some(to) = monitor.workspaces_mut().get_mut(idx) {
|
||||
to.new_container_for_window(window);
|
||||
let _ = to.new_container_for_window(window);
|
||||
}
|
||||
|
||||
// whichever of the two is showing needs its tiles redone
|
||||
@@ -434,7 +434,7 @@ impl WindowManager {
|
||||
} else {
|
||||
match behaviour.current_behaviour {
|
||||
WindowContainerBehaviour::Create => {
|
||||
workspace.new_container_for_window(window);
|
||||
let _ = workspace.new_container_for_window(window);
|
||||
workspace.layer = WorkspaceLayer::Tiling;
|
||||
self.update_focused_workspace(false, false)?;
|
||||
}
|
||||
@@ -442,7 +442,7 @@ impl WindowManager {
|
||||
workspace
|
||||
.focused_container_mut()
|
||||
.ok_or_eyre("there is no focused container")?
|
||||
.add_window(window);
|
||||
.add_window(window, ())?;
|
||||
workspace.layer = WorkspaceLayer::Tiling;
|
||||
self.update_focused_workspace(true, false)?;
|
||||
}
|
||||
@@ -556,7 +556,7 @@ impl WindowManager {
|
||||
None => {}
|
||||
Some(window) => {
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
workspace.new_container_for_window(window);
|
||||
let _ = workspace.new_container_for_window(window);
|
||||
self.update_focused_workspace(false, false)?;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -353,7 +353,7 @@ impl WindowManager {
|
||||
if let Some(window) = maximized {
|
||||
let id = window.id;
|
||||
let mut container = crate::container::Container::default();
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
place(
|
||||
self,
|
||||
Some(window),
|
||||
|
||||
@@ -724,7 +724,7 @@ impl WorkspaceScrolling for Workspace {
|
||||
|
||||
if let Some(container) = self.containers_mut().get_mut(idx) {
|
||||
for window in windows {
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
}
|
||||
|
||||
// the window that had focus is the one that is showing
|
||||
@@ -734,7 +734,7 @@ impl WorkspaceScrolling for Workspace {
|
||||
container.focus_window(at);
|
||||
}
|
||||
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
}
|
||||
|
||||
self.focus_container(idx);
|
||||
@@ -763,17 +763,17 @@ impl WorkspaceScrolling for Workspace {
|
||||
|
||||
// the window that stays was one of the tabs, and may be the one that was out of sight, so
|
||||
// it is put where it is shown as well, or its column is left empty until focus reaches it
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
|
||||
// the strip is about to be told that there are more containers than it has columns for,
|
||||
// and so each of them is a column, until they are put in this one
|
||||
let mut count = 0;
|
||||
for (offset, window) in rest.into_iter().enumerate() {
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
|
||||
// it was one of the tabs that were out of sight, and has to be put where it is shown
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
|
||||
self.insert_container_at_idx(idx + 1 + offset, container);
|
||||
count += 1;
|
||||
@@ -946,7 +946,7 @@ mod tests {
|
||||
|
||||
for id in first..first + count {
|
||||
let mut container = Container::default();
|
||||
container.add_window(Window::from(id));
|
||||
let _ = container.add_window(Window::from(id), ());
|
||||
let idx = workspace.containers().len();
|
||||
workspace.insert_container_at_idx(idx, container);
|
||||
}
|
||||
@@ -969,7 +969,7 @@ mod tests {
|
||||
|
||||
for id in 2..=5 {
|
||||
let mut container = Container::default();
|
||||
container.add_window(Window::from(id));
|
||||
let _ = container.add_window(Window::from(id), ());
|
||||
let idx = workspace
|
||||
.scrolling_insertion_idx()
|
||||
.unwrap_or_else(|| workspace.containers().len());
|
||||
@@ -1176,7 +1176,7 @@ mod tests {
|
||||
let idx = workspace.focused_container_idx();
|
||||
let container = workspace.containers_mut().get_mut(idx).unwrap();
|
||||
container.focus_window(focused);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
assert!(HIDDEN_WINDOWS.lock().contains(&hidden));
|
||||
|
||||
assert!(workspace.toggle_scrolling_column_stack().unwrap());
|
||||
@@ -1216,7 +1216,7 @@ mod tests {
|
||||
..Workspace::default()
|
||||
};
|
||||
let mut container = Container::default();
|
||||
container.add_window(Window::from(9101));
|
||||
let _ = container.add_window(Window::from(9101), ());
|
||||
workspace.insert_container_at_idx(0, container);
|
||||
|
||||
workspace.expand_scrolling_column();
|
||||
|
||||
@@ -1326,7 +1326,7 @@ impl WindowManager {
|
||||
}
|
||||
}
|
||||
if changed_focus && let Some(container) = workspace.focused_container_mut() {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(mouse_follows_focus)?;
|
||||
}
|
||||
@@ -1444,7 +1444,7 @@ impl WindowManager {
|
||||
let next_idx = direction.next_idx(current_idx, len);
|
||||
|
||||
container.focus_window(next_idx);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(mouse_follows_focus)?;
|
||||
@@ -1637,7 +1637,7 @@ impl WindowManager {
|
||||
workspace.new_monocle_container()?;
|
||||
|
||||
for container in workspace.containers_mut() {
|
||||
container.hide(None);
|
||||
let _ = container.hide(None, ());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1656,7 +1656,7 @@ impl WindowManager {
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
|
||||
for container in workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
workspace.reintegrate_monocle_container()
|
||||
@@ -1684,7 +1684,7 @@ impl WindowManager {
|
||||
.cycle_monocle_container(direction)?;
|
||||
|
||||
for container in self.focused_workspace_mut()?.containers_mut() {
|
||||
container.hide(None);
|
||||
let _ = container.hide(None, ());
|
||||
}
|
||||
|
||||
self.update_focused_workspace(true, true)
|
||||
@@ -2518,7 +2518,7 @@ impl WindowManager {
|
||||
|
||||
if target_workspace.monocle_container.is_some() {
|
||||
for container in target_workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
for window in target_workspace.floating_windows_mut() {
|
||||
@@ -2848,7 +2848,7 @@ impl WindowManager {
|
||||
container.windows_mut().swap(current_idx, next_idx);
|
||||
|
||||
container.focus_window(next_idx);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(mouse_follows_focus)?;
|
||||
@@ -2890,7 +2890,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
container.focus_window(idx);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(mouse_follows_focus)?;
|
||||
@@ -2937,7 +2937,7 @@ impl WindowManager {
|
||||
&& let Some(w_idx_to_focus) = c.idx_for_window(hwnd)
|
||||
{
|
||||
c.focus_window(w_idx_to_focus);
|
||||
c.load_focused_window();
|
||||
let _ = c.load_focused_window(());
|
||||
}
|
||||
self.update_focused_workspace(self.mouse_follows_focus, true)
|
||||
}
|
||||
@@ -3185,7 +3185,7 @@ impl WindowManager {
|
||||
//workspace `window_container_behaviour` in my opinion! Maybe this should be done
|
||||
//on the `new_container_for_window` function instead.
|
||||
// TODO: not sure about this clone
|
||||
target_workspace.new_container_for_window(*window);
|
||||
let _ = target_workspace.new_container_for_window(*window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3918,7 +3918,7 @@ impl WindowManager {
|
||||
.ok_or_eyre("there is no workspace for this monitor")?;
|
||||
|
||||
for container in origin_workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
origin_workspace.reintegrate_monocle_container()?;
|
||||
|
||||
@@ -544,7 +544,7 @@ impl WorkspaceExt for Workspace {
|
||||
}
|
||||
|
||||
for c in self.containers_mut() {
|
||||
c.restore();
|
||||
let _ = c.restore();
|
||||
}
|
||||
|
||||
return Ok(window);
|
||||
@@ -577,7 +577,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.focus_previous_container();
|
||||
}
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(false)?;
|
||||
}
|
||||
@@ -593,7 +593,7 @@ impl WorkspaceExt for Workspace {
|
||||
monitor_wp: &Option<Wallpaper>,
|
||||
) -> eyre::Result<()> {
|
||||
if let Some(container) = &mut self.monocle_container {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(mouse_follows_focus)?;
|
||||
@@ -614,7 +614,7 @@ impl WorkspaceExt for Workspace {
|
||||
}
|
||||
|
||||
for container in self.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
if let Some(container) = self.focused_container_mut() {
|
||||
@@ -672,7 +672,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.monocle_container = None;
|
||||
self.monocle_container_restore_idx = None;
|
||||
} else {
|
||||
monocle_container.load_focused_window();
|
||||
let _ = monocle_container.load_focused_window(());
|
||||
}
|
||||
|
||||
self.maximized_window = Option::from(window);
|
||||
@@ -699,7 +699,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.resize_dimensions.remove(focused_idx);
|
||||
}
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
}
|
||||
|
||||
self.maximized_window = Option::from(window);
|
||||
@@ -742,7 +742,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.monocle_container = None;
|
||||
self.monocle_container_restore_idx = None;
|
||||
} else {
|
||||
monocle_container.load_focused_window();
|
||||
let _ = monocle_container.load_focused_window(());
|
||||
}
|
||||
|
||||
self.maximized_window = Option::from(window);
|
||||
@@ -776,7 +776,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.resize_dimensions.remove(container_idx);
|
||||
}
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
}
|
||||
|
||||
self.maximized_window = Option::from(window);
|
||||
@@ -804,7 +804,7 @@ impl WorkspaceExt for Workspace {
|
||||
}
|
||||
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
|
||||
// we shouldn't use insert_container_at_index here because it doesn't make sense for
|
||||
// monocle and maximized toggles which take over the whole screen before being reinserted
|
||||
@@ -1217,7 +1217,7 @@ mod tests {
|
||||
ws.focus_container(2);
|
||||
|
||||
// simulate a new window being launched on this workspace
|
||||
ws.new_container_for_window(Window::from(123));
|
||||
let _ = ws.new_container_for_window(Window::from(123));
|
||||
|
||||
// new length should be 5, with the focus on the new window at index 4
|
||||
assert_eq!(ws.containers().len(), 5);
|
||||
@@ -1229,7 +1229,7 @@ mod tests {
|
||||
|
||||
// when inserting a new container at index 0, index 3's container should not change
|
||||
ws.focus_container(0);
|
||||
ws.new_container_for_window(Window::from(234));
|
||||
let _ = ws.new_container_for_window(Window::from(234));
|
||||
assert_eq!(
|
||||
ws.containers()[3].id.to_string(),
|
||||
state.get(&3).unwrap().to_string()
|
||||
@@ -1288,7 +1288,7 @@ mod tests {
|
||||
// new_container_for_floating_window which usually handles unfloating
|
||||
let window = ws.floating_windows_mut().pop_back().unwrap();
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
ws.insert_container_at_idx(ws.focused_container_idx(), container);
|
||||
|
||||
// all indexes should be at their original position
|
||||
@@ -1729,7 +1729,7 @@ mod tests {
|
||||
}
|
||||
|
||||
// Add new window to container
|
||||
workspace.new_container_for_window(Window::from(2));
|
||||
let _ = workspace.new_container_for_window(Window::from(2));
|
||||
|
||||
// Container 0 should have 1 window
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
@@ -2117,7 +2117,7 @@ mod tests {
|
||||
|
||||
for id in ids {
|
||||
fake.open_window(*id, "foot", "foot", &format!("terminal {id}"));
|
||||
workspace.new_container_for_window(Window::from(*id));
|
||||
let _ = workspace.new_container_for_window(Window::from(*id));
|
||||
}
|
||||
|
||||
(fake, workspace)
|
||||
@@ -2210,10 +2210,10 @@ mod tests {
|
||||
fn hiding_a_workspace_hides_every_window_but_the_one_it_is_told_to_leave() -> eyre::Result<()> {
|
||||
let (fake, mut workspace) = workspace_with_a_stack(&[471, 472, 473]);
|
||||
|
||||
with_backend(fake.clone(), || workspace.hide(Some(471)));
|
||||
let _ = with_backend(fake.clone(), || workspace.hide(Some(471)));
|
||||
assert!(!fake.is_hidden(471) && fake.is_hidden(472) && fake.is_hidden(473));
|
||||
|
||||
with_backend(fake.clone(), || workspace.hide(None));
|
||||
let _ = with_backend(fake.clone(), || workspace.hide(None));
|
||||
assert!(fake.is_hidden(471));
|
||||
Ok(())
|
||||
}
|
||||
@@ -2225,7 +2225,7 @@ mod tests {
|
||||
with_backend(fake.clone(), || {
|
||||
workspace.new_monocle_container().unwrap();
|
||||
for container in workspace.containers_mut() {
|
||||
container.hide(None);
|
||||
let _ = container.hide(None, ());
|
||||
}
|
||||
});
|
||||
(fake, workspace)
|
||||
@@ -2236,7 +2236,7 @@ mod tests {
|
||||
{
|
||||
let (fake, mut workspace) = workspace_in_monocle(&[481, 482, 483]);
|
||||
assert!(fake.is_hidden(481) && fake.is_hidden(482) && !fake.is_hidden(483));
|
||||
with_backend(fake.clone(), || workspace.hide(None));
|
||||
let _ = with_backend(fake.clone(), || workspace.hide(None));
|
||||
assert!(
|
||||
fake.is_hidden(483),
|
||||
"leaving the workspace hides the monocle window too"
|
||||
@@ -2256,7 +2256,7 @@ mod tests {
|
||||
fn hiding_a_workspace_in_monocle_hides_the_monocle_window_too() -> eyre::Result<()> {
|
||||
let (fake, mut workspace) = workspace_in_monocle(&[491, 492]);
|
||||
|
||||
with_backend(fake.clone(), || workspace.hide(None));
|
||||
let _ = with_backend(fake.clone(), || workspace.hide(None));
|
||||
|
||||
assert!(fake.is_hidden(491) && fake.is_hidden(492));
|
||||
Ok(())
|
||||
|
||||
@@ -319,7 +319,7 @@ fn a_maximized_window_is_hidden_with_its_workspace_and_shown_and_focused_with_it
|
||||
send(&fake, &mut wm, SocketMessage::ToggleMaximize);
|
||||
let workspace = wm.focused_workspace_mut().unwrap();
|
||||
|
||||
with_backend(fake.clone(), || workspace.hide(None));
|
||||
let _ = with_backend(fake.clone(), || workspace.hide(None));
|
||||
assert!(fake.is_hidden(36_071) && fake.is_hidden(36_072));
|
||||
|
||||
fake.clear_commands();
|
||||
|
||||
@@ -18,8 +18,20 @@ use objc2_core_foundation::CGRect;
|
||||
/// The windows that share one tile of a workspace's layout
|
||||
pub type Container = komorebi_core::Container<Window>;
|
||||
|
||||
/// Where the macOS daemon hides a window: the corner of the monitor and, when it is known, the
|
||||
/// bounds of the display of the monitor (a window that hangs over the edge of a display is not
|
||||
/// always on the display that a lookup by its position finds).
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq)]
|
||||
pub struct MacosHideSpot {
|
||||
/// The corner the window is parked in
|
||||
pub position: WindowHidingPosition,
|
||||
/// The bounds of the display, or `None` to look the display up by the window's position
|
||||
pub screen: Option<CGRect>,
|
||||
}
|
||||
|
||||
impl ContainerWindow for Window {
|
||||
type Id = u32;
|
||||
type HideSpot = MacosHideSpot;
|
||||
|
||||
fn id(&self) -> u32 {
|
||||
self.id
|
||||
@@ -29,27 +41,37 @@ impl ContainerWindow for Window {
|
||||
self.exe()
|
||||
}
|
||||
|
||||
/// Hides the window in the default corner. The macOS daemon does not hide through this: it
|
||||
/// uses [`ContainerExt`], which carries the monitor's corner and display, and logs a failure
|
||||
/// instead of ignoring it. This is the shared model's one-argument form.
|
||||
fn hide_window(&self) {
|
||||
if let Err(error) = self.hide(WindowHidingPosition::default()) {
|
||||
tracing::warn!("failed to hide window {}: {error}", self.id);
|
||||
fn hide_window(&self, spot: MacosHideSpot) -> eyre::Result<()> {
|
||||
// hiding moves the window through Accessibility, which a unit test does not have
|
||||
if cfg!(test) {
|
||||
tracing::info!(
|
||||
"not hiding window {} to {} during test execution",
|
||||
self.id,
|
||||
spot.position
|
||||
);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Ok(self.hide_on(spot.position, spot.screen)?)
|
||||
}
|
||||
|
||||
fn restore_window(&self) {
|
||||
if let Err(error) = self.restore() {
|
||||
tracing::warn!("failed to restore window {}: {error}", self.id);
|
||||
fn restore_window(&self) -> eyre::Result<()> {
|
||||
if cfg!(test) {
|
||||
tracing::info!("not restoring window {} during test execution", self.id);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Ok(self.restore()?)
|
||||
}
|
||||
|
||||
fn hide_stacked(&self) {
|
||||
self.hide_window();
|
||||
fn hide_stacked(&self, spot: MacosHideSpot) -> eyre::Result<()> {
|
||||
self.hide_window(spot)
|
||||
}
|
||||
|
||||
fn restore_stacked(&self) {
|
||||
self.restore_window();
|
||||
fn restore_stacked(&self) -> eyre::Result<()> {
|
||||
self.restore_window()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
use crate::window::Window;
|
||||
use crate::windows_backend::backend;
|
||||
use color_eyre::eyre;
|
||||
use komorebi_backend::WindowId;
|
||||
use komorebi_core::ContainerWindow;
|
||||
use komorebi_core::WorkspaceWindow;
|
||||
@@ -14,6 +15,7 @@ pub type Container = komorebi_core::Container<Window>;
|
||||
|
||||
impl ContainerWindow for Window {
|
||||
type Id = isize;
|
||||
type HideSpot = ();
|
||||
|
||||
fn id(&self) -> isize {
|
||||
self.hwnd
|
||||
@@ -23,20 +25,24 @@ impl ContainerWindow for Window {
|
||||
Window::exe(*self)
|
||||
}
|
||||
|
||||
fn hide_window(&self) {
|
||||
fn hide_window(&self, _spot: ()) -> eyre::Result<()> {
|
||||
let _ = backend().hide(WindowId::from_hwnd(self.hwnd));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_window(&self) {
|
||||
fn restore_window(&self) -> eyre::Result<()> {
|
||||
let _ = backend().restore(WindowId::from_hwnd(self.hwnd));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn hide_stacked(&self) {
|
||||
fn hide_stacked(&self, _spot: ()) -> eyre::Result<()> {
|
||||
self.hide_with_border(false);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_stacked(&self) {
|
||||
fn restore_stacked(&self) -> eyre::Result<()> {
|
||||
self.restore_with_border(false);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ impl MonitorExt for Monitor {
|
||||
if i == focused_idx {
|
||||
workspace.restore(mouse_follows_focus, hmonitor, &monitor_wp)?;
|
||||
} else {
|
||||
workspace.hide(None);
|
||||
let _ = workspace.hide(None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,11 +459,11 @@ impl MonitorExt for Monitor {
|
||||
|
||||
if target_workspace.monocle_container.is_some() {
|
||||
for container in target_workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
for window in target_workspace.floating_windows_mut() {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
}
|
||||
|
||||
target_workspace.reintegrate_monocle_container()?;
|
||||
|
||||
@@ -2326,7 +2326,7 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
||||
if i == focused_idx {
|
||||
to_focus = Some(*window);
|
||||
} else {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
backend().raise(WindowId::from_hwnd(window.hwnd))?;
|
||||
}
|
||||
}
|
||||
@@ -2334,7 +2334,7 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
||||
if let Some(focused_window) = &to_focus {
|
||||
// The focused window should be the last one raised to make sure it is
|
||||
// on top
|
||||
focused_window.restore_window();
|
||||
let _ = focused_window.restore_window();
|
||||
backend().raise(WindowId::from_hwnd(focused_window.hwnd))?;
|
||||
}
|
||||
|
||||
@@ -2359,7 +2359,7 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
||||
backend().raise(WindowId::from_hwnd(window.hwnd))?;
|
||||
}
|
||||
for window in workspace.floating_windows() {
|
||||
window.hide_window();
|
||||
let _ = window.hide_window(());
|
||||
}
|
||||
} else {
|
||||
let focused_container_idx = workspace.focused_container_idx();
|
||||
|
||||
@@ -514,7 +514,7 @@ impl WindowManager {
|
||||
"ignoring show event for window already associated with another workspace"
|
||||
);
|
||||
|
||||
window.hide_window();
|
||||
let _ = window.hide_window(());
|
||||
proceed = false;
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ impl WindowManager {
|
||||
} else {
|
||||
match behaviour.current_behaviour {
|
||||
WindowContainerBehaviour::Create => {
|
||||
workspace.new_container_for_window(window);
|
||||
let _ = workspace.new_container_for_window(window);
|
||||
workspace.layer = WorkspaceLayer::Tiling;
|
||||
self.update_focused_workspace(false, false)?;
|
||||
}
|
||||
@@ -606,7 +606,7 @@ impl WindowManager {
|
||||
workspace
|
||||
.focused_container_mut()
|
||||
.ok_or_eyre("there is no focused container")?
|
||||
.add_window(window);
|
||||
.add_window(window, ())?;
|
||||
workspace.layer = WorkspaceLayer::Tiling;
|
||||
self.update_focused_workspace(true, false)?;
|
||||
stackbar_manager::send_notification();
|
||||
@@ -643,7 +643,7 @@ impl WindowManager {
|
||||
if !(monocle_window_event || workspace.layer != WorkspaceLayer::Tiling)
|
||||
&& monocle_container.is_some()
|
||||
{
|
||||
window.hide_window();
|
||||
let _ = window.hide_window(());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1057,10 +1057,10 @@ impl WindowManager {
|
||||
if workspace.monocle_container.is_some() {
|
||||
tracing::info!("disabling monocle");
|
||||
for container in workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
for window in workspace.floating_windows_mut() {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
}
|
||||
workspace.reintegrate_monocle_container()?;
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ impl WorkspaceScrolling for Workspace {
|
||||
|
||||
if let Some(container) = self.containers_mut().get_mut(idx) {
|
||||
for window in windows {
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
}
|
||||
|
||||
// the window that had focus is the one that is showing
|
||||
@@ -702,7 +702,7 @@ impl WorkspaceScrolling for Workspace {
|
||||
}
|
||||
|
||||
if !cfg!(test) {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,17 +730,17 @@ impl WorkspaceScrolling for Workspace {
|
||||
|
||||
// the window that stays was one of the tabs, and may be the one that was out of sight, so
|
||||
// it is put where it is shown as well, or its column is left empty until focus reaches it
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
|
||||
// the strip is about to be told that there are more containers than it has columns for,
|
||||
// and so each of them is a column, until they are put in this one
|
||||
let mut count = 0;
|
||||
for (offset, window) in rest.into_iter().enumerate() {
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
|
||||
// it was one of the tabs that were out of sight, and has to be put where it is shown
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
|
||||
self.insert_container_at_idx(idx + 1 + offset, container);
|
||||
count += 1;
|
||||
@@ -942,7 +942,7 @@ mod tests {
|
||||
|
||||
for hwnd in first..first + count {
|
||||
let mut container = Container::default();
|
||||
container.add_window(Window::from(hwnd));
|
||||
let _ = container.add_window(Window::from(hwnd), ());
|
||||
let idx = workspace.containers().len();
|
||||
workspace.insert_container_at_idx(idx, container);
|
||||
}
|
||||
@@ -965,7 +965,7 @@ mod tests {
|
||||
|
||||
for hwnd in 2..=5 {
|
||||
let mut container = Container::default();
|
||||
container.add_window(Window::from(hwnd));
|
||||
let _ = container.add_window(Window::from(hwnd), ());
|
||||
let idx = workspace
|
||||
.scrolling_insertion_idx()
|
||||
.unwrap_or_else(|| workspace.containers().len());
|
||||
@@ -1172,7 +1172,7 @@ mod tests {
|
||||
let idx = workspace.focused_container_idx();
|
||||
let container = workspace.containers_mut().get_mut(idx).unwrap();
|
||||
container.focus_window(focused);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
assert!(HIDDEN_HWNDS.lock().contains(&hidden));
|
||||
|
||||
assert!(workspace.toggle_scrolling_column_stack().unwrap());
|
||||
@@ -1212,7 +1212,7 @@ mod tests {
|
||||
..Workspace::default()
|
||||
};
|
||||
let mut container = Container::default();
|
||||
container.add_window(Window::from(9101));
|
||||
let _ = container.add_window(Window::from(9101), ());
|
||||
workspace.insert_container_at_idx(0, container);
|
||||
|
||||
workspace.expand_scrolling_column();
|
||||
|
||||
@@ -710,7 +710,7 @@ impl WindowManager {
|
||||
|
||||
// Hide the window we are about to remove if it is on the currently focused workspace
|
||||
if op.is_origin(focused_monitor_idx, focused_workspace_idx) {
|
||||
window.hide_window();
|
||||
let _ = window.hide_window(());
|
||||
should_update_focused_workspace = true;
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ impl WindowManager {
|
||||
//when moving to another workspace by a `workspace_rule` should honor that
|
||||
//workspace `window_container_behaviour` in my opinion! Maybe this should be done
|
||||
//on the `new_container_for_window` function instead.
|
||||
target_workspace.new_container_for_window(Window::from(op.hwnd));
|
||||
let _ = target_workspace.new_container_for_window(Window::from(op.hwnd));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,7 +957,7 @@ impl WindowManager {
|
||||
.ok_or_eyre("there is no workspace for this monitor")?;
|
||||
let mut uncloack_amount = 0;
|
||||
for container in origin_workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
uncloack_amount += 1;
|
||||
}
|
||||
origin_workspace.reintegrate_monocle_container()?;
|
||||
@@ -1518,7 +1518,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
if !ignore_restore {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1762,11 +1762,11 @@ impl WindowManager {
|
||||
|
||||
if target_workspace.monocle_container.is_some() {
|
||||
for container in target_workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
for window in target_workspace.floating_windows_mut() {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
}
|
||||
|
||||
target_workspace.reintegrate_monocle_container()?;
|
||||
@@ -2760,7 +2760,7 @@ impl WindowManager {
|
||||
let next_idx = direction.next_idx(current_idx, len);
|
||||
|
||||
container.focus_window(next_idx);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(self.mouse_follows_focus)?;
|
||||
@@ -2797,7 +2797,7 @@ impl WindowManager {
|
||||
container.windows_mut().swap(current_idx, next_idx);
|
||||
|
||||
container.focus_window(next_idx);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(self.mouse_follows_focus)?;
|
||||
@@ -2830,7 +2830,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
container.focus_window(idx);
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(self.mouse_follows_focus)?;
|
||||
@@ -2872,7 +2872,7 @@ impl WindowManager {
|
||||
&& let Some(w_idx_to_focus) = c.idx_for_window(hwnd)
|
||||
{
|
||||
c.focus_window(w_idx_to_focus);
|
||||
c.load_focused_window();
|
||||
let _ = c.load_focused_window(());
|
||||
}
|
||||
self.update_focused_workspace(self.mouse_follows_focus, true)
|
||||
}
|
||||
@@ -2975,7 +2975,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
if changed_focus && let Some(container) = workspace.focused_container_mut() {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(self.mouse_follows_focus)?;
|
||||
}
|
||||
@@ -3175,11 +3175,11 @@ impl WindowManager {
|
||||
workspace.new_monocle_container()?;
|
||||
|
||||
for container in workspace.containers_mut() {
|
||||
container.hide(None);
|
||||
let _ = container.hide(None, ());
|
||||
}
|
||||
|
||||
for window in workspace.floating_windows_mut() {
|
||||
window.hide_window();
|
||||
let _ = window.hide_window(());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -3192,11 +3192,11 @@ impl WindowManager {
|
||||
let workspace = self.focused_workspace_mut()?;
|
||||
|
||||
for container in workspace.containers_mut() {
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
for window in workspace.floating_windows_mut() {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
}
|
||||
|
||||
workspace.reintegrate_monocle_container()
|
||||
@@ -3214,7 +3214,7 @@ impl WindowManager {
|
||||
.cycle_monocle_container(direction)?;
|
||||
|
||||
for container in self.focused_workspace_mut()?.containers_mut() {
|
||||
container.hide(None);
|
||||
let _ = container.hide(None, ());
|
||||
}
|
||||
|
||||
// borders were getting funny during cycles, can't be bothered to root cause it
|
||||
|
||||
+16
-16
@@ -431,7 +431,7 @@ impl WorkspaceExt for Workspace {
|
||||
if let Some(container) = &self.monocle_container
|
||||
&& let Some(window) = container.focused_window()
|
||||
{
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
window.focus(mouse_follows_focus)?;
|
||||
return self.apply_wallpaper(hmonitor, monitor_wp);
|
||||
}
|
||||
@@ -446,7 +446,7 @@ impl WorkspaceExt for Workspace {
|
||||
to_focus = Option::from(*window);
|
||||
}
|
||||
|
||||
container.restore();
|
||||
let _ = container.restore();
|
||||
}
|
||||
|
||||
if let Some(container) = self.focused_container_mut() {
|
||||
@@ -454,7 +454,7 @@ impl WorkspaceExt for Workspace {
|
||||
}
|
||||
|
||||
for window in self.floating_windows() {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
}
|
||||
|
||||
// Do this here to make sure that an error doesn't stop the restoration of other windows
|
||||
@@ -464,13 +464,13 @@ impl WorkspaceExt for Workspace {
|
||||
if self.maximized_window.is_none() && matches!(self.layer, WorkspaceLayer::Tiling) {
|
||||
window.focus(mouse_follows_focus)?;
|
||||
} else if let Some(maximized_window) = self.maximized_window {
|
||||
maximized_window.restore_window();
|
||||
let _ = maximized_window.restore_window();
|
||||
maximized_window.focus(mouse_follows_focus)?;
|
||||
} else if let Some(floating_window) = self.focused_floating_window() {
|
||||
floating_window.focus(mouse_follows_focus)?;
|
||||
}
|
||||
} else if let Some(maximized_window) = self.maximized_window {
|
||||
maximized_window.restore_window();
|
||||
let _ = maximized_window.restore_window();
|
||||
maximized_window.focus(mouse_follows_focus)?;
|
||||
} else if let Some(floating_window) = self.focused_floating_window() {
|
||||
floating_window.focus(mouse_follows_focus)?;
|
||||
@@ -706,14 +706,14 @@ impl WorkspaceExt for Workspace {
|
||||
}
|
||||
if hidden.get(i).copied().unwrap_or_default() {
|
||||
// it is seen on another monitor wherever it rests here
|
||||
window.hide_window();
|
||||
let _ = window.hide_window(());
|
||||
} else {
|
||||
if crate::scrolling::should_restore_when_placed(
|
||||
window.hwnd,
|
||||
container.focused_window().map(|w| w.hwnd),
|
||||
&HIDDEN_HWNDS.lock(),
|
||||
) {
|
||||
window.restore_window();
|
||||
let _ = window.restore_window();
|
||||
}
|
||||
|
||||
backend().set_rect(WindowId::from_hwnd(window.hwnd), layout)?;
|
||||
@@ -815,7 +815,7 @@ impl WorkspaceExt for Workspace {
|
||||
}
|
||||
|
||||
for c in self.containers() {
|
||||
c.restore();
|
||||
let _ = c.restore();
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
@@ -857,7 +857,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.focus_previous_container();
|
||||
}
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
if let Some(window) = container.focused_window() {
|
||||
window.focus(false)?;
|
||||
}
|
||||
@@ -891,7 +891,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.monocle_container = None;
|
||||
self.monocle_container_restore_idx = None;
|
||||
} else {
|
||||
monocle_container.load_focused_window();
|
||||
let _ = monocle_container.load_focused_window(());
|
||||
}
|
||||
|
||||
self.maximized_window = Option::from(window);
|
||||
@@ -920,7 +920,7 @@ impl WorkspaceExt for Workspace {
|
||||
self.resize_dimensions.remove(focused_idx);
|
||||
}
|
||||
} else {
|
||||
container.load_focused_window();
|
||||
let _ = container.load_focused_window(());
|
||||
}
|
||||
|
||||
self.maximized_window = Option::from(window);
|
||||
@@ -961,7 +961,7 @@ impl WorkspaceExt for Workspace {
|
||||
|
||||
self.focused_container_mut()
|
||||
.ok_or_eyre("there is no container")?
|
||||
.load_focused_window();
|
||||
.load_focused_window(())?;
|
||||
|
||||
self.maximized_window = None;
|
||||
self.maximized_window_restore_idx = None;
|
||||
@@ -1077,7 +1077,7 @@ mod tests {
|
||||
ws.focus_container(2);
|
||||
|
||||
// simulate a new window being launched on this workspace
|
||||
ws.new_container_for_window(Window::from(123));
|
||||
let _ = ws.new_container_for_window(Window::from(123));
|
||||
|
||||
// new length should be 5, with the focus on the new window at index 4
|
||||
assert_eq!(ws.containers().len(), 5);
|
||||
@@ -1093,7 +1093,7 @@ mod tests {
|
||||
|
||||
// when inserting a new container at index 0, index 3's container should not change
|
||||
ws.focus_container(0);
|
||||
ws.new_container_for_window(Window::from(234));
|
||||
let _ = ws.new_container_for_window(Window::from(234));
|
||||
assert_eq!(
|
||||
ws.containers()[3].id.to_string(),
|
||||
state.get(&3).unwrap().to_string()
|
||||
@@ -1152,7 +1152,7 @@ mod tests {
|
||||
// new_container_for_floating_window which usually handles unfloating
|
||||
let window = ws.floating_windows_mut().pop_back().unwrap();
|
||||
let mut container = Container::default();
|
||||
container.add_window(window);
|
||||
let _ = container.add_window(window, ());
|
||||
ws.insert_container_at_idx(ws.focused_container_idx(), container);
|
||||
|
||||
// all indexes should be at their original position
|
||||
@@ -1599,7 +1599,7 @@ mod tests {
|
||||
}
|
||||
|
||||
// Add new window to container
|
||||
workspace.new_container_for_window(Window::from(2));
|
||||
let _ = workspace.new_container_for_window(Window::from(2));
|
||||
|
||||
// Container 0 should have 1 window
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
|
||||
Reference in new issue
Block a user