GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: add title, class name, and process name to `NativeWindow`
Lars Berger553724717e6d
diff --git a/packages/wm/src/common/platform/native_window.rs b/packages/wm/src/common/platform/native_window.rsindex 6585502e..9d91a1f5 100644--- a/packages/wm/src/common/platform/native_window.rs+++ b/packages/wm/src/common/platform/native_window.rs@@ -1,15 +1,57 @@+use std::cell::RefCell;++use anyhow::Result;+use super::WindowHandle;pub struct NativeWindow {pub handle: WindowHandle,- pub title: String,- pub process_name: String,- pub class_name: String,+ title: Option<RefCell<String>>,+ process_name: Option<RefCell<String>>,+ class_name: Option<RefCell<String>>,}impl NativeWindow {pub fn new(handle: WindowHandle) -> Self {- todo!()+ Self {+ handle,+ title: None,+ process_name: None,+ class_name: None,+ }+ }++ fn title(&self) -> Result<String> {+ match self.title {+ Some(title) => Ok(title.borrow().clone()),+ None => {+ let title = windows_api::window_title_by_handle()?;+ self.title = Some(RefCell::new(title));+ Ok(title)+ }+ }+ }++ fn process_name(&self) -> Result<String> {+ match self.process_name {+ Some(process_name) => Ok(process_name.borrow().clone()),+ None => {+ let process_name = windows_api::process_name_by_handle()?;+ self.process_name = Some(RefCell::new(process_name));+ Ok(process_name)+ }+ }+ }++ fn class_name(&self) -> Result<String> {+ match self.class_name {+ Some(class_name) => Ok(class_name.borrow().clone()),+ None => {+ let class_name = windows_api::class_name_by_handle()?;+ self.class_name = Some(RefCell::new(class_name));+ Ok(class_name)+ }+ }}pub fn is_visible(&self) -> bool {diff --git a/packages/wm/src/common/platform/platform.rs b/packages/wm/src/common/platform/platform.rsindex ba5f5e83..f1801812 100644--- a/packages/wm/src/common/platform/platform.rs+++ b/packages/wm/src/common/platform/platform.rs@@ -21,10 +21,10 @@ impl Platform {Ok(())}- pub fn new_event_listener(+ pub async fn new_event_listener(config: Arc<Mutex<UserConfig>>,config_changes_rx: UnboundedReceiver<UserConfig>,) -> Result<EventListener> {- EventListener::start(config, config_changes_rx)+ EventListener::start(config, config_changes_rx).await}}diff --git a/packages/wm/src/main.rs b/packages/wm/src/main.rsindex ad6f995c..b12aef63 100644--- a/packages/wm/src/main.rs+++ b/packages/wm/src/main.rs@@ -57,9 +57,11 @@ async fn start_wm(config_path: Option<String>) -> Result<()> {let (config_changes_tx, config_changes_rx) =mpsc::unbounded_channel::<UserConfig>();+ // Start listening for platform events.let mut event_listener =Platform::new_event_listener(config.clone(), config_changes_rx).await?;+let mut ipc_server = IpcServer::start().await?;// Start watcher process for restoring hidden windows on crash.diff --git a/packages/wm/src/wm_state.rs b/packages/wm/src/wm_state.rsindex 7374e2a3..17a505f1 100644--- a/packages/wm/src/wm_state.rs+++ b/packages/wm/src/wm_state.rs@@ -4,6 +4,7 @@ use std::{rc::{Rc, Weak},sync::Arc,};+use tokio::sync::Mutex;use uuid::Uuid;