GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: change `WmEvent` to not use separate structs
Lars Bergerccc8e7efa816
diff --git a/packages/wm/src/monitors/commands/add_monitor.rs b/packages/wm/src/monitors/commands/add_monitor.rsindex 86c8cf38..d108b3ad 100644--- a/packages/wm/src/monitors/commands/add_monitor.rs+++ b/packages/wm/src/monitors/commands/add_monitor.rs@@ -1,13 +1,9 @@use anyhow::Context;use crate::{- common::platform::NativeMonitor,- containers::commands::attach_container,- monitors::Monitor,- user_config::UserConfig,- wm_event::{MonitorAddedEvent, WmEvent},- wm_state::WmState,- workspaces::commands::activate_workspace,+ common::platform::NativeMonitor, containers::commands::attach_container,+ monitors::Monitor, user_config::UserConfig, wm_event::WmEvent,+ wm_state::WmState, workspaces::commands::activate_workspace,};pub fn add_monitor(@@ -26,9 +22,9 @@ pub fn add_monitor(0,)?;- state.emit_event(WmEvent::MonitorAdded(MonitorAddedEvent {+ state.emit_event(WmEvent::MonitorAdded {added_monitor: monitor.clone(),- }));+ });// Activate a workspace on the newly added monitor.activate_workspace(None, &monitor, state, config)diff --git a/packages/wm/src/wm_event.rs b/packages/wm/src/wm_event.rsindex de1bdcd1..abd1dfe0 100644--- a/packages/wm/src/wm_event.rs+++ b/packages/wm/src/wm_event.rs@@ -7,82 +7,46 @@ use crate::{workspaces::Workspace,};-#[derive(Debug)]-pub struct BindingModeChangedEvent {- pub new_binding_mode: String,-}--#[derive(Debug)]-pub struct FocusChangedEvent {- pub focused_container: Container,-}--#[derive(Debug)]-pub struct FocusedContainerMovedEvent {- pub focused_container: Container,-}--#[derive(Debug)]-pub struct MonitorAddedEvent {- pub added_monitor: Monitor,-}--#[derive(Debug)]-pub struct MonitorRemovedEvent {- pub removed_id: Uuid,- pub removed_device_name: String,-}--#[derive(Debug)]-pub struct NativeFocusSyncedEvent {- pub focused_container: Container,-}--#[derive(Debug)]-pub struct TilingDirectionChangedEvent {- pub new_tiling_direction: TilingDirection,-}--#[derive(Debug)]-pub struct WindowManagedEvent {- pub managed_window: Container,-}--#[derive(Debug)]-pub struct WindowUnmanagedEvent {- pub unmanaged_id: Uuid,- pub unmanaged_handle: WindowHandle,-}--#[derive(Debug)]-pub struct WorkspaceActivatedEvent {- pub activated_workspace: Workspace,-}--#[derive(Debug)]-pub struct WorkspaceDeactivatedEvent {- pub deactivated_id: Uuid,- pub deactivated_name: String,-}--#[derive(Debug)]-pub struct WorkingAreaResizedEvent {- pub affected_monitor: Container,-}-#[derive(Debug)]pub enum WmEvent {- BindingModeChanged(BindingModeChangedEvent),- FocusChanged(FocusChangedEvent),- FocusedContainerMoved(FocusedContainerMovedEvent),- MonitorAdded(MonitorAddedEvent),- MonitorRemoved(MonitorRemovedEvent),- NativeFocusSynced(NativeFocusSyncedEvent),- TilingDirectionChanged(TilingDirectionChangedEvent),+ BindingModeChanged {+ new_binding_mode: String,+ },+ FocusChanged {+ focused_container: Container,+ },+ FocusedContainerMoved {+ focused_container: Container,+ },+ MonitorAdded {+ added_monitor: Monitor,+ },+ MonitorRemoved {+ removed_id: Uuid,+ removed_device_name: String,+ },+ NativeFocusSynced {+ focused_container: Container,+ },+ TilingDirectionChanged {+ new_tiling_direction: TilingDirection,+ },UserConfigReloaded,- WindowManaged(WindowManagedEvent),- WindowUnmanaged(WindowUnmanagedEvent),- WorkspaceActivated(WorkspaceActivatedEvent),- WorkspaceDeactivated(WorkspaceDeactivatedEvent),- WorkingAreaResized(WorkingAreaResizedEvent),+ WindowManaged {+ managed_window: Container,+ },+ WindowUnmanaged {+ unmanaged_id: Uuid,+ unmanaged_handle: WindowHandle,+ },+ WorkspaceActivated {+ activated_workspace: Workspace,+ },+ WorkspaceDeactivated {+ deactivated_id: Uuid,+ deactivated_name: String,+ },+ WorkingAreaResized {+ affected_monitor: Monitor,+ },}diff --git a/packages/wm/src/workspaces/commands/activate_workspace.rs b/packages/wm/src/workspaces/commands/activate_workspace.rsindex 78a20186..1d713ee1 100644--- a/packages/wm/src/workspaces/commands/activate_workspace.rs+++ b/packages/wm/src/workspaces/commands/activate_workspace.rs@@ -5,7 +5,7 @@ use crate::{containers::{commands::attach_container, traits::PositionBehavior},monitors::Monitor,user_config::{UserConfig, WorkspaceConfig},- wm_event::{WmEvent, WorkspaceActivatedEvent},+ wm_event::WmEvent,wm_state::WmState,workspaces::Workspace,};@@ -42,9 +42,9 @@ pub fn activate_workspace(0,)?;- state.emit_event(WmEvent::WorkspaceActivated(WorkspaceActivatedEvent {+ state.emit_event(WmEvent::WorkspaceActivated {activated_workspace: workspace,- }));+ });Ok(())}