Skip to content

Commit

Permalink
fix(hook): win event hook crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Oct 1, 2024
1 parent abd5e88 commit ff78daa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Changelog

## [Unreleased]
## [2.0.0-beta.11]
### breaking changes
- Window Manager Layout Conditions was reimplemented, old conditions (v1) will fail.

Expand Down
3 changes: 2 additions & 1 deletion src/background/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ fn setup(app: &mut tauri::App<tauri::Wry>) -> Result<(), Box<dyn std::error::Err

seelen.start()?;
log_error!(try_register_tray_icon(app));
trace_lock!(PERFORMANCE_HELPER).end("setup");
Ok(())
}

Expand Down Expand Up @@ -168,7 +169,7 @@ fn is_already_runnning() -> bool {
fn main() -> Result<()> {
color_eyre::install().expect("Failed to install color_eyre");
register_panic_hook();
trace_lock!(PERFORMANCE_HELPER).start("init");
trace_lock!(PERFORMANCE_HELPER).start("setup");

let command = trace_lock!(SEELEN_COMMAND_LINE).clone();
let matches = match command.try_get_matches() {
Expand Down
14 changes: 8 additions & 6 deletions src/background/seelen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
state::application::{FullState, FULL_STATE},
system::{declare_system_events_handlers, release_system_events_handlers},
trace_lock,
utils::{ahk::AutoHotKey, spawn_named_thread, PERFORMANCE_HELPER},
utils::{ahk::AutoHotKey, PERFORMANCE_HELPER},
windows_api::WindowsApi,
};

Expand Down Expand Up @@ -172,7 +172,7 @@ impl Seelen {
}
}

fn start_async() -> Result<()> {
async fn start_async() -> Result<()> {
if FULL_STATE.load().is_weg_enabled() {
SeelenWeg::enumerate_all_windows()?;
}
Expand All @@ -182,12 +182,11 @@ impl Seelen {
}

Self::start_ahk_shortcuts()?;
trace_lock!(PERFORMANCE_HELPER).end("init");
Self::refresh_auto_start_path().await?;
Ok(())
}

pub fn start(&mut self) -> Result<()> {
register_win_hook()?;
declare_system_events_handlers()?;

if self.state().is_rofi_enabled() {
Expand All @@ -206,9 +205,12 @@ impl Seelen {
trace_lock!(MONITOR_MANAGER).listen_changes(Self::on_monitor_event);

self.refresh_windows_positions()?;
spawn_named_thread("Start Async", || log_error!(Self::start_async()))?;
register_win_hook()?;

tauri::async_runtime::spawn(async {
log_error!(Self::refresh_auto_start_path().await);
trace_lock!(PERFORMANCE_HELPER).start("lazy setup");
log_error!(Self::start_async().await);
trace_lock!(PERFORMANCE_HELPER).end("lazy setup");
});
Ok(())
}
Expand Down

0 comments on commit ff78daa

Please sign in to comment.