refactor(kde): the workspace is komorebi-core's Workspace over KdePlatform

komorebi-for-kde/komorebi/src/workspace.rs no longer defines Workspace:
`type Workspace = komorebi_core::Workspace<KdePlatform>`, with
WorkspaceLayer, WorkspaceWindowLocation, CachedLayoutDefault and the
threshold helpers re-exported from the crate. KdePlatform implements
WorkspacePlatform (the window is Window, the state holds
scrolling_placed, the hooks forward to window::foreground_window_id and
cursor_position, to should_act_window with the regex table, to the three
scrolling lookups, and after_floating_removed refocuses a floating
window). The functions that moved in the previous revision are gone from
the file; every other method of the old impl (update, hide, restore,
remove_window, apply_wallpaper, load_static_config, adopt_maximized_window,
the scrolling glue of scrolling.rs, ...) is now a method of the extension
traits WorkspaceExt (workspace.rs) and WorkspaceScrolling (scrolling.rs),
unchanged in body, which each caller imports. Workspace.scrolling_placed is
state.scrolling_placed. static_config::workspace_config(&Workspace) replaces
the From<&Workspace> impl for WorkspaceConfig, which the orphan rule
forbids. The tests stay in place.

No behaviour change: same bodies, same order; serialised state and the
schema are the ones tests/schemas.rs and the fixtures pin.

Verified: KDE cargo test --workspace --no-fail-fast (native, lite env):
875 passed, 0 failed. Not run: VM suites.
This commit is contained in:
LGUG2Z committed 2026-10-31 12:50:34 -07:00
1 parent f225e51982
commit 0679be6621
13 files changed
+502 -1475

No files matched your search

