diff --git a/packages/desktop/src/providers/komorebi/provider.rs b/packages/desktop/src/providers/komorebi/provider.rs index 8483f8c2..4fed55e1 100644 --- a/packages/desktop/src/providers/komorebi/provider.rs +++ b/packages/desktop/src/providers/komorebi/provider.rs @@ -4,6 +4,7 @@ use std::{ }; use async_trait::async_trait; +use komorebi_client::Monitor; use tokio::{ sync::mpsc::Sender, task::{self, AbortHandle}, @@ -17,7 +18,7 @@ use crate::providers::{ variables::ProviderVariables, }; -use super::KomorebiProviderConfig; +use super::{KomorebiMonitor, KomorebiProviderConfig}; const SOCKET_NAME: &str = "zebar.sock"; @@ -33,6 +34,33 @@ impl KomorebiProvider { abort_handle: None, } } + + fn transform_response( + state: komorebi_client::State, + ) -> KomorebiVariables { + let monitors = state + .monitors + .elements() + .into_iter() + .map(|&monitor| KomorebiMonitor { + id: monitor.id(), + name: monitor.name().to_string(), + device_id: monitor.device_id().clone(), + size: monitor.size(), + work_area_size: KomorebiRect { + left: size.left, + top: size.top, + right: size.right, + bottom: size.bottom, + }, + work_area_offset: monitor.work_area_offset(), + work_area_size: monitor.work_area_size(), + workspaces: monitor.workspaces(), + }) + .collect(); + + KomorebiVariables { monitors } + } } #[async_trait] diff --git a/packages/desktop/src/providers/komorebi/variables.rs b/packages/desktop/src/providers/komorebi/variables.rs index b5145d75..5ca78a32 100644 --- a/packages/desktop/src/providers/komorebi/variables.rs +++ b/packages/desktop/src/providers/komorebi/variables.rs @@ -1,8 +1,80 @@ -use komorebi_client::{Monitor, Ring}; use serde::Serialize; #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct KomorebiVariables { - pub monitors: Ring, + pub monitors: Vec, +} + +#[derive(Serialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct KomorebiMonitor { + pub id: isize, + pub name: String, + pub device_id: Option, + pub size: KomorebiRect, + pub work_area_offset: Option, + pub work_area_size: KomorebiRect, + pub workspaces: Vec, +} + +#[derive(Serialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct KomorebiWorkspace { + pub container_padding: u64, + pub floating_windows: Vec, + pub latest_layout: Vec, + pub layout: KomorebiLayout, + pub layout_flip: Option, + pub name: String, + pub maximized_window: Option, + pub monocle_container: Option, + pub tiling_containers: Vec, + pub workspace_padding: u64, +} + +#[derive(Serialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct KomorebiContainer { + pub class: String, + pub exe: String, + pub hwnd: u64, + pub size: KomorebiRect, + pub title: String, +} + +#[derive(Serialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct KomorebiWindow { + pub class: String, + pub exe: String, + pub hwnd: u64, + pub size: KomorebiRect, + pub title: String, +} + +#[derive(Serialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct KomorebiRect { + pub left: u64, + pub top: u64, + pub right: u64, + pub bottom: u64, +} + +#[derive(Serialize, Debug, Clone)] +#[serde(rename_all = "snake_case")] +pub enum KomorebiLayout { + Bsp, + VerticalStack, + HorizontalStack, + UltrawideVerticalStack, + Rows, +} + +#[derive(Serialize, Debug, Clone)] +#[serde(rename_all = "snake_case")] +pub enum KomorebiLayoutFlip { + Horizontal, + Vertical, }