mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-23 17:18:40 +02:00
feat(wm): add apply state socket message
This allows clients to send a state and get it applied to the wm. By using the already there apply_state function we have all the safety we need to apply the sent state. This is also intentionally not open for the komorebic binary because I think the average user doesnt need such a command and this is much safer also to not give them the ability.
This commit is contained in:
@@ -15,6 +15,7 @@ use strum::EnumString;
|
|||||||
|
|
||||||
use crate::KomorebiTheme;
|
use crate::KomorebiTheme;
|
||||||
use crate::animation::prefix::AnimationPrefix;
|
use crate::animation::prefix::AnimationPrefix;
|
||||||
|
use crate::state::State;
|
||||||
|
|
||||||
// Re-export everything from komorebi-layouts
|
// Re-export everything from komorebi-layouts
|
||||||
pub use komorebi_layouts::Arrangement;
|
pub use komorebi_layouts::Arrangement;
|
||||||
@@ -256,6 +257,8 @@ pub enum SocketMessage {
|
|||||||
StaticConfigSchema,
|
StaticConfigSchema,
|
||||||
GenerateStaticConfig,
|
GenerateStaticConfig,
|
||||||
DebugWindow(isize),
|
DebugWindow(isize),
|
||||||
|
// low level commands
|
||||||
|
ApplyState(State),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SocketMessage {
|
impl SocketMessage {
|
||||||
|
|||||||
@@ -2296,6 +2296,9 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue))
|
|||||||
SocketMessage::Theme(ref theme) => {
|
SocketMessage::Theme(ref theme) => {
|
||||||
theme_manager::send_notification(*theme.clone());
|
theme_manager::send_notification(*theme.clone());
|
||||||
}
|
}
|
||||||
|
SocketMessage::ApplyState(ref state) => {
|
||||||
|
self.apply_state(state.clone());
|
||||||
|
}
|
||||||
// Deprecated commands
|
// Deprecated commands
|
||||||
SocketMessage::AltFocusHack(_)
|
SocketMessage::AltFocusHack(_)
|
||||||
| SocketMessage::IdentifyBorderOverflowApplication(_, _) => {}
|
| SocketMessage::IdentifyBorderOverflowApplication(_, _) => {}
|
||||||
|
|||||||
@@ -239,23 +239,30 @@ impl WindowManager {
|
|||||||
let mouse_follows_focus = self.mouse_follows_focus;
|
let mouse_follows_focus = self.mouse_follows_focus;
|
||||||
for (monitor_idx, monitor) in self.monitors_mut().iter_mut().enumerate() {
|
for (monitor_idx, monitor) in self.monitors_mut().iter_mut().enumerate() {
|
||||||
let mut focused_workspace = 0;
|
let mut focused_workspace = 0;
|
||||||
for (workspace_idx, workspace) in monitor.workspaces_mut().iter_mut().enumerate() {
|
if let Some(state_monitor) = state.monitors.elements().get(monitor_idx) {
|
||||||
if let Some(state_monitor) = state.monitors.elements().get(monitor_idx)
|
monitor
|
||||||
&& let Some(state_workspace) = state_monitor.workspaces().get(workspace_idx)
|
.workspaces_mut()
|
||||||
|
.resize(state_monitor.workspaces().len(), Workspace::default());
|
||||||
|
|
||||||
|
for (workspace_idx, workspace) in
|
||||||
|
monitor.workspaces_mut().iter_mut().enumerate()
|
||||||
{
|
{
|
||||||
// to make sure padding and layout_options changes get applied for users after a quick restart
|
if let Some(state_workspace) = state_monitor.workspaces().get(workspace_idx)
|
||||||
let container_padding = workspace.container_padding;
|
{
|
||||||
let workspace_padding = workspace.workspace_padding;
|
// to make sure padding and layout_options changes get applied for users after a quick restart
|
||||||
let layout_options = workspace.layout_options;
|
let container_padding = workspace.container_padding;
|
||||||
|
let workspace_padding = workspace.workspace_padding;
|
||||||
|
let layout_options = workspace.layout_options;
|
||||||
|
|
||||||
*workspace = state_workspace.clone();
|
*workspace = state_workspace.clone();
|
||||||
|
|
||||||
workspace.container_padding = container_padding;
|
workspace.container_padding = container_padding;
|
||||||
workspace.workspace_padding = workspace_padding;
|
workspace.workspace_padding = workspace_padding;
|
||||||
workspace.layout_options = layout_options;
|
workspace.layout_options = layout_options;
|
||||||
|
|
||||||
if state_monitor.focused_workspace_idx() == workspace_idx {
|
if state_monitor.focused_workspace_idx() == workspace_idx {
|
||||||
focused_workspace = workspace_idx;
|
focused_workspace = workspace_idx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1334
schema.bar.json
1334
schema.bar.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user