+2
View File
@@ -2576,9 +2576,11 @@ dependencies = [
name = "komorebi-core"
version = "0.1.42"
dependencies = [
"color-eyre",
"komorebi-collections",
"komorebi-config",
"komorebi-layouts",
"komorebi-scrolling",
"nanoid",
"schemars 1.2.3",
"serde",
+1
View File
@@ -36,6 +36,7 @@
#![deny(missing_docs)]
use crate::workspace::WorkspaceExt;
use crate::DISPLAY_INDEX_PREFERENCES;
use crate::backend::backend;
use crate::container::Container;
+1
View File
@@ -11,6 +11,7 @@
//! workspace it is in, asks the compositor to show the focused workspace's desktop, which shows its
//! windows and hides the others, and gives the focus to the workspace's focused window.
use crate::workspace::WorkspaceExt;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::DEFAULT_WORKSPACE_PADDING;
use crate::backend::backend;
@@ -219,6 +219,8 @@
//! Once a message has been handled, every subscriber is sent a notification of it
//! ([`notify_subscribers`]).
use crate::scrolling::WorkspaceScrolling;
use crate::workspace::WorkspaceExt;
use crate::DATA_DIR;
use crate::DISPLAY_INDEX_PREFERENCES;
use crate::FLOATING_APPLICATIONS;
@@ -88,6 +88,7 @@
//! [`Monitor::assign_windows_to_workspaces`]: crate::monitor::Monitor::assign_windows_to_workspaces
//! [`Window::set_position`]: crate::window::Window::set_position
use crate::workspace::WorkspaceExt;
use crate::FLOATING_APPLICATIONS;
use crate::HIDDEN_WINDOWS;
use crate::Notification;
@@ -35,6 +35,7 @@
#![deny(missing_docs)]
use crate::workspace::WorkspaceExt;
use crate::core::Rect;
use crate::window::Window;
use crate::window_manager::WindowManager;
+209 -142
View File
@@ -13,9 +13,8 @@
//!
//! [`WindowManager::pan`] moves the view along the strip without moving the focus.
use crate::workspace::WorkspaceExt;
use crate::container::Container;
use crate::core::DefaultLayout;
use crate::core::Layout;
use crate::core::LayoutOptions;
use crate::core::OperationDirection;
use crate::core::PanDirection;
@@ -185,7 +184,36 @@ pub(crate) fn should_restore_when_placed(
focused_in_container == Some(window) && hidden.contains(&window)
}
impl Workspace {
impl WindowManager {
/// Move the view of the focused workspace one step, a column, to the left or the right, and
/// let it come to rest with a column against an edge of the screen. Focus goes to the nearest
/// column in view if the focused one is not. Nothing happens in a layout that is not Scrolling.
///
/// # Errors
///
/// There is no focused workspace, or it cannot be tiled again.
#[tracing::instrument(skip(self))]
pub fn pan(&mut self, direction: PanDirection) -> eyre::Result<()> {
let workspace = self.focused_workspace_mut()?;
if !workspace.begin_scrolling_pan() {
return Ok(());
}
let step = workspace
.scrolling_pan_step()
.and_then(|step| u32::try_from(step).ok())
.unwrap_or_default();
workspace.pan_scrolling(direction.strip_offset(step));
let focus_moved = workspace.end_scrolling_pan(0.0);
self.update_focused_workspace(focus_moved && self.mouse_follows_focus, focus_moved)
}
}
pub(crate) trait WorkspaceScrolling {
/// Learn from what windows turned out to be when they were sent to where the layout put them,
/// which is that some of them are wider than the layout said and will not be any narrower.
///
@@ -200,8 +228,160 @@ impl Workspace {
/// time to draw at the size that it was asked for, so this is for [`Workspace::update`] to call
/// when the windows were last placed [`WIDTH_SETTLE`] ago, and not while a window is being
/// dragged by an edge.
pub(crate) fn adopt_actual_widths(&mut self, around_window: i32, viewport_width: i32) -> bool {
let (Some(space), Some(placed)) = (self.scrolling.as_mut(), self.scrolling_placed.as_ref())
fn adopt_actual_widths(&mut self, around_window: i32, viewport_width: i32) -> bool;
fn scrolling_ids(&self) -> Vec<String>;
/// Set how many columns the Scrolling layout shows at once, keeping every other layout option.
fn set_scrolling_columns(&mut self, columns: usize);
/// Make the space match the containers, and the focus, as they are now.
fn sync_scrolling(&mut self, viewport: komorebi_scrolling::Viewport);
/// Say what the column of the container at this index was given, as it is about to be taken
/// out of the workspace, for the workspace that it is put in to find.
fn note_scrolling_departure(&self, idx: usize);
/// Make the space match the containers and the focus as they are now, for a space that is
/// there to be made to match.
///
/// This is for a change that is about to be made to the containers, and that the space is
/// going to be told about directly. The space has to know what there is before it is told
/// what goes.
fn sync_scrolling_containers(&mut self);
/// Give focus to what the strip says should have it after the container `removed` has gone,
/// and tell whether the strip had anything to say.
///
/// Focus goes back to the column that the closed one was opened next to, if nothing has
/// moved focus since, and otherwise to the column that takes its place on the right. Focus that
/// is not on the closed column stays where it is. This is not what the other layouts do, which
/// always move focus to the left.
fn focus_after_scrolling_removal(&mut self, removed: &str) -> bool;
/// Where every container goes in `work_area`, from left to right, with `container_padding`
/// taken off every side of each.
fn layout_scrolling(
&mut self,
work_area: &Rect,
container_padding: i32,
) -> Vec<ScrollingPlacement>;
/// Where the container that a new window gets goes, if the strip has a say: after the last
/// tile of the column that has focus.
///
/// A new window is a column of its own beside the focused one, and not a tile in the middle of
/// it, which is what the container after the focused one would be if the column has other
/// tiles below.
fn scrolling_insertion_idx(&self) -> Option<usize>;
/// Where focus would go from the focused container in this direction, in the strip as it is
/// now, or `None` if it would not go anywhere.
///
/// Left and right are the neighbouring columns, and focus goes to the tile that had it last
/// in the one it arrives at. Up and down are the tiles of the focused column, and stop at
/// the ends.
fn scrolling_idx_for_direction(
&self,
direction: OperationDirection,
) -> Option<usize>;
/// Make the order of the containers the order of the tiles of the strip, and focus the tile
/// that the strip says has it.
///
/// Most of what the strip does leaves the order alone. What moves a tile past another does
/// not, and the list of containers is what is true, so it is made to match.
fn apply_scrolling_order(&mut self);
/// Make the space agree with which container has focus, and give back the id of that
/// container, for a command that is about the focused column.
///
/// There is nothing to do until a layout has made the space, and in a layout that is not
/// Scrolling.
fn focused_scrolling_column(&mut self) -> Option<String>;
/// Move the focused column one place to the left or right, or the focused tile one place up
/// or down in its column, and tell whether anything moved.
///
/// A column moves with all of its tiles.
fn move_scrolling(&mut self, direction: OperationDirection) -> bool;
/// Take the neighbouring tile on one side into the focused column: the first tile of the
/// column on the right to the bottom of it, or the last tile of the column on the left to the
/// top of it. Up and down mean nothing here.
fn consume_scrolling(&mut self, direction: OperationDirection);
/// Take the focused tile out of its column and put it in a column of its own on the right.
fn expel_scrolling(&mut self);
/// Stack the windows of the focused column in one tile, or spread the stack in the focused tile
/// out into the tiles of a column, whichever it is, and tell whether there was anything to do.
///
/// A column of several tiles becomes one tile that is a stack of all of their windows, in the
/// order that they were in, with the window that had focus still showing. A tile that is a stack
/// becomes a column of a tile for each of its windows, in the order of its tabs, with focus on
/// the window that had it. Either way the column keeps its width, but the heights that its tiles
/// were given are not remembered for when it is toggled back.
fn toggle_scrolling_column_stack(&mut self) -> eyre::Result<bool>;
/// Put the windows of all of the containers with these ids in the first of them, in order.
fn stack_scrolling_column(&mut self, column: &[String]) -> eyre::Result<()>;
/// Put each of the windows of the focused container in a container of its own, in the same
/// column, and tell whether it had more than one.
fn unstack_scrolling_column(&mut self) -> eyre::Result<bool>;
/// Put every column back to the width that the `columns` option gives, which forgets every
/// width that was set by resizing, by a preset, or by taking the full width, and every window
/// back to an equal share of the height of its column. The narrowest that windows were found
/// to accept is forgotten as well.
///
/// The focused column stays where it is on screen unless it has to scroll to stay in view.
fn reset_scrolling_sizes(&mut self);
/// Make the focused column as wide as the screen, or give it back the width that it had.
fn toggle_scrolling_full_width(&mut self);
/// Make the focused column as wide as it can be without scrolling anything else out of view,
/// which is to fill the room that the columns in view leave. Only the Scrolling layout has
/// columns to expand.
fn expand_scrolling_column(&mut self);
/// Start moving the strip across the screen, and tell whether there is one to move. Only the
/// Scrolling layout has a strip, and not before a layout has made it.
fn begin_scrolling_pan(&mut self) -> bool;
/// Move the strip by `dx` pixels on the screen, to the right if it is positive. Nothing else
/// changes: not which container has focus, nor the width of any.
fn pan_scrolling(&mut self, dx: f64);
/// Let go of the strip, going at `velocity` pixels a second on the screen, to the right if it
/// is positive, and let it come to rest, which is with a column against an edge of the screen.
/// Focus goes to the nearest column that is fully in view if the focused one is not, and
/// this tells whether it moved.
fn end_scrolling_pan(&mut self, velocity: f64) -> bool;
/// How far one step of a pan goes, if nothing says: a column of the width that a new one
/// is given.
fn scrolling_pan_step(&self) -> Option<i32>;
/// Centre the focused column on the screen, this once.
fn center_scrolling_column(&mut self);
/// Make the focused column wider or narrower with the horizontal edges, and the focused window
/// taller or shorter in its column with the vertical ones.
fn resize_scrolling_column(
&mut self,
direction: OperationDirection,
sizing: Sizing,
delta: i32,
);
}
impl WorkspaceScrolling for Workspace {
fn adopt_actual_widths(&mut self, around_window: i32, viewport_width: i32) -> bool {
let (Some(space), Some(placed)) = (self.scrolling.as_mut(), self.state.scrolling_placed.as_ref())
else {
return false;
};
@@ -260,11 +440,6 @@ impl Workspace {
adopted
}
/// Whether the workspace is laid out as a strip of columns.
pub(crate) fn is_scrolling(&self) -> bool {
matches!(self.layout, Layout::Default(DefaultLayout::Scrolling))
}
fn scrolling_ids(&self) -> Vec<String> {
self.containers()
.iter()
@@ -272,8 +447,7 @@ impl Workspace {
.collect()
}
/// Set how many columns the Scrolling layout shows at once, keeping every other layout option.
pub fn set_scrolling_columns(&mut self, columns: usize) {
fn set_scrolling_columns(&mut self, columns: usize) {
let mut options = self.layout_options.unwrap_or(LayoutOptions {
scrolling: None,
grid: None,
@@ -294,7 +468,6 @@ impl Workspace {
self.layout_options = Some(options);
}
/// Make the space match the containers, and the focus, as they are now.
fn sync_scrolling(&mut self, viewport: komorebi_scrolling::Viewport) {
let options = scrolling_options(self.effective_layout_options());
let ids = self.scrolling_ids();
@@ -311,9 +484,7 @@ impl Workspace {
);
}
/// Say what the column of the container at this index was given, as it is about to be taken
/// out of the workspace, for the workspace that it is put in to find.
pub(crate) fn note_scrolling_departure(&self, idx: usize) {
fn note_scrolling_departure(&self, idx: usize) {
if let Some(space) = &self.scrolling
&& let Some(container) = self.containers().get(idx)
&& let Some(record) = space.column_record(&container.id)
@@ -322,13 +493,7 @@ impl Workspace {
}
}
/// Make the space match the containers and the focus as they are now, for a space that is
/// there to be made to match.
///
/// This is for a change that is about to be made to the containers, and that the space is
/// going to be told about directly. The space has to know what there is before it is told
/// what goes.
pub(crate) fn sync_scrolling_containers(&mut self) {
fn sync_scrolling_containers(&mut self) {
let ids = self.scrolling_ids();
let focused = self
.focused_container()
@@ -340,14 +505,7 @@ impl Workspace {
}
}
/// Give focus to what the strip says should have it after the container `removed` has gone,
/// and tell whether the strip had anything to say.
///
/// Focus goes back to the column that the closed one was opened next to, if nothing has
/// moved focus since, and otherwise to the column that takes its place on the right. Focus that
/// is not on the closed column stays where it is. This is not what the other layouts do, which
/// always move focus to the left.
pub(crate) fn focus_after_scrolling_removal(&mut self, removed: &str) -> bool {
fn focus_after_scrolling_removal(&mut self, removed: &str) -> bool {
let Some(space) = self.scrolling.as_mut() else {
return false;
};
@@ -365,9 +523,7 @@ impl Workspace {
true
}
/// Where every container goes in `work_area`, from left to right, with `container_padding`
/// taken off every side of each.
pub(crate) fn layout_scrolling(
fn layout_scrolling(
&mut self,
work_area: &Rect,
container_padding: i32,
@@ -380,13 +536,7 @@ impl Workspace {
.unwrap_or_default()
}
/// Where the container that a new window gets goes, if the strip has a say: after the last
/// tile of the column that has focus.
///
/// A new window is a column of its own beside the focused one, and not a tile in the middle of
/// it, which is what the container after the focused one would be if the column has other
/// tiles below.
pub(crate) fn scrolling_insertion_idx(&self) -> Option<usize> {
fn scrolling_insertion_idx(&self) -> Option<usize> {
if !self.is_scrolling() {
return None;
}
@@ -401,13 +551,7 @@ impl Workspace {
.map(|idx| idx + 1)
}
/// Where focus would go from the focused container in this direction, in the strip as it is
/// now, or `None` if it would not go anywhere.
///
/// Left and right are the neighbouring columns, and focus goes to the tile that had it last
/// in the one it arrives at. Up and down are the tiles of the focused column, and stop at
/// the ends.
pub(crate) fn scrolling_idx_for_direction(
fn scrolling_idx_for_direction(
&self,
direction: OperationDirection,
) -> Option<usize> {
@@ -434,11 +578,6 @@ impl Workspace {
}
}
/// Make the order of the containers the order of the tiles of the strip, and focus the tile
/// that the strip says has it.
///
/// Most of what the strip does leaves the order alone. What moves a tile past another does
/// not, and the list of containers is what is true, so it is made to match.
fn apply_scrolling_order(&mut self) {
let Some(space) = self.scrolling.as_ref() else {
return;
@@ -466,11 +605,6 @@ impl Workspace {
self.resize_dimensions = vec![None; self.containers().len()];
}
/// Make the space agree with which container has focus, and give back the id of that
/// container, for a command that is about the focused column.
///
/// There is nothing to do until a layout has made the space, and in a layout that is not
/// Scrolling.
fn focused_scrolling_column(&mut self) -> Option<String> {
if !self.is_scrolling() || self.scrolling.is_none() {
return None;
@@ -482,11 +616,7 @@ impl Workspace {
.map(|container| container.id.clone())
}
/// Move the focused column one place to the left or right, or the focused tile one place up
/// or down in its column, and tell whether anything moved.
///
/// A column moves with all of its tiles.
pub(crate) fn move_scrolling(&mut self, direction: OperationDirection) -> bool {
fn move_scrolling(&mut self, direction: OperationDirection) -> bool {
let Some(id) = self.focused_scrolling_column() else {
return false;
};
@@ -524,10 +654,7 @@ impl Workspace {
moved
}
/// Take the neighbouring tile on one side into the focused column: the first tile of the
/// column on the right to the bottom of it, or the last tile of the column on the left to the
/// top of it. Up and down mean nothing here.
pub(crate) fn consume_scrolling(&mut self, direction: OperationDirection) {
fn consume_scrolling(&mut self, direction: OperationDirection) {
if self.focused_scrolling_column().is_none() {
return;
}
@@ -547,8 +674,7 @@ impl Workspace {
}
}
/// Take the focused tile out of its column and put it in a column of its own on the right.
pub(crate) fn expel_scrolling(&mut self) {
fn expel_scrolling(&mut self) {
if self.focused_scrolling_column().is_none() {
return;
}
@@ -562,15 +688,7 @@ impl Workspace {
}
}
/// Stack the windows of the focused column in one tile, or spread the stack in the focused tile
/// out into the tiles of a column, whichever it is, and tell whether there was anything to do.
///
/// A column of several tiles becomes one tile that is a stack of all of their windows, in the
/// order that they were in, with the window that had focus still showing. A tile that is a stack
/// becomes a column of a tile for each of its windows, in the order of its tabs, with focus on
/// the window that had it. Either way the column keeps its width, but the heights that its tiles
/// were given are not remembered for when it is toggled back.
pub(crate) fn toggle_scrolling_column_stack(&mut self) -> eyre::Result<bool> {
fn toggle_scrolling_column_stack(&mut self) -> eyre::Result<bool> {
let Some(id) = self.focused_scrolling_column() else {
return Ok(false);
};
@@ -592,7 +710,6 @@ impl Workspace {
self.unstack_scrolling_column()
}
/// Put the windows of all of the containers with these ids in the first of them, in order.
fn stack_scrolling_column(&mut self, column: &[String]) -> eyre::Result<()> {
let focused_window = self
.focused_container()
@@ -632,8 +749,6 @@ impl Workspace {
Ok(())
}
/// Put each of the windows of the focused container in a container of its own, in the same
/// column, and tell whether it had more than one.
fn unstack_scrolling_column(&mut self) -> eyre::Result<bool> {
let idx = self.focused_container_idx();
@@ -693,13 +808,7 @@ impl Workspace {
Ok(true)
}
/// Put every column back to the width that the `columns` option gives, which forgets every
/// width that was set by resizing, by a preset, or by taking the full width, and every window
/// back to an equal share of the height of its column. The narrowest that windows were found
/// to accept is forgotten as well.
///
/// The focused column stays where it is on screen unless it has to scroll to stay in view.
pub(crate) fn reset_scrolling_sizes(&mut self) {
fn reset_scrolling_sizes(&mut self) {
if let Some(space) = self.scrolling.as_mut() {
space.reset_widths();
space.reset_heights();
@@ -713,8 +822,7 @@ impl Workspace {
}
}
/// Make the focused column as wide as the screen, or give it back the width that it had.
pub(crate) fn toggle_scrolling_full_width(&mut self) {
fn toggle_scrolling_full_width(&mut self) {
if let Some(id) = self.focused_scrolling_column()
&& let Some(space) = self.scrolling.as_mut()
{
@@ -722,10 +830,7 @@ impl Workspace {
}
}
/// Make the focused column as wide as it can be without scrolling anything else out of view,
/// which is to fill the room that the columns in view leave. Only the Scrolling layout has
/// columns to expand.
pub(crate) fn expand_scrolling_column(&mut self) {
fn expand_scrolling_column(&mut self) {
if self.is_scrolling()
&& self.focused_scrolling_column().is_some()
&& let Some(space) = self.scrolling.as_mut()
@@ -734,9 +839,7 @@ impl Workspace {
}
}
/// Start moving the strip across the screen, and tell whether there is one to move. Only the
/// Scrolling layout has a strip, and not before a layout has made it.
pub(crate) fn begin_scrolling_pan(&mut self) -> bool {
fn begin_scrolling_pan(&mut self) -> bool {
if !self.is_scrolling() || self.scrolling.is_none() {
return false;
}
@@ -752,19 +855,13 @@ impl Workspace {
}
}
/// Move the strip by `dx` pixels on the screen, to the right if it is positive. Nothing else
/// changes: not which container has focus, nor the width of any.
pub(crate) fn pan_scrolling(&mut self, dx: f64) {
fn pan_scrolling(&mut self, dx: f64) {
if let Some(space) = self.scrolling.as_mut() {
space.pan_by(dx);
}
}
/// Let go of the strip, going at `velocity` pixels a second on the screen, to the right if it
/// is positive, and let it come to rest, which is with a column against an edge of the screen.
/// Focus goes to the nearest column that is fully in view if the focused one is not, and
/// this tells whether it moved.
pub(crate) fn end_scrolling_pan(&mut self, velocity: f64) -> bool {
fn end_scrolling_pan(&mut self, velocity: f64) -> bool {
let Some(space) = self.scrolling.as_mut() else {
return false;
};
@@ -785,9 +882,7 @@ impl Workspace {
}
}
/// How far one step of a pan goes, if nothing says: a column of the width that a new one
/// is given.
pub(crate) fn scrolling_pan_step(&self) -> Option<i32> {
fn scrolling_pan_step(&self) -> Option<i32> {
let space = self.scrolling.as_ref()?;
let viewport = f64::from(space.viewport().width);
@@ -799,8 +894,7 @@ impl Workspace {
Some(step.round() as i32)
}
/// Centre the focused column on the screen, this once.
pub(crate) fn center_scrolling_column(&mut self) {
fn center_scrolling_column(&mut self) {
if self.focused_scrolling_column().is_some()
&& let Some(space) = self.scrolling.as_mut()
{
@@ -808,9 +902,7 @@ impl Workspace {
}
}
/// Make the focused column wider or narrower with the horizontal edges, and the focused window
/// taller or shorter in its column with the vertical ones.
pub(crate) fn resize_scrolling_column(
fn resize_scrolling_column(
&mut self,
direction: OperationDirection,
sizing: Sizing,
@@ -827,38 +919,13 @@ impl Workspace {
scrolling::resize(space, &id, direction, sizing, delta);
}
}
}
impl WindowManager {
/// Move the view of the focused workspace one step, a column, to the left or the right, and
/// let it come to rest with a column against an edge of the screen. Focus goes to the nearest
/// column in view if the focused one is not. Nothing happens in a layout that is not Scrolling.
///
/// # Errors
///
/// There is no focused workspace, or it cannot be tiled again.
#[tracing::instrument(skip(self))]
pub fn pan(&mut self, direction: PanDirection) -> eyre::Result<()> {
let workspace = self.focused_workspace_mut()?;
if !workspace.begin_scrolling_pan() {
return Ok(());
}
let step = workspace
.scrolling_pan_step()
.and_then(|step| u32::try_from(step).ok())
.unwrap_or_default();
workspace.pan_scrolling(direction.strip_offset(step));
let focus_moved = workspace.end_scrolling_pan(0.0);
self.update_focused_workspace(focus_moved && self.mouse_follows_focus, focus_moved)
}
}
#[cfg(test)]
mod tests {
use crate::core::DefaultLayout;
use crate::core::Layout;
use super::*;
use crate::HIDDEN_WINDOWS;
use crate::backend::fake::FakeBackend;
@@ -1244,7 +1311,7 @@ mod tests {
})
.collect();
workspace.scrolling_placed = Some(Placed::new(widths));
workspace.state.scrolling_placed = Some(Placed::new(widths));
}
#[test]
@@ -1315,7 +1382,7 @@ mod tests {
let mut workspace = workspace_from(3, 9221, 2);
place_windows(&mut workspace);
workspace.scrolling_placed = Some(Placed::new([]));
workspace.state.scrolling_placed = Some(Placed::new([]));
assert!(!workspace.adopt_actual_widths(0, AREA.right));
});
+1 -1
View File
@@ -227,7 +227,7 @@ impl From<&WindowManager> for State {
.clone(),
promotion_swap_container_idx: None,
scrolling: None,
scrolling_placed: None,
state: Default::default(),
})
.collect::<VecDeque<_>>();
ws.focus(monitor.workspaces.focused_idx());
@@ -24,6 +24,7 @@
//! [`DEFAULT_WORKSPACE_PADDING`] and the others in [`crate`]), and an optional key set to `null`
//! is the same as one that is left out.
use crate::workspace::WorkspaceExt;
use crate::DATA_DIR;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::DEFAULT_MOUSE_FOLLOWS_FOCUS;
@@ -100,8 +101,10 @@ pub use komorebi_config::static_config::ThemeOptions;
pub use komorebi_config::static_config::Wallpaper;
pub use komorebi_config::static_config::WorkspaceConfig;
impl From<&Workspace> for WorkspaceConfig {
fn from(value: &Workspace) -> Self {
/// The `komorebi.json` entry that describes a workspace (the shared `Workspace` is not local, so this is
/// a function and not a `From` impl)
pub fn workspace_config(value: &Workspace) -> WorkspaceConfig {
{
let mut layout_rules = HashMap::new();
for (threshold, layout) in &value.layout_rules {
match layout {
@@ -145,7 +148,7 @@ impl From<&Workspace> for WorkspaceConfig {
let tile = if value.tile { None } else { Some(false) };
Self {
WorkspaceConfig {
name: value
.name
.clone()
@@ -208,7 +211,7 @@ impl From<&Monitor> for MonitorConfig {
fn from(value: &Monitor) -> Self {
let mut workspaces = vec![];
for w in value.workspaces() {
workspaces.push(WorkspaceConfig::from(w));
workspaces.push(workspace_config(w));
}
let default_container_padding = DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst);
@@ -48,6 +48,8 @@
//!
//! [`listen_for_commands`]: crate::process_command::listen_for_commands
use crate::scrolling::WorkspaceScrolling;
use crate::workspace::WorkspaceExt;
use crate::DATA_DIR;
use crate::HIDDEN_WINDOWS;
use crate::LibraryError;
File diff suppressed because it is too large. Load diff
@@ -7,6 +7,7 @@
use komorebi::backend::fake::Command;
use komorebi::backend::fake::FakeBackend;
use komorebi::workspace::WorkspaceExt;
use komorebi::backend::with_backend;
use komorebi::core::CycleDirection;
use komorebi::core::OperationDirection;
@@ -12,6 +12,7 @@ use komorebi::window_manager::WindowManager;
use komorebi::window_manager_event::KWinNotification;
use komorebi::window_manager_event::SystemNotification;
use komorebi::window_manager_event::WindowManagerEvent;
use komorebi::workspace::WorkspaceExt;
use std::sync::Arc;
fn desktop(rules: Option<&str>) -> (Arc<FakeBackend>, WindowManager) {