mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-24 18:31:22 +01:00
This commit ensures that new features such as stackbar, particularly where the configuration is located in the global state, can be configured via SocketMessages. A few structs had to be moved to komorebi-core to make this possible. I've also cleaned up a bunch of strum snake_case attrs which seemed to be unused. A new GlobalState SocketMessage has been introduced, and going forward we should make sure that this can send all global state to a requester, and move global state out of the State handler, which should only handle window manager state.
39 lines
834 B
Rust
39 lines
834 B
Rust
use std::num::NonZeroUsize;
|
|
|
|
use clap::ValueEnum;
|
|
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use strum::Display;
|
|
use strum::EnumString;
|
|
|
|
#[derive(
|
|
Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
|
)]
|
|
pub enum CycleDirection {
|
|
Previous,
|
|
Next,
|
|
}
|
|
|
|
impl CycleDirection {
|
|
#[must_use]
|
|
pub const fn next_idx(&self, idx: usize, len: NonZeroUsize) -> usize {
|
|
match self {
|
|
Self::Previous => {
|
|
if idx == 0 {
|
|
len.get() - 1
|
|
} else {
|
|
idx - 1
|
|
}
|
|
}
|
|
Self::Next => {
|
|
if idx == len.get() - 1 {
|
|
0
|
|
} else {
|
|
idx + 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|